Skip to content

Commit

Permalink
Obsolete more built-in aliases.
Browse files Browse the repository at this point in the history
- Make `command-do` the default name and `group` the obsolete alias.
  - Rename `loopy--parse-group-command` to `loopy--parse-command-do-command`.
  -
  • Loading branch information
okamsn committed Sep 6, 2024
1 parent 38126cc commit 60327b8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
12 changes: 1 addition & 11 deletions doc/loopy-doc.org
Original file line number Diff line number Diff line change
Expand Up @@ -1303,9 +1303,8 @@ value and do no affect how the loop iterates.
(do (message "%d" i)))
#+END_SRC

#+findex: group
#+findex: command-do
- =(group|command-do [CMDS])= :: Evaluate multiple loop commands, as if in a
- =(command-do [CMDS])= :: Evaluate multiple loop commands, as if in a
=progn=. This is similar to =do=, but runs commands instead of normal Lisp
expressions. Currently, this command is only useful when used within the
=if= command.
Expand All @@ -1314,15 +1313,6 @@ value and do no affect how the loop iterates.
;; Report whether an even number is found, or return the sum of
;; the list's elements. To be clear, this is not an idiomatic example.

;; Returns sum:
;; => 9
(loopy (list i '(1 3 5))
(if (cl-evenp i)
(group
(do (message "Even found."))
(return i))
(sum i)))

;; Returns the detected even number:
;; => 2
(loopy (list i '(1 3 2 5))
Expand Down
4 changes: 2 additions & 2 deletions loopy-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ This command does not wait for VAL to change before updating VAR."
(loopy--latter-body (setq ,cnt (1+ ,cnt)))))))))

;;;;;; Group
(cl-defun loopy--parse-group-command ((_ &rest body))
"Parse the `group' loop command.
(cl-defun loopy--parse-command-do-command ((_ &rest body))
"Parse the `command-do' loop command.
BODY is one or more commands to be grouped by a `progn' form.
This command is suitable for using as the first sub-command in an
Expand Down
4 changes: 2 additions & 2 deletions loopy-vars.el
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Definition must exist. Neither argument need be quoted."
(defvar loopy--obsolete-aliases
'((array across)
(array-ref arrayf arrayingf stringf stringingf across-ref)
(command-do group)
(cons on)
(list in)
(list-ref listf listingf in-ref)
Expand Down Expand Up @@ -179,7 +180,7 @@ true names and lists of aliases.
(array-ref . loopy--parse-array-ref-command)
(at . loopy--parse-at-command)
(collect . loopy--parse-collect-command)
(command-do . loopy--parse-group-command)
(command-do . loopy--parse-command-do-command)
(concat . loopy--parse-concat-command)
(cond . loopy--parse-cond-command)
(cons . loopy--parse-cons-command)
Expand All @@ -188,7 +189,6 @@ true names and lists of aliases.
(do . loopy--parse-do-command)
(find . loopy--parse-find-command)
(set-accum . loopy--parse-set-accum-command)
(group . loopy--parse-group-command)
(if . loopy--parse-if-command)
(iter . loopy--parse-iter-command)
(leave . loopy--parse-leave-command)
Expand Down
14 changes: 7 additions & 7 deletions tests/tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -844,20 +844,20 @@ SYMS-STR are the string names of symbols from `loopy-iter-bare-commands'."
:iter-bare ((set . setting)
(return . returning)))

;;;;; Group
(loopy-deftest group
;;;;; command-do
(loopy-deftest command-do
:result '((2 4 6) (2 4 6))
:body ((list i '(1 2 3 4 5 6))
(if (cl-evenp i)
(_group (collect c1 i)
(collect c2 i)))
(_command-do (collect c1 i)
(collect c2 i)))
(finally-return c1 c2))
:repeat _group
:loopy ((_group . (group command-do)))
:repeat _command-do
:loopy ((_command-do . (command-do command-do)))
;; Technically don't need to test (and wouldn't work if we used `for' inside,
;; anyway).
:iter-keyword ((list . list)
(_group . (group command-do))))
(_command-do . (command-do command-do))))

;;;;; Set-Prev
(loopy-deftest set-prev
Expand Down

0 comments on commit 60327b8

Please sign in to comment.