* Doubts about a function for my org-capture template
@ 2022-10-15 15:14 Juan Manuel Macías
2022-10-16 8:32 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Juan Manuel Macías @ 2022-10-15 15:14 UTC (permalink / raw)
To: orgmode
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Doubts about a function for my org-capture template
2022-10-15 15:14 Doubts about a function for my org-capture template Juan Manuel Macías
@ 2022-10-16 8:32 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-10-16 8:32 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: orgmode
Juan Manuel Macías <maciaschain@posteo.net> writes:
> 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.
Would you mind providing exact steps needed to reproduce the problem?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-16 8:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-15 15:14 Doubts about a function for my org-capture template Juan Manuel Macías
2022-10-16 8:32 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).