I am trying to create a capture-template which will prompt the user to define a subheading so that it can place the capture as a level 3 heading under the appropriate level 2 heading within an org file. For example:


I want to be able to specify in the mini buffer whether a capture will be added as a level 3 heading to one of the two level 2 headings CLASSNAME1 or CLASSNAME2.

I have found somewhat similar questions posted about this but none have actually solved my issue.

My template is currently as follows:

("c" "Class" entry (file+olp "~/gtd/tickler.org" "Classes" org-get-classname) "* %^{Class Type}\nSCHEDULED: %^{Class time1}T-%^{Class time2}T\n:LOCATION: %^{Location}\n")

(The level 1 heading * Classes is within the file: ~/gtd/tickler.org)

My org-get-classname function looks like:

(defun org-get-classname () (setq subheading-name (read-string "Enter subheading: ")) (subheading-name))

I am simply trying to prompt the user for the name of the level 2 heading with org-get-classname and then use that to add the capture as a level 3 heading.

Currently, when trying to use this capture-template I am told:

Wrong type argument: stringp, org-get-classname

I have been playing around with file+function as well but have not found any success with that either.

This is my first week trying out emacs so I am very new at this point, and I do not have prior experience with elisp so any advice would be appreciated.

  • The error msg tells you that Emacs evaluated the symbol org-get-classname as a variable, and found that its value was not a string (a string was expected). Where are you setting its value? You say it's a function. Did you mean to quote it, so you pass it as a symbol (whose function value is used)? Or did you mean to put it in parens, to invoke it as a functions? – Drew Jan 15 at 21:41
  • @Drew I'm trying to evaluate the org-get-classname within the template so that when the template is used the user has to specify which level 2 heading they want the capture to be placed in. From what I understand, org-get-classname should return whatever string the user inputs and I want that to go in place of the org-get-classname evaluation within the template. – MaxFlame Jan 15 at 21:49
  • But you show that it's a function, not a variable, yet your code uses it as a variable. Please reread my comment. Do you want 'org-get-classname (pass the symbol, so the caller can, e.g., invoke the function) or (org-get-classname) (call the function, returning its value) or org-get-classname (evaluate it as a variable). You're doing the last of these - is that appropriate? – Drew Jan 15 at 21:53
  • @Drew I think that I want to be invoking the function to use the returned value but I tried both 'org-get-classname and (org-get-classname) and I got similar error messages to my original implementation: for 'org-get-classname: Wrong type argument: stringp, (quote org-get-classname) and for (org-get-classname): Wrong type argument: stringp, (org-get-classname). – MaxFlame Jan 15 at 22:00
  • I believe you want file+function rather than file+olp. One example of use is at emacs.stackexchange.com/a/12577/2710 . You will need to use read-string or completing-read to get the input from the user. – Andrew Swann Jan 16 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.