Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think pmr is right about the fact that the functions for choosing a file location as part of a template happen too early for your needs.</p> <p>One way to integrate with org capture refile workflow would be to use the standard org capture template system to file your new word into the vocab buffer then use a custom elisp function as a hook, probably into org-capture-before-finalize-hook, to file the new definition into the right location.</p> <p>I wrote up the following function as a sample that prompts for a word and definition and inserts it into an org buffer in the right place. If it suits your needs you could bind this to a key of your choice, or use it as a starting point for the hook approach.</p> <pre><code>;; ;; remove extra spaces between stars and the headline text ;; (defun tidy-headlines () (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "^\\*+\\([[:space:]][[:space:]]+\\)" (point-max) t) (replace-match " " nil nil nil 1)))) ;; ;; function for storing things in vocab files like cashew /C/CA/Cashew ;; (defun insert-vocab-word (vocab-word definition) "prompts for a word then opens a vocab file and puts the word in place" (interactive "sWord: \nsDefinition: ") (find-file "~/org/vocab.org") (tidy-headlines) (goto-char (point-min)) (let* ((first-char (upcase (substring vocab-word 0 1))) (first-two-chars (upcase (substring vocab-word 0 2)))) (while (and (re-search-forward "^\\* " (point-max) t) (string&lt; (buffer-substring-no-properties (point) (+ 1 (point))) first-char))) (if (string= (buffer-substring-no-properties (point) (+ 1 (point))) first-char) (let* ((end-of-subtree (save-excursion (org-end-of-subtree) (point)))) (while (and (re-search-forward "^\\*\\* " end-of-subtree t) (string&lt; (buffer-substring-no-properties (point) (+ 2 (point))) first-two-chars))) (if (string= (buffer-substring-no-properties (point) (+ 2 (point))) first-two-chars) (let* ((end-of-subtree2 (save-excursion (org-end-of-subtree) (point)))) (while (and (re-search-forward "^\\*\\*\\* " end-of-subtree2 t) (string&lt; (word-at-point) vocab-word))) (if (string&lt; vocab-word (word-at-point)) (progn (beginning-of-line) (org-insert-heading t)) (org-insert-heading-after-current)) (insert vocab-word) (org-insert-subheading t) (insert definition)) (progn (if (string&lt; first-two-chars (buffer-substring-no-properties (point) (+ 2 (point)))) (progn (beginning-of-line) (org-insert-heading t)) (org-insert-heading-after-current)) (insert first-two-chars) (org-insert-subheading t) (insert vocab-word) (org-insert-subheading t) (insert definition)))) (progn (org-insert-heading-after-current) (insert first-char) (org-insert-subheading t) (insert first-two-chars) (org-insert-subheading t) (insert vocab-word) (org-insert-subheading t) (insert definition))))) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload