Skip to content

Commit 1e4503e

Browse files
author
Rahguzar
committed
Use cl-loop for aas-post-self-insert-hook
1 parent 45d9a7a commit 1e4503e

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

aas.el

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -220,25 +220,21 @@ the first element always nil for update logic simplicity.
220220
Gets updated by `aas-post-self-insert-hook'.")
221221

222222
(defun aas-post-self-insert-hook ()
223-
"Try to expand snippets automatically.
223+
"Try to expand snippets automatically for KEYS.
224224
225225
Use for the typing history, `aas--current-prefix-maps' and
226226
`this-command-keys' for the current typed key.."
227227
(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))))
232-
(cond ((keymapp key-result)
233-
;; Collect the keymap for the next call
234-
(cl-callf2 cons key-result next-maps))
235-
((and (functionp key-result) (funcall key-result))
236-
;; an ending! no need to call interactively,`aas-expand-snippet-maybe'
237-
;; takes care of that
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)))
228+
(cl-loop for candidate in-ref aas--current-prefix-maps do
229+
(let ((key-result (lookup-key candidate (this-command-keys))))
230+
(cond ((keymapp key-result)
231+
;; Collect the keymap for the next call
232+
(setf candidate key-result))
233+
((and (functionp key-result) (funcall key-result))
234+
;; an ending! no need to call interactively,`aas-expand-snippet-maybe'
235+
;; takes care of that. Clear the map so we start over next time.
236+
(cl-return (setq aas--current-prefix-maps nil)))))
237+
finally do (cl-callf2 delq nil aas--current-prefix-maps)))
242238

243239
;;;###autoload
244240
(defun aas-activate-keymap (keymap-symbol)

0 commit comments

Comments
 (0)