mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
Use seq-doseq for iterating over strings in ERC
* lisp/erc/erc-common.el (erc--doarray): Remove unused function. * lisp/erc/erc.el (erc--channel-mode-types, erc--process-channel-modes) (erc--parse-user-modes): Replace `erc--doarray' with `seq-doseq'. * test/lisp/erc/erc-tests.el (erc--doarray): Remove test.
This commit is contained in:
parent
12730179ac
commit
c84aea1c1b
3 changed files with 3 additions and 35 deletions
|
|
@ -641,25 +641,6 @@ Otherwise, return LIST-OR-ATOM."
|
|||
(car ,list-or-atom)
|
||||
,list-or-atom))))
|
||||
|
||||
(defmacro erc--doarray (spec &rest body)
|
||||
"Map over ARRAY, running BODY with VAR bound to iteration element.
|
||||
Behave more or less like `seq-doseq', but tailor operations for
|
||||
arrays.
|
||||
|
||||
\(fn (VAR ARRAY [RESULT]) BODY...)"
|
||||
(declare (indent 1) (debug ((symbolp form &optional form) body)))
|
||||
(let ((array (make-symbol "array"))
|
||||
(len (make-symbol "len"))
|
||||
(i (make-symbol "i")))
|
||||
`(let* ((,array ,(nth 1 spec))
|
||||
(,len (length ,array))
|
||||
(,i 0))
|
||||
(while-let (((< ,i ,len))
|
||||
(,(car spec) (aref ,array ,i)))
|
||||
,@body
|
||||
(cl-incf ,i))
|
||||
,(nth 2 spec))))
|
||||
|
||||
(provide 'erc-common)
|
||||
|
||||
;;; erc-common.el ends here
|
||||
|
|
|
|||
|
|
@ -7607,7 +7607,7 @@ Use the getter of the same name to retrieve the current value.")
|
|||
(ct (make-char-table 'erc--channel-mode-types))
|
||||
(type ?a))
|
||||
(dolist (cs types)
|
||||
(erc--doarray (c cs)
|
||||
(seq-doseq (c cs)
|
||||
(aset ct c type))
|
||||
(cl-incf type))
|
||||
(make-erc--channel-mode-types :key key
|
||||
|
|
@ -7626,7 +7626,7 @@ complement relevant letters in STRING."
|
|||
(table (erc--channel-mode-types-table obj))
|
||||
(fallbackp (erc--channel-mode-types-fallbackp obj))
|
||||
(+p t))
|
||||
(erc--doarray (c string)
|
||||
(seq-doseq (c string)
|
||||
(cond ((= ?+ c) (setq +p t))
|
||||
((= ?- c) (setq +p nil))
|
||||
((and status-letters (string-search (string c) status-letters))
|
||||
|
|
@ -7719,7 +7719,7 @@ dropped were they not already absent."
|
|||
(let ((addp t)
|
||||
;;
|
||||
redundant-add redundant-drop adding dropping)
|
||||
(erc--doarray (c string)
|
||||
(seq-doseq (c string)
|
||||
(pcase c
|
||||
(?+ (setq addp t))
|
||||
(?- (setq addp nil))
|
||||
|
|
|
|||
|
|
@ -165,19 +165,6 @@
|
|||
|
||||
(advice-remove 'buffer-local-value 'erc-with-server-buffer)))
|
||||
|
||||
(ert-deftest erc--doarray ()
|
||||
(let ((array "abcdefg")
|
||||
out)
|
||||
;; No return form.
|
||||
(should-not (erc--doarray (c array) (push c out)))
|
||||
(should (equal out '(?g ?f ?e ?d ?c ?b ?a)))
|
||||
|
||||
;; Return form evaluated upon completion.
|
||||
(setq out nil)
|
||||
(should (= 42 (erc--doarray (c array (+ 39 (length out)))
|
||||
(when (cl-evenp c) (push c out)))))
|
||||
(should (equal out '(?f ?d ?b)))))
|
||||
|
||||
(ert-deftest erc-hide-prompt ()
|
||||
(let ((erc-hide-prompt erc-hide-prompt)
|
||||
(inhibit-message noninteractive)
|
||||
|
|
|
|||
Loading…
Reference in a new issue