branch: master commit 352c33ae12fd0860350defb10d59c4713f039570 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Finalize transition to `read-char' * ace-window.el (aw--callback-body): Remove. (aw--callback): Remove. (aw--doit): Do a `read-char' loop, in case there's more than one level. Don't run the hooks any more - they're not necessary. --- ace-window.el | 84 ++++++++++++++++++++------------------------------------ 1 files changed, 30 insertions(+), 54 deletions(-) diff --git a/ace-window.el b/ace-window.el index 9a86b76..4076495 100644 --- a/ace-window.el +++ b/ace-window.el @@ -116,43 +116,6 @@ This hook is set to nil with each call to `ace-window'.") (defvar aw--current-op nil "A function of one argument to call.") -(defun aw--callback-body (char) - (let* ((index (or (cl-position char aw-keys) - (length aw-keys))) - (node (nth index (cdr ace-jump-search-tree)))) - (cond ((null node) - (message "No such position candidate.") - ;; (ace-jump-done) - ) - - ((eq (car node) 'branch) - (let ((old-tree ace-jump-search-tree)) - (setq ace-jump-search-tree (cons 'branch (cdr node))) - (ace-jump-update-overlay-in-search-tree - ace-jump-search-tree aw-keys) - (setf (cdr node) nil) - (ace-jump-delete-overlay-in-search-tree old-tree))) - - ((eq (car node) 'leaf) - (let ((aj-data (overlay-get (cdr node) 'aj-data))) - (ace-jump-done) - (ace-jump-push-mark) - (run-hooks 'ace-jump-mode-before-jump-hook) - (funcall aw--current-op aj-data)) - (run-hooks 'ace-window-end-hook) - (run-hooks 'ace-window-end-once-hook) - (setq ace-window-end-once-hook) - (run-hooks 'ace-jump-mode-end-hook)) - - (t - (ace-jump-done) - (error "[AceJump] Internal error: tree node type is invalid"))))) - -(defun aw--callback () - "Call `aw--current-op' for the window selected by ace-jump." - (interactive) - (aw--callback-body (aref (this-command-keys) 0))) - (defun aw--done () (setq ace-jump-query-char nil) (setq ace-jump-current-mode nil) @@ -254,23 +217,36 @@ Set mode line to MODE-LINE during the selection process." ;; turn off helm transient map (remove-hook 'post-command-hook 'helm--maybe-update-keymap) (unwind-protect - (let ((char (read-char mode-line))) - (aw--callback-body char)) - (aw--done)) - - - ;; override the local key map - ;; (let ((map (make-keymap))) - ;; (dolist (key-code aw-keys) - ;; (define-key map (make-string 1 key-code) 'aw--callback)) - ;; (define-key map [t] 'ace-jump-done) - ;; (if (fboundp 'set-transient-map) - ;; (set-transient-map map) - ;; (set-temporary-overlay-map map))) - - ;; (add-hook 'mouse-leave-buffer-hook 'ace-jump-done) - ;; (add-hook 'kbd-macro-termination-hook 'ace-jump-done) - ))))) + (let (char node) + (catch 'done + (while t + (setq char (read-char mode-line)) + (setq node (nth (or (cl-position char aw-keys) (length aw-keys)) + (cdr ace-jump-search-tree))) + (cond ((null node) + (message "No such position candidate.") + (throw 'done nil)) + + ((eq (car node) 'branch) + (let ((old-tree ace-jump-search-tree)) + (setq ace-jump-search-tree (cons 'branch (cdr node))) + (ace-jump-update-overlay-in-search-tree + ace-jump-search-tree aw-keys) + (setf (cdr node) + nil) + (ace-jump-delete-overlay-in-search-tree old-tree))) + + ((eq (car node) 'leaf) + (let ((aj-data (overlay-get (cdr node) 'aj-data))) + (ace-jump-done) + (ace-jump-push-mark) + (run-hooks 'ace-jump-mode-before-jump-hook) + (funcall aw--current-op aj-data)) + (throw 'done t)) + + (t + (error "[AceJump] Internal error: tree node type is invalid")))))) + (aw--done))))))) ;; ——— Interactive ————————————————————————————————————————————————————————————— ;;;###autoload