Function: treemacs--post-command
treemacs--post-command is a byte-compiled function defined in
treemacs-mode.el.
Signature
(treemacs--post-command)
Documentation
Set the default directory to the nearest directory of the current node.
If there is no node at point use "~/" instead. Also skip hidden buttons (as employed by variadic extensions).
Used as a post command hook.
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-mode.el
(defun treemacs--post-command ()
"Set the default directory to the nearest directory of the current node.
If there is no node at point use \"~/\" instead.
Also skip hidden buttons (as employed by variadic extensions).
Used as a post command hook."
(let ((newline-char 10)
(point-max (point-max)))
(unless (equal newline-char (char-before point-max))
(treemacs-with-writable-buffer
(save-excursion
(goto-char point-max)
(insert newline-char)
;; make sure that the projects-end marker keeps pointing at
;; the end of the last project button
(when (and (eq t treemacs--in-this-buffer)
(equal (point) (marker-position (treemacs--projects-end))))
(move-marker (treemacs--projects-end) (1- (point))))))))
(-when-let (btn (treemacs-current-button))
(when (treemacs-button-get btn 'invisible)
(treemacs-next-line 1))
(-if-let* ((project (treemacs-project-of-node btn))
(path (or (treemacs-button-get btn :default-directory)
(treemacs--nearest-path btn))))
(when (and (treemacs-project->is-readable? project)
(file-readable-p path))
(setf treemacs--eldoc-msg (treemacs--get-eldoc-message path)
default-directory (treemacs--add-trailing-slash
(if (file-directory-p path) path (file-name-directory path)))))
(setf treemacs--eldoc-msg nil)
(when (eq t treemacs--in-this-buffer)
(setf default-directory "~/")))))