* [PATCH] Remove redundant 'function's around lambda
@ 2020-11-17 16:55 Stefan Kangas
2020-11-19 3:07 ` Kyle Meyer
2020-11-19 10:44 ` Neil Jerram
0 siblings, 2 replies; 8+ messages in thread
From: Stefan Kangas @ 2020-11-17 16:55 UTC (permalink / raw)
To: Org-mode
[-- Attachment #1: Type: text/plain, Size: 546 bytes --]
I've been working on removing redundant `function' around `lambda' in
Emacs core, so here is a patch which does the same for Org-mode. Note
that Info node `(elisp) Anonymous Functions' says that:
The read syntax ‘#'’ is a short-hand for using ‘function’. The
following forms are all equivalent:
(lambda (x) (* x x))
(function (lambda (x) (* x x)))
#'(lambda (x) (* x x))
IOW, we can safely remove the wrapped `function' form.
Please see the attached. (My copyright assignment is on file.)
[-- Attachment #2: 0001-Remove-redundant-function-s-around-lambda.patch --]
[-- Type: text/x-diff, Size: 26882 bytes --]
From 7604ccc02a60334ef5c2135c5fb3abae4bed2468 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Tue, 17 Nov 2020 17:35:49 +0100
Subject: [PATCH] Remove redundant 'function's around lambda
* contrib/lisp/org-secretary.el (join):
* contrib/lisp/ox-taskjuggler.el (org-taskjuggler-project-plan):
* lisp/org-clock.el (org-resolve-clocks):
* lisp/org-element.el (org-element--interpret-affiliated-keywords):
* lisp/org-list.el (org-list-struct, org-list-get-item-number)
(org-list-separating-blank-lines-number)
(org-list-struct-fix-bul, org-list-struct-apply-struct):
* lisp/org.el (org-agenda-files, org-toggle-heading):
* lisp/ox-ascii.el (org-ascii-table-row):
* lisp/ox-beamer.el (org-beamer--format-section)
(org-beamer-template):
* lisp/ox-odt.el (org-odt--image-size)
(org-odt--render-image/formula):
* testing/org-batch-test-init.el (load-path): Remove redundant
'function's around lambda.
---
contrib/lisp/org-secretary.el | 2 +-
contrib/lisp/ox-taskjuggler.el | 5 +-
lisp/org-clock.el | 13 +-
lisp/org-element.el | 25 ++-
lisp/org-list.el | 326 ++++++++++++++++-----------------
lisp/org.el | 22 +--
lisp/ox-ascii.el | 53 +++---
lisp/ox-beamer.el | 32 ++--
lisp/ox-odt.el | 25 ++-
testing/org-batch-test-init.el | 6 +-
10 files changed, 246 insertions(+), 263 deletions(-)
diff --git a/contrib/lisp/org-secretary.el b/contrib/lisp/org-secretary.el
index babfb7539..654fcc1a0 100644
--- a/contrib/lisp/org-secretary.el
+++ b/contrib/lisp/org-secretary.el
@@ -177,7 +177,7 @@
(global-set-key "\C-cj" 'org-sec-tag-entry)
(defun join (lst sep &optional pre post)
- (mapconcat (function (lambda (x) (concat pre x post))) lst sep))
+ (mapconcat (lambda (x) (concat pre x post)) lst sep))
(defun org-sec-get-with ()
(if org-sec-with
diff --git a/contrib/lisp/ox-taskjuggler.el b/contrib/lisp/ox-taskjuggler.el
index 8c43b0629..93088144c 100644
--- a/contrib/lisp/ox-taskjuggler.el
+++ b/contrib/lisp/ox-taskjuggler.el
@@ -720,9 +720,8 @@ Return complete project plan as a string in TaskJuggler syntax."
(mapconcat
'org-element-normalize-string
(mapcar
- (function
- (lambda (report)
- (replace-regexp-in-string "%title" report-title report t t)))
+ (lambda (report)
+ (replace-regexp-in-string "%title" report-title report t t))
org-taskjuggler-default-reports) "")))))))))
(defun org-taskjuggler--build-project (project info)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9efd99be8..6c7a797ff 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1164,13 +1164,12 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
(org-clock-resolve
clock
(or prompt-fn
- (function
- (lambda (clock)
- (format
- "Dangling clock started %d mins ago"
- (floor (org-time-convert-to-integer
- (org-time-since (cdr clock)))
- 60)))))
+ (lambda (clock)
+ (format
+ "Dangling clock started %d mins ago"
+ (floor (org-time-convert-to-integer
+ (org-time-since (cdr clock)))
+ 60))))
(or last-valid
(cdr clock)))))))))))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 2ad557d21..a2582b822 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4655,19 +4655,18 @@ to interpret. Return Org syntax as a string."
"Return ELEMENT's affiliated keywords as Org syntax.
If there is no affiliated keyword, return the empty string."
(let ((keyword-to-org
- (function
- (lambda (key value)
- (let (dual)
- (when (member key org-element-dual-keywords)
- (setq dual (cdr value) value (car value)))
- (concat "#+" (downcase key)
- (and dual
- (format "[%s]" (org-element-interpret-data dual)))
- ": "
- (if (member key org-element-parsed-keywords)
- (org-element-interpret-data value)
- value)
- "\n"))))))
+ (lambda (key value)
+ (let (dual)
+ (when (member key org-element-dual-keywords)
+ (setq dual (cdr value) value (car value)))
+ (concat "#+" (downcase key)
+ (and dual
+ (format "[%s]" (org-element-interpret-data dual)))
+ ": "
+ (if (member key org-element-parsed-keywords)
+ (org-element-interpret-data value)
+ value)
+ "\n")))))
(mapconcat
(lambda (prop)
(let ((value (org-element-property prop element))
diff --git a/lisp/org-list.el b/lisp/org-list.el
index b8383283b..312f08a33 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -600,25 +600,23 @@ Assume point is at an item."
(beg-cell (cons (point) (current-indentation)))
itm-lst itm-lst-2 end-lst end-lst-2 struct
(assoc-at-point
- (function
- ;; Return association at point.
- (lambda (ind)
- (looking-at org-list-full-item-re)
- (let ((bullet (match-string-no-properties 1)))
- (list (point)
- ind
- bullet
- (match-string-no-properties 2) ; counter
- (match-string-no-properties 3) ; checkbox
- ;; Description tag.
- (and (string-match-p "[-+*]" bullet)
- (match-string-no-properties 4)))))))
+ ;; Return association at point.
+ (lambda (ind)
+ (looking-at org-list-full-item-re)
+ (let ((bullet (match-string-no-properties 1)))
+ (list (point)
+ ind
+ bullet
+ (match-string-no-properties 2) ; counter
+ (match-string-no-properties 3) ; checkbox
+ ;; Description tag.
+ (and (string-match-p "[-+*]" bullet)
+ (match-string-no-properties 4))))))
(end-before-blank
- (function
- ;; Ensure list ends at the first blank line.
- (lambda ()
- (skip-chars-backward " \r\t\n")
- (min (1+ (point-at-eol)) lim-down)))))
+ ;; Ensure list ends at the first blank line.
+ (lambda ()
+ (skip-chars-backward " \r\t\n")
+ (min (1+ (point-at-eol)) lim-down))))
;; 1. Read list from starting item to its beginning, and save
;; top item position and indentation in BEG-CELL. Also store
;; ending position of items in END-LST.
@@ -1003,23 +1001,22 @@ alist of ancestors, as returned by `org-list-parents-alist'.
Return value is a list of integers. Counters have an impact on
that value."
(let ((get-relative-number
- (function
- (lambda (item struct prevs)
- ;; Return relative sequence number of ITEM in the sub-list
- ;; it belongs. STRUCT is the list structure. PREVS is
- ;; the alist of previous items.
- (let ((seq 0) (pos item) counter)
- (while (and (not (setq counter (org-list-get-counter pos struct)))
- (setq pos (org-list-get-prev-item pos struct prevs)))
- (cl-incf seq))
- (if (not counter) (1+ seq)
- (cond
- ((string-match "[A-Za-z]" counter)
- (+ (- (string-to-char (upcase (match-string 0 counter))) 64)
- seq))
- ((string-match "[0-9]+" counter)
- (+ (string-to-number (match-string 0 counter)) seq))
- (t (1+ seq)))))))))
+ (lambda (item struct prevs)
+ ;; Return relative sequence number of ITEM in the sub-list
+ ;; it belongs. STRUCT is the list structure. PREVS is
+ ;; the alist of previous items.
+ (let ((seq 0) (pos item) counter)
+ (while (and (not (setq counter (org-list-get-counter pos struct)))
+ (setq pos (org-list-get-prev-item pos struct prevs)))
+ (cl-incf seq))
+ (if (not counter) (1+ seq)
+ (cond
+ ((string-match "[A-Za-z]" counter)
+ (+ (- (string-to-char (upcase (match-string 0 counter))) 64)
+ seq))
+ ((string-match "[0-9]+" counter)
+ (+ (string-to-number (match-string 0 counter)) seq))
+ (t (1+ seq))))))))
;; Cons each parent relative number into return value (OUT).
(let ((out (list (funcall get-relative-number item struct prevs)))
(parent item))
@@ -1181,14 +1178,13 @@ some heuristics to guess the result."
(cdr (assq 'plain-list-item org-blank-before-new-entry)))
usr-blank
(count-blanks
- (function
- (lambda ()
- ;; Count blank lines above beginning of line.
- (save-excursion
- (count-lines (goto-char (point-at-bol))
- (progn (skip-chars-backward " \r\t\n")
- (forward-line)
- (point))))))))
+ (lambda ()
+ ;; Count blank lines above beginning of line.
+ (save-excursion
+ (count-lines (goto-char (point-at-bol))
+ (progn (skip-chars-backward " \r\t\n")
+ (forward-line)
+ (point)))))))
(cond
;; Trivial cases where there should be none.
((not insert-blank-p) 0)
@@ -1651,65 +1647,64 @@ PREVS is the alist of previous items, as returned by
This function modifies STRUCT."
(let ((case-fold-search nil)
(fix-bul
- (function
- ;; Set bullet of ITEM in STRUCT, depending on the type of
- ;; first item of the list, the previous bullet and counter
- ;; if any.
- (lambda (item)
- (let* ((prev (org-list-get-prev-item item struct prevs))
- (prev-bul (and prev (org-list-get-bullet prev struct)))
- (counter (org-list-get-counter item struct))
- (bullet (org-list-get-bullet item struct))
- (alphap (and (not prev)
- (org-list-use-alpha-bul-p item struct prevs))))
- (org-list-set-bullet
- item struct
- (org-list-bullet-string
- (cond
- ;; Alpha counter in alpha list: use counter.
- ((and prev counter
- (string-match "[a-zA-Z]" counter)
- (string-match "[a-zA-Z]" prev-bul))
- ;; Use cond to be sure `string-match' is used in
- ;; both cases.
- (let ((real-count
- (cond
- ((string-match "[a-z]" prev-bul) (downcase counter))
- ((string-match "[A-Z]" prev-bul) (upcase counter)))))
- (replace-match real-count nil nil prev-bul)))
- ;; Num counter in a num list: use counter.
- ((and prev counter
- (string-match "[0-9]+" counter)
- (string-match "[0-9]+" prev-bul))
- (replace-match counter nil nil prev-bul))
- ;; No counter: increase, if needed, previous bullet.
- (prev
- (org-list-inc-bullet-maybe (org-list-get-bullet prev struct)))
- ;; Alpha counter at first item: use counter.
- ((and counter (org-list-use-alpha-bul-p item struct prevs)
- (string-match "[A-Za-z]" counter)
- (string-match "[A-Za-z]" bullet))
- (let ((real-count
- (cond
- ((string-match "[a-z]" bullet) (downcase counter))
- ((string-match "[A-Z]" bullet) (upcase counter)))))
- (replace-match real-count nil nil bullet)))
- ;; Num counter at first item: use counter.
- ((and counter
- (string-match "[0-9]+" counter)
- (string-match "[0-9]+" bullet))
- (replace-match counter nil nil bullet))
- ;; First bullet is alpha uppercase: use "A".
- ((and alphap (string-match "[A-Z]" bullet))
- (replace-match "A" nil nil bullet))
- ;; First bullet is alpha lowercase: use "a".
- ((and alphap (string-match "[a-z]" bullet))
- (replace-match "a" nil nil bullet))
- ;; First bullet is num: use "1".
- ((string-match "\\([0-9]+\\|[A-Za-z]\\)" bullet)
- (replace-match "1" nil nil bullet))
- ;; Not an ordered list: keep bullet.
- (t bullet)))))))))
+ ;; Set bullet of ITEM in STRUCT, depending on the type of
+ ;; first item of the list, the previous bullet and counter
+ ;; if any.
+ (lambda (item)
+ (let* ((prev (org-list-get-prev-item item struct prevs))
+ (prev-bul (and prev (org-list-get-bullet prev struct)))
+ (counter (org-list-get-counter item struct))
+ (bullet (org-list-get-bullet item struct))
+ (alphap (and (not prev)
+ (org-list-use-alpha-bul-p item struct prevs))))
+ (org-list-set-bullet
+ item struct
+ (org-list-bullet-string
+ (cond
+ ;; Alpha counter in alpha list: use counter.
+ ((and prev counter
+ (string-match "[a-zA-Z]" counter)
+ (string-match "[a-zA-Z]" prev-bul))
+ ;; Use cond to be sure `string-match' is used in
+ ;; both cases.
+ (let ((real-count
+ (cond
+ ((string-match "[a-z]" prev-bul) (downcase counter))
+ ((string-match "[A-Z]" prev-bul) (upcase counter)))))
+ (replace-match real-count nil nil prev-bul)))
+ ;; Num counter in a num list: use counter.
+ ((and prev counter
+ (string-match "[0-9]+" counter)
+ (string-match "[0-9]+" prev-bul))
+ (replace-match counter nil nil prev-bul))
+ ;; No counter: increase, if needed, previous bullet.
+ (prev
+ (org-list-inc-bullet-maybe (org-list-get-bullet prev struct)))
+ ;; Alpha counter at first item: use counter.
+ ((and counter (org-list-use-alpha-bul-p item struct prevs)
+ (string-match "[A-Za-z]" counter)
+ (string-match "[A-Za-z]" bullet))
+ (let ((real-count
+ (cond
+ ((string-match "[a-z]" bullet) (downcase counter))
+ ((string-match "[A-Z]" bullet) (upcase counter)))))
+ (replace-match real-count nil nil bullet)))
+ ;; Num counter at first item: use counter.
+ ((and counter
+ (string-match "[0-9]+" counter)
+ (string-match "[0-9]+" bullet))
+ (replace-match counter nil nil bullet))
+ ;; First bullet is alpha uppercase: use "A".
+ ((and alphap (string-match "[A-Z]" bullet))
+ (replace-match "A" nil nil bullet))
+ ;; First bullet is alpha lowercase: use "a".
+ ((and alphap (string-match "[a-z]" bullet))
+ (replace-match "a" nil nil bullet))
+ ;; First bullet is num: use "1".
+ ((string-match "\\([0-9]+\\|[A-Za-z]\\)" bullet)
+ (replace-match "1" nil nil bullet))
+ ;; Not an ordered list: keep bullet.
+ (t bullet))))))))
(mapc fix-bul (mapcar #'car struct))))
(defun org-list-struct-fix-ind (struct parents &optional bullet-size)
@@ -1755,21 +1750,20 @@ all others cases, the return value will be nil.
This function modifies STRUCT."
(let ((all-items (mapcar #'car struct))
(set-parent-box
- (function
- (lambda (item)
- (let* ((box-list
- (mapcar (lambda (child)
- (org-list-get-checkbox child struct))
- (org-list-get-children item struct parents))))
- (org-list-set-checkbox
- item struct
- (cond
- ((and (member "[ ]" box-list) (member "[X]" box-list)) "[-]")
- ((member "[-]" box-list) "[-]")
- ((member "[X]" box-list) "[X]")
- ((member "[ ]" box-list) "[ ]")
- ;; Parent has no boxed child: leave box as-is.
- (t (org-list-get-checkbox item struct))))))))
+ (lambda (item)
+ (let* ((box-list
+ (mapcar (lambda (child)
+ (org-list-get-checkbox child struct))
+ (org-list-get-children item struct parents))))
+ (org-list-set-checkbox
+ item struct
+ (cond
+ ((and (member "[ ]" box-list) (member "[X]" box-list)) "[-]")
+ ((member "[-]" box-list) "[-]")
+ ((member "[X]" box-list) "[X]")
+ ((member "[ ]" box-list) "[ ]")
+ ;; Parent has no boxed child: leave box as-is.
+ (t (org-list-get-checkbox item struct)))))))
parent-list)
;; 1. List all parents with a checkbox.
(mapc
@@ -1840,56 +1834,54 @@ Initial position of cursor is restored after the changes."
(org-inlinetask-outline-regexp)))
(item-re (org-item-re))
(shift-body-ind
- (function
- ;; Shift the indentation between END and BEG by DELTA.
- ;; Start from the line before END.
- (lambda (end beg delta)
- (goto-char end)
- (skip-chars-backward " \r\t\n")
- (beginning-of-line)
- (while (or (> (point) beg)
- (and (= (point) beg)
- (not (looking-at item-re))))
- (cond
- ;; Skip inline tasks.
- ((and inlinetask-re (looking-at inlinetask-re))
- (org-inlinetask-goto-beginning))
- ;; Shift only non-empty lines.
- ((looking-at-p "^[ \t]*\\S-")
- (indent-line-to (+ (current-indentation) delta))))
- (forward-line -1)))))
- (modify-item
- (function
- ;; Replace ITEM first line elements with new elements from
- ;; STRUCT, if appropriate.
- (lambda (item)
- (goto-char item)
- (let* ((new-ind (org-list-get-ind item struct))
- (old-ind (current-indentation))
- (new-bul (org-list-bullet-string
- (org-list-get-bullet item struct)))
- (old-bul (org-list-get-bullet item old-struct))
- (new-box (org-list-get-checkbox item struct)))
- (looking-at org-list-full-item-re)
- ;; a. Replace bullet
- (unless (equal old-bul new-bul)
- (replace-match new-bul nil nil nil 1))
- ;; b. Replace checkbox.
- (cond
- ((equal (match-string 3) new-box))
- ((and (match-string 3) new-box)
- (replace-match new-box nil nil nil 3))
- ((match-string 3)
- (looking-at ".*?\\([ \t]*\\[[ X-]\\]\\)")
- (replace-match "" nil nil nil 1))
- (t (let ((counterp (match-end 2)))
- (goto-char (if counterp (1+ counterp) (match-end 1)))
- (insert (concat new-box (unless counterp " "))))))
- ;; c. Indent item to appropriate column.
- (unless (= new-ind old-ind)
- (delete-region (goto-char (point-at-bol))
- (progn (skip-chars-forward " \t") (point)))
- (indent-to new-ind)))))))
+ ;; Shift the indentation between END and BEG by DELTA.
+ ;; Start from the line before END.
+ (lambda (end beg delta)
+ (goto-char end)
+ (skip-chars-backward " \r\t\n")
+ (beginning-of-line)
+ (while (or (> (point) beg)
+ (and (= (point) beg)
+ (not (looking-at item-re))))
+ (cond
+ ;; Skip inline tasks.
+ ((and inlinetask-re (looking-at inlinetask-re))
+ (org-inlinetask-goto-beginning))
+ ;; Shift only non-empty lines.
+ ((looking-at-p "^[ \t]*\\S-")
+ (indent-line-to (+ (current-indentation) delta))))
+ (forward-line -1))))
+ (modify-item
+ ;; Replace ITEM first line elements with new elements from
+ ;; STRUCT, if appropriate.
+ (lambda (item)
+ (goto-char item)
+ (let* ((new-ind (org-list-get-ind item struct))
+ (old-ind (current-indentation))
+ (new-bul (org-list-bullet-string
+ (org-list-get-bullet item struct)))
+ (old-bul (org-list-get-bullet item old-struct))
+ (new-box (org-list-get-checkbox item struct)))
+ (looking-at org-list-full-item-re)
+ ;; a. Replace bullet
+ (unless (equal old-bul new-bul)
+ (replace-match new-bul nil nil nil 1))
+ ;; b. Replace checkbox.
+ (cond
+ ((equal (match-string 3) new-box))
+ ((and (match-string 3) new-box)
+ (replace-match new-box nil nil nil 3))
+ ((match-string 3)
+ (looking-at ".*?\\([ \t]*\\[[ X-]\\]\\)")
+ (replace-match "" nil nil nil 1))
+ (t (let ((counterp (match-end 2)))
+ (goto-char (if counterp (1+ counterp) (match-end 1)))
+ (insert (concat new-box (unless counterp " "))))))
+ ;; c. Indent item to appropriate column.
+ (unless (= new-ind old-ind)
+ (delete-region (goto-char (point-at-bol))
+ (progn (skip-chars-forward " \t") (point)))
+ (indent-to new-ind))))))
;; 1. First get list of items and position endings. We maintain
;; two alists: ITM-SHIFT, determining indentation shift needed
;; at item, and END-LIST, a pseudo-alist where key is ending
diff --git a/lisp/org.el b/lisp/org.el
index 2b50f94ee..54064ec8a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15322,9 +15322,8 @@ used by the agenda files. If ARCHIVE is `ifmode', do this only if
files)))
(when org-agenda-skip-unavailable-files
(setq files (delq nil
- (mapcar (function
- (lambda (file)
- (and (file-readable-p file) file)))
+ (mapcar (lambda (file)
+ (and (file-readable-p file) file))
files))))
(when (or (eq archives t)
(and (eq archives 'ifmode) (eq org-agenda-archives-mode t)))
@@ -17942,15 +17941,14 @@ when a numeric prefix argument is given, its value determines the
number of stars to add."
(interactive "P")
(let ((skip-blanks
- (function
- ;; Return beginning of first non-blank line, starting from
- ;; line at POS.
- (lambda (pos)
- (save-excursion
- (goto-char pos)
- (while (org-at-comment-p) (forward-line))
- (skip-chars-forward " \r\t\n")
- (point-at-bol)))))
+ ;; Return beginning of first non-blank line, starting from
+ ;; line at POS.
+ (lambda (pos)
+ (save-excursion
+ (goto-char pos)
+ (while (org-at-comment-p) (forward-line))
+ (skip-chars-forward " \r\t\n")
+ (point-at-bol))))
beg end toggled)
;; Determine boundaries of changes. If a universal prefix has
;; been given, put the list in a region. If region ends at a bol,
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index e5240f5c8..a2a9a9c06 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -1940,33 +1940,32 @@ CONTENTS is the row contents. INFO is a plist used as
a communication channel."
(when (eq (org-element-property :type table-row) 'standard)
(let ((build-hline
- (function
- (lambda (lcorner horiz vert rcorner)
- (concat
- (apply
- 'concat
- (org-element-map table-row 'table-cell
- (lambda (cell)
- (let ((width (org-ascii--table-cell-width cell info))
- (borders (org-export-table-cell-borders cell info)))
- (concat
- ;; In order to know if CELL starts the row, do
- ;; not compare it with the first cell in the
- ;; row as there might be a special column.
- ;; Instead, compare it with first exportable
- ;; cell, obtained with `org-element-map'.
- (when (and (memq 'left borders)
- (eq (org-element-map table-row 'table-cell
- 'identity info t)
- cell))
- lcorner)
- (make-string (+ 2 width) (string-to-char horiz))
- (cond
- ((not (memq 'right borders)) nil)
- ((eq (car (last (org-element-contents table-row))) cell)
- rcorner)
- (t vert)))))
- info)) "\n"))))
+ (lambda (lcorner horiz vert rcorner)
+ (concat
+ (apply
+ 'concat
+ (org-element-map table-row 'table-cell
+ (lambda (cell)
+ (let ((width (org-ascii--table-cell-width cell info))
+ (borders (org-export-table-cell-borders cell info)))
+ (concat
+ ;; In order to know if CELL starts the row, do
+ ;; not compare it with the first cell in the
+ ;; row as there might be a special column.
+ ;; Instead, compare it with first exportable
+ ;; cell, obtained with `org-element-map'.
+ (when (and (memq 'left borders)
+ (eq (org-element-map table-row 'table-cell
+ 'identity info t)
+ cell))
+ lcorner)
+ (make-string (+ 2 width) (string-to-char horiz))
+ (cond
+ ((not (memq 'right borders)) nil)
+ ((eq (car (last (org-element-contents table-row))) cell)
+ rcorner)
+ (t vert)))))
+ info)) "\n")))
(utf8p (eq (plist-get info :ascii-charset) 'utf-8))
(borders (org-export-table-cell-borders
(org-element-map table-row 'table-cell 'identity info t)
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 66589fac5..ebc13259a 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -379,12 +379,11 @@ used as a communication channel."
:parent 'latex
:transcoders
(let ((protected-output
- (function
- (lambda (object contents info)
- (let ((code (org-export-with-backend
- 'beamer object contents info)))
- (if (org-string-nw-p code) (concat "\\protect" code)
- code))))))
+ (lambda (object contents info)
+ (let ((code (org-export-with-backend
+ 'beamer object contents info)))
+ (if (org-string-nw-p code) (concat "\\protect" code)
+ code)))))
(mapcar #'(lambda (type) (cons type protected-output))
'(bold footnote-reference italic strike-through timestamp
underline))))
@@ -812,17 +811,16 @@ holding export options."
(org-latex-make-preamble info)
;; Insert themes.
(let ((format-theme
- (function
- (lambda (prop command)
- (let ((theme (plist-get info prop)))
- (when theme
- (concat command
- (if (not (string-match "\\[.*\\]" theme))
- (format "{%s}\n" theme)
- (format "%s{%s}\n"
- (match-string 0 theme)
- (org-trim
- (replace-match "" nil nil theme)))))))))))
+ (lambda (prop command)
+ (let ((theme (plist-get info prop)))
+ (when theme
+ (concat command
+ (if (not (string-match "\\[.*\\]" theme))
+ (format "{%s}\n" theme)
+ (format "%s{%s}\n"
+ (match-string 0 theme)
+ (org-trim
+ (replace-match "" nil nil theme))))))))))
(mapconcat (lambda (args) (apply format-theme args))
'((:beamer-theme "\\usetheme")
(:beamer-color-theme "\\usecolortheme")
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 4a0cca612..da351ef82 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2200,10 +2200,10 @@ SHORT-CAPTION are strings."
(defun org-odt--image-size
(file info &optional user-width user-height scale dpi embed-as)
(let* ((--pixels-to-cms
- (lambda (pixels dpi)
- (let ((cms-per-inch 2.54)
- (inches (/ pixels dpi)))
- (* cms-per-inch inches))))
+ (lambda (pixels dpi)
+ (let ((cms-per-inch 2.54)
+ (inches (/ pixels dpi)))
+ (* cms-per-inch inches))))
(--size-in-cms
(lambda (size-in-pixels dpi)
(and size-in-pixels
@@ -2467,15 +2467,14 @@ used as a communication channel."
(outer (nth 2 frame-cfg))
;; User-specified frame params (from #+ATTR_ODT spec)
(user user-frame-params)
- (--merge-frame-params (function
- (lambda (default user)
- "Merge default and user frame params."
- (if (not user) default
- (cl-assert (= (length default) 3))
- (cl-assert (= (length user) 3))
- (cl-loop for u in user
- for d in default
- collect (or u d)))))))
+ (--merge-frame-params (lambda (default user)
+ "Merge default and user frame params."
+ (if (not user) default
+ (cl-assert (= (length default) 3))
+ (cl-assert (= (length user) 3))
+ (cl-loop for u in user
+ for d in default
+ collect (or u d))))))
(cond
;; Case 1: Image/Formula has no caption.
;; There is only one frame, one that surrounds the image
diff --git a/testing/org-batch-test-init.el b/testing/org-batch-test-init.el
index 863875617..87216cffd 100644
--- a/testing/org-batch-test-init.el
+++ b/testing/org-batch-test-init.el
@@ -5,9 +5,9 @@
;; clean load-path
(setq load-path
(delq nil (mapcar
- (function (lambda (p)
- (unless (string-match "lisp\\(/packages\\)?/org$" p)
- p)))
+ (lambda (p)
+ (unless (string-match "lisp\\(/packages\\)?/org$" p)
+ p))
load-path)))
;; remove property list to defeat cus-load and remove autoloads
(mapatoms (function (lambda (s)
--
2.29.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove redundant 'function's around lambda
2020-11-17 16:55 [PATCH] Remove redundant 'function's around lambda Stefan Kangas
@ 2020-11-19 3:07 ` Kyle Meyer
2020-11-19 3:44 ` Stefan Kangas
2020-12-14 6:49 ` Bastien
2020-11-19 10:44 ` Neil Jerram
1 sibling, 2 replies; 8+ messages in thread
From: Kyle Meyer @ 2020-11-19 3:07 UTC (permalink / raw)
To: Stefan Kangas; +Cc: Org-mode
Stefan Kangas writes:
> I've been working on removing redundant `function' around `lambda' in
> Emacs core, so here is a patch which does the same for Org-mode.
Thanks.
> Subject: [PATCH] Remove redundant 'function's around lambda
[...]
> diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
> index 4a0cca612..da351ef82 100644
> --- a/lisp/ox-odt.el
> +++ b/lisp/ox-odt.el
> @@ -2200,10 +2200,10 @@ SHORT-CAPTION are strings."
> (defun org-odt--image-size
> (file info &optional user-width user-height scale dpi embed-as)
> (let* ((--pixels-to-cms
> - (lambda (pixels dpi)
> - (let ((cms-per-inch 2.54)
> - (inches (/ pixels dpi)))
> - (* cms-per-inch inches))))
> + (lambda (pixels dpi)
> + (let ((cms-per-inch 2.54)
> + (inches (/ pixels dpi)))
> + (* cms-per-inch inches))))
All these look good to me except this unrelated whitespace change, which
actually touches the change ported from your 61dca6e92a (Don't quote
lambdas in several places, 2020-11-14) in the Emacs repo.
Org files don't use a consistent style, despite Org's .dir-locals.el
setting indent-tabs-mode to t, which should probably be changed to match
Emacs's nil value. At any rate, I've dropped this hunk since it's not
actually making the advertised change, and pushed the rest with
1a480e01a.
Thanks again.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove redundant 'function's around lambda
2020-11-19 3:07 ` Kyle Meyer
@ 2020-11-19 3:44 ` Stefan Kangas
2020-12-14 6:49 ` Bastien
1 sibling, 0 replies; 8+ messages in thread
From: Stefan Kangas @ 2020-11-19 3:44 UTC (permalink / raw)
To: Kyle Meyer; +Cc: Org-mode
Kyle Meyer <kyle@kyleam.com> writes:
> All these look good to me except this unrelated whitespace change, which
> actually touches the change ported from your 61dca6e92a (Don't quote
> lambdas in several places, 2020-11-14) in the Emacs repo.
I must have included that part by mistake, sorry about that.
> Org files don't use a consistent style, despite Org's .dir-locals.el
> setting indent-tabs-mode to t, which should probably be changed to match
> Emacs's nil value. At any rate, I've dropped this hunk since it's not
> actually making the advertised change, and pushed the rest with
> 1a480e01a.
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove redundant 'function's around lambda
2020-11-17 16:55 [PATCH] Remove redundant 'function's around lambda Stefan Kangas
2020-11-19 3:07 ` Kyle Meyer
@ 2020-11-19 10:44 ` Neil Jerram
2020-11-19 14:51 ` Stefan Kangas
1 sibling, 1 reply; 8+ messages in thread
From: Neil Jerram @ 2020-11-19 10:44 UTC (permalink / raw)
To: Stefan Kangas; +Cc: Org-mode
[-- Attachment #1: Type: text/plain, Size: 620 bytes --]
On Tue, 17 Nov 2020 at 17:08, Stefan Kangas <stefan@marxist.se> wrote:
> I've been working on removing redundant `function' around `lambda' in
> Emacs core,
I'm slightly curious about the history and reasoning around this. If I
understand correctly, (lambda ...) on its own has always worked, and it's
never been strictly necessary to add (quote ...) or (function ...) around
it. Then sometime (Emacs 19 or later, I think) it started being
recommended to use (function ...).
Do you know why that recommendation started, and should I understand that
the reasoning for it has now evaporated?
Best wishes,
Neil
[-- Attachment #2: Type: text/html, Size: 998 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove redundant 'function's around lambda
2020-11-19 10:44 ` Neil Jerram
@ 2020-11-19 14:51 ` Stefan Kangas
2020-11-19 15:16 ` Neil Jerram
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2020-11-19 14:51 UTC (permalink / raw)
To: Neil Jerram; +Cc: Org-mode
Neil Jerram <neiljerram@gmail.com> writes:
>> I've been working on removing redundant `function' around `lambda' in
>> Emacs core,
>
> I'm slightly curious about the history and reasoning around this. If I
> understand correctly, (lambda ...) on its own has always worked, and it's
> never been strictly necessary to add (quote ...) or (function ...) around
> it. Then sometime (Emacs 19 or later, I think) it started being
> recommended to use (function ...).
>
> Do you know why that recommendation started, and should I understand that
> the reasoning for it has now evaporated?
Correct, there is no reason to do this.
I don't know the history here, and there are people on emacs-devel that
would know better.
I _suspect_ that the byte-compiler first got the capability to optimize
calls to anonymous functions, but that it required to explicitly marked
as such with `function'. Later, it grew the capability to recognize
lambda as such automatically. But I don't know if that is correct; it's
just a guess. In any case, they are no longer needed as lambda and
lambda+function are equivalent.
(Note that the worst thing here is to do `(quote (lambda ...))' as that
defeats byte-compiler optimizations altogether.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove redundant 'function's around lambda
2020-11-19 14:51 ` Stefan Kangas
@ 2020-11-19 15:16 ` Neil Jerram
0 siblings, 0 replies; 8+ messages in thread
From: Neil Jerram @ 2020-11-19 15:16 UTC (permalink / raw)
To: Stefan Kangas; +Cc: Org-mode
[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]
On Thu, 19 Nov 2020 at 14:51, Stefan Kangas <stefan@marxist.se> wrote:
> Neil Jerram <neiljerram@gmail.com> writes:
>
> >> I've been working on removing redundant `function' around `lambda' in
> >> Emacs core,
> >
> > I'm slightly curious about the history and reasoning around this. If I
> > understand correctly, (lambda ...) on its own has always worked, and it's
> > never been strictly necessary to add (quote ...) or (function ...) around
> > it. Then sometime (Emacs 19 or later, I think) it started being
> > recommended to use (function ...).
> >
> > Do you know why that recommendation started, and should I understand that
> > the reasoning for it has now evaporated?
>
> Correct, there is no reason to do this.
>
> I don't know the history here, and there are people on emacs-devel that
> would know better.
>
> I _suspect_ that the byte-compiler first got the capability to optimize
> calls to anonymous functions, but that it required to explicitly marked
> as such with `function'. Later, it grew the capability to recognize
> lambda as such automatically. But I don't know if that is correct; it's
> just a guess. In any case, they are no longer needed as lambda and
> lambda+function are equivalent.
>
> (Note that the worst thing here is to do `(quote (lambda ...))' as that
> defeats byte-compiler optimizations altogether.)
>
Many thanks Stefan!
[-- Attachment #2: Type: text/html, Size: 1901 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove redundant 'function's around lambda
2020-11-19 3:07 ` Kyle Meyer
2020-11-19 3:44 ` Stefan Kangas
@ 2020-12-14 6:49 ` Bastien
2020-12-23 5:11 ` Kyle Meyer
1 sibling, 1 reply; 8+ messages in thread
From: Bastien @ 2020-12-14 6:49 UTC (permalink / raw)
To: Kyle Meyer; +Cc: Org-mode, Stefan Kangas
Hi Kyle,
Kyle Meyer <kyle@kyleam.com> writes:
> Org files don't use a consistent style, despite Org's .dir-locals.el
> setting indent-tabs-mode to t, which should probably be changed to match
> Emacs's nil value.
FWIW, I'm all for setting `indent-tabs-mode' to nil in Org's .dir-locals.el.
Your call, of course.
--
Bastien
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove redundant 'function's around lambda
2020-12-14 6:49 ` Bastien
@ 2020-12-23 5:11 ` Kyle Meyer
0 siblings, 0 replies; 8+ messages in thread
From: Kyle Meyer @ 2020-12-23 5:11 UTC (permalink / raw)
To: Bastien; +Cc: Org-mode, Stefan Kangas
Bastien writes:
> Hi Kyle,
>
> Kyle Meyer <kyle@kyleam.com> writes:
>
>> Org files don't use a consistent style, despite Org's .dir-locals.el
>> setting indent-tabs-mode to t, which should probably be changed to match
>> Emacs's nil value.
>
> FWIW, I'm all for setting `indent-tabs-mode' to nil in Org's .dir-locals.el.
Sounds good, thanks for your input. Done (bd1c3187c).
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-12-23 5:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-17 16:55 [PATCH] Remove redundant 'function's around lambda Stefan Kangas
2020-11-19 3:07 ` Kyle Meyer
2020-11-19 3:44 ` Stefan Kangas
2020-12-14 6:49 ` Bastien
2020-12-23 5:11 ` Kyle Meyer
2020-11-19 10:44 ` Neil Jerram
2020-11-19 14:51 ` Stefan Kangas
2020-11-19 15:16 ` Neil Jerram
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).