[O] ob-python specify session error

2019-06-18 Thread stardiviner


#+begin_src python :session wxpy
from wxpy import *
#+end_src

When I =[C-c C-c]= eval source block, I got following error:

#+begin_example
Debugger entered--Lisp error: (wrong-number-of-arguments (0 . 0) 1)
  py-toggle-shells("python")
  (cond ((and (eq 'python org-babel-python-mode) (fboundp 'run-python)) (if 
(not (version< "24.1" emacs-version)) (run-python cmd) (if python-buffer nil 
(setq python-buffer (org-babel-python-with-earmuffs session))) (let 
((python-shell-buffer-name (org-babel-python-without-earmuffs python-buffer))) 
(run-python cmd ((and (eq 'python-mode org-babel-python-mode) (fboundp 
'py-shell)) (py-toggle-shells py-default-interpreter) (let* ((bufname (if (and 
python-buffer (buffer-live-p python-buffer)) (replace-regexp-in-string 
"^\\*\\([^*]+\\)\\*$" "\\1" python-buffer) (concat "Python-" (symbol-name 
session (py-which-bufname bufname)) (py-shell) (setq python-buffer 
(org-babel-python-with-earmuffs bufname (t (error "No function available 
for running an inferior Pyth...")))
  (let* ((session (if session (intern session) :default)) (python-buffer 
(org-babel-python-session-buffer session)) (cmd (if (member system-type 
'(cygwin windows-nt ms-dos)) (concat org-babel-python-command " -i") 
org-babel-python-command))) (cond ((and (eq 'python org-babel-python-mode) 
(fboundp 'run-python)) (if (not (version< "24.1" emacs-version)) (run-python 
cmd) (if python-buffer nil (setq python-buffer (org-babel-python-with-earmuffs 
session))) (let ((python-shell-buffer-name (org-babel-python-without-earmuffs 
python-buffer))) (run-python cmd ((and (eq 'python-mode 
org-babel-python-mode) (fboundp 'py-shell)) (py-toggle-shells 
py-default-interpreter) (let* ((bufname (if (and python-buffer ...) 
(replace-regexp-in-string "^\\*\\([^*]+\\)\\*$" "\\1" python-buffer) (concat 
"Python-" ...))) (py-which-bufname bufname)) (py-shell) (setq python-buffer 
(org-babel-python-with-earmuffs bufname (t (error "No function available 
for running an inferior Pyth..."))) (setq org-babel-python-buffers (cons (cons 
session python-buffer) (assq-delete-all session org-babel-python-buffers))) 
session)
  (progn (let* ((session (if session (intern session) :default)) (python-buffer 
(org-babel-python-session-buffer session)) (cmd (if (member system-type 
'(cygwin windows-nt ms-dos)) (concat org-babel-python-command " -i") 
org-babel-python-command))) (cond ((and (eq 'python org-babel-python-mode) 
(fboundp 'run-python)) (if (not (version< "24.1" emacs-version)) (run-python 
cmd) (if python-buffer nil (setq python-buffer (org-babel-python-with-earmuffs 
session))) (let ((python-shell-buffer-name ...)) (run-python cmd ((and (eq 
'python-mode org-babel-python-mode) (fboundp 'py-shell)) (py-toggle-shells 
py-default-interpreter) (let* ((bufname (if ... ... ...)) (py-which-bufname 
bufname)) (py-shell) (setq python-buffer (org-babel-python-with-earmuffs 
bufname (t (error "No function available for running an inferior 
Pyth..."))) (setq org-babel-python-buffers (cons (cons session python-buffer) 
(assq-delete-all session org-babel-python-buffers))) session))
  (unwind-protect (progn (let* ((session (if session (intern session) 
:default)) (python-buffer (org-babel-python-session-buffer session)) (cmd (if 
(member system-type '...) (concat org-babel-python-command " -i") 
org-babel-python-command))) (cond ((and (eq 'python org-babel-python-mode) 
(fboundp 'run-python)) (if (not (version< "24.1" emacs-version)) (run-python 
cmd) (if python-buffer nil (setq python-buffer ...)) (let (...) (run-python 
cmd ((and (eq 'python-mode org-babel-python-mode) (fboundp 'py-shell)) 
(py-toggle-shells py-default-interpreter) (let* ((bufname ...) 
(py-which-bufname bufname)) (py-shell) (setq python-buffer 
(org-babel-python-with-earmuffs bufname (t (error "No function available 
for running an inferior Pyth..."))) (setq org-babel-python-buffers (cons (cons 
session python-buffer) (assq-delete-all session org-babel-python-buffers))) 
session)) (set-window-configuration wconfig))
  (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let* 
((session (if session (intern session) :default)) (python-buffer 
(org-babel-python-session-buffer session)) (cmd (if (member system-type ...) 
(concat org-babel-python-command " -i") org-babel-python-command))) (cond ((and 
(eq ... org-babel-python-mode) (fboundp ...)) (if (not ...) (run-python cmd) 
(if python-buffer nil ...) (let ... ...))) ((and (eq ... org-babel-python-mode) 
(fboundp ...)) (py-toggle-shells py-default-interpreter) (let* (... ...) 
(py-shell) (setq python-buffer ...))) (t (error "No function available for 
running an inferior Pyth..."))) (setq org-babel-python-buffers (cons (cons 
session python-buffer) (assq-delete-all session org-babel-python-buffers))) 
session)) (set-window-configuration wconfig)))
  org-babel-python-initiate-session-by-key("yes")
  (org-babel-python-session-buffer (org-babel-python-initiate-session-by-k

[O] Help with dblocks and table formulas (and an RFC on quantitative logging)

2019-06-18 Thread Eric Abrahamsen
Hi all,

I'm finally trying to scratch a very old itch of mine: quantitative
logging in Org. Basically it's the same idea as org-clock, except
generalized to log random values. Rather than explain at length, below is
what a sample todo would look like, plus the created dblock. You specify
a LOG_VALUES property (multiple labels are possible), and then anytime
you take a note, you're prompted to enter values for those labels. Then
there's a command for making the dblock.

*** CHECK Test blood glucose
SCHEDULED: <2019-06-19 Wed +1d>
:PROPERTIES:
:ID:   dummy
:LOG_VALUES: MG
:LAST_REPEAT: [2019-06-18 Tue 19:55]
:END:
:LOGBOOK:
- State "DONE"  from "CHECK"  [2019-06-18 Tue 19:56] \\
  MG: 98;
- State "DONE"  from "CHECK"  [2019-06-17 Mon 19:55] \\
  MG: 110;
- State "DONE"  from "CHECK"  [2019-06-16 Sun 19:55] \\
  MG: 103;
:END:

#+BEGIN: log :id "dummy"
| Timestamp  |  Mg |
|+-|
| [2019-06-18 Tue 19:56] |  98 |
| [2019-06-17 Mon 19:55] | 110 |
| [2019-06-16 Sun 19:55] | 103 |
#+END:

The code for this is below, I'm sure it's a mess and doesn't take into
account hardly any of the variety of Org configs.

But it sort of works! I have a few questions:

1. I can't reliably trigger the note prompting using TODO keyword setup.
   The above example is actually manually adjusted because I couldn't
   get it to prompt for a note when going into DONE state, even with
   DONE(@). But presumably that's my own confusion.
2. I don't know how to handle defining table formulas. Are users meant
   to insert them manually into the dblock? As a property on the
   heading? What's the usual thing to do?
3. What I'd really like is to have this integrated with clocking, so
   that clocking out also prompts for log values, and then you can make
   tables that show not only how many hours you worked today, but also
   how many... widgets you frobbed in that time. I guess this isn't
   really a question, just an indication of where I hope it might go.
   
Anyway, this is a total work in progress, but I would be curious if
anyone would find this useful, and for what.

Eric

#+src elisp
;;; Code:

(require 'org)

(defun org-log-prompt ()
  "Prompt the user for log values.
Insert values into the current log note."
  ;; This is called in the log buffer.  Only fire for state and note;
  ;; later add clock-out.
  (when (memq org-log-note-purpose '(state note))
(let ((values
   (with-current-buffer (marker-buffer org-log-note-marker)
 (save-excursion
   (goto-char org-log-note-marker)
   (org-entry-get (point) "LOG_VALUES" 'selective)
  (when (and (stringp values) (null (string-empty-p values)))
(unless (bolp)   ; This might follow a clock line.
  (insert "; "))
(dolist (val (split-string values))
  ;; Maybe strip off units.
  (setq val (substring val 0 (string-match-p "\\[" val)))
  (insert val ": ")
  (insert (read-string (format "%s: " val)) "; "))

(defun org-log--collect-data (id)
  "Collect log data from heading with id ID.
When valid data is found, it is returned as a list of lists.
Each sublist starts with the timestamp of the log entry, followed
by data keys and values, in the order they were found in the log
entry.

If no valid data is found, return nil."
  (save-excursion
(org-id-goto id)
(goto-char (org-log-beginning))
(let* ((struct (org-list-struct))
   (labels (org-entry-get (point) "LOG_VALUES" 'selective))
   (entries (when (and (stringp labels)
   (null (string-empty-p labels)))
  ;; First element is a list of value labels.
  (list (cons "TIMESTAMP"
  (mapcar (lambda (str)
(substring
 str 0 (string-match-p "\\[" str)))
  (split-string labels))
   elt data)
  (when (and entries struct)
;; Get onto the list item.
(forward-char)
(while (equal 'item (org-element-type
 (setq elt (org-element-at-point
  ;; Move past state/timestamp line.
  (forward-line)
  (while (re-search-forward "[[:upper:]]+: \\([^;]+\\)"
(point-at-eol) t)
(push (match-string-no-properties 1) data))
  (when data
(save-excursion
  (forward-line -1)
  ;; Get the log entry timestamp.
  (setq data
(cons (if (re-search-forward org-ts-regexp-inactive
 (point-at-eol) t)
  (match-string-no-properties 0)
"none")
  (nreverse data
(push data entries)
(setq d

[O] How can I customize ID names in html?

2019-06-18 Thread buybuyxyz
How can I customize id names in html?

= test.org begin#+TITLE: test#+AUTHOR: buybuyxyz#+EMAIL: 
buybuy...@yahoo.co.jp#+LANGUAGE: ja#+OPTIONS: toc:t num:t author:t creator:nil 
LaTeX:t _:{} #+MACRO: em @$1@
* test1
* test2
= test.org end

I generate test.html from test.org.


I do following command
grep id= test.html
I get following output.
1 
test12 test2

I would like to generate the prefix of ID names to be xyz instead of org.
How can I customize id names (ex. orgccfde4a)?



[O] How can I customize ID names in html?

2019-06-18 Thread buybuyxyz
How can I customize id names in html?

= test.org begin#+TITLE: test#+AUTHOR: buybuyxyz#+EMAIL: 
buybuy...@yahoo.co.jp#+LANGUAGE: ja#+OPTIONS: toc:t num:t author:t creator:nil 
LaTeX:t _:{} #+MACRO: em @$1@
* test1
* test2
= test.org end

I generate test.html from test.org.


I do following command
grep id= test.html
I get following output.
1 
test12 test2

I would like to generate the prefix of ID names to be xyz instead of org.
How can I customize id names (ex. orgccfde4a)?



Re: [O] org-drill futures

2019-06-18 Thread Stig Brautaset
>> phillip.l...@russet.org.uk (Phillip Lord) writes:
>>
>>> I've launched an fork of org-drill. I have tried to reach Paul Sexton,
>>> the original author, and had some feedback (he was happy for my take
>>> over), but not managed to get the repository moved.
>>>
>>> https://gitlab.com/phillord/org-drill/
>>>
...
>> I would suggest the opposite: move it to GNU ELPA, for example, so we
>> can remove it from contrib.
>
> Yes, I am quite happy with that also -- it would save the effort of
> syncing it. It would have to be MELPA though, because I don't think we
> have papers (I can check). This does have the disadvantage of requiring
> people to update their config/installed packages, but it's probably
> okay.

I would love to see org-drill available in MELPA. It's the most
important package I use from contrib. Moving it to MELPA means I'm
closer to being able to live with the version of Org that ships with
Emacs, and would not have to install org-plus-contrib.

To that end I've created a branch[1] for adding your fork to MELPA.
Based on your previous messages in this thread, I assume I have your
permission to submit a PR? Or is there a good reason to wait with this
for the moment?

Stig

[1]: https://github.com/stig/melpa/compare/master...stig:org-drill