emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 1082953 24/68: ace-window.el: add custom buffer ignoring


From: Oleh Krehel
Subject: [elpa] master 1082953 24/68: ace-window.el: add custom buffer ignoring
Date: Sat, 21 Mar 2015 19:06:55 +0000

branch: master
commit 10829530238766ce7a6be210a9c59cdf5ca88b02
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ace-window.el: add custom buffer ignoring
    
    * ace-window.el (aw-ignored-buffers): New custom variable.  Set this to
      a list of buffer names that are often around, but you don't want to
      switch to them.
    
      (aw-ignore-on): New custom variable. This value can be toggled with
      M-0 `ace-window'.
    
      (aw-ignored-p): New function.
      (aw-list-visual-area): Don't return ignored windows.
      (aw-generic): Add ignoring.
      (ace-window): With 0 prefix argument, toggle `aw-ignore-on'.
---
 ace-window.el |   46 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/ace-window.el b/ace-window.el
index 80ece68..8f212f6 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -74,6 +74,21 @@
           (const :tag "global" global)
           (const :tag "frame" frame)))
 
+(defcustom aw-ignored-buffers '("*Calc Trail*")
+  "List of buffers to ignore when selecting window."
+  :group 'ace-window)
+
+(defcustom aw-ignore-on t
+  "When t, `ace-window' will ignore `aw-ignored-buffers'.
+Use M-0 `ace-window' to toggle this value."
+  :group 'ace-window)
+
+(defun aw-ignored-p (window)
+  "Return t if WINDOW should be ignored."
+  (and aw-ignore-on
+       (member (buffer-name (window-buffer window))
+               aw-ignored-buffers)))
+
 ;;;###autoload
 (defun aw-list-visual-area ()
   "Forward to `ace-jump-list-visual-area', removing invisible frames."
@@ -83,7 +98,8 @@
        (or (not (and (frame-live-p f)
                      (frame-visible-p f)))
            (and (= (frame-height f) 10)
-                (= (frame-width f) 10)))))
+                (= (frame-width f) 10))
+           (aw-ignored-p (aj-visual-area-window x)))))
    (ace-jump-list-visual-area)))
 
 ;; ——— Macros 
——————————————————————————————————————————————————————————————————
@@ -146,9 +162,19 @@ HANDLER is a function that takes a window argument."
                        'aw-visual-area<)))
            (cl-case (length visual-area-list)
              (0)
-             (1)
+             (1
+              (when (aw-ignored-p (selected-window))
+                (other-window 1)))
              (2
-              (,handler (next-window nil nil next-window-scope)))
+              (if (aw-ignored-p (selected-window))
+                  (other-window 1)
+                (let ((sw (selected-window))
+                      (w (next-window nil nil next-window-scope)))
+                  (while (aw-ignored-p w)
+                    (select-window w)
+                    (setq w (next-window nil nil next-window-scope)))
+                  (select-window sw)
+                  (,handler w))))
              (t
               (let ((candidate-list
                      (mapcar (lambda (va)
@@ -217,15 +243,17 @@ Variations are described below.
 
 By default, behaves like extended `other-window'.
 
-Prefixed with one \\[universal-argument], does a swap between
- selected window and current window, so that the selected buffer
- moves to current window (and current buffer moves to selected
- window).
+Prefixed with one \\[universal-argument], does a swap between selected window
+ and current window, so that the selected buffer moves to current window (and
+ current buffer moves to selected window).
 
-Prefixed with two \\[universal-argument]'s, deletes the selected
- window."
+Prefixed with two \\[universal-argument]'s, deletes the selected window."
   (interactive "p")
   (cl-case arg
+    (0
+     (setq aw-ignore-on
+           (not aw-ignore-on))
+     (ace-select-window))
     (4 (ace-swap-window))
     (16 (ace-delete-window))
     (t (ace-select-window))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]