emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: No Wayman <iarchivedmywholelife@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Bug: org-capture-get-template can't use a lambda for template function. [9.2.6 (9.2.6-7-g634880-elpaplus @ /home/n/.emacs.d/elpa/org-plus-contrib-20191118/)]
Date: Thu, 12 Dec 2019 11:25:28 -0500	[thread overview]
Message-ID: <87r219zf2f.fsf@gmail.com> (raw)


Remember to cover the basics, that is, what you expected to happen 
and
what in fact did happen.  You don't know how to make a good 
report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

Noticed that one cannot use a lambda function as a template 
generating function.
Doing so results in the error:

Wrong type argument: symbolp, (lambda...)

The cause is the fboundp check in org-capture-get-template.
Changing this to functionp allows a lambda to be specified and is 
consistent with what org-capture-set-target-location allows.

I'm not sure if there are any corner cases I'm unaware of, but it 
seems like a simple patch:

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index ef3561563..a8a4e1e89 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -706,7 +706,7 @@ of the day at point (if any) or the current 
HH:MM time."
 	  (setq txt (org-file-contents file))
 	(setq txt (format "* Template file %s not found" (nth 1 txt)))))
      ((and (listp txt) (eq (car txt) 'function))
-      (if (fboundp (nth 1 txt))
+      (if (functionp (nth 1 txt))
 	  (setq txt (funcall (nth 1 txt)))
 	(setq txt (format "* Template function %s not found" (nth 1 
 txt)))))
      ((not txt) (setq txt ""))

Thanks,
nv

Emacs  : GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X 
toolkit, cairo version 1.17.3, Xaw3d scroll bars)
 of 2019-12-10
Package: Org mode version 9.2.6 (9.2.6-7-g634880-elpaplus @ 
/home/n/.emacs.d/elpa/org-plus-contrib-20191118/)

             reply	other threads:[~2019-12-12 16:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 16:25 No Wayman [this message]
2019-12-12 21:36 ` Bug: org-capture-get-template can't use a lambda for template function. [9.2.6 (9.2.6-7-g634880-elpaplus @ /home/n/.emacs.d/elpa/org-plus-contrib-20191118/)] Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r219zf2f.fsf@gmail.com \
    --to=iarchivedmywholelife@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).