diff options
Diffstat (limited to 'hui-treemacs.el')
| -rw-r--r-- | hui-treemacs.el | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/hui-treemacs.el b/hui-treemacs.el index db1aee6..2cdface 100644 --- a/hui-treemacs.el +++ b/hui-treemacs.el @@ -4,7 +4,7 @@ ;; ;; Orig-Date: 19-Nov-17 ;; -;; Copyright (C) 2017 Free Software Foundation, Inc. +;; Copyright (C) 2017-2019 Free Software Foundation, Inc. ;; See the "HY-COPY" file for license information. ;; ;; This file is part of GNU Hyperbole. @@ -18,14 +18,21 @@ (eval-and-compile (require 'treemacs nil t)) -(eval-when (load) - (unless (>= (string-to-number treemacs-version) 1.14) - (error "(hui-treemacs): Hyperbole requires Treemacs package version 1.14 or greater"))) +(unless (and (featurep 'treemacs) (string-greaterp treemacs-version "v2")) + (error "(hui-treemacs): Hyperbole requires Treemacs package version 2.0 or greater")) ;;; ************************************************************************ ;;; smart-treemacs functions ;;; ************************************************************************ +;; Want to be able to select Treemacs window with ace-window. +;; This also averts window labeling problems with ace-window. +(eval-after-load "ace-window" + '(setq aw-ignored-buffers (delq 'treemacs-mode aw-ignored-buffers))) + +(unless (fboundp 'treemacs-quit) + (fset 'treemacs-quit #'bury-buffer)) + ;;;###autoload (defun smart-treemacs () "Uses a single key or mouse key to manipulate directory entries. @@ -51,10 +58,10 @@ If key is pressed: (interactive) (cond ((first-line-p) (if (eolp) - (treemacs-toggle) + (treemacs-quit) (hact 'link-to-directory default-directory))) ((and (last-line-p) (eolp)) - (treemacs-toggle)) + (treemacs-quit)) ((eolp) (funcall (if assist-flag assist-key-eol-function action-key-eol-function))) (t (let ((over-icon (and (treemacs-current-button) @@ -65,7 +72,7 @@ If key is pressed: (hact 'link-to-buffer-tmp (seq-elt result 0) (seq-elt result 1)) ;; (bufferp result) (hact 'link-to-buffer-tmp result)) - (treemacs-push-button current-prefix-arg)))))) + (treemacs-toggle-node current-prefix-arg)))))) ;;;###autoload (defun smart-treemacs-modeline () @@ -77,28 +84,24 @@ quit/hide the Treemacs window. Otherwise, display the Treemacs window with the default directory of the buffer modeline clicked upon. Suitable for use as a value of `action-key-modeline-buffer-id-function'." - (if (fboundp 'treemacs) - (progn - (require 'treemacs) - (cond - ;; Clicked on Treemacs buffer id - ((if action-key-depress-window - (treemacs-is-treemacs-window? action-key-depress-window) - (string-match " Treemacs " (format-mode-line mode-line-format))) - ;; Quit/hide treemacs. - (treemacs-toggle)) - ;; - ;; Treemacs is visible and displaying the same dir as - ;; the default dir of the clicked on modeline. - ((and (treemacs-buffer-exists?) - (string-equal (expand-file-name default-directory) - (with-current-buffer (treemacs-buffer-exists?) - default-directory))) - ;; Quit/hide treemacs. - (treemacs-toggle)) - ;; - ;; Otherwise, invoke treemacs on the default dir of the clicked on modeline. - (t (treemacs)))) - (error "(smart-treemacs-modeline): Treemacs package is not installed"))) + (cond + ;; Clicked on Treemacs buffer id + ((if action-key-depress-window + (treemacs-is-treemacs-window? action-key-depress-window) + (string-match " Treemacs " (format-mode-line mode-line-format))) + ;; Quit/hide treemacs. + (treemacs-quit)) + ;; + ;; Treemacs is visible and displaying the same dir as + ;; the default dir of the clicked on modeline. + ((and (eq (treemacs-current-visibility) 'visible) + (string-equal (expand-file-name default-directory) + (with-current-buffer (treemacs-get-local-buffer) + default-directory))) + ;; Quit/hide treemacs. + (treemacs-quit)) + ;; + ;; Otherwise, invoke treemacs on the default dir of the clicked on modeline. + (t (treemacs)))) (provide 'hui-treemacs) |
