Skip to content

Commit eb03c12

Browse files
committed
Obsolete more built-in aliases.
- Make `command-do` the default name and `group` the obsolete alias. - Rename `loopy--parse-group-command` to `loopy--parse-command-do-command`. - Obsolete `expr` and `exprs` for `set`. - Obsolete `prev-expr` for `set-prev`. Remove mention of the alias `prev` from the Org documentation, which should have been done in the previous round of obsoletions. See this PR #207 and issue #168, as well as previous obsoletions in PR #206 and issue #126.
1 parent 38126cc commit eb03c12

File tree

5 files changed

+37
-44
lines changed

5 files changed

+37
-44
lines changed

CHANGELOG.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@ This document describes the user-facing changes to Loopy.
1818
- Remove the deprecated positional arguments to the `numbers` command ([#205]).
1919

2020
- To cut back on an over-abundance of choice and to simplify documentation, the
21-
following built-in aliases have been made obsolete ([#126], [#206]). They can
22-
still be added manually via `loopy-defalias`.
21+
following built-in aliases have been made obsolete ([#126], [#168], [#206],
22+
[#207]). They can still be added manually via `loopy-defalias`.
2323
- `array`: `across`
2424
- `array-ref`: `arrayf`, `arrayingf`, `stringf`, `stringingf`, `across-ref`
25+
- `command-do`: `group`
2526
- `cons`: `on`
2627
- `list`: `in`
2728
- `list-ref`: `listf`, `listingf`, `in-ref`
2829
- `map-ref`: `mapf`, `mappingf`
2930
- `numbers`: `num`, `nums`
3031
- `numbers-down`: `nums-down`, `numdown`, `num-down`, `numsdown`
3132
- `numbers-up`: `nums-up`, `numup`, `num-up`, `numsup`
32-
- `set-prev`: `prev`
33+
- `set`: `expr`, `exprs`
34+
- `set-prev`: `prev`, `prev-expr`
3335
- `sequence`: `elements`
3436
- `sequence-index`: `sequencei`, `seqi`, `listi`, `arrayi`, `stringi`
3537
- `sequence-ref`: `seqf`, `sequencef`, `sequencingf`, `elements-ref`
@@ -42,10 +44,12 @@ This document describes the user-facing changes to Loopy.
4244

4345

4446
[#126]: https://github.com/okamsn/loopy/issues/126
47+
[#168]: https://github.com/okamsn/loopy/issues/168
4548
[#169]: https://github.com/okamsn/loopy/issues/169
4649
[#203]: https://github.com/okamsn/loopy/pull/203
4750
[#205]: https://github.com/okamsn/loopy/pull/205
4851
[#206]: https://github.com/okamsn/loopy/pull/206
52+
[#207]: https://github.com/okamsn/loopy/pull/207
4953

5054

5155
## 0.13.0

doc/loopy-doc.org

+15-27
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,10 @@ is assigned a value from the list after collecting =i= into =coll=.
658658
#+END_SRC
659659

660660
For convenience and understanding, the same command might have multiple names,
661-
called {{{dfn(aliases)}}}. For example, the command =set= has an alias =expr=,
662-
because =set= is used to /set/ a variable to the value of an /expression/.
663-
Similary, the =array= command has the alias =string=, because the =array=
664-
command can be used to iterate through the elements of an array or string[fn:1].
665-
You can define custom aliases using the macro ~loopy-defalias~ ([[#custom-aliases][Custom Aliases]]).
661+
called {{{dfn(aliases)}}}. Similary, the =array= command has the alias
662+
=string=, because the =array= command can be used to iterate through the
663+
elements of an array or string[fn:1]. You can define custom aliases using the
664+
macro ~loopy-defalias~ ([[#custom-aliases][Custom Aliases]]).
666665

667666
Similar to other libraries, many commands have an alias of the
668667
present-participle form (the "-ing" form). A few examples are seen in the table
@@ -682,7 +681,7 @@ command iterates through the elements in the list.
682681
For simplicity, the commands are described using the following notation:
683682

684683
- If a command has multiple names, the names are separated by a vertical bar,
685-
such as in =set|expr=.
684+
such as in =array|string=.
686685
- =VAR= is an unquoted symbol that will be used as a variable name, such as =i=
687686
in =(list i my-list)=.
688687
- =FUNC= is a quoted Lisp function name, such as ~#'my-func~ or ~'my-func~, a
@@ -1303,9 +1302,8 @@ value and do no affect how the loop iterates.
13031302
(do (message "%d" i)))
13041303
#+END_SRC
13051304

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

1317-
;; Returns sum:
1318-
;; => 9
1319-
(loopy (list i '(1 3 5))
1320-
(if (cl-evenp i)
1321-
(group
1322-
(do (message "Even found."))
1323-
(return i))
1324-
(sum i)))
1325-
13261315
;; Returns the detected even number:
13271316
;; => 2
13281317
(loopy (list i '(1 3 2 5))
@@ -1337,11 +1326,11 @@ value and do no affect how the loop iterates.
13371326
#+findex: setting
13381327
#+findex: expr
13391328
#+findex: exprs
1340-
- =(set|expr VAR [EXPRS])= :: Bind =VAR= to each =EXPR= in order. Once the last
1329+
- =(set VAR [EXPRS])= :: Bind =VAR= to each =EXPR= in order. Once the last
13411330
=EXPR= is reached, it is used repeatedly for the rest of the loop. With no
13421331
=EXPR=, =VAR= is bound to ~nil~ during each iteration of the loop.
13431332

1344-
This command also has the aliases =setting= and =exprs=.
1333+
This command also has the aliases =setting=.
13451334

13461335
Unlike the Emacs Lisp function ~set~, the variable name should not be quoted.
13471336
Unlike the Emacs Lisp special form ~setq~, the command =set= only sets one
@@ -1366,17 +1355,16 @@ value and do no affect how the loop iterates.
13661355
#+findex: set-prev
13671356
#+findex: setting-prev
13681357
#+findex: prev-set
1369-
#+findex: prev-expr
1370-
#+findex: prev
1371-
- =(set-prev|prev-expr VAR VAL &key back)= :: Bind =VAR= to a value =VAL= from a
1372-
previous cycle in the loop. With =BACK= (default: 1), use the value from that
1373-
many cycles previous. _If not enough cycles have passed yet, then the value
1374-
of =VAR= is not modified._ This command /does not/ work like a queue for
1358+
- =(set-prev VAR VAL &key back)= :: Bind =VAR= to a value =VAL= from a previous
1359+
cycle in the loop. With =BACK= (default: 1), use the value from that many
1360+
cycles previous. _If not enough cycles have passed yet, then the value of
1361+
=VAR= is not modified._ This command /does not/ work like a queue for
13751362
recording =VAL=; it always uses the value from the =BACK=-th previous cycle,
13761363
regardless of when the command is run. The value used is always the value at
13771364
the end of the cycle.
13781365

1379-
This command also has the aliases =setting-prev=, =prev-set=, and =prev=.
1366+
This command also has the aliases =setting-prev= and, for typo tolerance,
1367+
=prev-set=.
13801368

13811369
#+begin_src emacs-lisp
13821370
;; => (nil 1 2 3 4)
@@ -4411,7 +4399,7 @@ options ~loopy-iter-bare-commands~ and
44114399
~loopy-iter-bare-special-macro-arguments~.
44124400

44134401
By default, the following commands are not recognized:
4414-
- =do= and =group=, which are not needed.
4402+
- =do= and =command-do=, which are not needed.
44154403

44164404
- Commands that exists only as a command version of an existing Lisp feature,
44174405
such as =if=, =cond=, =when=, and =unless=.

loopy-commands.el

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ This command does not wait for VAL to change before updating VAR."
265265
(loopy--latter-body (setq ,cnt (1+ ,cnt)))))))))
266266

267267
;;;;;; Group
268-
(cl-defun loopy--parse-group-command ((_ &rest body))
269-
"Parse the `group' loop command.
268+
(cl-defun loopy--parse-command-do-command ((_ &rest body))
269+
"Parse the `command-do' loop command.
270270
271271
BODY is one or more commands to be grouped by a `progn' form.
272272
This command is suitable for using as the first sub-command in an

loopy-vars.el

+6-5
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,16 @@ Definition must exist. Neither argument need be quoted."
7777
(defvar loopy--obsolete-aliases
7878
'((array across)
7979
(array-ref arrayf arrayingf stringf stringingf across-ref)
80+
(command-do group)
8081
(cons on)
8182
(list in)
8283
(list-ref listf listingf in-ref)
8384
(map-ref mapf mappingf)
8485
(numbers num nums)
8586
(numbers-down nums-down numdown num-down numsdown)
8687
(numbers-up nums-up numup num-up numsup)
87-
(set-prev prev)
88+
(set exprs expr)
89+
(set-prev prev prev-expr)
8890
(sequence elements)
8991
(sequence-index sequencei seqi listi arrayi stringi)
9092
(sequence-ref seqf sequencef sequencingf elements-ref))
@@ -137,9 +139,9 @@ Definition must exist. Neither argument need be quoted."
137139
(reduce . (reducing callf))
138140
(return . (returning))
139141
(return-from . (returning-from))
140-
(set . (setting exprs expr))
142+
(set . (setting))
141143
(set-accum . (setting-accum))
142-
(set-prev . (setting-prev prev-expr prev-set))
144+
(set-prev . (setting-prev prev-set))
143145
(sequence . (sequencing seq seqing))
144146
(sequence-index . ( seq-index seqing-index
145147
sequencing-index
@@ -179,7 +181,7 @@ true names and lists of aliases.
179181
(array-ref . loopy--parse-array-ref-command)
180182
(at . loopy--parse-at-command)
181183
(collect . loopy--parse-collect-command)
182-
(command-do . loopy--parse-group-command)
184+
(command-do . loopy--parse-command-do-command)
183185
(concat . loopy--parse-concat-command)
184186
(cond . loopy--parse-cond-command)
185187
(cons . loopy--parse-cons-command)
@@ -188,7 +190,6 @@ true names and lists of aliases.
188190
(do . loopy--parse-do-command)
189191
(find . loopy--parse-find-command)
190192
(set-accum . loopy--parse-set-accum-command)
191-
(group . loopy--parse-group-command)
192193
(if . loopy--parse-if-command)
193194
(iter . loopy--parse-iter-command)
194195
(leave . loopy--parse-leave-command)

tests/tests.el

+7-7
Original file line numberDiff line numberDiff line change
@@ -844,20 +844,20 @@ SYMS-STR are the string names of symbols from `loopy-iter-bare-commands'."
844844
:iter-bare ((set . setting)
845845
(return . returning)))
846846

847-
;;;;; Group
848-
(loopy-deftest group
847+
;;;;; command-do
848+
(loopy-deftest command-do
849849
:result '((2 4 6) (2 4 6))
850850
:body ((list i '(1 2 3 4 5 6))
851851
(if (cl-evenp i)
852-
(_group (collect c1 i)
853-
(collect c2 i)))
852+
(_command-do (collect c1 i)
853+
(collect c2 i)))
854854
(finally-return c1 c2))
855-
:repeat _group
856-
:loopy ((_group . (group command-do)))
855+
:repeat _command-do
856+
:loopy ((_command-do . (command-do command-do)))
857857
;; Technically don't need to test (and wouldn't work if we used `for' inside,
858858
;; anyway).
859859
:iter-keyword ((list . list)
860-
(_group . (group command-do))))
860+
(_command-do . (command-do command-do))))
861861

862862
;;;;; Set-Prev
863863
(loopy-deftest set-prev

0 commit comments

Comments
 (0)