diff options
| -rw-r--r-- | lisp/erc/erc-common.el | 19 | ||||
| -rw-r--r-- | lisp/erc/erc.el | 6 | ||||
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 13 |
3 files changed, 3 insertions, 35 deletions
diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index 116f702ab3e..1a0b9c323d1 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el | |||
| @@ -641,25 +641,6 @@ Otherwise, return LIST-OR-ATOM." | |||
| 641 | (car ,list-or-atom) | 641 | (car ,list-or-atom) |
| 642 | ,list-or-atom)))) | 642 | ,list-or-atom)))) |
| 643 | 643 | ||
| 644 | (defmacro erc--doarray (spec &rest body) | ||
| 645 | "Map over ARRAY, running BODY with VAR bound to iteration element. | ||
| 646 | Behave more or less like `seq-doseq', but tailor operations for | ||
| 647 | arrays. | ||
| 648 | |||
| 649 | \(fn (VAR ARRAY [RESULT]) BODY...)" | ||
| 650 | (declare (indent 1) (debug ((symbolp form &optional form) body))) | ||
| 651 | (let ((array (make-symbol "array")) | ||
| 652 | (len (make-symbol "len")) | ||
| 653 | (i (make-symbol "i"))) | ||
| 654 | `(let* ((,array ,(nth 1 spec)) | ||
| 655 | (,len (length ,array)) | ||
| 656 | (,i 0)) | ||
| 657 | (while-let (((< ,i ,len)) | ||
| 658 | (,(car spec) (aref ,array ,i))) | ||
| 659 | ,@body | ||
| 660 | (cl-incf ,i)) | ||
| 661 | ,(nth 2 spec)))) | ||
| 662 | |||
| 663 | (provide 'erc-common) | 644 | (provide 'erc-common) |
| 664 | 645 | ||
| 665 | ;;; erc-common.el ends here | 646 | ;;; erc-common.el ends here |
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index cec261feb43..572b73188e3 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el | |||
| @@ -7607,7 +7607,7 @@ Use the getter of the same name to retrieve the current value.") | |||
| 7607 | (ct (make-char-table 'erc--channel-mode-types)) | 7607 | (ct (make-char-table 'erc--channel-mode-types)) |
| 7608 | (type ?a)) | 7608 | (type ?a)) |
| 7609 | (dolist (cs types) | 7609 | (dolist (cs types) |
| 7610 | (erc--doarray (c cs) | 7610 | (seq-doseq (c cs) |
| 7611 | (aset ct c type)) | 7611 | (aset ct c type)) |
| 7612 | (cl-incf type)) | 7612 | (cl-incf type)) |
| 7613 | (make-erc--channel-mode-types :key key | 7613 | (make-erc--channel-mode-types :key key |
| @@ -7626,7 +7626,7 @@ complement relevant letters in STRING." | |||
| 7626 | (table (erc--channel-mode-types-table obj)) | 7626 | (table (erc--channel-mode-types-table obj)) |
| 7627 | (fallbackp (erc--channel-mode-types-fallbackp obj)) | 7627 | (fallbackp (erc--channel-mode-types-fallbackp obj)) |
| 7628 | (+p t)) | 7628 | (+p t)) |
| 7629 | (erc--doarray (c string) | 7629 | (seq-doseq (c string) |
| 7630 | (cond ((= ?+ c) (setq +p t)) | 7630 | (cond ((= ?+ c) (setq +p t)) |
| 7631 | ((= ?- c) (setq +p nil)) | 7631 | ((= ?- c) (setq +p nil)) |
| 7632 | ((and status-letters (string-search (string c) status-letters)) | 7632 | ((and status-letters (string-search (string c) status-letters)) |
| @@ -7719,7 +7719,7 @@ dropped were they not already absent." | |||
| 7719 | (let ((addp t) | 7719 | (let ((addp t) |
| 7720 | ;; | 7720 | ;; |
| 7721 | redundant-add redundant-drop adding dropping) | 7721 | redundant-add redundant-drop adding dropping) |
| 7722 | (erc--doarray (c string) | 7722 | (seq-doseq (c string) |
| 7723 | (pcase c | 7723 | (pcase c |
| 7724 | (?+ (setq addp t)) | 7724 | (?+ (setq addp t)) |
| 7725 | (?- (setq addp nil)) | 7725 | (?- (setq addp nil)) |
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 1bbee0dad52..5c1a34bc3fa 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -165,19 +165,6 @@ | |||
| 165 | 165 | ||
| 166 | (advice-remove 'buffer-local-value 'erc-with-server-buffer))) | 166 | (advice-remove 'buffer-local-value 'erc-with-server-buffer))) |
| 167 | 167 | ||
| 168 | (ert-deftest erc--doarray () | ||
| 169 | (let ((array "abcdefg") | ||
| 170 | out) | ||
| 171 | ;; No return form. | ||
| 172 | (should-not (erc--doarray (c array) (push c out))) | ||
| 173 | (should (equal out '(?g ?f ?e ?d ?c ?b ?a))) | ||
| 174 | |||
| 175 | ;; Return form evaluated upon completion. | ||
| 176 | (setq out nil) | ||
| 177 | (should (= 42 (erc--doarray (c array (+ 39 (length out))) | ||
| 178 | (when (cl-evenp c) (push c out))))) | ||
| 179 | (should (equal out '(?f ?d ?b))))) | ||
| 180 | |||
| 181 | (ert-deftest erc-hide-prompt () | 168 | (ert-deftest erc-hide-prompt () |
| 182 | (let ((erc-hide-prompt erc-hide-prompt) | 169 | (let ((erc-hide-prompt erc-hide-prompt) |
| 183 | (inhibit-message noninteractive) | 170 | (inhibit-message noninteractive) |