When I org-capture from elfeed-entry buffer (I defined custom functions to extract elfeed entry buffer content) in the second time and later, the bellowing error raised up. The first-time capture is fine. Here is the error backtrace: #+begin_example Debugger entered--Lisp error: (wrong-type-argument stringp nil) expand-file-name(nil) userlock--check-content-unchanged("~/Org/Tasks/Tasks.org") userlock--ask-user-about-supersession-threat("~/Org/Tasks/Tasks.org") delete-region(269 270) (let ((pos (point))) (org-back-over-empty-lines) (delete-region (point) pos) (if (> n 0) (progn (newline n)))) org-capture-empty-lines-before() (let ((origin (point-marker))) (if (bolp) nil (insert "\n")) (org-capture-empty-lines-before) (let ((beg (point))) (save-restriction (if insert-here? (progn (narrow-to-region beg beg))) (org-paste-subtree level template 'for-yank)) (org-capture-position-for-last-stored beg) (org-capture-empty-lines-after) (if (org-at-heading-p) nil (outline-next-heading)) (org-capture-mark-kill-region origin (point)) (org-capture-narrow beg (if (eobp) (point) (1- (point)))) (org-capture--position-cursor beg (point)))) (let ((template (org-capture-get :template)) (reversed? (org-capture-get :prepend)) (exact-position (org-capture-get :exact-position)) (insert-here? (org-capture-get :insert-here)) (level 1)) (org-capture-verify-tree template) (if exact-position (progn (goto-char exact-position))) (cond (insert-here? (setq level (org-get-valid-level (if (or (org-at-heading-p) (condition-case nil ... ...)) (org-outline-level) 1)))) ((org-capture-get :target-entry-p) (setq level (org-get-valid-level (if (org-at-heading-p) (org-outline-level) 1) 1)) (if reversed? (outline-next-heading) (org-end-of-subtree t t))) (reversed? (goto-char (point-min)) (if (org-at-heading-p) nil (outline-next-heading))) (t (goto-char (point-max)) (let (buffers dead-properties) (if (and (not (buffer-base-buffer)) (not (memq ... org-fold-core--indirect-buffers))) (setq buffers (list (current-buffer))) (let ((tail ...)) (while tail (let ... ... ...)))) (let ((tail buffers)) (while tail (let (...) (save-current-buffer ... ... ...) (setq tail ...))))))) (let ((origin (point-marker))) (if (bolp) nil (insert "\n")) (org-capture-empty-lines-before) (let ((beg (point))) (save-restriction (if insert-here? (progn (narrow-to-region beg beg))) (org-paste-subtree level template 'for-yank)) (org-capture-position-for-last-stored beg) (org-capture-empty-lines-after) (if (org-at-heading-p) nil (outline-next-heading)) (org-capture-mark-kill-region origin (point)) (org-capture-narrow beg (if (eobp) (point) (1- (point)))) (org-capture--position-cursor beg (point))))) org-capture-place-entry() (let nil (org-capture-place-entry)) (cond ((memq val '(entry nil)) (let nil (org-capture-place-entry))) ((eq val 'table-line) (let nil (org-capture-place-table-line))) ((eq val 'plain) (let nil (org-capture-place-plain-text))) ((eq val 'item) (let nil (org-capture-place-item))) ((eq val 'checkitem) (let nil (org-capture-place-item)))) (let* ((val (org-capture-get :type))) (cond ((memq val '(entry nil)) (let nil (org-capture-place-entry))) ((eq val 'table-line) (let nil (org-capture-place-table-line))) ((eq val 'plain) (let nil (org-capture-place-plain-text))) ((eq val 'item) (let nil (org-capture-place-item))) ((eq val 'checkitem) (let nil (org-capture-place-item))))) org-capture-place-template(nil) (condition-case error (org-capture-place-template (eq (car (org-capture-get :target)) 'function)) ((error quit) (if (and (buffer-base-buffer (current-buffer)) (string-prefix-p "CAPTURE-" (buffer-name))) (progn (kill-buffer (current-buffer)))) (set-window-configuration (org-capture-get :return-to-wconf)) (error "Capture template `%s': %s" (org-capture-get :key) (error-message-string error)))) (cond ((equal entry "C") (customize-variable 'org-capture-templates)) ((equal entry "q") (user-error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) (org-capture-put :original-buffer orig-buf :original-file (or (buffer-file-name orig-buf) (and (featurep 'dired) (car (rassq orig-buf dired-buffers)))) :original-file-nondirectory (and (buffer-file-name orig-buf) (file-name-nondirectory (buffer-file-name orig-buf))) :annotation annotation :initial initial :return-to-wconf (current-window-configuration) :default-time (or org-overriding-default-time (org-current-time))) (org-capture-set-target-location (and (equal goto 0) 'here)) (condition-case error (org-capture-put :template (org-capture-fill-template)) ((error quit) (if (get-buffer "*Capture*") (kill-buffer "*Capture*")) (error "Capture abort: %s" (error-message-string error)))) (setq org-capture-clock-keep (org-capture-get :clock-keep)) (condition-case error (org-capture-place-template (eq (car (org-capture-get :target)) 'function)) ((error quit) (if (and (buffer-base-buffer (current-buffer)) (string-prefix-p "CAPTURE-" (buffer-name))) (progn (kill-buffer (current-buffer)))) (set-window-configuration (org-capture-get :return-to-wconf)) (error "Capture template `%s': %s" (org-capture-get :key) (error-message-string error)))) (if (and (derived-mode-p 'org-mode) (org-capture-get :clock-in)) (progn (condition-case nil (progn (if (org-clock-is-active) (progn ...)) (org-clock-in) (set (make-local-variable ...) (copy-marker org-clock-marker))) (error "Could not start the clock in this capture buffer")))) (if (org-capture-get :immediate-finish) (progn (org-capture-finalize))))) (let* ((orig-buf (current-buffer)) (annotation (if (and (boundp 'org-capture-link-is-already-stored) org-capture-link-is-already-stored) (plist-get org-store-link-plist :annotation) (condition-case nil (progn (org-store-link nil)) (error nil)))) (entry (or org-capture-entry (org-capture-select-template keys))) initial) (setq initial (or org-capture-initial (and (org-region-active-p) (buffer-substring (point) (mark))))) (if (stringp initial) (progn (remove-text-properties 0 (length initial) '(read-only t) initial))) (if (stringp annotation) (progn (remove-text-properties 0 (length annotation) '(read-only t) annotation))) (cond ((equal entry "C") (customize-variable 'org-capture-templates)) ((equal entry "q") (user-error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) (org-capture-put :original-buffer orig-buf :original-file (or (buffer-file-name orig-buf) (and (featurep 'dired) (car (rassq orig-buf dired-buffers)))) :original-file-nondirectory (and (buffer-file-name orig-buf) (file-name-nondirectory (buffer-file-name orig-buf))) :annotation annotation :initial initial :return-to-wconf (current-window-configuration) :default-time (or org-overriding-default-time (org-current-time))) (org-capture-set-target-location (and (equal goto 0) 'here)) (condition-case error (org-capture-put :template (org-capture-fill-template)) ((error quit) (if (get-buffer "*Capture*") (kill-buffer "*Capture*")) (error "Capture abort: %s" (error-message-string error)))) (setq org-capture-clock-keep (org-capture-get :clock-keep)) (condition-case error (org-capture-place-template (eq (car (org-capture-get :target)) 'function)) ((error quit) (if (and (buffer-base-buffer ...) (string-prefix-p "CAPTURE-" ...)) (progn (kill-buffer ...))) (set-window-configuration (org-capture-get :return-to-wconf)) (error "Capture template `%s': %s" (org-capture-get :key) (error-message-string error)))) (if (and (derived-mode-p 'org-mode) (org-capture-get :clock-in)) (progn (condition-case nil (progn (if ... ...) (org-clock-in) (set ... ...)) (error "Could not start the clock in this capture buffer")))) (if (org-capture-get :immediate-finish) (progn (org-capture-finalize)))))) (cond ((equal goto '(4)) (org-capture-goto-target keys)) ((equal goto '(16)) (org-capture-goto-last-stored)) (t (let* ((orig-buf (current-buffer)) (annotation (if (and (boundp ...) org-capture-link-is-already-stored) (plist-get org-store-link-plist :annotation) (condition-case nil (progn ...) (error nil)))) (entry (or org-capture-entry (org-capture-select-template keys))) initial) (setq initial (or org-capture-initial (and (org-region-active-p) (buffer-substring (point) (mark))))) (if (stringp initial) (progn (remove-text-properties 0 (length initial) '(read-only t) initial))) (if (stringp annotation) (progn (remove-text-properties 0 (length annotation) '(read-only t) annotation))) (cond ((equal entry "C") (customize-variable 'org-capture-templates)) ((equal entry "q") (user-error "Abort")) (t (org-capture-set-plist entry) (org-capture-get-template) (org-capture-put :original-buffer orig-buf :original-file (or (buffer-file-name orig-buf) (and ... ...)) :original-file-nondirectory (and (buffer-file-name orig-buf) (file-name-nondirectory ...)) :annotation annotation :initial initial :return-to-wconf (current-window-configuration) :default-time (or org-overriding-default-time (org-current-time))) (org-capture-set-target-location (and (equal goto 0) 'here)) (condition-case error (org-capture-put :template (org-capture-fill-template)) ((error quit) (if ... ...) (error "Capture abort: %s" ...))) (setq org-capture-clock-keep (org-capture-get :clock-keep)) (condition-case error (org-capture-place-template (eq ... ...)) ((error quit) (if ... ...) (set-window-configuration ...) (error "Capture template `%s': %s" ... ...))) (if (and (derived-mode-p ...) (org-capture-get :clock-in)) (progn (condition-case nil ... ...))) (if (org-capture-get :immediate-finish) (progn (org-capture-finalize)))))))) org-capture(nil) funcall-interactively(org-capture nil) call-interactively(org-capture nil nil) command-execute(org-capture) #+end_example And here is my emacs minimal config try to reproduce this error but can't and don't know how to reproduce it. #+begin_src emacs-lisp (require 'org-capture) (setq org-capture-templates `(("t" ,(format "%s\tstart a clock task" (all-the-icons-faicon "hourglass-start" :face 'all-the-icons-red :v-adjust 0.05)) entry (file "~/Org/Tasks/Tasks.org") "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n" :clock-in t :clock-resume t :clock-keep t :empty-lines 1) )) (use-package all-the-icons :ensure t) (use-package elfeed :ensure t ;; For debugging ;; :preface (setq elfeed-log-level 'debug) :commands (elfeed elfeed-update) :custom ((elfeed-db-directory (expand-file-name ".elfeed" user-emacs-directory)) ;; specify proxy for elfeed backend cURL. (elfeed-curl-extra-arguments '("--proxy" "socks5h:// 127.0.0.1:7890")) ;; elfeed startup initial tags (elfeed-initial-tags '(unread)) (elfeed-feeds '(;; Programming ;; ("http://blog.stackoverflow.com/feed/" programming stackoverflow) ;; ("http://programmers.blogoverflow.com/feed/" programming stackoverflow) ;; Emacs ;; ("https://www.reddit.com/r/emacs/.rss" emacs reddit) ; Reddit r/Emacs ;; ("https://planet.emacslife.com/atom.xml" emacs planet) ; Planet Emacslife ;; ("https://www.reddit.com/r/orgmode/.rss" org-mode reddit) ; Reddit r/Org-mode ;; ("https://emacs-china.org/posts.rss" emacs china) ; Emacs China 最新帖子 ;; ("https://emacs-china.org/latest.rss" emacs china) ; Emacs China 最新话题 ("https://sachachua.com/blog/feed/atom/" blog emacs) ; Sacha Chua Blog ("http://feeds.feedburner.com/TheKitchinResearchGroup" blog emacs) ; The Kitchin Research Group ("https://200ok.ch/atom.xml" blog emacs) ; 200ok.ch )) ) :init (advice-add 'elfeed :after #'elfeed-update) ; auto update after entering elfeed. ;; (run-at-time nil (* 4 60 60) #'elfeed-update) ; auto update elfeed every 4 hours. ;; FIXME: `elfeed' use `switch-to-buffer'. (add-to-list 'display-buffer-alist '("^\\*elfeed-search\\*" . (display-buffer-below-selected))) :config ;; (define-key elfeed-search-mode-map (kbd "#") 'elfeed-search-set-filter) (defalias 'elfeed-search-toggle-all-star ; [m], [*] (elfeed-expose #'elfeed-search-toggle-all 'star) "Toggle the `star' tag to all selected entries.") (define-key elfeed-search-mode-map (kbd "m") 'elfeed-search-toggle-all-star) ;; Auto close elfeed buffers when quit Emacs. (defun elfeed-quit () "Close elfeed buffers." (interactive) (elfeed-db-save) (dolist (buffer '("*elfeed-log*" "*elfeed-search*" "*elfeed-entry*")) (when (buffer-live-p (get-buffer buffer)) (with-current-buffer buffer (kill-buffer))))) (define-key elfeed-search-mode-map (kbd "q") 'elfeed-quit) (add-hook 'kill-emacs-hook #'elfeed-quit) ;; support Org Mode Capture template (defun my/org-capture-elfeed-title () (with-current-buffer "*elfeed-entry*" (elfeed-entry-title elfeed-show-entry))) (defun my/org-capture-elfeed-date () (with-current-buffer "*elfeed-entry*" (format-time-string "[%Y-%m-%d %a %H:%M]" (seconds-to-time (elfeed-entry-date elfeed-show-entry))))) (defun my/org-capture-elfeed-source () (with-current-buffer "*elfeed-entry*" (let ((feed (elfeed-entry-feed elfeed-show-entry))) (elfeed-feed-title feed)))) (defun my/org-capture-elfeed-content () (with-current-buffer "*elfeed-entry*" (let* ((content (elfeed-deref (elfeed-entry-content elfeed-show-entry))) (type (elfeed-entry-content-type elfeed-show-entry)) (feed (elfeed-entry-feed elfeed-show-entry)) (base-url (and feed (elfeed-compute-base (elfeed-feed-url feed))))) (if content (if (eq type 'html) (progn (unless (fboundp 'org-web-tools--html-to-org-with-pandoc) (require 'org-web-tools)) (let ((org-web-tools-pandoc-sleep-time 5)) (org-web-tools--html-to-org-with-pandoc content))) (insert content)))))) (with-eval-after-load 'org-capture (add-to-list 'org-capture-templates `("r" ,(format "%s\tcapture elfeed RSS feed content to Org buffer" (all-the-icons-faicon "rss" :face 'all-the-icons-blue-alt)) entry (file "") "* %(my/org-capture-elfeed-title) :PROPERTIES: :SOURCE: %(my/org-capture-elfeed-source) :DATE(original): %(my/org-capture-elfeed-date) :DATE: %u :END: %(my/org-capture-elfeed-content)" :empty-lines 1 :jump-to-captured t) :append)) ;; auto re-format elfeed entry org-capture buffer. (defun my/elfeed-format-org-capture-buffer () "A helper command to Delete org-capture elfeed-entry ending backslash \\." (interactive) (goto-char (point-min)) (replace-string "\\" "") (replace-string " " "") ;; using regex replace using \( \)\{2,\} which means 2 or more consecutive spaces and replace that with 1 space. (replace-regexp "\\( \\)\\{2,\\}" " ") (org-mark-subtree) ; or `org-mark-element', `mark-whole-buffer' (call-interactively 'org-fill-paragraph) ; or `fill-paragraph' ) (add-hook 'org-capture-mode-hook #'my/elfeed-format-org-capture-buffer) ;; Download link media with youtube-dl. (defun youtube-dl-cmd-wrapper (url) "Downloads the URL with youtube-dl in an async shell" (let ((default-directory "~/Downloads")) (async-shell-command (format "youtube-dl %s" url)))) (defun elfeed-youtube-dl (&optional use-generic-p) "Use youtube-dl to download the link media." (interactive "P") (let ((entries (elfeed-search-selected))) (cl-loop for entry in entries do (elfeed-untag entry 'unread) when (elfeed-entry-link entry) do (youtube-dl-cmd-wrapper it)) (mapc #'elfeed-search-update-entry entries) (unless (use-region-p) (forward-line)))) (define-key elfeed-search-mode-map (kbd "d") 'elfeed-youtube-dl) ) #+end_src I might need to take some time to bisect my Emacs config with bug-hunter to check whether some options caused this error. I will add more details later. If you have any clue about this error, thanks for the hint. [stardiviner] GPG key ID: 47C32433 IRC(freeenode): stardiviner Twitter: @numbchild Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433 Blog: http://stardiviner.github.io/