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--render-image/formula):
* testing/org-batch-test-init.el (load-path): Remove redundant
'function's around lambda.
This commit is contained in:
Stefan Kangas 2020-11-17 17:35:49 +01:00 committed by Kyle Meyer
parent 93087e0b3a
commit 1a480e01a4
10 changed files with 242 additions and 259 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)))))))))))

View File

@ -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))

View File

@ -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

View File

@ -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,

View File

@ -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)

View File

@ -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")

View File

@ -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

View File

@ -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)