update packages
This commit is contained in:
@@ -16,8 +16,10 @@
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;; Functions relating to using the mouse in treemacs.
|
||||
;;; NOTE: This module is lazy-loaded.
|
||||
|
||||
;; Functions relating to using the mouse in treemacs.
|
||||
|
||||
;; NOTE: This module is lazy-loaded.
|
||||
|
||||
;;; Code:
|
||||
|
||||
@@ -43,16 +45,21 @@
|
||||
|
||||
(defun treemacs--builtin-project-mouse-selection-menu ()
|
||||
"Build a mouse selection menu for project.el projects."
|
||||
(if (eq project--list 'unset)
|
||||
(list (vector "Project.el list is empty" #'ignore))
|
||||
(-let [projects
|
||||
(->> project--list
|
||||
(--map (treemacs-canonical-path (car it)))
|
||||
(--reject (treemacs-is-path it :in-workspace))
|
||||
(-sort #'string<))]
|
||||
(if (null projects)
|
||||
(list (vector "All Project.el projects are alread in the workspace" #'ignore))
|
||||
(--map (vector it (lambda () (interactive) (treemacs-add-project-to-workspace it))) projects)))))
|
||||
(pcase (if (fboundp 'project-known-project-roots)
|
||||
(->> (project-known-project-roots)
|
||||
(-map #'treemacs-canonical-path)
|
||||
(-sort #'string<))
|
||||
'unavailable)
|
||||
(`unavailable
|
||||
(list (vector "Project.el api is not available" #'ignore)))
|
||||
(`nil
|
||||
(list (vector "Project.el list is empty" #'ignore)))
|
||||
(projects
|
||||
(pcase (--reject (treemacs-is-path it :in-workspace) projects)
|
||||
(`nil
|
||||
(list (vector "All Project.el projects are alread in the workspace" #'ignore)))
|
||||
(candidates
|
||||
(--map (vector it (lambda () (interactive) (treemacs-add-project-to-workspace it))) candidates))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun treemacs-leftclick-action (event)
|
||||
@@ -77,12 +84,13 @@ Must be bound to a mouse click, or EVENT will not be supplied."
|
||||
;;;###autoload
|
||||
(defun treemacs-doubleclick-action (event)
|
||||
"Run the appropriate double-click action for the current node.
|
||||
In the default configuration this means to do the same as `treemacs-RET-action'.
|
||||
In the default configuration this means to expand/collapse directories and open
|
||||
files and tags in the most recently used window.
|
||||
|
||||
This function's exact configuration is stored in
|
||||
`treemacs-doubleclick-actions-config'.
|
||||
|
||||
Must be bound to a mouse click, or EVENT will not be supplied."
|
||||
Must be bound to a mouse double click to properly handle a click EVENT."
|
||||
(interactive "e")
|
||||
(when (eq 'double-mouse-1 (elt event 0))
|
||||
(goto-char (posn-point (cadr event)))
|
||||
@@ -160,12 +168,12 @@ and ignore any prefix argument."
|
||||
:dir-action (find-file-noselect (treemacs-safe-button-get btn :path))
|
||||
:tag-action (treemacs--tag-noselect btn)
|
||||
:window (selected-window)
|
||||
:save-window t
|
||||
:window-arg '(4)
|
||||
:ensure-window-split nil
|
||||
:no-match-explanation "")))
|
||||
|
||||
(defun treemacs--imenu-tag-noselect (file tag-path)
|
||||
"Return a list of the source buffer for FILE and the position of the tag from TAG-PATH."
|
||||
"Return a list of the source buffer for FILE and the tag's from TAG-PATH."
|
||||
(let ((tag (-last-item tag-path))
|
||||
(path (-butlast tag-path)))
|
||||
(condition-case e
|
||||
@@ -174,8 +182,8 @@ and ignore any prefix argument."
|
||||
(let ((index (treemacs--get-imenu-index file)))
|
||||
(dolist (path-item path)
|
||||
(setq index (cdr (assoc path-item index))))
|
||||
(-let [(buf . pos) (treemacs--extract-position
|
||||
(cdr (--first (equal (car it) tag) index)))]
|
||||
(-let [(buf . pos)
|
||||
(treemacs--extract-position (cdr (--first (equal (car it) tag) index)) path)]
|
||||
;; some imenu implementations, like markdown, will only provide
|
||||
;; a raw buffer position (an int) to move to
|
||||
(list (or buf (get-file-buffer file)) pos))))
|
||||
@@ -200,7 +208,9 @@ and ignore any prefix argument."
|
||||
(marker-position (save-excursion (xref-location-marker (xref-item-location item))))))
|
||||
(-let [(tag-buf . tag-pos)
|
||||
(treemacs-with-button-buffer btn
|
||||
(-> btn (treemacs-button-get :marker) (treemacs--extract-position)))]
|
||||
(let ((marker (treemacs-button-get :marker btn))
|
||||
(path (treemacs-button-get :path btn)))
|
||||
(treemacs--extract-position marker path)))]
|
||||
(if tag-buf
|
||||
(list tag-buf tag-pos)
|
||||
(pcase treemacs-goto-tag-strategy
|
||||
@@ -247,6 +257,7 @@ and ignore any prefix argument."
|
||||
["Open" treemacs-visit-node-no-split :visible ,(check node)]
|
||||
("Open With" :visible ,(not (null node))
|
||||
["Open Directly" treemacs-visit-node-no-split]
|
||||
["Open In External Application" treemacs-visit-node-in-external-application]
|
||||
["Open With Vertical Split" treemacs-visit-node-vertical-split]
|
||||
["Open With Horizontal Split" treemacs-visit-node-horizontal-split]
|
||||
["Open With Ace" treemacs-visit-node-ace]
|
||||
@@ -255,10 +266,10 @@ and ignore any prefix argument."
|
||||
["Open Tags" treemacs-toggle-node :visible ,(check (memq state '(file-node-closed tag-node-closed)))]
|
||||
["Close Tags" treemacs-toggle-node :visible ,(check (memq state '(file-node-open tag-node-open)))]
|
||||
|
||||
["--" #'ignore :visible ,(check node)]
|
||||
["Rename" treemacs-rename :visible ,(check node)]
|
||||
["Delete" treemacs-delete :visible ,(check node)]
|
||||
["Move" treemacs-move-file :visible ,(check node)]
|
||||
["--" #'ignore :visible ,(check node)]
|
||||
["Rename" treemacs-rename-file :visible ,(check node)]
|
||||
["Delete" treemacs-delete-file :visible ,(check node)]
|
||||
["Move" treemacs-move-file :visible ,(check node)]
|
||||
("Copy"
|
||||
["Copy File" treemacs-copy-file :visible ,(check node)]
|
||||
["Copy Absolute Path" treemacs-copy-absolute-path-at-point :visible ,(check node)]
|
||||
@@ -300,12 +311,14 @@ and ignore any prefix argument."
|
||||
(cmd (lookup-key menu (apply 'vector choice))))
|
||||
;; In the terminal clicking on a nested menu item does not expand it, but actually
|
||||
;; selects it as the chosen use option. So as a workaround we need to manually go
|
||||
;; thtough the menus until we land on an executable command.
|
||||
(while (not (commandp cmd))
|
||||
;; through the menus until we land on an executable command.
|
||||
(while (and (not (commandp cmd))
|
||||
(not (eq cmd menu)))
|
||||
(setf menu choice
|
||||
choice (x-popup-menu event cmd)
|
||||
cmd (lookup-key cmd (apply 'vector choice))))
|
||||
(when cmd (call-interactively cmd))
|
||||
(when (and cmd (commandp cmd))
|
||||
(call-interactively cmd))
|
||||
(hl-line-highlight)))))
|
||||
|
||||
(provide 'treemacs-mouse-interface)
|
||||
|
||||
Reference in New Issue
Block a user