From 9b3b15ffb308a57f23a12b30bdc60a7621c88540 Mon Sep 17 00:00:00 2001 From: Yoav Marco Date: Tue, 26 Apr 2022 23:58:20 +0300 Subject: [PATCH 1/4] refactor function documentation --- aas.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aas.el b/aas.el index 8ef8d5e..4a04e0f 100644 --- a/aas.el +++ b/aas.el @@ -251,8 +251,8 @@ Use for the typing history, `aas--current-prefix-maps' and ;; unseccesfull. remove dead end from the list (cl-callf cdr current-map-sublist) (setcdr prev current-map-sublist))) - ;; Make sure the loop progresses even in the face of odd output from - ;; `this-command-keys' + ;; Make sure the loop progress even in the face of objectionable output from + ;; (this-command-keys) (t (cl-callf cdr current-map-sublist) (setcdr prev current-map-sublist)))))) From 5211fdf908562746a8400b494c92220530efc6a4 Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Sat, 2 Oct 2021 23:25:09 +0200 Subject: [PATCH 2/4] Cleanup + remove unused variable --- aas.el | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/aas.el b/aas.el index 4a04e0f..9eada07 100644 --- a/aas.el +++ b/aas.el @@ -225,36 +225,19 @@ Gets updated by `aas-post-self-insert-hook'.") Use for the typing history, `aas--current-prefix-maps' and `this-command-keys' for the current typed key.." (cl-callf nconc (cdr aas--current-prefix-maps) (list aas--prefix-map)) - (let ((current-map-sublist (cdr aas--current-prefix-maps)) - (prev aas--current-prefix-maps) - current-map - key-result) + (let ((current-map-sublist (cdr aas--current-prefix-maps))) (while current-map-sublist - (setq current-map (car current-map-sublist) - key-result (lookup-key current-map (this-command-keys))) - (cond ((null key-result) - ;; remove dead end from the list - (cl-callf cdr current-map-sublist) - (setcdr prev current-map-sublist)) - ((keymapp key-result) - ;; update tree - (setcar current-map-sublist key-result) - (setq prev current-map-sublist) - (cl-callf cdr current-map-sublist)) - ((functionp key-result) - ;; an ending! no need to call interactively,`aas-expand-snippet-maybe' - ;; takes care of that - (if (funcall key-result) - ;; condition evaluated to true, and snippet expanded! - (setq current-map-sublist nil ; stop the loop - aas--current-prefix-maps (list nil)) ; abort all other snippet - ;; unseccesfull. remove dead end from the list - (cl-callf cdr current-map-sublist) - (setcdr prev current-map-sublist))) - ;; Make sure the loop progress even in the face of objectionable output from - ;; (this-command-keys) - (t (cl-callf cdr current-map-sublist) - (setcdr prev current-map-sublist)))))) + (let* ((current-map (car current-map-sublist)) + (key-result (lookup-key current-map (this-command-keys)))) + (cond ((keymapp key-result) + ;; update tree + (setcar current-map-sublist key-result)) + ((and (functionp key-result) (funcall key-result)) + ;; an ending! no need to call interactively,`aas-expand-snippet-maybe' + ;; takes care of that + (setq current-map-sublist nil ; stop the loop + aas--current-prefix-maps (list nil)))); abort all other snippets + (cl-callf cdr current-map-sublist))))) ;;;###autoload (defun aas-activate-keymap (keymap-symbol) From 45d9a7a4a646d1a1b8131f71ae00cb6300b70c95 Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Mon, 4 Oct 2021 20:50:03 +0200 Subject: [PATCH 3/4] Simplify aas-post-self-insert-hook --- aas.el | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/aas.el b/aas.el index 9eada07..7fa5595 100644 --- a/aas.el +++ b/aas.el @@ -224,20 +224,21 @@ Gets updated by `aas-post-self-insert-hook'.") Use for the typing history, `aas--current-prefix-maps' and `this-command-keys' for the current typed key.." - (cl-callf nconc (cdr aas--current-prefix-maps) (list aas--prefix-map)) - (let ((current-map-sublist (cdr aas--current-prefix-maps))) - (while current-map-sublist - (let* ((current-map (car current-map-sublist)) - (key-result (lookup-key current-map (this-command-keys)))) + (cl-callf nconc aas--current-prefix-maps (list aas--prefix-map)) + (let ((next-maps nil)) + (while aas--current-prefix-maps + (let* ((candidate (car aas--current-prefix-maps)) + (key-result (lookup-key candidate (this-command-keys)))) (cond ((keymapp key-result) - ;; update tree - (setcar current-map-sublist key-result)) + ;; Collect the keymap for the next call + (cl-callf2 cons key-result next-maps)) ((and (functionp key-result) (funcall key-result)) ;; an ending! no need to call interactively,`aas-expand-snippet-maybe' ;; takes care of that - (setq current-map-sublist nil ; stop the loop - aas--current-prefix-maps (list nil)))); abort all other snippets - (cl-callf cdr current-map-sublist))))) + (setq aas--current-prefix-maps nil ; stop the loop + next-maps nil))) ; abort the collected snippets + (cl-callf cdr aas--current-prefix-maps))) + (setq aas--current-prefix-maps next-maps))) ;;;###autoload (defun aas-activate-keymap (keymap-symbol) From 4c43b32c51dd582674a9ab192486db2312965ee6 Mon Sep 17 00:00:00 2001 From: Rahguzar Date: Wed, 8 Mar 2023 23:30:17 +0100 Subject: [PATCH 4/4] Use cl-loop for aas-post-self-insert-hook --- aas.el | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/aas.el b/aas.el index 7fa5595..9e0afb5 100644 --- a/aas.el +++ b/aas.el @@ -225,20 +225,18 @@ Gets updated by `aas-post-self-insert-hook'.") Use for the typing history, `aas--current-prefix-maps' and `this-command-keys' for the current typed key.." (cl-callf nconc aas--current-prefix-maps (list aas--prefix-map)) - (let ((next-maps nil)) - (while aas--current-prefix-maps - (let* ((candidate (car aas--current-prefix-maps)) - (key-result (lookup-key candidate (this-command-keys)))) - (cond ((keymapp key-result) - ;; Collect the keymap for the next call - (cl-callf2 cons key-result next-maps)) - ((and (functionp key-result) (funcall key-result)) - ;; an ending! no need to call interactively,`aas-expand-snippet-maybe' - ;; takes care of that - (setq aas--current-prefix-maps nil ; stop the loop - next-maps nil))) ; abort the collected snippets - (cl-callf cdr aas--current-prefix-maps))) - (setq aas--current-prefix-maps next-maps))) + (cl-loop for candidate in-ref aas--current-prefix-maps do + (let ((key-result (lookup-key candidate (this-command-keys)))) + (cond ((keymapp key-result) + ;; Collect the keymap for the next call + (setf candidate key-result)) + ((and (functionp key-result) (funcall key-result)) + ;; an ending! no need to call interactively,`aas-expand-snippet-maybe' + ;; takes care of that. Clear the map so we start over next time. + (cl-return (setq aas--current-prefix-maps nil))) + (t + (setf candidate nil)))) + finally do (cl-callf2 delq nil aas--current-prefix-maps))) ;;;###autoload (defun aas-activate-keymap (keymap-symbol)