Skip to content

Commit 45d9a7a

Browse files
RahguzarRahguzar
authored andcommitted
Simplify aas-post-self-insert-hook
1 parent 5211fdf commit 45d9a7a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

aas.el

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,21 @@ Gets updated by `aas-post-self-insert-hook'.")
224224
225225
Use for the typing history, `aas--current-prefix-maps' and
226226
`this-command-keys' for the current typed key.."
227-
(cl-callf nconc (cdr aas--current-prefix-maps) (list aas--prefix-map))
228-
(let ((current-map-sublist (cdr aas--current-prefix-maps)))
229-
(while current-map-sublist
230-
(let* ((current-map (car current-map-sublist))
231-
(key-result (lookup-key current-map (this-command-keys))))
227+
(cl-callf nconc aas--current-prefix-maps (list aas--prefix-map))
228+
(let ((next-maps nil))
229+
(while aas--current-prefix-maps
230+
(let* ((candidate (car aas--current-prefix-maps))
231+
(key-result (lookup-key candidate (this-command-keys))))
232232
(cond ((keymapp key-result)
233-
;; update tree
234-
(setcar current-map-sublist key-result))
233+
;; Collect the keymap for the next call
234+
(cl-callf2 cons key-result next-maps))
235235
((and (functionp key-result) (funcall key-result))
236236
;; an ending! no need to call interactively,`aas-expand-snippet-maybe'
237237
;; takes care of that
238-
(setq current-map-sublist nil ; stop the loop
239-
aas--current-prefix-maps (list nil)))); abort all other snippets
240-
(cl-callf cdr current-map-sublist)))))
238+
(setq aas--current-prefix-maps nil ; stop the loop
239+
next-maps nil))) ; abort the collected snippets
240+
(cl-callf cdr aas--current-prefix-maps)))
241+
(setq aas--current-prefix-maps next-maps)))
241242

242243
;;;###autoload
243244
(defun aas-activate-keymap (keymap-symbol)

0 commit comments

Comments
 (0)