emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-refile-get-targets wrong-type-argument [9.6.15 (release_9.6.15 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
@ 2024-09-14 14:34 Serghei Iakovlev
  2024-09-16 19:13 ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Serghei Iakovlev @ 2024-09-14 14:34 UTC (permalink / raw)
  To: emacs-orgmode

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

------------------------------------------------------------------------



Emacs  : 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
Package: Org mode version 9.6.15 (release_9.6.15 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)

current state:
==============
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-after-refile-insert-hook '(my|org-update-statistics-cookies-after-refile)
 org-crypt-key '("1E0B5331219BEA88")
 org-hide-emphasis-markers t
 org-bibtex-headline-format-function #[257 "\300.\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
 org-log-done 'time
 org-agenda-custom-commands '(("g" "Agenda" agenda "")
                              ("u" "Untagged Headings" tags "-{.*}"
                               ((org-agenda-overriding-header "Untagged Headings")))
                              ("o" "Unfinished, but not scheduled tasks"
                               ((tags-todo "-someday-project"
                                 ((org-agenda-skip-function
                                   'my-org-agenda-skip-parent-if-has-scheduled-childs)
                                  (org-agenda-overriding-header "Unscheduled Tasks"))
                                 )
                                )
                               )
                              ("O" "Scheduled, but with :someday: tag"
                               ((tags "+someday"
                                 ((org-agenda-skip-function
                                   '(or (org-agenda-skip-entry-if 'notscheduled)
                                     (org-agenda-skip-entry-if 'todo 'done))
                                   )
                                  (org-agenda-overriding-header "Scheduled Someday Tasks"))
                                 )
                                )
                               )
                              ("p" "Pick a task from unscheduled list"
                               ((tags "+someday"
                                 ((org-agenda-skip-function
                                   '(or (org-agenda-skip-entry-if 'scheduled)
                                     (org-agenda-skip-entry-if 'todo 'done))
                                   )
                                  (org-agenda-overriding-header "Backlog"))
                                 )
                                )
                               )
                              ("N" "Non-business: Open focus projects"
                               ((tags "+focus+project-CATEGORY={airslate\\|business}"
                                 ((org-agenda-skip-function
                                   '(org-agenda-skip-entry-if 'todo 'done))
                                  (org-agenda-overriding-header
                                   "Personal Focus: Open Projects")
                                  )
                                 )
                                )
                               )
                              ("B" "Business: Open focus projects"
                               ((tags "+focus+project+CATEGORY={airslate\\|business}"
                                 ((org-agenda-skip-function
                                   '(org-agenda-skip-entry-if 'todo 'done))
                                  (org-agenda-overriding-header
                                   "Business Focus: Open Projects")
                                  )
                                 )
                                )
                               )
                              ("P" "Stuck Projects"
                               ((tags "+project-someday-DONE-CANCELED"
                                 ((org-agenda-skip-function
                                   'my-org-agenda-skip-non-stuck-projects)
                                  (org-agenda-overriding-header
                                   "Stuck Projects with open but not scheduled sub-tasks")
                                  )
                                 )
                                )
                               )
                              ("w" "Tasks done this week"
                               ((tags
                                 (format "TODO=\"DONE\"&CLOSED>=\"<%s>\""
                                  (my-get-week-start-date))
                                 ((org-agenda-overriding-header "Tasks done this week")))
                                (tags
                                 (format "TODO=\"TODO\"&LAST_REPEAT>=\"<%s>\""
                                  (my-get-week-start-date))
                                 ((org-agenda-overriding-header
                                   "Recurrent tasks acted upon this week")
                                  )
                                 )
                                )
                               ((org-agenda-cmp-user-defined 'my-org-cmp-closed)
                                (org-agenda-sorting-strategy '(user-defined-down)))
                               )
                              ("W" "Tasks done this month"
                               ((tags
                                 (format "TODO=\"DONE\"&CLOSED>=\"<%s>\""
                                  (my-get-month-start-date))
                                 ((org-agenda-overriding-header "Tasks done this month")))
                                (tags
                                 (format "TODO=\"TODO\"&LAST_REPEAT>=\"<%s>\""
                                  (my-get-month-start-date))
                                 ((org-agenda-overriding-header
                                   "Recurrent tasks acted upon this month")
                                  )
                                 )
                                )
                               ((org-agenda-cmp-user-defined 'my-org-cmp-closed)
                                (org-agenda-sorting-strategy '(user-defined-down)))
                               )
                              ("-" "Standalone Tasks"
                               ((tags-todo "-project-DONE-CANCELED"
                                 ((org-agenda-skip-function
                                   '(my-org-agenda-skip-if-parent-has-tag "project"))
                                  (org-agenda-overriding-header
                                   "Standalone Tasks: No Projects or DONE Items")
                                  )
                                 )
                                )
                               )
                              ("R" . "Reports")
                              ("Rn" "No TODO events +180d"
                               ((agenda "No TODO events +180d"
                                 ((org-agenda-span 180) (org-agenda-time-grid nil)
                                  (org-agenda-entry-types '(:timestamp :sexp))
                                  (org-agenda-skip-function
                                   '(org-agenda-skip-entry-if 'todo 'any))
                                  )
                                 )
                                )
                               nil
                               ("/Users/serghei/Documents/Notes/Reports/agenda_180d_filtered.html")
                               )
                              ("Ra" "Detail agenda +31d"
                               ((agenda "Detail agenda"
                                 ((org-agenda-span 31) (org-agenda-time-grid nil)
                                  (org-agenda-skip-function
                                   '(org-agenda-skip-entry-if 'todo 'done))
                                  )
                                 )
                                )
                               nil
                               ("/Users/serghei/Documents/Notes/Reports/agenda_details_raw.html")
                               )
                              ("Rw" "Company work done this week"
                               ((tags
                                 (format "TODO=\"DONE\"&CLOSED>=\"<%s>\"|TODO=\"STARTED\""
                                  (my-get-week-start-date))
                                 ((org-agenda-overriding-header
                                   (concat "Tasks I worked on this week ("
                                    (string-join (my-weekly-agenda-export-range) " - ")
                                    ")")
                                   )
                                  )
                                 )
                                (tags
                                 (format "TODO=\"TODO\"&LAST_REPEAT>=\"<%s>\""
                                  (my-get-week-start-date))
                                 ((org-agenda-overriding-header
                                   "Recurrent tasks acted upon this week")
                                  )
                                 )
                                )
                               ((org-agenda-files '("airslate.org"))
                                (org-agenda-cmp-user-defined 'my-org-cmp-closed)
                                (org-agenda-sorting-strategy '(user-defined-down))
                                (org-agenda-hide-tags-regexp ".")
                                (org-agenda-prefix-format "  %?-12t% s")
                                (org-agenda-todo-keyword-format "%-10s"))
                               "/Users/serghei/Documents/Notes/Reports/serghei_work_review_2024.09.09-2024.09.15.txt")
                              )
 org-log-into-drawer t
 org-startup-folded t
 org-link-abbrev-alist '(("contact" . "/Users/serghei/org/contacts.org::"))
 org-agenda-files '("/Users/serghei/org/business.org" "/Users/serghei/org/airslate.org"
                    "/Users/serghei/org/blog.org" "/Users/serghei/org/contacts.org"
                    "/Users/serghei/org/flair.org" "/Users/serghei/org/hardware.org"
                    "/Users/serghei/org/inbox.org" "/Users/serghei/org/misc.org"
                    "/Users/serghei/org/notes.org")
 org-capture-templates '(("s" "Shorts" entry (file+headline "misc.org" "Shorts")
                          "* TODO %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines
                          1)
                         ("e" "Event" entry (file+headline "misc.org" "Events")
                          "* %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines 1)
                         ("k" "Contact" entry (file "")
                          "* %^{Name} %^g\n:PROPERTIES:\n:TYPE: %^{PROMPT|person|person|company|list|other}\n:EMAIL: %^{Email}\n:PHONE: %^{Phone}\n:STREET:\n:POSTALCODE:\n:CITY:\n:COUNTRY:\n:BIRTHDAY: %^{Birthday}t\n:URL:\n:NOTE: %^{NOTE}\n:CREATED: %U\n:END:\n\n" :empty-lines 1)
                         ("t" "Trip Checklist" checkitem
                          (file+headline "misc.org" "Trip Checklist"))
                         ("b" "Bookmark" entry (file+headline "notes.org" "Bookmarks")
                          "* %x%?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines 1)
                         ("i" "Blog Idea" entry
                          (file+headline "blog.org" "Captured Blog Ideas")
                          "* TODO %?        :blog:%^g\n:PROPERTIES:\n:CREATED: %U\n:ID: %^{PROMPT}\n:END:\n\n-----------------------\n- [ ] Link on older/similar articles?\n- [ ] Link on tag pages?\n\n" :empty-lines 1)
                         ("n" "Thought or Note" entry
                          (file+headline "notes.org" "Random Notes")
                          "* TODO %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines
                          1)
                         ("I" "Inbox, refile later" entry (file "")
                          "* %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines 0)
                         ("r" "To-Read" entry (file+headline "misc.org" "To-Read List")
                          "* TODO %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n%x\n\n"
                          :empty-lines 1)
                         ("w" "To-Watch" entry (file+headline "misc.org" "To-Watch List")
                          "* TODO %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n%x\n\n"
                          :empty-lines 1)
                         ("B" "Business")
                         ("Bs" "Shorts" entry (file+headline "business.org" "Shorts")
                          "* TODO %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines
                          1)
                         ("Bm" "Meeting Note" entry
                          (file+headline "airslate.org" "Meeting Notes")
                          "* TODO %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines
                          1)
                         ("Be" "Event" entry (file+headline "business.org" "Events")
                          "* %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines 1)
                         )
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-refile-targets '((nil :maxlevel . 4) (my-org-opened-buffer-files :maxlevel . 4)
                      (org-agenda-files :maxlevel . 4))
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-default-notes-file "/Users/serghei/org/inbox.org"
 org-agenda-exporter-settings '((htmlize-output-type 'css))
 org-refile-use-outline-path 'file
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-odt-format-inlinetask-function 'org-odt-format-inlinetask-default-function
 org-mobile-inbox-for-pull "/Users/serghei/org/inbox.org"
 org-ascii-format-drawer-function #[771 ".\207" [] 4 "\n\n(fn NAME CONTENTS WIDTH)"]
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines
                  org-cycle-optimize-window-after-visibility-change
                  org-cycle-display-inline-images)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-image-actual-width '(600)
 org-crypt-disable-auto-save nil
 org-mode-hook '(#[0
                   "\b\205.\301 \205.\302\303\301 !\304P!\305.!\205.\306.!\262.\207"
                   [org-ctags-enabled-p buffer-file-name expand-file-name
                    file-name-directory "/TAGS" file-exists-p visit-tags-table]
                   3]
                 #[0
                   "\305.\306	>\203.\307\n\310\311#\210\307\v\312\313#\210\307\v\314\315#\210\306	>\203,.\307\n\316\317#\210\307\n\320\321#\210\322	>\203>.\307\v\323\324#\210\307\v\325\324#\210\326	>\203P.\307\n\327\317#\210\307\n\330\321#\210\331	>\203_.\332\311\f\333BC\334#\210\335	>\203k.\332\311\336\334#\210\337	>\203w.\332\311\340\334#\210\341\342\343\344#\207"
                   [org-mouse-context-menu-function

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mouse-features

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mouse-map

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mode-map

                                                                                                                                                                                                                                                                                                                                                                                                                     org-outline-regexp

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mouse-context-menu

                                                                                                                                                                                                                                                                                                                                                                                                                     context-menu

                                                                                                                                                                                                                                                                                                                                                                                                                     org-defkey

                                                                                                                                                                                                                                                                                                                                                                                                                     [mouse-3]

                                                                                                                                                                                                                                                                                                                                                                                                                     nil

                                                                                                                                                                                                                                                                                                                                                                                                                     [mouse-3]

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mouse-show-context-menu

                                                                                                                                                                                                                                                                                                                                                                                                                     [down-mouse-1]

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mouse-down-mouse

                                                                                                                                                                                                                                                                                                                                                                                                                     [C-drag-mouse-1]

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mouse-move-tree

                                                                                                                                                                                                                                                                                                                                                                                                                     [C-down-mouse-1]

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mouse-move-tree-start

                                                                                                                                                                                                                                                                                                                                                                                                                     yank-link

                                                                                                                                                                                                                                                                                                                                                                                                                     [S-mouse-2]

                                                                                                                                                                                                                                                                                                                                                                                                                     org-mouse-yank-link

                                                                                                                                                                                                                                                                                                                                                                                                                     [drag-mouse-3]

                                                                                                                                                                                                                                                                                                                                                                                                                     move-tree

                                                                                                                                                                                                                                                                                                                                                                                                                     [drag-mouse-3]

                                                                                                                                                                                                                                                                                                                                                                                                                     [down-mouse-3]

                                                                                                                                                                                                                                                                                                                                                                                                                     activate-stars

                                                                                                                                                                                                                                                                                                                                                                                                                     font-lock-add-keywords

                                                                                                                                                                                                                                                                                                                                                                                                                     (0





                                                                                                                                                                                                                                                                                                                                                                                                                                                            `(face org-link mouse-face highlight keymap ,org-mouse-map)





                                                                                                                                                                                                                                                                                                                                                                                                                                                            'prepend)

                                                                                                                                                                                                                                                                                                                                                                                                                     t

                                                                                                                                                                                                                                                                                                                                                                                                                     activate-bullets

                                                                                                                                                                                                                                                                                                                                                                                                                     (("^[ 	]*\\([-+*]\\|[0-9]+[.)]\\) +"





                                                                                                                                                                                                                                                                                                                                                                                                                                          (1











                                                                                                                                                                                                                                                                                                                                                                                                                                                                               `(face org-link keymap ,org-mouse-map mouse-face highlight)











                                                                                                                                                                                                                                                                                                                                                                                                                                                                               'prepend)





                                                                                                                                                                                                                                                                                                                                                                                                                                          )





                                                                                                                                                                                                                                                                                                                                                                                                                                         )

                                                                                                                                                                                                                                                                                                                                                                                                                     activate-checkboxes

                                                                                                                                                                                                                                                                                                                                                                                                                     (("^[ 	]*\\(?:[-+*]\\|[0-9]+[.)]\\)[ 	]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ 	]*\\)?\\(\\[[- X]\\]\\)"



                                                                                                                                                                                                                                                                                                                                                                                                                                           (1







                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  `(face nil keymap ,org-mouse-map mouse-face highlight)







                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  prepend)



                                                                                                                                                                                                                                                                                                                                                                                                                                           )



                                                                                                                                                                                                                                                                                                                                                                                                                                          )

                                                                                                                                                                                                                                                                                                                                                                                                                     advice-add org-open-at-point :around org--mouse-open-at-point]
                   4]
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook before-save-hook org-encrypt-entries nil t] 5]
                 my|org-setup-environment
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook change-major-mode-hook org-fold-show-all append local] 5]
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook change-major-mode-hook org-babel-show-result-all append local]
                   5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes
                 #[0 "\301\211.\207" [imenu-create-index-function org-imenu-get-tree] 2])
 org-babel-load-languages '((C . t) (emacs-lisp . t) (haskell . t) (js . t) (latex . t)
                            (lisp . t) (makefile . t) (org . t) (python . t) (scheme . t)
                            (shell . t) (sql . t) (calc . t))
 org-mobile-directory "/Users/serghei/Documents/Notes"
 outline-minor-mode-hook '(outline-hide-body)
 org-agenda-time-grid '((daily today require-timed) (800 1000 1200 1400 1600 1800 2000)
                        "......" "----------------")
 org-agenda-span 1
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-latex-format-headline-function 'org-latex-format-headline-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-reveal-start-hook '(org-decrypt-entry)
 org-agenda-compact-blocks t
 org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 outline-isearch-open-invisible-function 'outline-isearch-open-invisible
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-agenda-mode-hook '(#[0
                          "\302.\303	\304\305#\210\303	\306\307#\210\303	\310\311#\210\303	\312\313#\210\303	\314\315#\207"
                          [org-mouse-context-menu-function

                                                                                                                                                        org-agenda-mode-map

                                                                                                                                                        org-mouse-agenda-context-menu

                                                                                                                                                        org-defkey

                                                                                                                                                        [mouse-3]

                                                                                                                                                        org-mouse-show-context-menu

                                                                                                                                                        [down-mouse-3]

                                                                                                                                                        org-mouse-move-tree-start

                                                                                                                                                        [C-mouse-4]

                                                                                                                                                        org-agenda-earlier

                                                                                                                                                        [C-mouse-5]

                                                                                                                                                        org-agenda-later

                                                                                                                                                        [drag-mouse-3]

                                                                                                                                                        #[257

                                                                                                                                                          "\300.!\211\301\267\202.\302\303!\207\304\303!\207\305\207"

                                                                                                                                                          [org-mouse-get-gesture





                                                                                                                                                                                                                               #s(hash-table











                                                                                                                                                                                                                                                        size











                                                                                                                                                                                                                                                        2











                                                                                                                                                                                                                                                        test











                                                                                                                                                                                                                                                        eq











                                                                                                                                                                                                                                                        rehash-size











                                                                                                                                                                                                                                                        1.5











                                                                                                                                                                                                                                                        rehash-threshold











                                                                                                                                                                                                                                                        0.8125











                                                                                                                                                                                                                                                        purecopy











                                                                                                                                                                                                                                                        t











                                                                                                                                                                                                                                                        data











                                                                                                                                                                                                                                                        (:left 9 :right 13)











                                                                                                                                                                                                                                                        )





                                                                                                                                                                                                                               org-agenda-earlier 1 org-agenda-later nil]

                                                                                                                                                          4 "\n\n(fn EVENT)" "e"]

                                                                                                                                                        ]
                          4]
                        my|org-agenda-refresh-on-idle (closure (t) nil (hl-line-mode 1)))
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-tangle-lang-exts '(("python" . "py") ("lisp" . "lisp") ("latex" . "tex")
                              ("haskell" . "hs") ("D" . "d") ("C++" . "cpp")
                              ("emacs-lisp" . "el") ("elisp" . "el"))
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
                     org-src-mode-configure-edit-buffer)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-tags-exclude-from-inheritance '("project" "crypt")
 org-fold-show-context-detail '((agenda . lineage) (bookmark-jump . lineage)
                                (isearch . lineage) (default . ancestors))
 org-todo-keywords '((sequence "TODO(t)" "STARTED(s)" "WAITING(w@/!)" "|" "DONE(d!/!)"
                      "CANCELED(c@/!)")
                     )
 org-mobile-force-id-on-agenda-items nil
 org-agenda-inhibit-startup t
 org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
 org-speed-command-hook '(org-speed-command-activate org-babel-speed-command-activate)
 org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-refile-use-cache t
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-enforce-todo-dependencies t
 org-fold-core-isearch-open-function 'org-fold--isearch-reveal
 org-latex-format-inlinetask-function 'org-latex-format-inlinetask-default-function
 org-persist-before-write-hook '(org-element--cache-persist-before-write)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-link-shell-confirm-function 'yes-or-no-p
 org-contacts-files '("/Users/serghei/org/contacts.org")
 org-babel-pre-tangle-hook '(save-buffer)
 org-agenda-loop-over-headlines-in-active-region nil
 org-todo-keyword-faces '(("TODO" :foreground "firebrick1" :weight bold)
                          ("STARTED" :foreground "red3" :weight bold)
                          ("WAITING" :foreground "orange" :weight bold)
                          ("DONE" :foreground "forest green" :weight bold)
                          ("CANCELED" :foreground "lime green" :weight bold))
 org-capture-mode-hook '((closure (t) nil (require 'org-contacts)))
 org-fold-reveal-start-hook '(org-decrypt-entry)
 org-occur-hook '(org-first-headline-recenter)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("attachment" :follow org-attach-follow :complete
                        org-attach-complete-link)
                       ("org-contact" :follow org-contacts-link-open :complete
                        org-contacts-link-complete :store org-contacts-link-store :face
                        org-contacts-link-face)
                       ("tel") ("id" :follow org-id-open)
                       ("eww" :follow org-eww-open :store org-eww-store-link)
                       ("rmail" :follow org-rmail-open :store org-rmail-store-link)
                       ("mhe" :follow org-mhe-open :store org-mhe-store-link)
                       ("irc" :follow org-irc-visit :store org-irc-store-link :export
                        org-irc-export)
                       ("info" :follow org-info-open :export org-info-export :store
                        org-info-store-link :insert-description
                        org-info-description-as-command)
                       ("gnus" :follow org-gnus-open :store org-gnus-store-link)
                       ("docview" :follow org-docview-open :export org-docview-export
                        :store org-docview-store-link)
                       ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link)
                       ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete
                        org-bbdb-complete-link :store org-bbdb-store-link)
                       ("w3m" :store org-w3m-store-link)
                       ("doi" :follow org-link-doi-open :export org-link-doi-export)
                       ("file+sys") ("file+emacs") ("shell" :follow org-link--open-shell)
                       ("news" :follow
                        #[514 "\301\300\302.Q.\"\207" ["news" browse-url ":"] 6
                          "\n\n(fn URL ARG)"]
                        )
                       ("mailto" :follow
                        #[514 "\301\300\302.Q.\"\207" ["mailto" browse-url ":"] 6
                          "\n\n(fn URL ARG)"]
                        :complete org-contacts-mailto-link-completion)
                       ("https" :follow
                        #[514 "\301\300\302.Q.\"\207" ["https" browse-url ":"] 6
                          "\n\n(fn URL ARG)"]
                        )
                       ("http" :follow
                        #[514 "\301\300\302.Q.\"\207" ["http" browse-url ":"] 6
                          "\n\n(fn URL ARG)"]
                        )
                       ("ftp" :follow
                        #[514 "\301\300\302.Q.\"\207" ["ftp" browse-url ":"] 6
                          "\n\n(fn URL ARG)"]
                        )
                       ("help" :follow org-link--open-help :store org-link--store-help)
                       ("file" :complete org-link-complete-file)
                       ("elisp" :follow org-link--open-elisp))
 org-html-format-headline-function 'org-html-format-headline-default-function
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-refile-allow-creating-parent-nodes 'confirm
 org-agenda-restore-windows-after-quit t
 org-outline-path-complete-in-steps nil
 org-fast-tag-selection-single-key t
 org-agenda-current-time-string "now - - - - - - - - - - - - - - - - - - - - - - - - -"
 org-agenda-block-separator 61
 org-refile-target-verify-function 'my-org-refile-target-verify
 )
-- 
Serghei Iakovlev


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] org-refile-get-targets wrong-type-argument [9.6.15 (release_9.6.15 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2024-09-14 14:34 [BUG] org-refile-get-targets wrong-type-argument [9.6.15 (release_9.6.15 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)] Serghei Iakovlev
@ 2024-09-16 19:13 ` Ihor Radchenko
  2024-09-18 11:30   ` Serghei Iakovlev
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2024-09-16 19:13 UTC (permalink / raw)
  To: Serghei Iakovlev; +Cc: emacs-orgmode

Serghei Iakovlev <lists@serghei.pl> writes:

> 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---
> ...
> --8<---------------cut here---------------start------------->8---
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   looking-at(nil)
>   org-refile-get-targets()
> ...
>  org-refile-targets '((nil :maxlevel . 4) (my-org-opened-buffer-files :maxlevel . 4)
>                       (org-agenda-files :maxlevel . 4))

You are running `org-refile-get-targets' using idle timer.
It means that it may be called in any buffer.

At the same time, you have (nil :maxlevel .4) in your
`org-refile-targets', instructing Org mode to examine current buffer for
refile targets.

Since you are on 9.6.15, Org mode should actually barf if
`org-refile-targets' is called in non-Org buffer.
So, I am a bit puzzled why you are running into errors that seemingly
originate from deeper into `org-refile-get-targets' logic (there is a
single `looking-at' call in `org-refile-get-targets' and it is after
checking major mode).

My only guess is that some of your Org buffers is not properly
initialized somehow. Maybe the timer is triggering in the middle of Org
mode loading or something?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] org-refile-get-targets wrong-type-argument [9.6.15 (release_9.6.15 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2024-09-16 19:13 ` Ihor Radchenko
@ 2024-09-18 11:30   ` Serghei Iakovlev
  2024-09-22  9:27     ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Serghei Iakovlev @ 2024-09-18 11:30 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Ihor Radchenko


> My only guess is that some of your Org buffers is not properly
> initialized somehow. Maybe the timer is triggering in the middle of Org
> mode loading or something?

I find it challenging to pinpoint the exact cause of the issue.
However, I can provide some additional context that might help.  The
problem seems to occur when I'm not using my laptop—often at night,
which aligns with the time `run-with-idle-timer' is triggered.
During these moments, my configuration and environment are relatively
static, as the workstation is idle.  I usually leave it in that state
in the evening, and the problem is only noticeable in the morning.

It's worth noting that the issue doesn't happen consistently — not
every night or even every week.  It just occasionally arises, leaving
me puzzled about what might need adjustment or modification to
prevent it.  Given its sporadic nature, I'm at a loss for how to
reproduce it consistently.

There is literally one lead, and it's this code snippet that I just
removed from my configuration:

--8<---------------cut here---------------start------------->8---
diff --git a/init.el b/init.el
index d18e70c..fbb0d62 100644
--- a/init.el
+++ b/init.el
@@ -1685,21 +1685,10 @@
 (define-key my-keyboard-map (kbd "b") #'my/org-move-bookmark-to-notes)

 ;;;;; Org Refile
-(defun my-org-opened-buffer-files ()
-  "Return the list of org files currently opened in Emacs."
-  (delq nil
-        (mapcar (lambda (x)
-                  (if (and (buffer-file-name x)
-                           (string-match "\\.org$"
-                                         (buffer-file-name x)))
-                      (buffer-file-name x)))
-                (buffer-list))))
-
 ;; Refile targets include this file and any file contributing
 ;; to the agenda - up to 4 levels deep.
 (setq org-refile-targets
       '((nil :maxlevel . 4)  ; nil means current buffer
-        (my-org-opened-buffer-files :maxlevel . 4)
         (org-agenda-files :maxlevel . 4)))

 ;; Targets start with the file name allows creating level 1 tasks.
--8<---------------cut here---------------end--------------->8---

It was added as part of one of my experiments, and I apparently don't
need this functionality at all.  So, I can easily remove it to test
this hypothesis. Unfortunately, I don't have any other leads at the
moment.

I would greatly appreciate any advice on how to investigate this
further or understand the root cause of the problem.


-- 
Serghei Iakovlev



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [BUG] org-refile-get-targets wrong-type-argument [9.6.15 (release_9.6.15 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2024-09-18 11:30   ` Serghei Iakovlev
@ 2024-09-22  9:27     ` Ihor Radchenko
  2024-11-22 17:41       ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2024-09-22  9:27 UTC (permalink / raw)
  To: Serghei Iakovlev; +Cc: emacs-orgmode

[ Adding Org mailing list back to the CC ]

> -(defun my-org-opened-buffer-files ()
> -  "Return the list of org files currently opened in Emacs."
> -  (delq nil
> -        (mapcar (lambda (x)
> -                  (if (and (buffer-file-name x)
> -                           (string-match "\\.org$"
> -                                         (buffer-file-name x)))
> -                      (buffer-file-name x)))
> -                (buffer-list))))
> -

> It was added as part of one of my experiments, and I apparently don't
> need this functionality at all.  So, I can easily remove it to test
> this hypothesis. Unfortunately, I don't have any other leads at the
> moment.
>
> I would greatly appreciate any advice on how to investigate this
> further or understand the root cause of the problem.

What you might do is adding
a check whether `org-complex-heading-regexp' is nil in any of the
buffers returned by your `my-org-opened-buffer-files' and raise an error
telling which buffer it is.

You may then check what's up with that buffer.

Best,
Ihor

Serghei Iakovlev <lists@serghei.pl> writes:

> The following message is a courtesy copy of an article
> that has been posted to gmane.emacs.orgmode as well.
>
>
>> My only guess is that some of your Org buffers is not properly
>> initialized somehow. Maybe the timer is triggering in the middle of Org
>> mode loading or something?
>
> I find it challenging to pinpoint the exact cause of the issue.
> However, I can provide some additional context that might help.  The
> problem seems to occur when I'm not using my laptop—often at night,
> which aligns with the time `run-with-idle-timer' is triggered.
> During these moments, my configuration and environment are relatively
> static, as the workstation is idle.  I usually leave it in that state
> in the evening, and the problem is only noticeable in the morning.
>
> It's worth noting that the issue doesn't happen consistently — not
> every night or even every week.  It just occasionally arises, leaving
> me puzzled about what might need adjustment or modification to
> prevent it.  Given its sporadic nature, I'm at a loss for how to
> reproduce it consistently.
>
> There is literally one lead, and it's this code snippet that I just
> removed from my configuration:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/init.el b/init.el
> index d18e70c..fbb0d62 100644
> --- a/init.el
> +++ b/init.el
> @@ -1685,21 +1685,10 @@
>  (define-key my-keyboard-map (kbd "b") #'my/org-move-bookmark-to-notes)
>
>  ;;;;; Org Refile
> -(defun my-org-opened-buffer-files ()
> -  "Return the list of org files currently opened in Emacs."
> -  (delq nil
> -        (mapcar (lambda (x)
> -                  (if (and (buffer-file-name x)
> -                           (string-match "\\.org$"
> -                                         (buffer-file-name x)))
> -                      (buffer-file-name x)))
> -                (buffer-list))))
> -
>  ;; Refile targets include this file and any file contributing
>  ;; to the agenda - up to 4 levels deep.
>  (setq org-refile-targets
>        '((nil :maxlevel . 4)  ; nil means current buffer
> -        (my-org-opened-buffer-files :maxlevel . 4)
>          (org-agenda-files :maxlevel . 4)))
>
>  ;; Targets start with the file name allows creating level 1 tasks.
> --8<---------------cut here---------------end--------------->8---
>
> It was added as part of one of my experiments, and I apparently don't
> need this functionality at all.  So, I can easily remove it to test
> this hypothesis. Unfortunately, I don't have any other leads at the
> moment.
>
> I would greatly appreciate any advice on how to investigate this
> further or understand the root cause of the problem.
>
>
> -- 
> Serghei Iakovlev

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] org-refile-get-targets wrong-type-argument [9.6.15 (release_9.6.15 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
  2024-09-22  9:27     ` Ihor Radchenko
@ 2024-11-22 17:41       ` Ihor Radchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2024-11-22 17:41 UTC (permalink / raw)
  To: Serghei Iakovlev; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

>> I would greatly appreciate any advice on how to investigate this
>> further or understand the root cause of the problem.
>
> What you might do is adding
> a check whether `org-complex-heading-regexp' is nil in any of the
> buffers returned by your `my-org-opened-buffer-files' and raise an error
> telling which buffer it is.
>
> You may then check what's up with that buffer.

No extra info for one month.
Since no clear problem is visible on Org side, I am closing this bug.
Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-22 17:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-14 14:34 [BUG] org-refile-get-targets wrong-type-argument [9.6.15 (release_9.6.15 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)] Serghei Iakovlev
2024-09-16 19:13 ` Ihor Radchenko
2024-09-18 11:30   ` Serghei Iakovlev
2024-09-22  9:27     ` Ihor Radchenko
2024-11-22 17:41       ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).