From: Stefan Kangas Date: Tue, 11 Feb 2025 18:04:00 +0000 (+0100) Subject: Delete redundant lambdas around unary functions X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cb92c0d2734674e0d74f41355f3e46bf36c21c04;p=emacs.git Delete redundant lambdas around unary functions This is not just stylistic, but also slightly faster. These are all regular defuns, of course, as this won't work with macros and defsubsts. * lisp/calc/calc-nlfit.el (math-nlfit-fit-curve) (calc-fit-hubbert-linear-curve): * lisp/calendar/cal-tex.el (cal-tex-latexify-list): * lisp/calendar/todo-mode.el (todo-sort): * lisp/cedet/semantic/ctxt.el (semantic-ctxt-end-of-symbol-default) (semantic-ctxt-current-symbol-default): * lisp/cedet/semantic/symref.el (semantic-symref-result-get-files): * lisp/cedet/semantic/texi.el (semantic-texi-command-completion-list): * lisp/descr-text.el (describe-char): * lisp/emacs-lisp/eieio-datadebug.el (data-debug-add-specialized-thing): * lisp/emacs-lisp/rmc.el (read-multiple-choice--short-answers): * lisp/eshell/em-pred.el (eshell-modifier-alist): * lisp/gnus/gnus-cache.el (gnus-cache-articles-in-group): * lisp/gnus/gnus-dired.el (gnus-dired-attach): * lisp/help-mode.el (help-package-def): * lisp/ibuf-ext.el (ibuffer-mark-modified-buffers): * lisp/image/image-dired.el: * lisp/international/quail.el (quail-keyseq-translate) (quail-get-translations): * lisp/isearch.el (isearch-pre-command-hook) (search-within-boundaries): * lisp/mail/supercite.el (sc-ask): * lisp/mh-e/mh-e.el (mh-variant-set): * lisp/net/rcirc.el (rcirc-nick-channels, rcirc-channel-nicks): (rcirc-browse-url): * lisp/obsolete/thumbs.el (thumbs-cleanup-thumbsdir): * lisp/org/org-agenda.el (org-agenda-filter-completion-function): * lisp/org/org-table.el (org-table-eval-formula): * lisp/org/org.el (org-set-regexps-and-options): * lisp/org/ox.el (org-export--get-inbuffer-options): * lisp/ses.el (ses-range): * lisp/textmodes/emacs-news-mode.el (emacs-news--buttonize): * lisp/textmodes/ispell.el (ispell-begin-tex-skip-regexp): * lisp/vc/vc-cvs.el (vc-cvs-stay-local-p): * lisp/window.el (window--state-get-1): * test/lisp/emacs-lisp/shortdoc-tests.el (shortdoc-all-groups-work): Delete redundant lambdas around unary functions. (Bug#66816) (cherry picked from commit 0e76716c5faa5e91ac3913b02ba4dc690cf5df83) --- diff --git a/lisp/calc/calc-nlfit.el b/lisp/calc/calc-nlfit.el index 2761f35061e..82874284b65 100644 --- a/lisp/calc/calc-nlfit.el +++ b/lisp/calc/calc-nlfit.el @@ -678,7 +678,7 @@ (sdata (if (math-contains-sdev-p ydata) (mapcar (lambda (x) (math-get-sdev x t)) ydata) nil)) - (ydata (mapcar (lambda (x) (math-get-value x)) ydata)) + (ydata (mapcar #'math-get-value ydata)) (calc-curve-varnames nil) (calc-curve-coefnames nil) (calc-curve-nvars 1) @@ -757,7 +757,7 @@ (sdata (if (math-contains-sdev-p pdata) (mapcar (lambda (x) (math-get-sdev x t)) pdata) nil)) - (pdata (mapcar (lambda (x) (math-get-value x)) pdata)) + (pdata (mapcar #'math-get-value pdata)) (poverqdata (math-map-binop 'math-div pdata qdata)) (parmvals (math-nlfit-least-squares qdata poverqdata sdata sdevv)) (finalparms (list (nth 0 parmvals) diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el index 30ba7cf2785..688e842604d 100644 --- a/lisp/calendar/cal-tex.el +++ b/lisp/calendar/cal-tex.el @@ -1600,7 +1600,7 @@ FINAL-SEPARATOR is non-nil." (or separator (setq separator "\\\\")) (let (result) (setq result - (mapconcat (lambda (x) (cal-tex-LaTeXify-string x)) + (mapconcat #'cal-tex-LaTeXify-string (dolist (d date-list (reverse result)) (and (car d) (calendar-date-equal date (car d)) diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 194c08bf0af..58920eee7f5 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -3770,7 +3770,7 @@ option `todo-categories-align'." "Return a copy of LIST, possibly sorted according to KEY." (let* ((l (copy-sequence list)) (fn (if (eq key 'alpha) - (lambda (x) (upcase x)) ; Alphabetize case insensitively. + #'upcase ; Alphabetize case insensitively. (lambda (x) (todo-get-count key x)))) ;; Keep track of whether the last sort by key was descending or ;; ascending. diff --git a/lisp/descr-text.el b/lisp/descr-text.el index a048822575c..ad55feb4ea8 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el @@ -407,8 +407,7 @@ The character information includes: (composition-string nil) (disp-vector (and display-table (aref display-table char))) (multibyte-p enable-multibyte-characters) - (overlays (mapcar (lambda (o) (overlay-properties o)) - (overlays-at pos))) + (overlays (mapcar #'overlay-properties (overlays-at pos))) (char-description (if (< char 128) (single-key-description char) (string (if (not multibyte-p) diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el index e496d9a3660..8d83b7717b5 100644 --- a/lisp/eshell/em-pred.el +++ b/lisp/eshell/em-pred.el @@ -122,7 +122,7 @@ The format of each entry is (?e . (lambda (lst) (mapcar #'file-name-extension lst))) (?t . (lambda (lst) (mapcar #'file-name-nondirectory lst))) (?q . #'identity) ; Obsolete as of Emacs 31.1. - (?u . (lambda (lst) (seq-uniq lst))) + (?u . #'seq-uniq) (?o . (lambda (lst) (sort lst #'string-lessp))) (?O . (lambda (lst) (sort lst #'string-greaterp))) (?j . (eshell-join-members)) diff --git a/lisp/gnus/gnus-cache.el b/lisp/gnus/gnus-cache.el index b9af1ec93bb..59c5d7bb891 100644 --- a/lisp/gnus/gnus-cache.el +++ b/lisp/gnus/gnus-cache.el @@ -502,7 +502,7 @@ Returns the list of articles removed." (file-name-coding-system nnmail-pathname-coding-system)) (when (file-exists-p dir) (setq articles - (sort (mapcar (lambda (name) (string-to-number name)) + (sort (mapcar #'string-to-number (directory-files dir nil "\\`[0-9]+\\'" t)) #'<)) ;; Update the cache active file, just to synch more. diff --git a/lisp/gnus/gnus-dired.el b/lisp/gnus/gnus-dired.el index 048dd02744d..06fb9573c37 100644 --- a/lisp/gnus/gnus-dired.el +++ b/lisp/gnus/gnus-dired.el @@ -133,10 +133,8 @@ filenames." ;; warn if user tries to attach without any files marked (if (null files-to-attach) (error "No files to attach") - (setq files-str - (mapconcat - (lambda (f) (file-name-nondirectory f)) - files-to-attach ", ")) + (setq files-str (mapconcat #'file-name-nondirectory + files-to-attach ", ")) (setq bufs (gnus-dired-mail-buffers)) ;; set up destination mail composition buffer diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 7350ac503cd..dc4001e1b12 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -368,7 +368,7 @@ The format is (FUNCTION ARGS...).") (define-button-type 'help-package-def :supertype 'help-xref - 'help-function (lambda (file) (dired file)) + 'help-function #'dired 'help-echo "mouse-2, RET: visit package directory") (define-button-type 'help-theme-def diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 131c7b523af..ff903325d98 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -1883,8 +1883,7 @@ Otherwise buffers whose name matches an element of (defun ibuffer-mark-modified-buffers () "Mark all modified buffers." (interactive "" ibuffer-mode) - (ibuffer-mark-on-buffer - (lambda (buf) (buffer-modified-p buf)))) + (ibuffer-mark-on-buffer #'buffer-modified-p)) ;;;###autoload (defun ibuffer-mark-unsaved-buffers () diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el index 6ec810e710f..d1a23bb957e 100644 --- a/lisp/image/image-dired.el +++ b/lisp/image/image-dired.el @@ -2084,7 +2084,7 @@ when using per-directory thumbnail file storage")) ;; ;; Sort function. Compare time between two files. ;; (lambda (l1 l2) ;; (time-less-p (car l1) (car l2))))) -;; (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) files)))) +;; (dirsize (apply #'+ (mapcar #'cadr files)))) ;; (while (> dirsize image-dired-dir-max-size) ;; (y-or-n-p ;; (format "Size of thumbnail directory: %d, delete old file %s? " diff --git a/lisp/international/quail.el b/lisp/international/quail.el index 94d4a758705..daa55b14b87 100644 --- a/lisp/international/quail.el +++ b/lisp/international/quail.el @@ -772,8 +772,7 @@ you type is correctly handled." (defun quail-keyseq-translate (keyseq) (apply 'string - (mapcar (lambda (x) (quail-keyboard-translate x)) - keyseq))) + (mapcar #'quail-keyboard-translate keyseq))) (defun quail-insert-kbd-layout (kbd-layout) "Insert the visual keyboard layout table according to KBD-LAYOUT. @@ -2144,9 +2143,7 @@ minibuffer and the selected frame has no other windows)." (setq str (format "%s[%s]" str - (concat (sort (mapcar (lambda (x) (car x)) - (cdr map)) - '<))))) + (concat (sort (mapcar #'car (cdr map)) #'<))))) ;; Show list of translations. (if (and quail-current-translations (not (quail-deterministic))) diff --git a/lisp/isearch.el b/lisp/isearch.el index f381223f26d..cb7c107660c 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -3190,7 +3190,7 @@ See more for options in `search-exit-option'." (setq isearch-pre-move-point (point))) ;; Append control characters to the search string ((eq search-exit-option 'append) - (unless (memq nil (mapcar (lambda (k) (characterp k)) key)) + (unless (memq nil (mapcar #'characterp key)) (isearch-process-search-string key key)) (setq this-command 'ignore)) ;; Other characters terminate the search and are then executed normally. @@ -4614,8 +4614,7 @@ defaults to the value of `isearch-search-fun-default' when nil." (match-data))))) (when found (goto-char found)) (when match-data (set-match-data - (mapcar (lambda (m) (copy-marker m)) - match-data)))) + (mapcar #'copy-marker match-data)))) (setq found (funcall (or search-fun (isearch-search-fun-default)) string (if bound (if isearch-forward diff --git a/lisp/mail/supercite.el b/lisp/mail/supercite.el index 66d8d6494eb..3df7c5e5b89 100644 --- a/lisp/mail/supercite.el +++ b/lisp/mail/supercite.el @@ -596,7 +596,7 @@ selected letter is returned, or nil if the question was not answered. Note that WORD is a string and LETTER is a character. All LETTERs in the list should be unique." (let* ((prompt (concat - (mapconcat (lambda (elt) (car elt)) alist ", ") + (mapconcat #'car alist ", ") "? (" (mapconcat (lambda (elt) (char-to-string (cdr elt))) alist "/") diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 3bc4006cfda..a7b7fb25c7f 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -2258,8 +2258,7 @@ PROCESS is the process object for the current connection." "Return list of channels for NICK. PROCESS is the process object for the current connection." (with-rcirc-process-buffer process - (mapcar (lambda (x) (car x)) - (gethash nick rcirc-nick-table)))) + (mapcar #'car (gethash nick rcirc-nick-table)))) (defun rcirc-put-nick-channel (process nick channel &optional line) "Add CHANNEL to list associated with NICK. @@ -2313,7 +2312,7 @@ PROCESS is the process object for the current connection." (if record (setq nicks (cons (cons k (cdr record)) nicks))))) rcirc-nick-table) - (mapcar (lambda (x) (car x)) + (mapcar #'car (sort (nconc pseudo-nicks nicks) (lambda (x y) (let ((lx (or (cdr x) 0)) @@ -2990,8 +2989,8 @@ If ARG is given, opens the URL in a new browser window." (filtered (seq-filter (lambda (x) (>= point (cdr x))) rcirc-urls)) - (completions (mapcar (lambda (x) (car x)) filtered)) - (defaults (mapcar (lambda (x) (car x)) filtered))) + (completions (mapcar #'car filtered)) + (defaults (mapcar #'car filtered))) (browse-url (completing-read "Rcirc browse-url: " completions nil nil (car defaults) nil defaults) arg))) diff --git a/lisp/obsolete/thumbs.el b/lisp/obsolete/thumbs.el index fb24fa26a83..582bb7f0caf 100644 --- a/lisp/obsolete/thumbs.el +++ b/lisp/obsolete/thumbs.el @@ -204,7 +204,7 @@ reached." ,f))) (directory-files (thumbs-thumbsdir) t (image-file-name-regexp))) (lambda (l1 l2) (time-less-p (car l1) (car l2))))) - (dirsize (apply #'+ (mapcar (lambda (x) (cadr x)) files-list)))) + (dirsize (apply #'+ (mapcar #'cadr files-list)))) (while (> dirsize thumbs-thumbsdir-max-size) (progn (message "Deleting file %s" (cadr (cdar files-list)))) diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index a2cf3c77be7..4691dc0bdd3 100644 --- a/lisp/org/org-agenda.el +++ b/lisp/org/org-agenda.el @@ -8188,7 +8188,7 @@ FLAG specifies the type of completion operation to perform. This function is passed as a collection function to `completing-read', which see." (let ((completion-ignore-case t) ;tags are case-sensitive - (confirm (lambda (x) (stringp x))) + (confirm #'stringp) (prefix "") (operator "") table diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el index c1f2da31535..534cf93107b 100644 --- a/lisp/org/org-table.el +++ b/lisp/org/org-table.el @@ -2539,8 +2539,7 @@ location of point." ;; replace fields with duration values if relevant (if duration (setq fields - (mapcar (lambda (x) (org-table-time-string-to-seconds x)) - fields))) + (mapcar #'org-table-time-string-to-seconds fields))) (if (eq numbers t) (setq fields (mapcar (lambda (x) diff --git a/lisp/org/org.el b/lisp/org/org.el index b3899922f2b..ca07b16c707 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -4282,7 +4282,7 @@ related expressions." '("ARCHIVE" "CATEGORY" "COLUMNS" "PRIORITIES")))) ;; Startup options. Get this early since it does change ;; behavior for other options (e.g., tags). - (let ((startup (cl-mapcan (lambda (value) (split-string value)) + (let ((startup (cl-mapcan #'split-string (cdr (assoc "STARTUP" alist))))) (dolist (option startup) (pcase (assoc-string option org-startup-options t) diff --git a/lisp/org/ox.el b/lisp/org/ox.el index a485e9064e2..39ab81b90ed 100644 --- a/lisp/org/ox.el +++ b/lisp/org/ox.el @@ -1552,7 +1552,7 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored." (newline (mapconcat #'identity values "\n")) (split - (cl-mapcan (lambda (v) (split-string v)) values)) + (cl-mapcan #'split-string values)) ((t) (org-last values)) (otherwise diff --git a/lisp/ses.el b/lisp/ses.el index eeef8f040f9..88e83ae160b 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -4011,7 +4011,7 @@ Use `math-format-value' as a printer for Calc objects." (unless reorient-x (setq result (mapcar #'nreverse result))) (when transpose - (let ((ret (mapcar (lambda (x) (list x)) (pop result))) iter) + (let ((ret (mapcar #'list (pop result))) iter) (while result (setq iter ret) (dolist (elt (pop result)) diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el index 4efe4a51612..14413809ac8 100644 --- a/lisp/textmodes/emacs-news-mode.el +++ b/lisp/textmodes/emacs-news-mode.el @@ -249,7 +249,7 @@ untagged NEWS entry." (while (re-search-forward "\"\\(([a-z0-9-]+)[ \n][^\"]\\{1,80\\}\\)\"" nil t) (buttonize-region (match-beginning 1) (match-end 1) - (lambda (node) (info node)) + #'info (match-string 1))))))) (defun emacs-news--sections (regexp) diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index ec975885682..5640aa93efa 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -3191,9 +3191,7 @@ otherwise, the current line is skipped." Generated from `ispell-tex-skip-alists'." (concat ;; raw tex keys - (mapconcat (lambda (lst) (car lst)) - (car ispell-tex-skip-alists) - "\\|") + (mapconcat #'car (car ispell-tex-skip-alists) "\\|") "\\|" ;; keys wrapped in begin{} (mapconcat (lambda (lst) diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index 91db030fa1c..06597ed7853 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -790,7 +790,7 @@ and that it passes `vc-cvs-global-switches' to it before FLAGS." If FILE is a list of files, return non-nil if any of them individually should stay local." (if (listp file) - (delq nil (mapcar (lambda (arg) (vc-cvs-stay-local-p arg)) file)) + (delq nil (mapcar #'vc-cvs-stay-local-p file)) (let ((stay-local vc-cvs-stay-local)) (if (symbolp stay-local) stay-local (let ((dirname (if (file-directory-p file) diff --git a/lisp/window.el b/lisp/window.el index b3081b0aec5..4359c678540 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -6257,8 +6257,7 @@ specific buffers." ,@(when next-buffers `((next-buffers . ,(if writable - (mapcar (lambda (buffer) (buffer-name buffer)) - next-buffers) + (mapcar #'buffer-name next-buffers) next-buffers)))) ,@(when prev-buffers `((prev-buffers diff --git a/test/lisp/emacs-lisp/shortdoc-tests.el b/test/lisp/emacs-lisp/shortdoc-tests.el index 14d757711be..560221f5533 100644 --- a/test/lisp/emacs-lisp/shortdoc-tests.el +++ b/test/lisp/emacs-lisp/shortdoc-tests.el @@ -56,7 +56,7 @@ (ert-deftest shortdoc-all-groups-work () "Test that all defined shortdoc groups display correctly." - (dolist (group (mapcar (lambda (x) (car x)) shortdoc--groups)) + (dolist (group (mapcar #'car shortdoc--groups)) (let ((buf-name (format "*Shortdoc %s*" group)) buf) (unwind-protect (progn