Infinite recursion on org-glossary--register-buffer-dependencies if org-glossary-global-terms is non-nil #7

Closed
opened 2022-08-06 16:29:40 +00:00 by hlissner · 1 comment
hlissner commented 2022-08-06 16:29:40 +00:00 (Migrated from github.com)

What happened

When setting org-glossary-global-terms explicitly, org-glossary--register-buffer-dependencies is called until it hits max-lisp-eval-depth and throws a excessive-lisp-nesting error.

Show backtrace
Debugger entered--Lisp error: (excessive-lisp-nesting)
  apply(debug (error (excessive-lisp-nesting)))
  (let ((backtrace (doom-backtrace))) (setq num-nonmacro-input-events (1+ num-nonmacro-input-events)) (apply #'debug args))
  doom-debugger(error (excessive-lisp-nesting))
  org-unbracket-string("\"" "\"" "/home/hlissner/.config/emacs/docs/appendix.org")
  org-strip-quotes("/home/hlissner/.config/emacs/docs/appendix.org")
  org-glossary--parse-include-value("/home/hlissner/.config/emacs/docs/appendix.org")
  org-glossary--register-buffer-dependencies((:file "/home/hlissner/.config/emacs/docs/appendix.org" :location nil :only-contents nil :line nil :env nil :minlevel nil))
  (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* ((v dep-files)) (setcdr v (cons path-spec (cdr v))))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))
  (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* ((v dep-files)) (setcdr v (cons path-spec ...)))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))))
  (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* (...) (setcdr v ...))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))))
  (let* ((term-cache (cdr (assoc path-spec org-glossary--terms-cache))) (included (plist-get term-cache :included)) (extras (mapcar #'org-glossary--parse-include-value (plist-get term-cache :extra-term-sources)))) (org-glossary--deregister-buffer-dependencies path-spec) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t ...))) (if dep-files (if (member path-spec dep-files) nil (let* ... ...)) (setq org-glossary--path-dependencies (cons ... org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))))))
  (let ((path-spec (or path-spec (org-glossary--complete-path-spec)))) (let* ((term-cache (cdr (assoc path-spec org-glossary--terms-cache))) (included (plist-get term-cache :included)) (extras (mapcar #'org-glossary--parse-include-value (plist-get term-cache :extra-term-sources)))) (org-glossary--deregister-buffer-dependencies path-spec) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files ...)) (if dep-files (if ... nil ...) (setq org-glossary--path-dependencies ...))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))))))
  [... repeats the last 6 frames thousands of times ...]
  org-glossary--register-buffer-dependencies((:file "/home/hlissner/.config/emacs/docs/appendix.org" :location nil :only-contents nil :line nil :env nil :minlevel nil))
  (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* ((v dep-files)) (setcdr v (cons path-spec (cdr v))))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))
  (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* ((v dep-files)) (setcdr v (cons path-spec ...)))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))))
  (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* (...) (setcdr v ...))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))))
  (let* ((term-cache (cdr (assoc path-spec org-glossary--terms-cache))) (included (plist-get term-cache :included)) (extras (mapcar #'org-glossary--parse-include-value (plist-get term-cache :extra-term-sources)))) (org-glossary--deregister-buffer-dependencies path-spec) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t ...))) (if dep-files (if (member path-spec dep-files) nil (let* ... ...)) (setq org-glossary--path-dependencies (cons ... org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))))))
  (let ((path-spec (or path-spec (org-glossary--complete-path-spec)))) (let* ((term-cache (cdr (assoc path-spec org-glossary--terms-cache))) (included (plist-get term-cache :included)) (extras (mapcar #'org-glossary--parse-include-value (plist-get term-cache :extra-term-sources)))) (org-glossary--deregister-buffer-dependencies path-spec) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files ...)) (if dep-files (if ... nil ...) (setq org-glossary--path-dependencies ...))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))))))
 org-glossary--register-buffer-dependencies()
  (progn (org-glossary-update-terms) (org-glossary--register-buffer-dependencies) (add-hook 'after-save-hook 'org-glossary--detect-updates-and-propagate nil t) (add-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t))
  (if org-glossary-mode (progn (org-glossary-update-terms) (org-glossary--register-buffer-dependencies) (add-hook 'after-save-hook 'org-glossary--detect-updates-and-propagate nil t) (add-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t)) (org-glossary--deregister-buffer-dependencies) (remove-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t))
  (let ((last-message (current-message))) (setq org-glossary-mode (if (eq arg 'toggle) (not org-glossary-mode) (> (prefix-numeric-value arg) 0))) (cond ((and org-glossary-mode org-glossary-automatic) (org-glossary--set-font-lock-keywords org-glossary-fontify-types-differently) (font-lock-add-keywords nil org-glossary--font-lock-keywords 'append)) (t (font-lock-remove-keywords nil org-glossary--font-lock-keywords) (save-excursion (save-restriction (widen) (font-lock-flush))))) (if org-glossary-mode (progn (org-glossary-update-terms) (org-glossary--register-buffer-dependencies) (add-hook 'after-save-hook 'org-glossary--detect-updates-and-propagate nil t) (add-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t)) (org-glossary--deregister-buffer-dependencies) (remove-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t)) org-glossary-mode (run-hooks 'org-glossary-mode-hook (if org-glossary-mode 'org-glossary-mode-on-hook 'org-glossary-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "Org-Glossary mode %sabled%s" (if org-glossary-mode "en" "dis") local))))))
  org-glossary-mode(1)
  eval-buffer(#<buffer  *load*> nil "/home/hlissner/test.el" nil t)  ; Reading at buffer position 1199
  load-with-code-conversion("/home/hlissner/test.el" "/home/hlissner/test.el" nil t)
  load("/home/hlissner/test.el" nil t)
  command-line-1(("-l" "/home/hlissner/test.el"))
  command-line()
  normal-top-level()

Steps to reproduce

(make-directory "~/org" t)
(find-file "~/org/test.org")
(with-temp-file "~/org/glossary.org") ; generate an empty dummy
(setq org-glossary-global-terms (list "~/org/glossary.org"))
(require 'ox) ; needed for #6
(org-glossary-mode +1)

(Reproduced in vanilla Emacs 29.0.50, 28.1, and 27.2)

System info

## What happened When setting `org-glossary-global-terms` explicitly, `org-glossary--register-buffer-dependencies` is called until it hits `max-lisp-eval-depth` and throws a `excessive-lisp-nesting` error. <details> <summary>Show backtrace</summary> ``` Debugger entered--Lisp error: (excessive-lisp-nesting) apply(debug (error (excessive-lisp-nesting))) (let ((backtrace (doom-backtrace))) (setq num-nonmacro-input-events (1+ num-nonmacro-input-events)) (apply #'debug args)) doom-debugger(error (excessive-lisp-nesting)) org-unbracket-string("\"" "\"" "/home/hlissner/.config/emacs/docs/appendix.org") org-strip-quotes("/home/hlissner/.config/emacs/docs/appendix.org") org-glossary--parse-include-value("/home/hlissner/.config/emacs/docs/appendix.org") org-glossary--register-buffer-dependencies((:file "/home/hlissner/.config/emacs/docs/appendix.org" :location nil :only-contents nil :line nil :env nil :minlevel nil)) (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* ((v dep-files)) (setcdr v (cons path-spec (cdr v))))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* ((v dep-files)) (setcdr v (cons path-spec ...)))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* (...) (setcdr v ...))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))))) (let* ((term-cache (cdr (assoc path-spec org-glossary--terms-cache))) (included (plist-get term-cache :included)) (extras (mapcar #'org-glossary--parse-include-value (plist-get term-cache :extra-term-sources)))) (org-glossary--deregister-buffer-dependencies path-spec) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t ...))) (if dep-files (if (member path-spec dep-files) nil (let* ... ...)) (setq org-glossary--path-dependencies (cons ... org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))))) (let ((path-spec (or path-spec (org-glossary--complete-path-spec)))) (let* ((term-cache (cdr (assoc path-spec org-glossary--terms-cache))) (included (plist-get term-cache :included)) (extras (mapcar #'org-glossary--parse-include-value (plist-get term-cache :extra-term-sources)))) (org-glossary--deregister-buffer-dependencies path-spec) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files ...)) (if dep-files (if ... nil ...) (setq org-glossary--path-dependencies ...))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))))))) [... repeats the last 6 frames thousands of times ...] org-glossary--register-buffer-dependencies((:file "/home/hlissner/.config/emacs/docs/appendix.org" :location nil :only-contents nil :line nil :env nil :minlevel nil)) (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* ((v dep-files)) (setcdr v (cons path-spec (cdr v))))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* ((v dep-files)) (setcdr v (cons path-spec ...)))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t (assoc dep-pspec org-glossary--path-dependencies)))) (if dep-files (if (member path-spec dep-files) nil (let* (...) (setcdr v ...))) (setq org-glossary--path-dependencies (cons (list dep-pspec path-spec) org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))))) (let* ((term-cache (cdr (assoc path-spec org-glossary--terms-cache))) (included (plist-get term-cache :included)) (extras (mapcar #'org-glossary--parse-include-value (plist-get term-cache :extra-term-sources)))) (org-glossary--deregister-buffer-dependencies path-spec) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files (and t ...))) (if dep-files (if (member path-spec dep-files) nil (let* ... ...)) (setq org-glossary--path-dependencies (cons ... org-glossary--path-dependencies)))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--)))))) (let ((path-spec (or path-spec (org-glossary--complete-path-spec)))) (let* ((term-cache (cdr (assoc path-spec org-glossary--terms-cache))) (included (plist-get term-cache :included)) (extras (mapcar #'org-glossary--parse-include-value (plist-get term-cache :extra-term-sources)))) (org-glossary--deregister-buffer-dependencies path-spec) (let ((--dolist-tail-- (nconc extras included))) (while --dolist-tail-- (let ((dep-pspec (car --dolist-tail--))) (let* ((dep-files ...)) (if dep-files (if ... nil ...) (setq org-glossary--path-dependencies ...))) (org-glossary--register-buffer-dependencies dep-pspec) (setq --dolist-tail-- (cdr --dolist-tail--))))))) org-glossary--register-buffer-dependencies() (progn (org-glossary-update-terms) (org-glossary--register-buffer-dependencies) (add-hook 'after-save-hook 'org-glossary--detect-updates-and-propagate nil t) (add-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t)) (if org-glossary-mode (progn (org-glossary-update-terms) (org-glossary--register-buffer-dependencies) (add-hook 'after-save-hook 'org-glossary--detect-updates-and-propagate nil t) (add-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t)) (org-glossary--deregister-buffer-dependencies) (remove-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t)) (let ((last-message (current-message))) (setq org-glossary-mode (if (eq arg 'toggle) (not org-glossary-mode) (> (prefix-numeric-value arg) 0))) (cond ((and org-glossary-mode org-glossary-automatic) (org-glossary--set-font-lock-keywords org-glossary-fontify-types-differently) (font-lock-add-keywords nil org-glossary--font-lock-keywords 'append)) (t (font-lock-remove-keywords nil org-glossary--font-lock-keywords) (save-excursion (save-restriction (widen) (font-lock-flush))))) (if org-glossary-mode (progn (org-glossary-update-terms) (org-glossary--register-buffer-dependencies) (add-hook 'after-save-hook 'org-glossary--detect-updates-and-propagate nil t) (add-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t)) (org-glossary--deregister-buffer-dependencies) (remove-hook 'kill-buffer-hook 'org-glossary--deregister-buffer-dependencies nil t)) org-glossary-mode (run-hooks 'org-glossary-mode-hook (if org-glossary-mode 'org-glossary-mode-on-hook 'org-glossary-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "Org-Glossary mode %sabled%s" (if org-glossary-mode "en" "dis") local)))))) org-glossary-mode(1) eval-buffer(#<buffer *load*> nil "/home/hlissner/test.el" nil t) ; Reading at buffer position 1199 load-with-code-conversion("/home/hlissner/test.el" "/home/hlissner/test.el" nil t) load("/home/hlissner/test.el" nil t) command-line-1(("-l" "/home/hlissner/test.el")) command-line() normal-top-level() ``` </details> ## Steps to reproduce ```elisp (make-directory "~/org" t) (find-file "~/org/test.org") (with-temp-file "~/org/glossary.org") ; generate an empty dummy (setq org-glossary-global-terms (list "~/org/glossary.org")) (require 'ox) ; needed for #6 (org-glossary-mode +1) ``` (Reproduced in vanilla Emacs 29.0.50, 28.1, and 27.2) ## System info - Emacs 29.0.50 (reproduced in 28.1 and 27.2 as well) - Org 9.6: emacs-straight/org-mode@5a49cc5f4f09910fd03d5db590ae2b80f5981a66
tecosaur commented 2022-08-06 16:39:44 +00:00 (Migrated from github.com)

I think 6da6d51ca2 fixes this.

I think 6da6d51ca24ef8d17c41feb4788917e4e7c1f720 fixes this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tec/org-glossary#7
No description provided.