treemacs
treemacs copied to clipboard
Treemacs: `(wrong-type-argument number-or-marker-p nil)`
Hello, I get an error, but I don't know how to reproduce. This error occured when I: a. create treemacs window b. move focus to other window c. switch focus to treemacs window d. delete treemacs window. e. create treemacs window, and repeat abcdabcdabcd very quickly. then this error will occur:
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
treemacs--apply-annotations-deferred(#<marker (moves after insertion) at 2309 in *Treemacs-Scoped-Buffer-#<frame elisp/treemacs.el - GNU Emacs at Mufasa 0x19ddf60>*> "/home/exec/.config/emacs" #<buffer *Treemacs-Scoped-Buffer-#<frame elisp/treemacs.el - GNU Emacs at Mufasa 0x19ddf60>*> #<process Process Future>)
apply(treemacs--apply-annotations-deferred (#<marker (moves after insertion) at 2309 in *Treemacs-Scoped-Buffer-#<frame elisp/treemacs.el - GNU Emacs at Mufasa 0x19ddf60>*> "/home/exec/.config/emacs" #<buffer *Treemacs-Scoped-Buffer-#<frame elisp/treemacs.el - GNU Emacs at Mufasa 0x19ddf60>*> #<process Process Future>))
timer-event-handler([t 26291 17083 672268 nil treemacs--apply-annotations-deferred (#<marker (moves after insertion) at 2309 in *Treemacs-Scoped-Buffer-#<frame elisp/treemacs.el - GNU Emacs at Mufasa 0x19ddf60>*> "/home/exec/.config/emacs" #<buffer *Treemacs-Scoped-Buffer-#<frame elisp/treemacs.el - GNU Emacs at Mufasa 0x19ddf60>*> #<process Process Future>) nil 824000 nil])
The treemacs repo I use is:
362bfa5 - (HEAD -> master, origin/master, origin/HEAD) [Misc] Checkdoc fixes. (3 weeks ago) <Alexander Miller>
What information should I provide to assist in investigating this? Thank you.
d. delete treemacs window.
Delete with Q or close with q?
create treemacs window, and repeat abcdabcdabcd
You mean just type random stuff in some buffer or in treemacs?
Anyway,for better debugging output eval this after loading treemacs:
(defun treemacs--apply-annotations-deferred (btn path buffer git-future)
"Deferred application for annotations for BTN and PATH.
Runs on a timer after BTN was expanded and will apply annotations for all of
BTN's *immediate* children.
Change will happen in BUFFER, given that it is alive.
GIT-FUTURE is only awaited when `deferred' git-mode is used.
BTN: Button
PATH: Node Path
BUFFER: Buffer
GIT-FUTURE: Pfuture"
(when (eq 'deferred treemacs--git-mode)
(ht-set! treemacs--git-cache path
(treemacs--get-or-parse-git-result git-future)))
(when (buffer-live-p buffer)
(with-current-buffer buffer
(save-excursion
(treemacs-with-writable-buffer
(let* ((depth (1+ (treemacs-button-get btn :depth)))
(git-info (or (ht-get treemacs--git-cache (treemacs-button-get btn :key))
treemacs--empty-table)))
;; the depth check ensures that we only iterate over the nodes that
;; are below parent-btn and stop when we've moved on to nodes that
;; are above or belong to the next project
(while (and (setq btn (next-button btn))
(>= (treemacs-button-get btn :depth) depth))
(when (= depth (treemacs-button-get btn :depth))
(treemacs-log "Apply annotationat at [%s %s] git-info [%s] annotation [%s]"
btn
(when btn (treemacs-button-get btn :key))
(when btn (ht-get git-info (treemacs-button-get btn :path)))
(when btn (treemacs-get-annotation (treemacs-button-get btn :path))))
(treemacs--do-apply-annotation
btn
(ht-get git-info (treemacs-button-get btn :key)))))))))))
This will add log output about what exactly treemacs is trying to do. You'll see a lot of lines like this:
[Treemacs] Apply annotationat at [#<marker (moves after insertion) at 2651 in Treemacs-Scoped-Buffer-#<frame SCRATCH.el - GNU Emacs at am-laptop 0x59c0c205a0e8>> /home/am/Documents/git/treemacs/src/elisp/treemacs.el] git-info [nil] annotation [#s(treemacs-annotation nil nil nil nil treemacs-git-unmodified-face)]
Hopefully that will give us the line where things break.
Hello, I get this error today. And I don't know how to reproduce:
Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
treemacs--consolidate-projects()
treemacs--show-single-project("/home/exec/.config/emacs" "emacs")
treemacs--do-follow-project()
#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7>()
apply(#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7> nil)
timer-event-handler([t 0 0 100000 nil #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7> nil idle 0 nil])
redisplay(t)
pos-tip-compute-pixel-position(nil #<window 3 on ediff.el> 874 39 nil nil 44)
pos-tip-show-no-propertize(#("The footer should be: (provide 'ediff)\\n;;; ediff.el ends here" 0 62 (face (:font #<font-object "-JB-JetBrainsMono Nerd Font-regular-normal-normal-*-24-*-*-*-m-0-iso10646-1"> :foreground "white" :background "gray10"))) nil nil #<window 3 on ediff.el> 3 874 39 nil nil 44)
pos-tip-show("The footer should be: (provide 'ediff)\\n;;; ediff.el ends here" nil nil nil 3 nil nil nil 44)
flycheck-pos-tip-error-messages((#s(flycheck-error :buffer #<buffer ediff.el> :checker emacs-lisp-checkdoc :filename "/home/exec/.config/emacs/elisp/ediff.el" :line 24 :column nil :message "The footer should be: (provide 'ediff)\\n;;; ediff.el ends here" :level info :id nil :group nil :-end-line nil :-end-column nil)))
flycheck-display-errors((#s(flycheck-error :buffer #<buffer ediff.el> :checker emacs-lisp-checkdoc :filename "/home/exec/.config/emacs/elisp/ediff.el" :line 24 :column nil :message "The footer should be: (provide 'ediff)\\n;;; ediff.el ends here" :level info :id nil :group nil :-end-line nil :-end-column nil)))
flycheck-display-error-at-point()
apply(flycheck-display-error-at-point nil)
timer-event-handler([t 26328 15683 352569 nil flycheck-display-error-at-point nil nil 554000 nil])
This issue has been automatically marked as stale because it has not had recent activity (this bot only works as a reminder, it will not close issues).
A similar error happens, but I don't know how to reproduce it.
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
treemacs--apply-annotations-deferred(#<marker (moves after insertion) at 1091 in *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> "/home/exec/.rustup/toolchains/1.81.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread" #<buffer *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> nil)
apply(treemacs--apply-annotations-deferred (#<marker (moves after insertion) at 1091 in *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> "/home/exec/.rustup/toolchains/1.81.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread" #<buffer *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> nil))
timer-event-handler([t 26513 48899 143510 nil treemacs--apply-annotations-deferred (#<marker (moves after insertion) at 1091 in *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> "/home/exec/.rustup/toolchains/1.81.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread" #<buffer *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> nil) nil 57000 nil])
pfuture-await-to-finish(#<process Process Future<1>>)
treemacs--parse-flattened-dirs("/home/exec/Projects/github.com/nervosnetwork/ckb" #<process Process Future<1>>)
treemacs--expand-root-node(#<marker (moves after insertion) at 3 in *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*>)
treemacs--show-single-project("/home/exec/Projects/github.com/nervosnetwork/ckb" "ckb")
#<subr treemacs--do-follow-project>()
apply(#<subr treemacs--do-follow-project> nil)
(progn (apply orig-fun args))
(if (buffer-file-name) (progn (apply orig-fun args)))
exec/treemacs-follow-project-advice(#<subr treemacs--do-follow-project>)
apply(exec/treemacs-follow-project-advice #<subr treemacs--do-follow-project> nil)
treemacs--do-follow-project()
#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7>()
apply(#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7> nil)
timer-event-handler([t 0 0 100000 nil #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7> nil idle 0 nil])
Happened again:
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
treemacs--apply-annotations-deferred(#<marker (moves after insertion) at 153 in *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> "/home/exec/.emacs.d/elpaca/builds" #<buffer *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> nil)
apply(treemacs--apply-annotations-deferred (#<marker (moves after insertion) at 153 in *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> "/home/exec/.emacs.d/elpaca/builds" #<buffer *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> nil))
timer-event-handler([t 26513 62612 537789 nil treemacs--apply-annotations-deferred (#<marker (moves after insertion) at 153 in *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> "/home/exec/.emacs.d/elpaca/builds" #<buffer *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*> nil) nil 936000 nil])
pfuture-await-to-finish(#<process Process Future<1>>)
treemacs--parse-flattened-dirs("/home/exec/.config/emacs" #<process Process Future<1>>)
treemacs--expand-root-node(#<marker (moves after insertion) at 3 in *Treemacs-Scoped-Buffer-#<frame *scratch* - GNU Emacs at Mufasa 0x22e44800>*>)
treemacs--show-single-project("/home/exec/.config/emacs" "emacs")
#<subr treemacs--do-follow-project>()
apply(#<subr treemacs--do-follow-project> nil)
(progn (apply orig-fun args))
(if (buffer-file-name) (progn (apply orig-fun args)))
exec/treemacs-follow-project-advice(#<subr treemacs--do-follow-project>)
apply(exec/treemacs-follow-project-advice #<subr treemacs--do-follow-project> nil)
treemacs--do-follow-project()
#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7>()
apply(#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7> nil)
timer-event-handler([t 0 0 100000 nil #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_7> nil idle 0 nil])
This issue has been automatically marked as stale because it has not had recent activity (this bot only works as a reminder, it will not close issues).
Those stack traces don't help on their own, you need to follow the instructions in https://github.com/Alexander-Miller/treemacs/issues/1118#issuecomment-2273379170
Since it's used as a idle timer ran after 0.5s (hard coded in treemacs--create-branch) which wil be created fresh new one each time treemacs--create-branch invoked, but its first arg btn is a marker which may invisible at some time such as expand/hide repeatly frequently speeder than the timer period, thus the inline function treemacs-button-get can not get its depth but return nil where the error occurred as for (let* ((depth (1+ (treemacs-button-get btn :depth))) failed.
Bracktrace:
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
1+(nil)
(let* ((depth (1+ (get-text-property btn :depth))) (git-info (or (gethash (get-text-property btn :key) treemacs--git-cache nil) treemacs--empty-table))) (while (and (setq btn (next-button btn)) (>= (get-text-property btn :depth) depth)) (if (= depth (get-text-property btn :depth)) (progn (let* ((git-face (gethash ... git-info nil)) (path (get-text-property btn :path)) (ann (gethash path treemacs--annotation-store nil)) (btn-start (or ... ...)) (btn-end (or ... ...))) (goto-char btn) (goto-char (or (next-single-property-change btn ... ... ...) btn-end)) (delete-region (point) (line-end-position)) (if (null ann) (if git-face (progn ... ...)) (let (... ... ... ...) (let ... ... ...) (if suffix-value ...))))))))
(let (buffer-read-only) (let* ((depth (1+ (get-text-property btn :depth))) (git-info (or (gethash (get-text-property btn :key) treemacs--git-cache nil) treemacs--empty-table))) (while (and (setq btn (next-button btn)) (>= (get-text-property btn :depth) depth)) (if (= depth (get-text-property btn :depth)) (progn (let* ((git-face ...) (path ...) (ann ...) (btn-start ...) (btn-end ...)) (goto-char btn) (goto-char (or ... btn-end)) (delete-region (point) (line-end-position)) (if (null ann) (if git-face ...) (let ... ... ...))))))))
(save-excursion (let (buffer-read-only) (let* ((depth (1+ (get-text-property btn :depth))) (git-info (or (gethash (get-text-property btn :key) treemacs--git-cache nil) treemacs--empty-table))) (while (and (setq btn (next-button btn)) (>= (get-text-property btn :depth) depth)) (if (= depth (get-text-property btn :depth)) (progn (let* (... ... ... ... ...) (goto-char btn) (goto-char ...) (delete-region ... ...) (if ... ... ...))))))))
(save-current-buffer (set-buffer buffer) (save-excursion (let (buffer-read-only) (let* ((depth (1+ (get-text-property btn :depth))) (git-info (or (gethash ... treemacs--git-cache nil) treemacs--empty-table))) (while (and (setq btn (next-button btn)) (>= (get-text-property btn :depth) depth)) (if (= depth (get-text-property btn :depth)) (progn (let* ... ... ... ... ...))))))))
(progn (save-current-buffer (set-buffer buffer) (save-excursion (let (buffer-read-only) (let* ((depth (1+ ...)) (git-info (or ... treemacs--empty-table))) (while (and (setq btn ...) (>= ... depth)) (if (= depth ...) (progn ...))))))))
(if (buffer-live-p buffer) (progn (save-current-buffer (set-buffer buffer) (save-excursion (let (buffer-read-only) (let* ((depth ...) (git-info ...)) (while (and ... ...) (if ... ...))))))))
treemacs--apply-annotations-deferred(#<marker (moves after insertion) at 12 in *Treemacs-Scoped-Buffer-#<frame F1 0x559095349080>*>
apply(treemacs--apply-annotations-deferred (#<marker (moves after insertion) at 12 in *Treemacs-Scoped-Buffer-#<frame F1 0x559095349080>*>
timer-event-handler([t 26617 58499 74171 nil treemacs--apply-annotations-deferred (#<marker (moves after insertion) at 12 in *Treemacs-Scoped-Buffer-#<frame F1 0x559095349080>*>
Solution:
The old timer should not be triggerred after a new one created, where we should use cancel-function-timers to avoid this.
Hope for solving this issue as much thanks to this project.
Regards.
This issue has been automatically marked as stale because it has not had recent activity (this bot only works as a reminder, it will not close issues).