]> git.eshelyaron.com Git - emacs.git/commitdiff
Delete redundant lambdas around unary functions
authorStefan Kangas <stefankangas@gmail.com>
Tue, 11 Feb 2025 18:04:00 +0000 (19:04 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 12 Feb 2025 10:51:50 +0000 (11:51 +0100)
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)

25 files changed:
lisp/calc/calc-nlfit.el
lisp/calendar/cal-tex.el
lisp/calendar/todo-mode.el
lisp/descr-text.el
lisp/eshell/em-pred.el
lisp/gnus/gnus-cache.el
lisp/gnus/gnus-dired.el
lisp/help-mode.el
lisp/ibuf-ext.el
lisp/image/image-dired.el
lisp/international/quail.el
lisp/isearch.el
lisp/mail/supercite.el
lisp/net/rcirc.el
lisp/obsolete/thumbs.el
lisp/org/org-agenda.el
lisp/org/org-table.el
lisp/org/org.el
lisp/org/ox.el
lisp/ses.el
lisp/textmodes/emacs-news-mode.el
lisp/textmodes/ispell.el
lisp/vc/vc-cvs.el
lisp/window.el
test/lisp/emacs-lisp/shortdoc-tests.el

index 2761f35061e5f24d4070b6dd8e09768e9774af94..82874284b657353634b72ca2c341e0b0a047a5fe 100644 (file)
           (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)
           (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)
index 30ba7cf2785e5016ad0f5d935f55e55b32caf3bc..688e842604d18af9d849d8fbfd28df00c68e98e1 100644 (file)
@@ -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))
index 194c08bf0af1dd0768c42b319cc9fb563fcb1d6f..58920eee7f55a1a54db0af82d6d2da3468fc25fa 100644 (file)
@@ -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.
index a048822575c013529bff6798f7b9f224eb2c26f6..ad55feb4ea86e109eed87f097ad0db0bd03a5370 100644 (file)
@@ -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)
index e496d9a36601a6ded9092b67e1a30f38fa704ff0..8d83b7717b55a1851603fd94e591c40af1586563 100644 (file)
@@ -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))
index b9af1ec93bbc996a80f14058ece48431542cd50d..59c5d7bb89116ed8d055cf6e5a011f776f7a31a3 100644 (file)
@@ -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.
index 048dd02744da43e9cbe81a6faf511b061b36ca50..06fb9573c375a1a4261a6e44e47f93a02b8e8794 100644 (file)
@@ -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
index 7350ac503cdeef6c55f51eaee9e249bd03ff7741..dc4001e1b122dcd68893990c93a9e57fdbad8358 100644 (file)
@@ -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
index 131c7b523afc56d228a1fdf337c941fc4a956d0e..ff903325d9840aeaa2ffca3675541c4c8a9b6f60 100644 (file)
@@ -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 ()
index 6ec810e710f25670d4d1ca3e9e1f5eb2adc05057..d1a23bb957e4626705291e14e4f7b4b0040fafa6 100644 (file)
@@ -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? "
index 94d4a7587050d6a1393f3de04b926aa610c17783..daa55b14b87ae92ae9c1bca570ab2271e511782a 100644 (file)
@@ -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)))
index f381223f26d8852f6885f77126e78e0aff65c141..cb7c107660c064ffb40e07202c1845584012aa0b 100644 (file)
@@ -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
index 66d8d6494eb225982ce347691b3be313ca5fb56c..3df7c5e5b8955bfc03745e86c36f496ddee5cc63 100644 (file)
@@ -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 "/")
index 3bc4006cfda3aad5a753f4a298e834202e969266..a7b7fb25c7f2c51df72ab8023854f6b5d7e32f2a 100644 (file)
@@ -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)))
index fb24fa26a838fa7b90f1566c2e63182876328cd7..582bb7f0cafa25ea0c5c62635af7565605d6c1d9 100644 (file)
@@ -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))))
index a2cf3c77be7701fb42d1d25d39ba5f2dd47392a2..4691dc0bdd38797dcdcd7b245e5373aa80d5d8d7 100644 (file)
@@ -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
index c1f2da31535d2c48d058927cc481a0139d78b336..534cf93107b8d0b13dfff3133713a5b88cb86b71 100644 (file)
@@ -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)
index b3899922f2b5006d51ae983bb43e6577326b134f..ca07b16c707eed2d0ae8779ba065bd7da01c9c24 100644 (file)
@@ -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)
index a485e9064e235d42ecc9c84af48dd1490f7dc93f..39ab81b90edd20fb5393c5541f88fe25f9cb5ce6 100644 (file)
@@ -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
index eeef8f040f9206793621ffdf26d64855806208ec..88e83ae160b1081b44987217710c30b6c9a32639 100644 (file)
@@ -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))
index 4efe4a51612e2f2a50e20e4165d06135a28b46cd..14413809ac8cf3381992b1d9dc850081a30418e5 100644 (file)
@@ -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)
index ec975885682b5e14611a68a887b7fd12d2b50bea..5640aa93efa1614675a7e50f0c6e7c3faf43b91f 100644 (file)
@@ -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)
index 91db030fa1ca6f7ca20431a309cb2ec5dab07c83..06597ed7853b6f691cd17e876f8af93750c1d2fb 100644 (file)
@@ -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)
index b3081b0aec5ba64420deda930c18cad1b588f84f..4359c678540e732412973a8e31db68215307f420 100644 (file)
@@ -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
index 14d757711be6f5db133ca74af64db2906219786a..560221f5533be5cb29d2cca0062d8f0e27219c07 100644 (file)
@@ -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