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

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

[elpa] externals/ace-window be3a885 38/92: Fix so ace-window-display-mod


From: Stefan Monnier
Subject: [elpa] externals/ace-window be3a885 38/92: Fix so ace-window-display-mode ids are displayed in new frames
Date: Wed, 17 Mar 2021 18:39:17 -0400 (EDT)

branch: externals/ace-window
commit be3a885a557bdffa31631d613469d03b9a739638
Author: Bob Weiner <rsw@gnu.org>
Commit: Oleh Krehel <Oleh.Krehel@tomtom.com>

    Fix so ace-window-display-mode ids are displayed in new frames
    
    Add aw-ignore-p enhancements and expand documentation
    
    Allow mouse selection of window when only one choice in window list
    
    Add doc for aw-make-frame-char
    
    Utilize aw-make-frame-char in aw-dispatch-default plus comment fix
    
    In aw-update, let ignore-window-parameters be t to get all windows
    
    Remove treatment of aw-action as a window from a mouse click
    
    Fixes #121
---
 README.md     | 50 +++++++++++++++++++++++++++------
 ace-window.el | 88 +++++++++++++++++++++++++++++++++++++++--------------------
 2 files changed, 100 insertions(+), 38 deletions(-)

diff --git a/README.md b/README.md
index d295dea..6884bb8 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 
 ## What and why
 
-I'm sure you're aware of the `other-window` command. While it's great
+I'm sure you're aware of the `other-window` command.  While it's great
 for two windows, it quickly loses its value when there are more windows.
 You need to call it many times, and since it's not easily predictable,
 you have to check each time if you're in the window that you wanted.
@@ -24,13 +24,20 @@ bound in the default Emacs.
 
 ## Usage
 
-When there are two windows, `ace-window` will call `other-window`.  If
-there are more, each window will have the first character of its window
-identifier highlighted at the upper left of the window.  Pressing that
-character will either switch to that window or filter to the next
-character needed to select a specific window.  Note that, unlike
-`ace-jump-mode`, the position of point will not be changed, i.e. the
-same behavior as that of `other-window`.
+When there are two windows, `ace-window` will call `other-window`
+(unless `aw-dispatch-always` is set non-nil).  If there are more, each
+window will have the first character of its window label highlighted
+at the upper left of the window.  Pressing that character will either
+switch to that window or filter to the next character needed to select
+a specific window.  Note that, unlike `ace-jump-mode`, the position of
+point will not be changed, i.e. the same behavior as that of
+`other-window`.
+
+A special character defined by `aw-make-frame-char` (default = `z`)
+means create a new frame and use its window as the target.  The new
+frame's location is set relative to the prior selected frame's location
+and given by `aw-frame-offset`.  The new frame's size is given by
+`aw-frame-size`.  See their documentation strings for more information.
 
 The windows are ordered top-down, left-to-right. This means that if you
 remember your window layouts, you can switch windows without even
@@ -75,7 +82,7 @@ Aside from binding `ace-window`:
 the following customizations are available:
 
 ### `aw-keys`
-`aw-keys` - the list of initial characters used in window identifiers:
+`aw-keys` - the list of initial characters used in window labels:
 
     (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
 
@@ -130,3 +137,28 @@ This is the list of actions you can trigger from 
`ace-window` other than the
 When using ace-window, if the action character is followed by a string,
 then `ace-window` will be invoked again to select the target window for
 the action.  Otherwise, the current window is selected.
+
+### `aw-minibuffer-flag`
+
+When non-nil, also display `ace-window-mode` string in the minibuffer
+when `ace-window` is active.  This is useful when there are many
+side-by-side windows and the `ace-window-mode` string is cutoff in the
+minor mode area of the modeline.
+
+### `aw-ignored-buffers`
+
+List of buffers and major-modes to ignore when choosing a window from
+the window list.  Active only when `aw-ignore-on` is non-nil.  Windows
+displaying these buffers can still be chosen by typing their specific
+labels.
+
+### `aw-ignore-on`
+
+When t, `ace-window` will ignore buffers and major-modes in
+`aw-ignored-buffers`.  Use M-0 `ace-window` to toggle this value.
+  :type 'boolean)
+
+### `aw-ignore-current`
+
+When t, `ace-window` will ignore `selected-window'.
+
diff --git a/ace-window.el b/ace-window.el
index ee8e20d..1a062ee 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -332,7 +332,7 @@ LEAF is (PT . WND)."
   "Set mode line indicator to STR."
   (setq ace-window-mode str)
   (when (and aw-minibuffer-flag ace-window-mode)
-    (message "%s" str))
+    (message "%s" (string-trim-left str)))
   (force-mode-line-update))
 
 (defun aw--dispatch-action (char)
@@ -343,30 +343,39 @@ LEAF is (PT . WND)."
   "Make a new Emacs frame using the values of `aw-frame-size' and 
`aw-frame-offset'."
   (make-frame
    (delq nil
-         (list (when aw-frame-size
-                 (cons 'width
-                       (if (zerop (car aw-frame-size))
-                           (frame-width)
-                         (car aw-frame-size))))
-               (when aw-frame-size
-                 (cons 'height
-                       (if (zerop (cdr aw-frame-size))
-                           (frame-height)
-                         (car aw-frame-size))))
-               (cons 'left (+ (car aw-frame-offset)
-                              (car (frame-position))))
-               (cons 'top (+ (cdr aw-frame-offset)
-                             (cdr (frame-position))))))))
+         (list
+         ;; This first parameter is important because an
+         ;; aw-dispatch-alist command may not want to leave this
+         ;; frame with input focus.  If it is given focus, the
+         ;; command may not be able to return focus to a different
+         ;; frame since this is done asynchronously by the window
+         ;; manager.
+         '(no-focus-on-map . t)
+         (when aw-frame-size
+            (cons 'width
+                  (if (zerop (car aw-frame-size))
+                      (frame-width)
+                    (car aw-frame-size))))
+          (when aw-frame-size
+            (cons 'height
+                  (if (zerop (cdr aw-frame-size))
+                      (frame-height)
+                    (car aw-frame-size))))
+          (cons 'left (+ (car aw-frame-offset)
+                         (car (frame-position))))
+          (cons 'top (+ (cdr aw-frame-offset)
+                        (cdr (frame-position))))))))
 
 (defun aw-use-frame (window)
   "Create a new frame using the contents of WINDOW.
 
-The same size as the previous frame, offset by `aw-frame-offset'
-pixels."
+The new frame is set to the same size as the previous frame, offset by
+`aw-frame-offset' (x . y) pixels."
   (aw-switch-to-window window)
   (aw-make-frame))
 
 (defun aw-clean-up-avy-current-path ()
+  "Edit `avy-current-path' so only window label characters remain."
   ;; Remove any possible ace-window command char that may
   ;; precede the last specified window label, so
   ;; functions can use `avy-current-path' as the chosen
@@ -381,7 +390,16 @@ pixels."
         ((= char (aref (kbd "C-g") 0))
          (throw 'done 'exit))
         ((= char aw-make-frame-char)
-         (aw-use-frame (selected-window))
+        ;; Make a new frame and perform any action on its window.
+        (let ((start-win (selected-window))
+              (end-win (frame-selected-window (aw-make-frame))))
+          (if aw-action
+              ;; Action must be called from the start-win.  The action
+              ;; determines which window to leave selected.
+              (progn (select-frame-set-input-focus (window-frame start-win))
+                     (funcall aw-action end-win))
+            ;; Select end-win when no action
+            (aw-switch-to-window end-win)))
          (throw 'done 'exit))
         (t
          (let ((action (aw--dispatch-action char)))
@@ -392,6 +410,7 @@ pixels."
                        (aw-set-mode-line (format " Ace - %s" description)))
                    (funcall fn)
                    (throw 'done 'exit)))
+            (aw-clean-up-avy-current-path)
              ;; Prevent any char from triggering an avy dispatch command.
              (let ((avy-dispatch-alist))
                (avy-handler-default char)))))))
@@ -712,24 +731,35 @@ The point is writable, i.e. it's not part of space after 
newline."
               'ace-window-display-mode
               (default-value 'mode-line-format))))
         (force-mode-line-update t)
-        (add-hook 'window-configuration-change-hook 'aw-update))
+        (add-hook 'window-configuration-change-hook 'aw-update)
+       ;; Add at the end so does not precede select-frame call.
+       (add-hook 'after-make-frame-functions 'aw-update t))
     (set-default
      'mode-line-format
      (assq-delete-all
       'ace-window-display-mode
       (default-value 'mode-line-format)))
-    (remove-hook 'window-configuration-change-hook 'aw-update)))
+    (remove-hook 'window-configuration-change-hook 'aw-update)
+    (remove-hook 'after-make-frame-functions 'aw-update)))
 
-(defun aw-update ()
+(defun aw-update (&optional _frame)
   "Update ace-window-path window parameter for all windows."
-  (avy-traverse
-   (avy-tree (aw-window-list) aw-keys)
-   (lambda (path leaf)
-     (set-window-parameter
-      leaf 'ace-window-path
-      (propertize
-       (apply #'string (reverse path))
-       'face 'aw-mode-line-face)))))
+  ;; Ignored _frame argument is required when used as part of 
`after-make-frame-functions'.
+  ;;
+  ;; Ensure all windows are labeled so the user can select a specific
+  ;; one, even from the set of windows typically ignored when making a
+  ;; window list.
+  (let ((aw-ignore-on)
+       (aw-ignore-current)
+       (ignore-window-parameters t))
+    (avy-traverse
+     (avy-tree (aw-window-list) aw-keys)
+     (lambda (path leaf)
+       (set-window-parameter
+       leaf 'ace-window-path
+       (propertize
+        (apply #'string (reverse path))
+        'face 'aw-mode-line-face))))))
 
 (provide 'ace-window)
 



reply via email to

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