I have this org capture template saved in a tpl-quote.txt file:

* a title 
  :TIME: %U

%x  ;; contents in clipboard

And the org-capture-templates is

  (setq org-capture-templates
  (quote (("p" "Private Templates")
          ("pc" "Clipboard"
           (file+olp+datetree "~/Notebooks/org/default.org" "Capture")
           (file "~/Notebooks/org/tpl-quote.txt")
           :immediate-finish t))))

This worked alright in GUI Emacs.

If I start a GUI Emacs, run M-x server-start, then in a terminal run

emacsclient -ne '(org-capture nil "pc")'

it also worked Ok.

But if I start Emacs daemon emacs --daemon, then run the above emacsclient command I got the following error at my terminal:

*ERROR*: Capture abort: (wrong-type-argument char-or-string-p nil)

So it seems that the clipboard expansion %x is only working with GUI Emacs, deleting the %x it works again.

Is this the expected behavior?

My setup:

  • OS: Manjaro Linux
  • Emacs: 26.3
  • Org-mode: 9.1.9
  • emacs --daemon calls server-start. What happens if you first open a frame (and close it) and then run your command line?
    – RichieHH
    Mar 2, 2020 at 12:51
  • @RichieHH It gives the same error message. Could it be that something related to the X graphical things is not activated?
    – Jason
    Mar 2, 2020 at 12:56
  • What happens when you leave the frame open and explicitly call this function inside the scratch buffer for example?
    – RichieHH
    Mar 3, 2020 at 6:38
  • Also check with C-y (yank) in the scratch buffer.
    – RichieHH
    Mar 3, 2020 at 9:11


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.