Subject: 29.4; org-refile-get-targets wrong-type-argument

From: Serghei Iakovlev <[email-masked]>
Date: Sat, 14 Sep 2024 08:44:46 +0200

Hello,

I encountered an issue with `org-mode' in my Emacs configuration
related to periodic clearing of the refile cache during idle time.  I
am using the following code snippet, which runs during idle time to
clear the cache of refile targets:

--8<---------------cut here---------------start------------->8---
(run-with-idle-timer 600 t (lambda ()
                             (require 'org-refile)
                             (org-refile-cache-clear)
                             (org-refile-get-targets)))
--8<---------------cut here---------------end--------------->8---

As far as I can tell, the code is syntactically and semantically
correct.  However, it doesn't seem to work as expected and triggers
an error.  After enabling `toggle-debug-on-error', I found the
following error message in the morning:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  looking-at(nil)
  org-refile-get-targets()
  (closure (t) nil (require 'org-refile) (org-refile-cache-clear) (org-refile-get-targets))()
  apply((closure (t) nil (require 'org-refile) (org-refile-cache-clear) (org-refile-get-targets)) nil)
  timer-event-handler([t 0 600 0 t (closure (t) nil (require 'org-refile) (org-refile-cache-clear) (org-refile-get-targets)) nil idle 0 nil])
--8<---------------cut here---------------end--------------->8---

However, when I manually execute the `org-refile-get-targets' function,
it works without any issues.  Unfortunately, I cannot provide a more
reproducible scenario beyond what I've described here.

For further investigation, I am attaching links to my complete Emacs
configuration in the hope that it might help.  These are permalinks
to the specific commit reflecting the state of my configuration at
the time of the error:

init.el:
https://github.com/sergeyklay/.emacs.d/blob/01f971ea2e5e21dc20ac468799c55099ae9ae230/init.el

early-init.el
https://github.com/sergeyklay/.emacs.d/blob/01f971ea2e5e21dc20ac468799c55099ae9ae230/early-init.el

                    Serghei

--

In GNU Emacs 29.4 (build 1, aarch64-apple-darwin21.6.0, NS
 appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2024-08-02 built on
 armbob.lan
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.6.1

Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules 'CFLAGS=-DFD_SETSIZE=10000
 -DDARWIN_UNLIMITED_SELECT' --with-x-toolkit=no'

Configured features:
ACL GLIB GMP GNUTLS JPEG JSON LIBXML2 MODULES NOTIFY KQUEUE NS
PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  display-fill-column-indicator-mode: t
  rainbow-delimiters-mode: t
  which-key-mode: t
  save-place-mode: t
  savehist-mode: t
  recentf-mode: t
  winner-mode: t
  windmove-mode: t
  electric-pair-mode: t
  vertico-prescient-mode: t
  prescient-persist-mode: t
  vertico-mode: t
  marginalia-mode: t
  erc-spelling-mode: t
  flyspell-mode: t
  erc-services-mode: t
  erc-networks-mode: t
  pixel-scroll-precision-mode: t
  outline-minor-mode: t
  shell-dirtrack-mode: t
  server-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/Users/serghei/.emacs.d/elpa/transient-0.7.4/transient hides /Applications/Emacs.app/Contents/Resources/lisp/transient

Features:
(shadow emacsbug debug backtrace writegood-mode embark-org
embark-consult embark sort gnus-cite smiley shr-color mm-archive
mail-extr textsec uni-scripts idna-mapping uni-confusable
textsec-check gnus-async gnus-bcklg qp gnus-ml disp-table gnus-topic
nndraft nnmh utf-7 nnfolder network-stream nsm gnus-agent gnus-srvr
gnus-score score-mode nnvirtual gnus-msg nntp gnus-cache vc-hg vc-bzr
vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference
magit-extras magit-bookmark magit-submodule magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch
magit-clone magit-remote magit-commit magit-sequence magit-notes
magit-worktree magit-tag magit-merge magit-branch magit-reset
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log which-func magit-diff smerge-mode diff git-commit
log-edit pcvs-util add-log magit-core magit-autorevert autorevert
magit-margin magit-transient magit-process magit-mode transient
benchmark magit-git magit-base magit-section crm cus-start misearch
multi-isearch cl-print consult bookmark mhtml-mode rainbow-mode
css-mode smie js c-ts-common sgml-mode facemenu htmlize cl cal-iso
hl-line org-archive face-remap org-agenda
display-fill-column-indicator vc-git diff-mode vc-dispatcher shortdoc
help-fns radix-tree image-file image-converter org-indent oc-basic
ffap org-element org-persist org-id org-refile avl-tree generator
ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info
ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime
gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg dom
gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap
nnmail mail-source utf7 nnoo gnus-spec gnus-int gnus-range message
sendmail yank-media puny rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
gmm-utils mailheader gnus-win gnus nnheader gnus-util
text-property-search mail-utils range mm-util mail-prsvr ol-docview
doc-view filenotify jka-compr image-mode exif dired dired-loaddefs
ol-bibtex bibtex ol-bbdb ol-w3m ol-doi org-link-doi cursor-sensor
rainbow-delimiters which-key saveplace savehist recentf tree-widget
winner windmove elec-pair vertico-prescient prescient char-fold
orderless vertico marginalia sqlite-mode erc-track erc-match
erc-spelling flyspell-correct edmacro kmacro flyspell erc-services
erc-join erc-log erc-hl-nicks color erc-button erc-fill erc-stamp
erc-goodies erc thingatpt erc-backend erc-networks erc-common
erc-compat erc-loaddefs diary-lib diary-loaddefs pixel-scroll
cua-base modus-vivendi-theme modus-themes parse-time iso8601
org-cliplink org-cliplink-transport org-cliplink-string em-glob
esh-util files-x org-crypt ob-calc calc-store calc-trail calc-ext
calc calc-loaddefs rect calc-macs ob-sql ob-shell ob-scheme ob-python
python project pcase treesit ob-org ob-makefile ob-lisp ob-latex
ob-js ob-haskell ob-C cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs cus-edit pp cus-load
wid-edit org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src ob-comint org-pcomplete org-list org-footnote org-faces
org-entities time-date noutline outline icons ob-emacs-lisp ob-core
ob-eval org-cycle org-table ol rx org-fold org-fold-core org-keys oc
org-loaddefs find-func cal-menu calendar cal-loaddefs org-version
org-compat org-macs format-spec pass f dash s imenu password-store
auth-source-pass with-editor cl-extra help-mode shell pcomplete
comint ansi-osc ansi-color ring server compat compat-30 epa-file epa
derived epg rfc6068 epg-config bind-key easy-mmode ispell
benchmark-init advice finder-inf info anaconda-mode-autoloads
anzu-autoloads avy-autoloads benchmark-init-autoloads
consult-flyspell-autoloads csv-mode-autoloads
embark-consult-autoloads consult-autoloads embark-autoloads
erc-hl-nicks-autoloads flyspell-correct-autoloads git-modes-autoloads
ht-autoloads htmlize-autoloads magit-autoloads git-commit-autoloads
magit-section-autoloads marginalia-autoloads markdown-mode-autoloads
orderless-autoloads org-cliplink-autoloads org-contacts-autoloads
pass-autoloads password-store-otp-autoloads password-store-autoloads
pythonic-autoloads f-autoloads rainbow-delimiters-autoloads
rainbow-mode-autoloads sql-indent-autoloads transient-autoloads
ts-autoloads s-autoloads dash-autoloads vertico-prescient-autoloads
vertico-autoloads prescient-autoloads which-key-autoloads
with-editor-autoloads compat-autoloads writegood-mode-autoloads
yaml-mode-autoloads package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs password-cache json subr-x map byte-opt gv
bytecomp byte-compile url-vars cl-loaddefs cl-lib early-init rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock
syntax font-core term/tty-colors frame minibuffer nadvice seq simple
cl-generic indonesian philippine cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads
kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 1205614 212224)
 (symbols 48 53033 4)
 (strings 32 267105 41903)
 (string-bytes 1 7295282)
 (vectors 16 104190)
 (vector-slots 8 2150716 734460)
 (floats 8 1794 9619)
 (intervals 56 24161 2783)
 (buffers 984 46))