update packages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;;; treemacs.el --- A tree style file viewer package -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2020 Alexander Miller
|
||||
;; Copyright (C) 2021 Alexander Miller
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
@@ -52,7 +52,7 @@ interfere with auto-completion."
|
||||
(list ,@error-args)))))
|
||||
|
||||
(defmacro treemacs-with-writable-buffer (&rest body)
|
||||
"Temporarily turn off read-ony mode to execute BODY."
|
||||
"Temporarily turn off read-only mode to execute BODY."
|
||||
(declare (debug t))
|
||||
`(let (buffer-read-only)
|
||||
,@body))
|
||||
@@ -61,7 +61,7 @@ interfere with auto-completion."
|
||||
"Safely extract BUTTON's PROPERTIES.
|
||||
|
||||
Using `button-get' on a button located in a buffer that is not the current
|
||||
buffer does not work, so this function will run the property extaction from
|
||||
buffer does not work, so this function will run the property extraction from
|
||||
inside BUTTON's buffer."
|
||||
`(with-current-buffer (marker-buffer ,button)
|
||||
,(if (= 1 (length properties))
|
||||
@@ -104,7 +104,8 @@ Log ERROR-MSG if no button is selected, otherwise run BODY."
|
||||
,@body))
|
||||
|
||||
(cl-defmacro treemacs-do-for-button-state
|
||||
(&key on-root-node-open
|
||||
(&key no-error
|
||||
on-root-node-open
|
||||
on-root-node-closed
|
||||
on-file-node-open
|
||||
on-file-node-closed
|
||||
@@ -113,12 +114,15 @@ Log ERROR-MSG if no button is selected, otherwise run BODY."
|
||||
on-tag-node-open
|
||||
on-tag-node-closed
|
||||
on-tag-node-leaf
|
||||
on-nil
|
||||
no-error)
|
||||
on-nil)
|
||||
"Building block macro to execute a form based on the current node state.
|
||||
Will bind to current button to 'btn' for the executon of the action forms.
|
||||
Will bind to current button to 'btn' for the execution of the action forms.
|
||||
When NO-ERROR is non-nil no error will be thrown if no match for the button
|
||||
state is achieved."
|
||||
state is achieved.
|
||||
Otherwise either one of ON-ROOT-NODE-OPEN, ON-ROOT-NODE-CLOSED,
|
||||
ON-FILE-NODE-OPEN, ON-FILE-NODE-CLOSED, ON-DIR-NODE-OPEN, ON-DIR-NODE-CLOSED,
|
||||
ON-TAG-NODE-OPEN, ON-TAG-NODE-CLOSED, ON-TAG-NODE-LEAF or ON-NIL will be
|
||||
executed."
|
||||
(declare (debug (&rest [sexp form])))
|
||||
`(-if-let (btn (treemacs-current-button))
|
||||
(pcase (treemacs-button-get btn :state)
|
||||
@@ -154,26 +158,33 @@ state is achieved."
|
||||
,on-nil))
|
||||
|
||||
(cl-defmacro treemacs--execute-button-action
|
||||
(&key save-window
|
||||
ensure-window-split
|
||||
split-function
|
||||
(&key no-match-explanation
|
||||
window
|
||||
split-function
|
||||
save-window
|
||||
ensure-window-split
|
||||
dir-action
|
||||
file-action
|
||||
tag-section-action
|
||||
tag-action
|
||||
no-match-explanation)
|
||||
tag-action)
|
||||
"Infrastructure macro for setting up actions on different button states.
|
||||
|
||||
Fetches the currently selected button and verifies it's in the correct state
|
||||
based on the given state actions.
|
||||
|
||||
If it isn't it will log NO-MATCH-EXPLANATION, if it is it selects WINDOW (or
|
||||
`next-window' if none is given) and splits it with SPLIT-FUNCTION if given.
|
||||
DIR-ACTION, FILE-ACTION, TAG-SECTION-ACTION and TAG-ACTION are inserted into a
|
||||
`pcase' statement matching the buttons state. Project root nodes are treated the
|
||||
same common directory nodes.
|
||||
If ENSURE-WINDOW-SPLIT is t treemacs will vertically split the window if
|
||||
|
||||
If SAVE-WINDOW is non-nil the selected window will remain selected after the
|
||||
actions have been executed.
|
||||
|
||||
If ENSURE-WINDOW-SPLIT is non-nil treemacs will vertically split the window if
|
||||
treemacs is the only window to make sure a buffer is opened next to it, not
|
||||
under or below it."
|
||||
under or below it.
|
||||
|
||||
DIR-ACTION, FILE-ACTION, TAG-SECTION-ACTION and TAG-ACTION are inserted into a
|
||||
`pcase' statement matching the buttons state. Project root nodes are treated
|
||||
the same common directory nodes."
|
||||
(declare (debug (&rest [sexp form])))
|
||||
(let ((valid-states (list)))
|
||||
(when dir-action
|
||||
@@ -240,7 +251,7 @@ the on-delete code will run twice."
|
||||
Finally execute FINAL-FORM after the code to restore the position has run.
|
||||
|
||||
This macro is meant for cases where a simple `save-excursion' will not do, like
|
||||
a refresh, which can potentially change the entire buffer layout. In pratice
|
||||
a refresh, which can potentially change the entire buffer layout. In practice
|
||||
this means attempt first to keep point on the same file/tag, and if that does
|
||||
not work keep it on the same line."
|
||||
(declare (debug (form body)))
|
||||
@@ -309,9 +320,19 @@ not work keep it on the same line."
|
||||
(set-window-point (selected-window) buffer-point))))
|
||||
,@final-form)))
|
||||
|
||||
(defmacro treemacs-with-workspace (workspace &rest body)
|
||||
"Use WORKSPACE as the current workspace when running BODY.
|
||||
Specifically this means that calls to `treemacs-current-workspace' will return
|
||||
WORKSPACE and if no workspace has been set for the current scope yet it will not
|
||||
be set either."
|
||||
(declare (indent 1) (debug (form body)))
|
||||
`(let ((treemacs-override-workspace ,workspace))
|
||||
(ignore treemacs-override-workspace)
|
||||
,@body))
|
||||
|
||||
(defmacro treemacs-run-in-every-buffer (&rest body)
|
||||
"Run BODY once locally in every treemacs buffer.
|
||||
Only includes treemacs filetree buffers, not extensions.
|
||||
Only includes treemacs file tree buffers, not extensions.
|
||||
Sets `treemacs-override-workspace' so calls to `treemacs-current-workspace'
|
||||
return the workspace of the active treemacs buffer."
|
||||
(declare (debug t))
|
||||
@@ -319,14 +340,13 @@ return the workspace of the active treemacs buffer."
|
||||
(let ((buffer (treemacs-scope-shelf->buffer shelf))
|
||||
(workspace (treemacs-scope-shelf->workspace shelf)))
|
||||
(when (buffer-live-p buffer)
|
||||
(-let [treemacs-override-workspace workspace]
|
||||
(ignore treemacs-override-workspace)
|
||||
(treemacs-with-workspace workspace
|
||||
(with-current-buffer buffer
|
||||
,@body))))))
|
||||
|
||||
(defmacro treemacs-run-in-all-derived-buffers (&rest body)
|
||||
"Run BODY once locally in every treemacs buffer.
|
||||
Inluceds *all* treemacs-mode-derived buffers, including extensions."
|
||||
Includes *all* treemacs-mode-derived buffers, including extensions."
|
||||
(declare (debug t))
|
||||
`(dolist (buffer (buffer-list))
|
||||
(when (buffer-local-value 'treemacs--in-this-buffer buffer)
|
||||
@@ -421,7 +441,7 @@ workspace. OP can be one of the following:
|
||||
default to calling `treemacs-current-workspace'.
|
||||
|
||||
LEFT and RIGHT are expected to be in treemacs canonical file path format (see
|
||||
also `treemacs--canonical-path').
|
||||
also `treemacs-canonical-path').
|
||||
|
||||
Even if LEFT or RIGHT should be a form and not a variable it is guaranteed that
|
||||
they will be evaluated only once."
|
||||
|
||||
Reference in New Issue
Block a user