[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 4546f20 01/14: Allow to switch the action in the middle of
From: |
Oleh Krehel |
Subject: |
[elpa] master 4546f20 01/14: Allow to switch the action in the middle of ace-window |
Date: |
Thu, 04 Jun 2015 17:05:13 +0000 |
branch: master
commit 4546f20f441d28ca33a8717b2942810bf46b4492
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to switch the action in the middle of ace-window
* ace-window.el (aw-select): Add an optional arg ACTION. Call it on
selected window. Set `avy-handler-function' to catch ?x and modify
ACTION into 'aw-delete-window.
(ace-select-window): Use callback-style.
Re #44
---
ace-window.el | 89 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 49 insertions(+), 40 deletions(-)
diff --git a/ace-window.el b/ace-window.el
index 791b34d..e1442a6 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -226,7 +226,7 @@ LEAF is (PT . WND)."
(setq aw--flip-keys
(mapcar (lambda (x) (aref (kbd x) 0)) val))))
-(defun aw-select (mode-line)
+(defun aw-select (mode-line &optional action)
"Return a selected other window.
Amend MODE-LINE to the mode line for the duration of the selection."
(let ((start-window (selected-window))
@@ -234,51 +234,60 @@ Amend MODE-LINE to the mode line for the duration of the
selection."
('global 'visible)
('frame 'frame)))
(wnd-list (aw-window-list))
- final-window)
- (cl-case (length wnd-list)
- (0
- start-window)
- (1
- (car wnd-list))
- (2
- (setq final-window (next-window nil nil next-window-scope))
- (while (and (aw-ignored-p final-window)
- (not (equal final-window start-window)))
- (setq final-window (next-window final-window nil next-window-scope)))
- final-window)
- (t
- (let ((candidate-list
- (mapcar (lambda (wnd)
- ;; can't jump if the buffer is empty
- (with-current-buffer (window-buffer wnd)
- (when (= 0 (buffer-size))
- (insert " ")))
- (cons (aw-offset wnd) wnd))
- wnd-list)))
- (aw--make-backgrounds wnd-list)
- (setq ace-window-mode mode-line)
- (force-mode-line-update)
- ;; turn off helm transient map
- (remove-hook 'post-command-hook 'helm--maybe-update-keymap)
- (unwind-protect
- (condition-case err
- (or (cdr (avy-read (avy-tree candidate-list aw-keys)
- #'aw--lead-overlay
- #'avy--remove-leading-chars))
- start-window)
- (error
- (if (memq (nth 2 err) aw--flip-keys)
- (aw--pop-window)
- (signal (car err) (cdr err)))))
- (aw--done)))))))
+ window)
+ (setq window
+ (cl-case (length wnd-list)
+ (0
+ start-window)
+ (1
+ (car wnd-list))
+ (2
+ (let ((wnd (next-window nil nil next-window-scope)))
+ (while (and (aw-ignored-p wnd)
+ (not (equal wnd start-window)))
+ (setq wnd (next-window wnd nil next-window-scope)))
+ wnd))
+ (t
+ (let ((candidate-list
+ (mapcar (lambda (wnd)
+ ;; can't jump if the buffer is empty
+ (with-current-buffer (window-buffer wnd)
+ (when (= 0 (buffer-size))
+ (insert " ")))
+ (cons (aw-offset wnd) wnd))
+ wnd-list)))
+ (aw--make-backgrounds wnd-list)
+ (setq ace-window-mode mode-line)
+ (force-mode-line-update)
+ ;; turn off helm transient map
+ (remove-hook 'post-command-hook 'helm--maybe-update-keymap)
+ (unwind-protect
+ (condition-case err
+ (let* ((avy-handler-function (lambda (char)
+ (if (eq char ?x)
+ (setq action
#'aw-delete-window)
+ (avy-handler-default
char))))
+ (res (avy-read (avy-tree candidate-list aw-keys)
+ #'aw--lead-overlay
+ #'avy--remove-leading-chars)))
+ (or (cdr res)
+ start-window))
+ (error
+ (if (memq (nth 2 err) aw--flip-keys)
+ (aw--pop-window)
+ (signal (car err) (cdr err)))))
+ (aw--done))))))
+ (if action
+ (funcall action window)
+ window)))
;;* Interactive
;;;###autoload
(defun ace-select-window ()
"Ace select window."
(interactive)
- (aw-switch-to-window
- (aw-select " Ace - Window")))
+ (aw-select " Ace - Window"
+ #'aw-switch-to-window))
;;;###autoload
(defun ace-delete-window ()
- [elpa] master updated (77c062f -> a4ab5a4), Oleh Krehel, 2015/06/04
- [elpa] master 4357c90 02/14: Add a require, Oleh Krehel, 2015/06/04
- [elpa] master cf91510 05/14: README.md: Add a section on midway switch, Oleh Krehel, 2015/06/04
- [elpa] master e777570 04/14: Allow to change window action midway, Oleh Krehel, 2015/06/04
- [elpa] master 1487ae1 07/14: Update README.md, Oleh Krehel, 2015/06/04
- [elpa] master eef897e 08/14: Update README.md, Oleh Krehel, 2015/06/04
- [elpa] master dd84ff6 09/14: Fix aw-ignore-current for 3 windows, Oleh Krehel, 2015/06/04
- [elpa] master 56ef753 06/14: Allow to midway switch from less than 3 windows, Oleh Krehel, 2015/06/04
- [elpa] master c82d439 03/14: Update requires, Oleh Krehel, 2015/06/04
- [elpa] master 155b6c6 11/14: ace-window.el: Bump version, Oleh Krehel, 2015/06/04
- [elpa] master 4546f20 01/14: Allow to switch the action in the middle of ace-window,
Oleh Krehel <=
- [elpa] master e5638b1 12/14: ace-window.el (aw-swap-invert): New defcustom, Oleh Krehel, 2015/06/04
- [elpa] master 243ee46 10/14: Allow to switch to all empty buffers (read-only as well), Oleh Krehel, 2015/06/04
- [elpa] master 97a2f93 13/14: Small changes to README, Oleh Krehel, 2015/06/04
- [elpa] master a4ab5a4 14/14: Merge commit '97a2f9340b19c1b8c31455b3219fb88f39d38f1b' from ace-window, Oleh Krehel, 2015/06/04