From 4053bd5201252850aa816150925aa256e5ab7238 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 30 Jul 2021 13:13:46 +0200 Subject: Work around long-standing seq.el compilation warning * lisp/emacs-lisp/seq.el (seq-contains): When using cl-defgeneric to define an obsolete function, it'll complain about it being obsolete. Suppress that warning. (Should probably be fixed in cl-defgeneric instead.) --- lisp/emacs-lisp/seq.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 6c15463ad52..e8fc4a28145 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -394,14 +394,15 @@ found or not." (setq count (+ 1 count)))) count)) -(cl-defgeneric seq-contains (sequence elt &optional testfn) - "Return the first element in SEQUENCE that is equal to ELT. +(with-suppressed-warnings ((obsolete seq-contains)) + (cl-defgeneric seq-contains (sequence elt &optional testfn) + "Return the first element in SEQUENCE that is equal to ELT. Equality is defined by TESTFN if non-nil or by `equal' if nil." - (declare (obsolete seq-contains-p "27.1")) - (seq-some (lambda (e) - (when (funcall (or testfn #'equal) elt e) - e)) - sequence)) + (declare (obsolete seq-contains-p "27.1")) + (seq-some (lambda (e) + (when (funcall (or testfn #'equal) elt e) + e)) + sequence))) (cl-defgeneric seq-contains-p (sequence elt &optional testfn) "Return non-nil if SEQUENCE contains an element equal to ELT. -- cgit v1.2.3 From c58f8dda2b2282302cf47ef3e7df6523bde606f5 Mon Sep 17 00:00:00 2001 From: Earl Hyatt Date: Sat, 14 Aug 2021 14:17:12 +0200 Subject: Add macro `seq-setq`. * doc/lispref/sequences.texi (seq-setq): Document this macro. * lisp/emacs-lisp/seq.el (seq-setq): New macro. * test/lisp/emacs-lisp/seq-tests.el (test-seq-setq): Test this macro (bug#50053). --- doc/lispref/sequences.texi | 17 +++++++++++++++++ lisp/emacs-lisp/seq.el | 8 ++++++++ test/lisp/emacs-lisp/seq-tests.el | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index 545fd408f88..20816ce8ca2 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi @@ -1111,6 +1111,23 @@ The @code{pcase} patterns provide an alternative facility for destructuring binding, see @ref{Destructuring with pcase Patterns}. @end defmac +@defmac seq-setq var-sequence val-sequence +@cindex sequence destructuring + This macro works similarly to @code{seq-let}, except that values are +assigned to variables as if by @code{setq} instead of as in a +@code{let} binding. + +@example +@group +(let ((a nil) + (b nil)) + (seq-setq (_ a _ b) '(1 2 3 4)) + (list a b)) +@result{} (2 4) +@end group +@end example +@end defmac + @defun seq-random-elt sequence This function returns an element of @var{sequence} taken at random. diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index e8fc4a28145..f0dc283f57d 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -93,6 +93,14 @@ name to be bound to the rest of SEQUENCE." (declare (indent 2) (debug (sexp form body))) `(pcase-let ((,(seq--make-pcase-patterns args) ,sequence)) ,@body)) + +(defmacro seq-setq (args sequence) + "Assign to the variables in ARGS the elements of SEQUENCE. + +ARGS can also include the `&rest' marker followed by a variable +name to be bound to the rest of SEQUENCE." + (declare (debug (sexp form))) + `(pcase-setq ,(seq--make-pcase-patterns args) ,sequence)) ;;; Basic seq functions that have to be implemented by new sequence types diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index 05c7fbe781e..44e855e2cfa 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -383,6 +383,30 @@ Evaluate BODY for each created sequence. (should (null b)) (should (null c))))) +(ert-deftest test-seq-setq () + (with-test-sequences (seq '(1 2 3 4)) + (let (a b c d e) + (seq-setq (a b c d e) seq) + (should (= a 1)) + (should (= b 2)) + (should (= c 3)) + (should (= d 4)) + (should (null e))) + (let (a b others) + (seq-setq (a b &rest others) seq) + (should (= a 1)) + (should (= b 2)) + (should (same-contents-p others (seq-drop seq 2))))) + (let ((a) + (seq '(1 (2 (3 (4)))))) + (seq-setq (_ (_ (_ (a)))) seq) + (should (= a 4))) + (let (seq a b c) + (seq-setq (a b c) seq) + (should (null a)) + (should (null b)) + (should (null c)))) + (ert-deftest test-seq-min-max () (with-test-sequences (seq '(4 5 3 2 0 4)) (should (= (seq-min seq) 0)) -- cgit v1.2.3 From 0cf0a2b98671671bb7639a17639ef2552b772cbe Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 17 Sep 2021 10:35:13 +0200 Subject: Add new sequence function 'seq-union' * lisp/emacs-lisp/seq.el (seq-union): New function. * doc/lispref/sequences.texi (Sequence Functions): * lisp/emacs-lisp/shortdoc.el (sequence): Document above new function. * test/lisp/emacs-lisp/seq-tests.el (test-seq-union): New test. --- doc/lispref/sequences.texi | 16 ++++++++++++++++ etc/NEWS | 5 +++++ lisp/emacs-lisp/seq.el | 11 +++++++++++ lisp/emacs-lisp/shortdoc.el | 2 ++ test/lisp/emacs-lisp/seq-tests.el | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index 20816ce8ca2..53d37199bf7 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi @@ -953,6 +953,22 @@ contain less elements than @var{n}. @var{n} must be an integer. If @end example @end defun +@defun seq-union sequence1 sequence2 &optional function +@cindex sequences, union of +@cindex union of sequences + This function returns a list of the elements that appear either in +@var{sequence1} or @var{sequence2}. If the optional argument +@var{function} is non-@code{nil}, it is a function of two arguments to +use to compare elements instead of the default @code{equal}. + +@example +@group +(seq-union [1 2 3] [3 5]) +@result{} (1 2 3 5) +@end group +@end example +@end defun + @defun seq-intersection sequence1 sequence2 &optional function @cindex sequences, intersection of @cindex intersection of sequences diff --git a/etc/NEWS b/etc/NEWS index eee6d2592bd..b1ad4dd1263 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -3855,6 +3855,11 @@ This function is like 'require', but searches 'custom-theme-load-path' instead of 'load-path'. It can be used by Custom themes to load supporting Lisp files when 'require' is unsuitable. ++++ +** New function 'seq-union'. +This function takes two sequences and returns a list of all elements +that appear in either of them. + +++ ** New function 'syntax-class-to-char'. This does almost the opposite of 'string-to-syntax' -- it returns the diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index f0dc283f57d..b7dcde87f41 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -467,6 +467,17 @@ negative integer or 0, nil is returned." (setq sequence (seq-drop sequence n))) (nreverse result)))) +(cl-defgeneric seq-union (sequence1 sequence2 &optional testfn) + "Return a list of all elements that appear in either SEQUENCE1 or SEQUENCE2. +Equality is defined by TESTFN if non-nil or by `equal' if nil." + (let ((accum (lambda (acc elt) + (if (seq-contains-p acc elt testfn) + acc + (cons elt acc))))) + (seq-reverse + (seq-reduce accum sequence2 + (seq-reduce accum sequence1 '()))))) + ;;;###autoload (cl-defgeneric seq-intersection (sequence1 sequence2 &optional testfn) "Return a list of the elements that appear in both SEQUENCE1 and SEQUENCE2. diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index adee6be379d..3e0d5aef022 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -809,6 +809,8 @@ There can be any number of :example/:result elements." :eval (seq-remove #'numberp '(1 2 c d 5))) (seq-group-by :eval (seq-group-by #'cl-plusp '(-1 2 3 -4 -5 6))) + (seq-union + :eval (seq-union '(1 2 3) '(3 5))) (seq-difference :eval (seq-difference '(1 2 3) '(2 3 4))) (seq-intersection diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el index 44e855e2cfa..bf79dd922bf 100644 --- a/test/lisp/emacs-lisp/seq-tests.el +++ b/test/lisp/emacs-lisp/seq-tests.el @@ -336,6 +336,38 @@ Evaluate BODY for each created sequence. (should (same-contents-p list vector)) (should (vectorp vector)))) +(ert-deftest test-seq-union () + (let ((v1 '(1 2 3)) + (v2 '(3 5))) + (should (same-contents-p (seq-union v1 v2) + '(1 2 3 5)))) + + (let ((v1 '(1 2 3 4 5 6)) + (v2 '(4 5 6 7 8 9))) + (should (same-contents-p (seq-union v1 v2) + '(1 2 3 4 5 6 7 8 9)))) + + (let ((v1 '(1 2 3 4 5 6)) + (v2 '(4 5 6 7 8 9))) + (should (same-contents-p (seq-union v1 v2) + '(1 2 3 4 5 6 7 8 9)))) + + (let ((v1 [1 2 3 4 5]) + (v2 [4 5 6 "a"])) + (should (same-contents-p (seq-union v1 v2) + '(1 2 3 4 5 6 "a")))) + + (let ((v1 '("a" "b" "c")) + (v2 '("f" "c" "e" "a"))) + (should (same-contents-p (seq-union v1 v2) + '("a" "b" "c" "f" "e")))) + + (let ((v1 '("a")) + (v2 '("a")) + (testfn #'eq)) + (should (same-contents-p (seq-union v1 v2 testfn) + '("a" "a"))))) + (ert-deftest test-seq-intersection () (let ((v1 [2 3 4 5]) (v2 [1 3 5 6 7])) -- cgit v1.2.3 From fb9df9b8834b795c8dd387e61df0a9dfded11dfc Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 17 Sep 2021 10:41:15 +0200 Subject: Make ediff-union into obsolete alias for seq-union * lisp/emacs-lisp/seq.el (seq-union): Autoload. * lisp/vc/ediff-util.el (ediff-union): Make into obsolete function alias for 'seq-union'. * lisp/vc/ediff-mult.el (ediff-intersect-directories): Update single caller. --- lisp/emacs-lisp/seq.el | 1 + lisp/vc/ediff-mult.el | 6 +++--- lisp/vc/ediff-util.el | 15 +-------------- 3 files changed, 5 insertions(+), 17 deletions(-) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index b7dcde87f41..87aba66daa7 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -467,6 +467,7 @@ negative integer or 0, nil is returned." (setq sequence (seq-drop sequence n))) (nreverse result)))) +;;;###autoload (cl-defgeneric seq-union (sequence1 sequence2 &optional testfn) "Return a list of all elements that appear in either SEQUENCE1 or SEQUENCE2. Equality is defined by TESTFN if non-nil or by `equal' if nil." diff --git a/lisp/vc/ediff-mult.el b/lisp/vc/ediff-mult.el index 20ff8f9f04d..0a168621dff 100644 --- a/lisp/vc/ediff-mult.el +++ b/lisp/vc/ediff-mult.el @@ -623,9 +623,9 @@ behavior." ;; compute difference list (setq difflist (ediff-set-difference - (ediff-union (ediff-union lis1 lis2 #'string=) - lis3 - #'string=) + (seq-union (seq-union lis1 lis2 #'string=) + lis3 + #'string=) common #'string=) difflist (delete "." difflist) diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el index 04043809436..0ae2f09ccdc 100644 --- a/lisp/vc/ediff-util.el +++ b/lisp/vc/ediff-util.el @@ -4161,20 +4161,6 @@ Mail anyway? (y or n) ") (setq lis1 (cdr lis1))) (cdr result))) - -;; eliminates duplicates using comparison-func -(defun ediff-union (lis1 lis2 comparison-func) - (let ((result (list 'a))) - (while lis1 - (or (ediff-member (car lis1) (cdr result) comparison-func) - (nconc result (list (car lis1)))) - (setq lis1 (cdr lis1))) - (while lis2 - (or (ediff-member (car lis2) (cdr result) comparison-func) - (nconc result (list (car lis2)))) - (setq lis2 (cdr lis2))) - (cdr result))) - ;; eliminates duplicates using comparison-func (defun ediff-set-difference (lis1 lis2 comparison-func) (let ((result (list 'a))) @@ -4187,6 +4173,7 @@ Mail anyway? (y or n) ") (define-obsolete-function-alias 'ediff-add-to-history #'add-to-history "27.1") (define-obsolete-function-alias 'ediff-copy-list #'copy-sequence "28.1") +(define-obsolete-function-alias 'ediff-union #'seq-union "28.1") (run-hooks 'ediff-load-hook) -- cgit v1.2.3 From 3e5298fc96c98d2296432d31ee1d3de86a4c466c Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 17 Sep 2021 14:01:20 +0200 Subject: Improve performance of seq-union * lisp/emacs-lisp/seq.el (seq-union): Improve performance by using nreverse instead of seq-reverse. --- lisp/emacs-lisp/seq.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 87aba66daa7..ae5988296d8 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -471,13 +471,13 @@ negative integer or 0, nil is returned." (cl-defgeneric seq-union (sequence1 sequence2 &optional testfn) "Return a list of all elements that appear in either SEQUENCE1 or SEQUENCE2. Equality is defined by TESTFN if non-nil or by `equal' if nil." - (let ((accum (lambda (acc elt) - (if (seq-contains-p acc elt testfn) - acc - (cons elt acc))))) - (seq-reverse - (seq-reduce accum sequence2 - (seq-reduce accum sequence1 '()))))) + (let* ((accum (lambda (acc elt) + (if (seq-contains-p acc elt testfn) + acc + (cons elt acc)))) + (result (seq-reduce accum sequence2 + (seq-reduce accum sequence1 '())))) + (nreverse result))) ;;;###autoload (cl-defgeneric seq-intersection (sequence1 sequence2 &optional testfn) -- cgit v1.2.3 From 35d0675467e61aff30c21544f87f55b1b1a2cfd3 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 24 Sep 2021 19:41:03 +0200 Subject: Prefer seq-random-elt to nth+random * lisp/emacs-lisp/seq.el (seq-random-elt): Autoload. * lisp/avoid.el (mouse-avoidance-random-shape): * lisp/epa-ks.el (epa-ks--query-url): * lisp/erc/erc-networks.el (erc-server-select): * lisp/gnus/gnus-fun.el (gnus--random-face-with-type) (gnus-fun-ppm-change-string): * lisp/net/soap-inspect.el (soap-sample-value-for-xs-simple-type): * lisp/obsolete/landmark.el (landmark-random-move): * lisp/play/mpuz.el (mpuz-build-random-perm): * lisp/play/zone.el (zone-pgm-stress): * lisp/vc/add-log.el (add-change-log-entry): * test/lisp/net/tramp-tests.el (tramp-test44-asynchronous-requests): Prefer seq-random-elt to nth+random. --- lisp/avoid.el | 10 +++------- lisp/emacs-lisp/seq.el | 1 + lisp/epa-ks.el | 3 +-- lisp/erc/erc-networks.el | 2 +- lisp/gnus/gnus-fun.el | 4 ++-- lisp/net/soap-inspect.el | 4 ++-- lisp/obsolete/landmark.el | 2 +- lisp/play/mpuz.el | 2 +- lisp/play/zone.el | 2 +- lisp/vc/add-log.el | 3 +-- test/lisp/net/tramp-tests.el | 5 ++--- 11 files changed, 16 insertions(+), 22 deletions(-) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/lisp/avoid.el b/lisp/avoid.el index d3afecf8cc2..03707d10465 100644 --- a/lisp/avoid.el +++ b/lisp/avoid.el @@ -43,7 +43,7 @@ ;; ;; (if (eq window-system 'x) ;; (mouse-avoidance-set-pointer-shape -;; (nth (random 4) +;; (seq-random-elt ;; (list x-pointer-man x-pointer-spider ;; x-pointer-gobbler x-pointer-gumby)))) ;; @@ -125,7 +125,6 @@ TOP-OR-BOTTOM-POS: Distance from top or bottom edge of frame or window." ;; Internal variables (defvar mouse-avoidance-state nil) (defvar mouse-avoidance-pointer-shapes nil) -(defvar mouse-avoidance-n-pointer-shapes 0) (defvar mouse-avoidance-old-pointer-shape nil) (defvar mouse-avoidance-animating-pointer nil) @@ -306,11 +305,8 @@ redefine this function to suit your own tastes." (all-completions "x-pointer-" obarray (lambda (x) (and (boundp x) - (integerp (symbol-value x))))))) - (setq mouse-avoidance-n-pointer-shapes - (length mouse-avoidance-pointer-shapes)))) - (nth (random mouse-avoidance-n-pointer-shapes) - mouse-avoidance-pointer-shapes)) + (integerp (symbol-value x))))))))) + (seq-random-elt mouse-avoidance-pointer-shapes)) (defun mouse-avoidance-ignore-p () (let ((mp (mouse-position))) diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index ae5988296d8..baafc51693c 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -570,6 +570,7 @@ SEQUENCE must be a sequence of numbers or markers." If no element is found, return nil." (ignore-errors (seq-elt sequence n))) +;;;###autoload (cl-defgeneric seq-random-elt (sequence) "Return a random element from SEQUENCE. Signal an error if SEQUENCE is empty." diff --git a/lisp/epa-ks.el b/lisp/epa-ks.el index ebdb1274218..35caa1a93c5 100644 --- a/lisp/epa-ks.el +++ b/lisp/epa-ks.el @@ -149,8 +149,7 @@ If EXACT is non-nil, don't accept approximate matches." (cond ((null epa-keyserver) (user-error "Empty keyserver pool")) ((listp epa-keyserver) - (nth (random (length epa-keyserver)) - epa-keyserver)) + (seq-random-elt epa-keyserver)) ((stringp epa-keyserver) epa-keyserver) ((error "Invalid type for `epa-keyserver'"))) diff --git a/lisp/erc/erc-networks.el b/lisp/erc/erc-networks.el index 1c7742afd21..678c596760b 100644 --- a/lisp/erc/erc-networks.el +++ b/lisp/erc/erc-networks.el @@ -824,7 +824,7 @@ As an example: (ports (if (listp (nth 3 srv)) (erc-ports-list (nth 3 srv)) (list (nth 3 srv)))) - (port (nth (random (length ports)) ports))) + (port (and ports (seq-random-elt ports)))) (erc :server host :port port))) ;;; The following experimental diff --git a/lisp/gnus/gnus-fun.el b/lisp/gnus/gnus-fun.el index 8bca4ffe38f..bfc57a2d605 100644 --- a/lisp/gnus/gnus-fun.el +++ b/lisp/gnus/gnus-fun.el @@ -103,7 +103,7 @@ PNG format." (remove nil (mapcar (lambda (f) (unless (string-match (or omit "^$") f) f)) (directory-files dir t ext)))) - (file (nth (random (length files)) files))) + (file (and files (seq-random-elt files)))) (when file (funcall fun file))))) @@ -315,7 +315,7 @@ colors of the displayed X-Faces." (let* ((possibilities '("%02x0000" "00%02x00" "0000%02x" "%02x%02x00" "00%02x%02x" "%02x00%02x")) (format (concat "'#%02x%02x%02x' '#" - (nth (random 6) possibilities) + (seq-random-elt possibilities) "'")) (values nil)) (dotimes (i 255) diff --git a/lisp/net/soap-inspect.el b/lisp/net/soap-inspect.el index b994b0ed862..5207ca8ff19 100644 --- a/lisp/net/soap-inspect.el +++ b/lisp/net/soap-inspect.el @@ -114,7 +114,7 @@ This is a specialization of `soap-sample-value' for (cond ((soap-xs-simple-type-enumeration type) (let ((enumeration (soap-xs-simple-type-enumeration type))) - (nth (random (length enumeration)) enumeration))) + (and enumeration (seq-random-elt enumeration)))) ((soap-xs-simple-type-pattern type) (format "a string matching %s" (soap-xs-simple-type-pattern type))) ((soap-xs-simple-type-length-range type) @@ -134,7 +134,7 @@ This is a specialization of `soap-sample-value' for (t (random 100))))) ((consp (soap-xs-simple-type-base type)) ; an union of values (let ((base (soap-xs-simple-type-base type))) - (soap-sample-value (nth (random (length base)) base)))) + (soap-sample-value (and base (seq-random-elt base))))) ((soap-xs-basic-type-p (soap-xs-simple-type-base type)) (soap-sample-value (soap-xs-simple-type-base type)))))) diff --git a/lisp/obsolete/landmark.el b/lisp/obsolete/landmark.el index cc4fd19c389..83e7649a69c 100644 --- a/lisp/obsolete/landmark.el +++ b/lisp/obsolete/landmark.el @@ -1470,7 +1470,7 @@ push him out of it." (mapc (lambda (direction) (put direction 'y_t 0)) landmark-directions) - (dolist (direction (nth (random 8) landmark-8-directions)) + (dolist (direction (seq-random-elt landmark-8-directions)) (put direction 'y_t 1.0)) (landmark-move)) diff --git a/lisp/play/mpuz.el b/lisp/play/mpuz.el index ff174fed6c2..df2b6fc867a 100644 --- a/lisp/play/mpuz.el +++ b/lisp/play/mpuz.el @@ -153,7 +153,7 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." (index 10) elem) (while letters - (setq elem (nth (random index) letters) + (setq elem (seq-random-elt letters) letters (delq elem letters) index (1- index)) (aset mpuz-digit-to-letter index elem) diff --git a/lisp/play/zone.el b/lisp/play/zone.el index 27aa48f4c9a..a5d4ac9dc66 100644 --- a/lisp/play/zone.el +++ b/lisp/play/zone.el @@ -596,7 +596,7 @@ If the element is a function or a list of a function and a number, (forward-line -1) (delete-region (point) (line-beginning-position 2)) (goto-char (point-min)) - (insert (nth (random (length lines)) lines))) + (insert (seq-random-elt lines))) (message (concat (make-string (random (- (frame-width) 5)) ? ) "grrr")) (sit-for 0.1))))) diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index 2e20284951f..1290d7e03a5 100644 --- a/lisp/vc/add-log.el +++ b/lisp/vc/add-log.el @@ -930,8 +930,7 @@ non-nil, otherwise in local time." (not (looking-at "[ \t]+.*<.*>$"))) (setq hit t))))) (forward-line 1) - (insert (nth (random (length new-entries)) - new-entries) + (insert (and new-entries (seq-random-elt new-entries)) (if use-hard-newlines hard-newline "\n") (if use-hard-newlines hard-newline "\n")) (forward-line -1)))) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 9f0264abc1b..f105c6f60ba 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -6787,8 +6787,7 @@ process sentinels. They shall not disturb each other." (let ((time (float-time)) (default-directory tmp-name) (file - (buffer-name - (nth (random (length buffers)) buffers))) + (buffer-name (seq-random-elt buffers))) ;; A remote operation in a timer could ;; confuse Tramp heavily. So we ignore this ;; error here. @@ -6853,7 +6852,7 @@ process sentinels. They shall not disturb each other." ;; the buffers. Mix with regular operation. (let ((buffers (copy-sequence buffers))) (while buffers - (let* ((buf (nth (random (length buffers)) buffers)) + (let* ((buf (seq-random-elt buffers)) (proc (get-buffer-process buf)) (file (process-get proc 'foo)) (count (process-get proc 'bar))) -- cgit v1.2.3 From c92444b4ba3b134378fe3deb7c040bef6b9fab54 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 25 Sep 2021 21:44:44 +0200 Subject: ; Bump seq version to 2.23 --- lisp/emacs-lisp/seq.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index baafc51693c..e7258c2da49 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -4,7 +4,7 @@ ;; Author: Nicolas Petton ;; Keywords: sequences -;; Version: 2.22 +;; Version: 2.23 ;; Package: seq ;; Maintainer: emacs-devel@gnu.org -- cgit v1.2.3 From c78e16962e63895d340f80cf245fad568a7da770 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 24 Sep 2021 14:46:56 +0200 Subject: ; Adjust overly long docstrings to fit 80 characters --- lisp/array.el | 5 +++-- lisp/cedet/data-debug.el | 3 ++- lisp/cedet/semantic/analyze/complete.el | 3 ++- lisp/cedet/semantic/db-find.el | 2 +- lisp/cedet/semantic/tag-ls.el | 19 ++++++++++++++----- lisp/emacs-lisp/eieio-core.el | 2 +- lisp/emacs-lisp/seq.el | 4 ++-- lisp/emulation/viper-cmd.el | 3 ++- lisp/emulation/viper-init.el | 3 ++- lisp/erc/erc-backend.el | 3 ++- lisp/erc/erc-dcc.el | 5 ++--- lisp/frameset.el | 3 ++- lisp/gnus/gnus-agent.el | 4 ++-- lisp/gnus/gnus-bookmark.el | 4 +++- lisp/gnus/gnus-fun.el | 3 ++- lisp/gnus/gnus-group.el | 6 ++++-- lisp/gnus/gnus-score.el | 4 +++- lisp/gnus/gnus-sum.el | 9 +++++---- lisp/gnus/nnvirtual.el | 8 +++++--- lisp/net/dbus.el | 3 ++- lisp/net/dictionary.el | 2 +- lisp/net/eudc.el | 5 +++-- lisp/net/ntlm.el | 4 ++-- lisp/net/tramp-gvfs.el | 11 +++++++---- lisp/net/tramp-sh.el | 2 +- lisp/org/ob-table.el | 3 ++- lisp/org/org-agenda.el | 3 ++- lisp/org/org-protocol.el | 15 ++++++++------- lisp/play/doctor.el | 4 ++-- lisp/progmodes/cc-cmds.el | 2 +- lisp/progmodes/flymake-proc.el | 7 ++++--- lisp/progmodes/idlwave.el | 3 ++- lisp/progmodes/prolog.el | 3 ++- lisp/progmodes/verilog-mode.el | 14 ++++++++++---- lisp/tab-bar.el | 7 ++++--- lisp/textmodes/texinfo.el | 3 ++- lisp/vc/ediff-merg.el | 3 ++- lisp/vc/ediff.el | 10 ++++++---- lisp/vc/vc-annotate.el | 3 ++- lisp/vc/vc-dir.el | 3 ++- lisp/vc/vc-dispatcher.el | 2 +- lisp/vc/vc.el | 4 ++-- lisp/whitespace.el | 4 ++-- test/lisp/auth-source-pass-tests.el | 6 ++++-- test/lisp/international/ucs-normalize-tests.el | 6 +++--- 45 files changed, 138 insertions(+), 87 deletions(-) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/lisp/array.el b/lisp/array.el index 6632da55dd4..2c9a6815d25 100644 --- a/lisp/array.el +++ b/lisp/array.el @@ -805,8 +805,9 @@ NOT recognized as integers or real numbers. The array MUST reside at the top of the buffer. TABs are not respected, and may be converted into spaces at any time. -Setting the variable `array-respect-tabs' to non-nil will prevent TAB conversion, -but will cause many functions to give errors if they encounter one. +Setting the variable `array-respect-tabs' to non-nil will prevent +TAB conversion, but will cause many functions to give errors if +they encounter one. Upon entering array mode, you will be prompted for the values of several variables. Others will be calculated based on the values you diff --git a/lisp/cedet/data-debug.el b/lisp/cedet/data-debug.el index 428848be04d..8f40a4db79d 100644 --- a/lisp/cedet/data-debug.el +++ b/lisp/cedet/data-debug.el @@ -413,7 +413,8 @@ PREBUTTONTEXT is some text between prefix and the stuff list button." ) (defun data-debug-insert-hash-table-button (hash-table prefix prebuttontext) - "Insert HASH-TABLE as expandable button with recursive prefix PREFIX and PREBUTTONTEXT in front of the button text." + "Insert HASH-TABLE as expandable button with recursive prefix PREFIX and +PREBUTTONTEXT in front of the button text." (let ((string (propertize (format "%s" hash-table) 'face 'font-lock-keyword-face))) (insert (propertize diff --git a/lisp/cedet/semantic/analyze/complete.el b/lisp/cedet/semantic/analyze/complete.el index 1e8cd9af088..5c3228ae166 100644 --- a/lisp/cedet/semantic/analyze/complete.el +++ b/lisp/cedet/semantic/analyze/complete.el @@ -70,7 +70,8 @@ context. Passing in a context is useful if the caller also needs to access parts of the analysis. The remaining FLAGS arguments are passed to the mode specific completion engine. Bad flags should be ignored by modes that don't use them. -See `semantic-analyze-possible-completions-default' for details on the default FLAGS. +See `semantic-analyze-possible-completions-default' for details +on the default FLAGS. Completions run through the following filters: * Elements currently in scope diff --git a/lisp/cedet/semantic/db-find.el b/lisp/cedet/semantic/db-find.el index 61baaa020f8..e6a7879775e 100644 --- a/lisp/cedet/semantic/db-find.el +++ b/lisp/cedet/semantic/db-find.el @@ -914,7 +914,7 @@ but should be good enough for debugging assertions." (null (car (cdr (car resultp))))))) (defun semanticdb-find-result-prin1-to-string (result) - "Presuming RESULT satisfies `semanticdb-find-results-p', provide a short PRIN1 output." + "If RESULT satisfies `semanticdb-find-results-p', provide a short PRIN1 output." (if (< (length result) 2) (concat "# (gnus-thread-highest-number h1) (gnus-thread-highest-number h2))) (defun gnus-thread-highest-number (thread) @@ -5187,7 +5188,7 @@ Unscored articles will be counted as having a score of zero." (gnus-article-sort-by-date h1 h2)) (defun gnus-thread-sort-by-most-recent-date (h1 h2) - "Sort threads such that the thread with the most recently dated article comes first." + "Sort threads such that the thread with most recently dated article is first." (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2))) (defsubst gnus-article-sort-by-newsgroups (h1 h2) @@ -5651,7 +5652,7 @@ or a straight list of headers." gnus-list-identifiers))) (defun gnus-summary-remove-list-identifiers () - "Remove list identifiers in `gnus-list-identifiers' from articles in the current group." + "Remove identifiers in `gnus-list-identifiers' from articles in current group." (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name)) changed subject) (when regexp diff --git a/lisp/gnus/nnvirtual.el b/lisp/gnus/nnvirtual.el index 03a0ff296f2..4136392c825 100644 --- a/lisp/gnus/nnvirtual.el +++ b/lisp/gnus/nnvirtual.el @@ -382,7 +382,8 @@ It is computed from the marks of individual component groups.") (defun nnvirtual-update-xref-header (group article prefix sysname) - "Edit current NOV header in current buffer to have an xref to the component group, and also server prefix any existing xref lines." + "Edit current NOV header in current buffer to have an xref to the component +group, and also server prefix any existing xref lines." ;; Move to beginning of Xref field, creating a slot if needed. (beginning-of-line) (looking-at @@ -569,7 +570,8 @@ If UPDATE-P is not nil, call gnus-group-update-group on the components." ;; unique reverse mapping. (defun nnvirtual-map-article (article) - "Return a cons of the component group and article corresponding to the given virtual ARTICLE." + "Return a cons of the component group and article corresponding to the given +virtual ARTICLE." (let ((table nnvirtual-mapping-table) entry group-pos) (while (and table @@ -590,7 +592,7 @@ If UPDATE-P is not nil, call gnus-group-update-group on the components." (defun nnvirtual-reverse-map-article (group article) - "Return the virtual article number corresponding to the given component GROUP and ARTICLE." + "Return virtual article number corresponding to component GROUP and ARTICLE." (when (numberp article) (let ((table nnvirtual-mapping-table) (group-pos 0) diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index 4116d293e1b..560ece67517 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el @@ -2073,7 +2073,8 @@ either a method name, a signal name, or an error name." (goto-char point))) (defun dbus-monitor-handler (&rest _args) - "Default handler for the \"org.freedesktop.DBus.Monitoring.BecomeMonitor\" interface. + "Default handler for the \"Monitoring.BecomeMonitor\" interface. +Its full name is \"org.freedesktop.DBus.Monitoring.BecomeMonitor\". It will be applied for all objects created by `dbus-register-monitor' which don't declare an own handler. The printed timestamps do not reflect the time the D-Bus message has passed the D-Bus diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index 85467cd7828..09d250fd7bf 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el @@ -1049,7 +1049,7 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." 'dictionary-display-match-result))) (defun dictionary-do-matching (word dictionary strategy function) - "Find matches for WORD with STRATEGY in DICTIONARY and display them with FUNCTION." + "Search for WORD with STRATEGY in DICTIONARY and display them with FUNCTION." (message "Lookup matching words for %s in %s using %s" word dictionary strategy) (dictionary-send-command diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el index 5c451c6556d..14e5c28b2dc 100644 --- a/lisp/net/eudc.el +++ b/lisp/net/eudc.el @@ -798,8 +798,9 @@ see `eudc-inline-expansion-servers'." "Query the directory server, and return the matching responses. The variable `eudc-inline-query-format' controls how to associate the individual QUERY-WORDS with directory attribute names. -After querying the server for the given string, the expansion specified by -`eudc-inline-expansion-format' is applied to the matches before returning them.inserted in the buffer at point. +After querying the server for the given string, the expansion +specified by `eudc-inline-expansion-format' is applied to the +matches before returning them.inserted in the buffer at point. Multiple servers can be tried with the same query until one finds a match, see `eudc-inline-expansion-servers'." (cond diff --git a/lisp/net/ntlm.el b/lisp/net/ntlm.el index 747a69fb5d4..0e0146df969 100644 --- a/lisp/net/ntlm.el +++ b/lisp/net/ntlm.el @@ -436,7 +436,7 @@ PASSWD is truncated to 14 bytes if longer." (make-string (- 15 len) 0))))) (defun ntlm-smb-owf-encrypt (passwd c8) - "Return response string of 24 bytes long for password string PASSWD based on DES encryption. + "Return response string of 24 bytes long for PASSWD based on DES encryption. PASSWD is of at most 14 bytes long and the challenge string C8 of 8 bytes long." (let* ((len (min (length passwd) 16)) @@ -459,7 +459,7 @@ PASSWD is of at most 14 bytes long and the challenge string C8 of (substring p15 7) t))) (defun ntlm-smb-hash (in key forw) - "Return hash string of length 8 for a string IN of length 8 and a string KEY of length 8. + "Return hash string of length 8 for IN of length 8 and KEY of length 8. FORW is t or nil." (let ((out (make-string 8 0)) (inb (make-string 64 0)) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 5f0e7bcd98c..115d005c0ca 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1833,8 +1833,9 @@ a downcased host name only." result)))) (defun tramp-gvfs-handler-mounted-unmounted (mount-info) - "Signal handler for the \"org.gtk.vfs.MountTracker.mounted\" and \ -\"org.gtk.vfs.MountTracker.unmounted\" signals." + "Signal handler for the gvfs \"mounted\" and \"unmounted\" signals. +Their full names are \"org.gtk.vfs.MountTracker.mounted\" and +\"org.gtk.vfs.MountTracker.unmounted\"." (ignore-errors (let ((signal-name (dbus-event-member-name last-input-event)) (elt mount-info)) @@ -2090,8 +2091,10 @@ It was \"a(say)\", but has changed to \"a{sv})\"." `(:struct ,(tramp-gvfs-dbus-string-to-byte-array mount-pref) ,mount-spec))) (defun tramp-gvfs-handler-volumeadded-volumeremoved (_dbus-name _id volume) - "Signal handler for the \"org.gtk.Private.RemoteVolumeMonitor.VolumeAdded\" \ -and \"org.gtk.Private.RemoteVolumeMonitor.VolumeRemoved\" signals." + "Signal handler for the gvfs \"VolumeAdded\" and \"VolumeRemoved\" signals. +Their full names are +\"org.gtk.Private.RemoteVolumeMonitor.VolumeAdded\" and +\"org.gtk.Private.RemoteVolumeMonitor.VolumeRemoved\"." (ignore-errors (let* ((signal-name (dbus-event-member-name last-input-event)) (uri (url-generic-parse-url (nth 5 volume))) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 0fe106684c5..dd92f226897 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1699,7 +1699,7 @@ ID-FORMAT valid values are `string' and `integer'." ;; FIXME: Fix function to work with count parameter. (defun tramp-do-directory-files-and-attributes-with-stat (vec localname &optional id-format) - "Implement `directory-files-and-attributes' for Tramp files using stat(1) command." + "Implement `directory-files-and-attributes' for Tramp files with stat(1) command." (tramp-message vec 5 "directory-files-and-attributes with stat: %s" localname) (tramp-send-command-and-read vec diff --git a/lisp/org/ob-table.el b/lisp/org/ob-table.el index 39a14a25d6c..e081708701d 100644 --- a/lisp/org/ob-table.el +++ b/lisp/org/ob-table.el @@ -78,7 +78,8 @@ So this `org-sbe' construct is the equivalent of the following source code block: - #+begin_src emacs-lisp :var results=source-block(n=val_at_col_2, m=3) :results silent + #+begin_src emacs-lisp :var results=source-block(n=val_at_col_2, m=3) \\ + :results silent results #+end_src diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index 23c62809a2b..271eac1c30d 100644 --- a/lisp/org/org-agenda.el +++ b/lisp/org/org-agenda.el @@ -1230,7 +1230,8 @@ For example, 9:30am would become 09:30 rather than 9:30." ":" minute ampm))) (defun org-agenda-time-of-day-to-ampm-maybe (time) - "Conditionally convert TIME to AM/PM format based on `org-agenda-timegrid-use-ampm'." + "Conditionally convert TIME to AM/PM format. +This is based on `org-agenda-timegrid-use-ampm'." (if org-agenda-timegrid-use-ampm (org-agenda-time-of-day-to-ampm time) time)) diff --git a/lisp/org/org-protocol.el b/lisp/org/org-protocol.el index 726c1ca2bae..ff8c08d5c5f 100644 --- a/lisp/org/org-protocol.el +++ b/lisp/org/org-protocol.el @@ -178,11 +178,11 @@ Possible properties are: :working-suffix - the replacement for online-suffix :base-url - the base URL, e.g. http://www.example.com/project/ Last slash required. - :working-directory - the local working directory. This is, what base-url will - be replaced with. - :redirects - A list of cons cells, each of which maps a regular - expression to match to a path relative to - :working-directory. + :working-directory - the local working directory. This is what + base-url will be replaced with. + :redirects - A list of cons cells, each of which maps a + regular expression to match to a path relative + to `:working-directory'. Example: @@ -216,8 +216,9 @@ Example: does not include any suffix properties, allowing local source file to be opened as found by OpenGrok. -Consider using the interactive functions `org-protocol-create' and -`org-protocol-create-for-org' to help you filling this variable with valid contents." +Consider using the interactive functions `org-protocol-create' +and `org-protocol-create-for-org' to help you filling this +variable with valid contents." :group 'org-protocol :type 'alist) diff --git a/lisp/play/doctor.el b/lisp/play/doctor.el index b855f7e35a1..33fecaa188a 100644 --- a/lisp/play/doctor.el +++ b/lisp/play/doctor.el @@ -1011,8 +1011,8 @@ Put dialogue in buffer." (defun doctor-subjsearch (sent key type) "Search for the subject of a sentence SENT, looking for the noun closest -to and preceding KEY by at least TYPE words. Set global variable `doctor-subj' to -the subject noun, and return the portion of the sentence following it." +to and preceding KEY by at least TYPE words. Set global variable `doctor-subj' +to the subject noun, and return the portion of the sentence following it." (let ((i (- (length sent) (length (memq key sent)) type))) (while (and (> i -1) (not (doctor-nounp (nth i sent)))) (setq i (1- i))) diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 6c3da667bfc..d40433a9b0d 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -480,7 +480,7 @@ function to control that." ;; This function is only used in XEmacs. (defun c-hungry-delete () - "Delete a non-whitespace char, or all whitespace up to the next non-whitespace char. + "Delete non-whitespace char, or all whitespace up to next non-whitespace char. The direction of deletion depends on the configuration: If the function `delete-forward-p' is defined and returns non-nil, it deletes forward using `c-hungry-delete-forward'. Otherwise it deletes diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el index 27b46a45c50..7f2aa0f469f 100644 --- a/lisp/progmodes/flymake-proc.el +++ b/lisp/progmodes/flymake-proc.el @@ -902,7 +902,7 @@ can also be executed interactively independently of temp-dir)))) (defun flymake-proc--delete-temp-directory (dir-name) - "Attempt to delete temp dir created by `flymake-proc-create-temp-with-folder-structure', do not fail on error." + "Attempt to delete temp dir DIR-NAME, do not fail on error." (let* ((temp-dir temporary-file-directory) (suffix (substring dir-name (1+ (length (directory-file-name temp-dir)))))) @@ -919,7 +919,8 @@ can also be executed interactively independently of (defvar-local flymake-proc--base-dir nil) (defun flymake-proc-init-create-temp-buffer-copy (create-temp-f) - "Make a temporary copy of the current buffer, save its name in buffer data and return the name." + "Make a temporary copy of the current buffer, save its name in buffer data. +Return the name." (let* ((source-file-name buffer-file-name) (temp-source-file-name (funcall create-temp-f source-file-name "flymake"))) @@ -1007,7 +1008,7 @@ Return full-name. Names are real, not patched." buildfile-name source-file-name))))) (defun flymake-proc--init-create-temp-source-and-master-buffer-copy (get-incl-dirs-f create-temp-f master-file-masks include-regexp) - "Find master file (or buffer), create its copy along with a copy of the source file." + "Find master file (or buffer), create its copy and a copy of the source file." (let* ((source-file-name buffer-file-name) (temp-source-file-name (flymake-proc-init-create-temp-buffer-copy create-temp-f)) (master-and-temp-master (flymake-proc--create-master-file diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index d6828eeffbb..4224e47d16d 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el @@ -1522,7 +1522,8 @@ No spaces before and 1 after a comma A minimum of 1 space before and after `=' (see `idlwave-expand-equal'). (idlwave-action-and-binding \"=\" (lambda (_) (idlwave-expand-equal -1 -1))) Capitalize system variables - action only - (idlwave-action-and-binding idlwave-sysvar (lambda (_) (capitalize-word 1) t))" + (idlwave-action-and-binding idlwave-sysvar + (lambda (_) (capitalize-word 1) t))" (if (not (equal select 'noaction)) ;; Add action (let* ((table (if select 'idlwave-indent-action-table diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el index 33ca01cc754..74a023775f8 100644 --- a/lisp/progmodes/prolog.el +++ b/lisp/progmodes/prolog.el @@ -2136,7 +2136,8 @@ A return value of N means N more left parentheses than right ones." (line-end-position))))) (defun prolog-electric--if-then-else () - "Insert spaces after the opening parenthesis, \"then\" (->) and \"else\" (;) branches. + "Insert spaces after the opening parenthesis. +\"then\" (->) and \"else\" (;) branches. Spaces are inserted if all preceding objects on the line are whitespace characters, parentheses, or then/else branches." (when prolog-electric-if-then-else-flag diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index ac6a8fbbcb1..d98230d9a0e 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el @@ -4038,9 +4038,12 @@ Some other functions are: \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block. \\[verilog-sk-specify] Insert a specify .. endspecify block. \\[verilog-sk-task] Insert a task .. begin .. end endtask block. - \\[verilog-sk-while] Insert a while (...) begin .. end block, prompting for details. - \\[verilog-sk-casex] Insert a casex (...) item: begin.. end endcase block, prompting for details. - \\[verilog-sk-casez] Insert a casez (...) item: begin.. end endcase block, prompting for details. + \\[verilog-sk-while] Insert a while (...) begin .. end block, + prompting for details. + \\[verilog-sk-casex] Insert a casex (...) item: begin.. end endcase block, + prompting for details. + \\[verilog-sk-casez] Insert a casez (...) item: begin.. end endcase block, + prompting for details. \\[verilog-sk-if] Insert an if (..) begin .. end block. \\[verilog-sk-else-if] Insert an else if (..) begin .. end block. \\[verilog-sk-comment] Insert a comment block. @@ -6580,7 +6583,8 @@ Return >0 for nested struct." nil)))) (defun verilog-at-constraint-p () - "If at the { of a constraint or coverpoint definition, return true, moving point to constraint." + "If at the { of a constraint or coverpoint definition, return true. +Also move point to constraint." (if (save-excursion (let ((p (point))) (and @@ -14985,7 +14989,9 @@ but instead, [[Fill in here]] happens!. (provide 'verilog-mode) +;;TODO: Could `byte-compile-docstring-max-column' be decreased? ;; Local Variables: +;; byte-compile-docstring-max-column: 90 ;; checkdoc-permit-comma-termination-flag:t ;; checkdoc-force-docstrings-flag:nil ;; indent-tabs-mode:nil diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index ceacd85971d..abf0e814c41 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1007,7 +1007,8 @@ on the tab bar instead." When this command is bound to a numeric key (with a prefix or modifier key using `tab-bar-select-tab-modifiers'), calling it without an argument will translate its bound numeric key to the numeric argument. -TAB-NUMBER counts from 1. Negative TAB-NUMBER counts tabs from the end of the tab bar." +TAB-NUMBER counts from 1. Negative TAB-NUMBER counts tabs from the end of +the tab bar." (interactive "P") (unless (integerp tab-number) (let ((key (event-basic-type last-command-event))) @@ -1908,7 +1909,7 @@ Letters do not insert themselves; instead, they are commands. (move-to-column tab-switcher-column)) (defun tab-switcher-unmark (&optional backup) - "Cancel all requested operations on window configuration on this line and move down. + "Cancel requested operations on window configuration on this line and move down. Optional prefix arg means move up." (interactive "P") (beginning-of-line) @@ -1920,7 +1921,7 @@ Optional prefix arg means move up." (move-to-column tab-switcher-column)) (defun tab-switcher-backup-unmark () - "Move up and cancel all requested operations on window configuration on line above." + "Move up one line and cancel requested operations on window configuration there." (interactive) (forward-line -1) (tab-switcher-unmark) diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index 135a4047318..7876a87a281 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el @@ -806,7 +806,8 @@ temporary file before the region itself. The buffer's header is all lines between the strings defined by `tex-start-of-header' and `tex-end-of-header' inclusive. The header must start in the first 100 lines. -The value of `texinfo-tex-trailer' is appended to the temporary file after the region." +The value of `texinfo-tex-trailer' is appended to the temporary +file after the region." (interactive "r") (require 'tex-mode) (let ((tex-command texinfo-tex-command) diff --git a/lisp/vc/ediff-merg.el b/lisp/vc/ediff-merg.el index 2bdce9e33c7..d0ce9d326d8 100644 --- a/lisp/vc/ediff-merg.el +++ b/lisp/vc/ediff-merg.el @@ -257,7 +257,8 @@ Buffer B." (defun ediff-re-merge () - "Remerge unmodified diff regions using a new default. Start with the current region." + "Remerge unmodified diff regions using a new default. +Start with the current region." (interactive) (let* ((default-variant-alist (list '("default-A") '("default-B") '("combined"))) diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el index 74ed1bd0ef2..e406275cd1a 100644 --- a/lisp/vc/ediff.el +++ b/lisp/vc/ediff.el @@ -680,7 +680,7 @@ MERGE-AUTOSTORE-DIR is the directory in which to store merged files." (defun ediff-merge-directories-with-ancestor (dir1 dir2 ancestor-dir regexp &optional merge-autostore-dir) - "Merge files in directories DIR1 and DIR2 using files in ANCESTOR-DIR as ancestors. + "Merge files in DIR1 and DIR2 using files in ANCESTOR-DIR as ancestors. Ediff merges files that have identical names in DIR1, DIR2. If a pair of files in DIR1 and DIR2 doesn't have an ancestor in ANCESTOR-DIR, Ediff will merge without ancestor. The fourth argument, REGEXP, is nil or a regular expression; @@ -746,7 +746,7 @@ MERGE-AUTOSTORE-DIR is the directory in which to store merged files." (defun ediff-merge-directory-revisions-with-ancestor (dir1 regexp &optional merge-autostore-dir) - "Run Ediff on a directory, DIR1, merging its files with their revisions and ancestors. + "Run Ediff on DIR1 and merge its files with their revisions and ancestors. The second argument, REGEXP, is a regular expression that filters the file names. Only the files that are under revision control are taken into account. MERGE-AUTOSTORE-DIR is the directory in which to store merged files." @@ -1600,7 +1600,8 @@ With optional NODE, goes to that node." ;;;###autoload (defun ediff-merge-with-ancestor-command () - "Call `ediff-merge-files-with-ancestor' with the next three command line arguments." + "Call `ediff-merge-files-with-ancestor' with the next three command line +arguments." (let ((file-a (nth 0 command-line-args-left)) (file-b (nth 1 command-line-args-left)) (ancestor (nth 2 command-line-args-left))) @@ -1637,7 +1638,8 @@ With optional NODE, goes to that node." ;;;###autoload (defun ediff-merge-directories-with-ancestor-command () - "Call `ediff-merge-directories-with-ancestor' with the next four command line arguments." + "Call `ediff-merge-directories-with-ancestor' with the next four command line +arguments." (let ((file-a (nth 0 command-line-args-left)) (file-b (nth 1 command-line-args-left)) (ancestor (nth 2 command-line-args-left)) diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el index 45bb17749bc..5a4ac1aca84 100644 --- a/lisp/vc/vc-annotate.el +++ b/lisp/vc/vc-annotate.el @@ -610,7 +610,8 @@ the file in question, search for the log entry required and move point." (vc-annotate-show-diff-revision-at-line-internal t)) (defun vc-annotate-show-changeset-diff-revision-at-line () - "Visit the diff of the revision at line from its previous revision for all files in the changeset." + "Visit diff of revision at line from previous revision. +This is done for all files in changeset." (interactive) (when (eq 'file (vc-call-backend vc-annotate-backend 'revision-granularity)) (error "The %s backend does not support changeset diffs" vc-annotate-backend)) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index f8b87170af5..d079b891e4d 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -1015,7 +1015,8 @@ child files." (nreverse result))) (defun vc-dir-child-files-and-states () - "Return the list of conses (FILE . STATE) for child files of the current entry if it's a directory. + "Return list of conses for child files of the current entry if it's a directory. +The conses have the format (FILE . STATE). If it is a file, return the corresponding cons for the file itself." (let* ((crt (ewoc-locate vc-ewoc)) (crt-data (ewoc-data crt)) diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index cd23bcce941..346974bdba8 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -404,7 +404,7 @@ Display the buffer in some window, but don't select it." (defvar compilation-error-regexp-alist) (defun vc-compilation-mode (backend) - "Setup `compilation-mode' after with the appropriate `compilation-error-regexp-alist'." + "Setup `compilation-mode' with the appropriate `compilation-error-regexp-alist'." (require 'compile) (let* ((error-regexp-alist (vc-make-backend-sym backend 'error-regexp-alist)) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 7d3b0f56f60..5b259fcdb33 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2624,7 +2624,7 @@ with its diffs (if the underlying VCS supports that)." ;;;###autoload (defun vc-log-incoming (&optional remote-location) - "Show a log of changes that will be received with a pull operation from REMOTE-LOCATION. + "Show log of changes that will be received with pull from REMOTE-LOCATION. When called interactively with a prefix argument, prompt for REMOTE-LOCATION." (interactive (when current-prefix-arg @@ -2637,7 +2637,7 @@ When called interactively with a prefix argument, prompt for REMOTE-LOCATION." ;;;###autoload (defun vc-log-outgoing (&optional remote-location) - "Show a log of changes that will be sent with a push operation to REMOTE-LOCATION. + "Show log of changes that will be sent with a push operation to REMOTE-LOCATION. When called interactively with a prefix argument, prompt for REMOTE-LOCATION." (interactive (when current-prefix-arg diff --git a/lisp/whitespace.el b/lisp/whitespace.el index d4f2b2890a8..6e132de536d 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -2193,8 +2193,8 @@ resultant list will be returned." limit t)) (defun whitespace-empty-at-bob-regexp (limit) - "Match spaces at beginning of buffer which do not contain the point at \ -beginning of buffer." + "Match spaces at beginning of buffer which do not contain +the point at beginning of buffer." (let ((b (point)) r) (cond diff --git a/test/lisp/auth-source-pass-tests.el b/test/lisp/auth-source-pass-tests.el index a0a97eca5eb..3da6f3e9b7b 100644 --- a/test/lisp/auth-source-pass-tests.el +++ b/test/lisp/auth-source-pass-tests.el @@ -97,7 +97,8 @@ This function is intended to be set to `auth-source-debug'." (defun auth-source-pass--explain-match-entry-p (entry hostname &optional user port) "Explainer function for `auth-source-pass-match-entry-p'. -ENTRY, HOSTNAME, USER and PORT are the same as in `auth-source-pass-match-entry-p'." +ENTRY, HOSTNAME, USER and PORT are the same as in +`auth-source-pass-match-entry-p'." `(entry ,entry store @@ -122,7 +123,8 @@ HOSTNAME, USER and PORT are passed unchanged to (defun auth-source-pass--explain-includes-sorted-entries (entries hostname &optional user port) "Explainer function for `auth-source-pass--includes-sorted-entries'. -ENTRIES, HOSTNAME, USER and PORT are the same as in `auth-source-pass--includes-sorted-entries'." +ENTRIES, HOSTNAME, USER and PORT are the same as in +`auth-source-pass--includes-sorted-entries'." `(store ,(auth-source-pass-entries) matching-entries diff --git a/test/lisp/international/ucs-normalize-tests.el b/test/lisp/international/ucs-normalize-tests.el index 52c3d3704eb..eb577b97dc4 100644 --- a/test/lisp/international/ucs-normalize-tests.el +++ b/test/lisp/international/ucs-normalize-tests.el @@ -123,9 +123,9 @@ The following invariants must be true for all conformant implementations..." (defsubst ucs-normalize-tests--rule2-holds-p (X) "Check 2nd conformance rule. -For every code point X assigned in this version of Unicode that is not specifically -listed in Part 1, the following invariants must be true for all conformant -implementations: +For every code point X assigned in this version of Unicode that +is not specifically listed in Part 1, the following invariants +must be true for all conformant implementations: X == toNFC(X) == toNFD(X) == toNFKC(X) == toNFKD(X)" (and (ucs-normalize-tests--normalization-chareq-p NFC X X) -- cgit v1.2.3 From b4b4cc98ac271d079916a4c412e134fe5b4ba4d8 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 29 Sep 2021 17:25:01 +0200 Subject: Revert "Obsolete local set difference functions in favor of seq-difference" This reverts commit 20f7fa691b7c2859b96550d9ccb326bf394e160d. gnus-set-difference is orders of magnitude faster than seq-difference (on these sets), and using seq-difference makes nnimap too slow. --- lisp/emacs-lisp/seq.el | 1 - lisp/gnus/gnus-cite.el | 4 ++-- lisp/gnus/gnus-range.el | 9 +++++++-- lisp/gnus/gnus-sum.el | 5 ++--- lisp/gnus/gnus-uu.el | 2 +- lisp/gnus/nnimap.el | 10 ++++------ lisp/gnus/spam.el | 14 +++++++++++--- 7 files changed, 27 insertions(+), 18 deletions(-) (limited to 'lisp/emacs-lisp/seq.el') diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 52c080388b7..451ff196316 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -490,7 +490,6 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil." (seq-reverse sequence1) '())) -;;;###autoload (cl-defgeneric seq-difference (sequence1 sequence2 &optional testfn) "Return a list of the elements that appear in SEQUENCE1 but not in SEQUENCE2. Equality is defined by TESTFN if non-nil or by `equal' if nil." diff --git a/lisp/gnus/gnus-cite.el b/lisp/gnus/gnus-cite.el index 34947cece89..e9c912109e2 100644 --- a/lisp/gnus/gnus-cite.el +++ b/lisp/gnus/gnus-cite.el @@ -839,7 +839,7 @@ See also the documentation for `gnus-article-highlight-citation'." (setq current (car loop) loop (cdr loop)) (setcdr current - (seq-difference (cdr current) numbers #'eq))))))))) + (gnus-set-difference (cdr current) numbers))))))))) (defun gnus-cite-parse-attributions () (let (al-alist) @@ -999,7 +999,7 @@ See also the documentation for `gnus-article-highlight-citation'." loop (cdr loop)) (if (eq current best) () - (setcdr current (seq-difference (cdr current) numbers #'eq)) + (setcdr current (gnus-set-difference (cdr current) numbers)) (when (null (cdr current)) (setq gnus-cite-loose-prefix-alist (delq current gnus-cite-loose-prefix-alist) diff --git a/lisp/gnus/gnus-range.el b/lisp/gnus/gnus-range.el index 7d12ae9fdcc..456209f3d9a 100644 --- a/lisp/gnus/gnus-range.el +++ b/lisp/gnus/gnus-range.el @@ -42,8 +42,13 @@ If RANGE is a single range, return (RANGE). Otherwise, return RANGE." (defun gnus-set-difference (list1 list2) "Return a list of elements of LIST1 that do not appear in LIST2." - (declare (obsolete seq-difference "28.1")) - (seq-difference list1 list2 #'eq)) + (let ((hash2 (make-hash-table :test 'eq)) + (result nil)) + (dolist (elt list2) (puthash elt t hash2)) + (dolist (elt list1) + (unless (gethash elt hash2) + (setq result (cons elt result)))) + (nreverse result))) (defun gnus-range-nconcat (&rest ranges) "Return a range comprising all the RANGES, which are pre-sorted. diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index b3d0460032d..d790655aa90 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -8590,9 +8590,8 @@ If UNREPLIED (the prefix), limit to unreplied articles." (interactive "P" gnus-summary-mode) (if unreplied (gnus-summary-limit - (seq-difference gnus-newsgroup-articles - gnus-newsgroup-replied - #'eq)) + (gnus-set-difference gnus-newsgroup-articles + gnus-newsgroup-replied)) (gnus-summary-limit gnus-newsgroup-replied)) (gnus-summary-position-point)) diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el index f7b761ee339..778a8a3ea03 100644 --- a/lisp/gnus/gnus-uu.el +++ b/lisp/gnus/gnus-uu.el @@ -579,7 +579,7 @@ didn't work, and overwrite existing files. Otherwise, ask each time." (defun gnus-new-processable (unmarkp articles) (if unmarkp (nreverse (seq-intersection gnus-newsgroup-processable articles #'eq)) - (seq-difference articles gnus-newsgroup-processable #'eq))) + (gnus-set-difference articles gnus-newsgroup-processable))) (defun gnus-uu-mark-by-regexp (regexp &optional unmark) "Set the process mark on articles whose subjects match REGEXP. diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 8a48cd87dba..059101c8907 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -1638,15 +1638,13 @@ If LIMIT, first try to limit the search to the N last articles." (setq start-article 1)) (let* ((unread (gnus-compress-sequence - (seq-difference - (seq-difference + (gnus-set-difference + (gnus-set-difference existing (gnus-sorted-union (cdr (assoc '%Seen flags)) - (cdr (assoc '%Deleted flags))) - #'eq) - (cdr (assoc '%Flagged flags)) - #'eq))) + (cdr (assoc '%Deleted flags)))) + (cdr (assoc '%Flagged flags))))) (read (gnus-range-difference (cons start-article high) unread))) (when (> start-article 1) diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el index 3f978918b9a..d00f0a60b66 100644 --- a/lisp/gnus/spam.el +++ b/lisp/gnus/spam.el @@ -710,8 +710,16 @@ finds ham or spam.") (defun spam-set-difference (list1 list2) "Return a set difference of LIST1 and LIST2. When either list is nil, the other is returned." - (declare (obsolete seq-difference "28.1")) - (seq-difference list1 list2 #'eq)) + (if (and list1 list2) + ;; we have two non-nil lists + (progn + (dolist (item (append list1 list2)) + (when (and (memq item list1) (memq item list2)) + (setq list1 (delq item list1)) + (setq list2 (delq item list2)))) + (append list1 list2)) + ;; if either of the lists was nil, return the other one + (if list1 list1 list2))) (defun spam-group-ham-mark-p (group mark &optional spam) "Checks if MARK is considered a ham mark in GROUP." @@ -1319,7 +1327,7 @@ In the case of mover backends, checks the setting of (new-articles (spam-list-articles gnus-newsgroup-articles classification)) - (changed-articles (seq-difference new-articles old-articles #'eq))) + (changed-articles (spam-set-difference new-articles old-articles))) ;; now that we have the changed articles, we go through the processors (dolist (backend (spam-backend-list)) (let (unregister-list) -- cgit v1.2.3