[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Doubts about a function for my org-capture template
From: |
Juan Manuel Macías |
Subject: |
Doubts about a function for my org-capture template |
Date: |
Sat, 15 Oct 2022 15:14:36 +0000 |
Hi all,
I have written this function to be able to choose the type of block in
which to enclose the marked content (by default, quote). So in
my org-capture template I put %(my-capture-block) instead of %i:
┌────
│ (defun my-capture-block ()
│ (let ((initial (org-capture-get :initial)))
│ (when initial
│ (let ((block-name
│ (read-string
│ "Block type for marked content (default quote): "
│ nil nil "quote")))
│ (format
│ "#+begin_%s\n%s\n#+end_%s"
│ block-name
│ initial
│ (if (string-match "\\(src\\)\\(.+\\)" block-name)
│ (match-string 1 block-name)
│ block-name))))))
└────
The function works fine from eww, but it doesn't work with org-protocol
+ qutebrowser, as the value of :initial in org-capture-plist seems to be
nil. I've solved it by enclosing %i between two sexp %(...), one to
format the #+begin_xxx and the other to guess the #+end_xxx, but it's
more verbose. Does anyone have a clue how to get the value of %i for
org-protocol with a function inside the template?
Best regards and happy weekend,
Juan Manuel
--
--
------------------------------------------------------
Juan Manuel Macías
https://juanmanuelmacias.com
https://lunotipia.juanmanuelmacias.com
https://gnutas.juanmanuelmacias.com
- Doubts about a function for my org-capture template,
Juan Manuel Macías <=