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.
And here is my emacs minimal config try to reproduce this error but can't and don't know how to reproduce it.
(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)
)
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.