-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture template 'X': Wrong type argument: stringp, nil #4832
Comments
Happens for me as well. Introduced in 9f08db8
|
This comment has been minimized.
This comment has been minimized.
I have the same problem, whenever I open org-agenda, i.e. org-agenda searched/opened org buffers backend. I can only make org-caputre work again by SPC-b-K, i.e. kill all bufer. |
This comment has been minimized.
This comment has been minimized.
Had the same issue. I find it only happens if I haven't yet opened the buffer I'm capturing to. Once the buffer is open, capture works correctly. |
Thanks @IsaacDempsey. I had a hunch I could fix it by opening that buffer and possibly editing/saving it. But I haven't had a chance to prove it. |
I cannot reproduce this. With or without an existing destination org file, with any of the default capture templates, on 26.3, 27.1, 27.2 or 28 (native-comp), on NixOS, Arch Linux, or MacOS (Big Sur).
|
i get this error too, here's my config and backtrace
(after! org
(setq
org-capture-templates
'(
; other entries here
("t" "tasks" entry
(file+olp+datetree "journal.org")
"* TODO %?\n%U"))))
Debugger entered--Lisp error: (error "Capture template ‘t’: Wrong type argument: stringp...")
error("Capture template `%s': %s" "t" "Wrong type argument: stringp, nil")
#f(compiled-function (&optional goto keys) "Capture something.\n\\<org-capture-mode-map>\nThis will let you select a template from `org-capture-templates', and\nthen file the newly captured information. The text is immediately\ninserted at the target location, and an indirect buffer is shown where\nyou can edit it. Pressing `\\[org-capture-finalize]' brings you back to the previous\nstate of Emacs, so that you can continue your work.\n\nWhen called interactively with a `\\[universal-argument]' prefix argument GOTO, don't\ncapture anything, just go to the file/headline where the selected\ntemplate stores its notes.\n\nWith a `\\[universal-argument] \\[universal-argument]' prefix argument, go to the last note stored.\n\nWhen called with a `C-0' (zero) prefix, insert a template at point.\n\nWhen called with a `C-1' (one) prefix, force prompting for a date when\na datetree entry is made.\n\nELisp programs can set KEYS to a string associated with a template\nin `org-capture-templates'. In this case, interactive selection\nwill be bypassed.\n\nIf `org-capture-use-agenda-date' is non-nil, capturing from the\nagenda will use the date at point as the default date. Then, a\n`C-1' prefix will tell the capture process to use the HH:MM time\nof the day at point (if any) or the current HH:MM time." (interactive "P") #<bytecode 0x5b4e76bfd41a2b4>)(nil)
apply(#f(compiled-function (&optional goto keys) "Capture something.\n\\<org-capture-mode-map>\nThis will let you select a template from `org-capture-templates', and\nthen file the newly captured information. The text is immediately\ninserted at the target location, and an indirect buffer is shown where\nyou can edit it. Pressing `\\[org-capture-finalize]' brings you back to the previous\nstate of Emacs, so that you can continue your work.\n\nWhen called interactively with a `\\[universal-argument]' prefix argument GOTO, don't\ncapture anything, just go to the file/headline where the selected\ntemplate stores its notes.\n\nWith a `\\[universal-argument] \\[universal-argument]' prefix argument, go to the last note stored.\n\nWhen called with a `C-0' (zero) prefix, insert a template at point.\n\nWhen called with a `C-1' (one) prefix, force prompting for a date when\na datetree entry is made.\n\nELisp programs can set KEYS to a string associated with a template\nin `org-capture-templates'. In this case, interactive selection\nwill be bypassed.\n\nIf `org-capture-use-agenda-date' is non-nil, capturing from the\nagenda will use the date at point as the default date. Then, a\n`C-1' prefix will tell the capture process to use the HH:MM time\nof the day at point (if any) or the current HH:MM time." (interactive "P") #<bytecode 0x5b4e76bfd41a2b4>) nil)
(let ((+file-templates-inhibit t)) (apply orig-fn args))
+file-templates-inhibit-in-org-capture-a(#f(compiled-function (&optional goto keys) "Capture something.\n\\<org-capture-mode-map>\nThis will let you select a template from `org-capture-templates', and\nthen file the newly captured information. The text is immediately\ninserted at the target location, and an indirect buffer is shown where\nyou can edit it. Pressing `\\[org-capture-finalize]' brings you back to the previous\nstate of Emacs, so that you can continue your work.\n\nWhen called interactively with a `\\[universal-argument]' prefix argument GOTO, don't\ncapture anything, just go to the file/headline where the selected\ntemplate stores its notes.\n\nWith a `\\[universal-argument] \\[universal-argument]' prefix argument, go to the last note stored.\n\nWhen called with a `C-0' (zero) prefix, insert a template at point.\n\nWhen called with a `C-1' (one) prefix, force prompting for a date when\na datetree entry is made.\n\nELisp programs can set KEYS to a string associated with a template\nin `org-capture-templates'. In this case, interactive selection\nwill be bypassed.\n\nIf `org-capture-use-agenda-date' is non-nil, capturing from the\nagenda will use the date at point as the default date. Then, a\n`C-1' prefix will tell the capture process to use the HH:MM time\nof the day at point (if any) or the current HH:MM time." (interactive "P") #<bytecode 0x5b4e76bfd41a2b4>) nil)
apply(+file-templates-inhibit-in-org-capture-a #f(compiled-function (&optional goto keys) "Capture something.\n\\<org-capture-mode-map>\nThis will let you select a template from `org-capture-templates', and\nthen file the newly captured information. The text is immediately\ninserted at the target location, and an indirect buffer is shown where\nyou can edit it. Pressing `\\[org-capture-finalize]' brings you back to the previous\nstate of Emacs, so that you can continue your work.\n\nWhen called interactively with a `\\[universal-argument]' prefix argument GOTO, don't\ncapture anything, just go to the file/headline where the selected\ntemplate stores its notes.\n\nWith a `\\[universal-argument] \\[universal-argument]' prefix argument, go to the last note stored.\n\nWhen called with a `C-0' (zero) prefix, insert a template at point.\n\nWhen called with a `C-1' (one) prefix, force prompting for a date when\na datetree entry is made.\n\nELisp programs can set KEYS to a string associated with a template\nin `org-capture-templates'. In this case, interactive selection\nwill be bypassed.\n\nIf `org-capture-use-agenda-date' is non-nil, capturing from the\nagenda will use the date at point as the default date. Then, a\n`C-1' prefix will tell the capture process to use the HH:MM time\nof the day at point (if any) or the current HH:MM time." (interactive "P") #<bytecode 0x5b4e76bfd41a2b4>) nil)
org-capture(nil)
#<subr funcall-interactively>(org-capture nil)
apply(#<subr funcall-interactively> (org-capture nil))
funcall-interactively(org-capture nil)
#<subr call-interactively>(org-capture nil nil)
apply(#<subr call-interactively> (org-capture nil nil))
explain-pause--wrap-call-interactively(#<subr call-interactively> org-capture nil nil)
apply(explain-pause--wrap-call-interactively #<subr call-interactively> (org-capture nil nil))
call-interactively(org-capture nil nil)
command-execute(org-capture) |
Met the same error, here's my config and backtrace, I suspect it was something related to the agenda:
(setq org-capture-templates
(quote (("t" "todo" entry (file "~/OneDrive/cone/refile.org")
"* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t)
("r" "respond" entry (file "~/OneDrive/cone/refile.org")
"* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
("n" "note" entry (file "~/OneDrive/cone/refile.org")
"* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
("b" "book" entry (file "~/OneDrive/cone/books.org")
"* TODO Read %? :BOOK:\n%U" :clock-in t :clock-resume t)
("j" "Journal" entry (file+olp+datetree "~/OneDrive/cone/diary.org")
"* %?\n%U\n" :clock-in t :clock-resume t)
("w" "org-protocol" entry (file "~/OneDrive/cone/refile.org")
"* TODO Review %c\n%U\n" :immediate-finish t)
("m" "Meeting" entry (file "~/OneDrive/cone/refile.org")
"* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
("p" "Phone call" entry (file "~/OneDrive/cone/refile.org")
"* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
("h" "Habit" entry (file "~/OneDrive/cone/refile.org")
"* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"%<<%Y-%m-%d %a .+1d/3d>>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n")))) |
(setq org-capture-templates
`(("i" "inbox"
entry
(file "/home/zwei/org/gtd/inbox.org")
"* "))) Steps to reproduce:
The above steps also work in the same manner when using other files ie using a If a capture template is opened before any agenda is ever opened, the error usually doesn't occur (but behaviour may be inconsistent in that case -- won't swear to it but I think it once gave me the error in this case awhile back). Misc eval and message info:Don't know if this is any help but I tried to figure out what was happening in the org-capture function that was causing problems which led me down this dubiously relevant path: ; 1.
(org-capture nil "i")
; 2. org-capture.el 692
(org-capture-place-template nil)
; 3. org.capture.el 1121
(org-switch-to-buffer-other-window
(org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
; 4. org-macs.el 234
(switch-to-buffer-other-window
(org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
; 5. window.el.gz 8516
(pop-to-buffer (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE") t)
; 6. window.el.gz 8249
(display-buffer (window-normalize-buffer-to-switch-to (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE")) t)
; 7. from the below backtrace
(+org--restart-mode-h)
The above 7 eval snippets all produce the same message
with Update: |
Spent quite some time, and I think I figured it out what happens. TLDR:
(use-package org
:defer t
:config
(defalias '+org--restart-mode-h #'ignore)) Note you will need to manually kill the half-broken org buffer to make it look proper. Backgrounds:According to the docstring of What happens:This should work fine, until we do an
And here is the definition of (defun +org--restart-mode-h ()
"Restart `org-mode', but only once."
(remove-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
'local)
(delq! (current-buffer) org-agenda-new-buffers)
(let ((file buffer-file-name)
(inhibit-redisplay t))
(kill-buffer)
(find-file file))) So "CAPTURE-inbox.org" is killed, and with This is not the only problem. This no-longer-valid buffer is then returned by Possible fixWe can use the imperfect workaround mentioned earlier, but it disables the automatic reload for half-broken org files. For a better solution, I think we need something like the following (Disclaimer: THIS IS JUST AN IDEA, AND IS NOT TESTED! For a workaround, see the first section TLDR.): (defun +org--restart-mode-h ()
"Restart `org-mode', but only once."
(remove-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
'local)
(delq! (current-buffer) org-agenda-new-buffers)
(let ((file buffer-file-name)
(old-buffer (current-buffer))
(inhibit-redisplay t)
new-buffer)
(kill-buffer)
(setq new-buffer (find-file file))
(unless (buffer-live-p old-buffer)
(make-indirect-buffer new-buffer old-buffer 'clone)))) And we also need to fix the return value of |
I can confirm that the workaround @yangsheng6810 suggests does work. Emacs version: 27.2 |
I didn't manage to make @yangsheng6810 's second suggestion work, probably because I don't understand how to fix the return value of
and now I can use capture without getting half-broken org buffers. (Not counting the capture buffers themselves that is.) |
Start to getting this message: condition-case: Error in a Doom startup hook: org-agenda-finalize-hook, +org-defer-mode-in-agenda-buffers-h, (error "Selecting deleted buffer") It's still about agenda and buffer. |
The initial issue seems to be fixed for me in the latest develop. Not sure if it's caused by the code changes or the dependencies update. |
This issue has been automatically marked stale because of a lack of recent activity. If this issue is still valid, reply to it or remove the label, or it will be closed in 7 days. |
Can't use any capture templates! Found this thread[0], other people are having the same issue. Other person experiencing this was told to make a new issue but I couldn't find it, so I'm making this one.
What did you expect to happen?
My capture template to work normally.
What actually happened?
I got an error saying that the wrong sort of arguments were being passed:
Capture template 'X': Wrong type argument: stringp, nil
Steps to reproduce:
Run any capture template
System information:
https://pastebin.com/DcgZFF08
The text was updated successfully, but these errors were encountered: