map)))
;; Sort the bindings and make a new keymap from them.
(setq bindings
- (sort bindings :key (compose #'bindings--menu-item-string
- #'cdr-safe)))
+ (sort bindings :key (compf bindings--menu-item-string cdr-safe)))
(nconc (make-sparse-keymap prompt) bindings)))
(defvar mode-line-major-mode-keymap
(interactive)
(calc-wrapper
(let (pos
- (vals (mapcar (lambda (v) (symbol-value (car v)))
- calc-mode-var-list)))
+ (vals (mapcar (compf symbol-value car) calc-mode-var-list)))
(unless calc-settings-file
(error "No `calc-settings-file' specified"))
(set-buffer (find-file-noselect (substitute-in-file-name
(let* ((today (calendar-current-date))
(year (calendar-read-sexp
"Bahá’í calendar year (not 0)"
- (lambda (x) (not (zerop x)))
+ (compf not zerop)
(calendar-extract-year
(calendar-bahai-from-absolute
(calendar-absolute-from-gregorian today)))))
Reads a year, month, and day."
(let* ((year (calendar-read-sexp
"Persian calendar year (not 0)"
- (lambda (x) (not (zerop x)))
+ (compf not zerop)
(calendar-extract-year
(calendar-persian-from-absolute
(calendar-absolute-from-gregorian
(pop-to-buffer-same-window name)))))
(put 'customize-group 'minibuffer-action
- (cons (lambda (g) (save-selected-window (customize-group g)))
+ (cons (compf save-selected-window customize-group)
"customize"))
;;;###autoload
"*Customize Apropos*")))
(put 'customize-apropos 'minibuffer-action
- (cons (lambda (p) (save-selected-window (customize-apropos p)))
+ (cons (compf save-selected-window customize-apropos)
"customize-apropos"))
;;;###autoload
(defun custom-theme-selections-toggle (widget &optional event)
(when (widget-value widget)
;; Deactivate multiple-selections.
- (if (< 1 (length (delq nil (mapcar (lambda (x) (widget-value (cdr x)))
+ (if (< 1 (length (delq nil (mapcar (compf widget-value cdr)
custom--listed-themes))))
(error "More than one theme is currently selected")))
(widget-toggle-action widget event)
found (length expansions))
;; Then all visible buffers.
(when (< found dabbrev-maximum-expansions)
- (walk-windows (compose search #'window-buffer) nil 'visible)
+ (walk-windows (compf [search] window-buffer) nil 'visible)
(setq expansions (nconc expansions more) more nil))
;; Then try other buffers.
(when (< found dabbrev-maximum-expansions)
;; While unassessed handlers still exist...
(while list
;; Sort list by the number of URLs assigned to each handler.
- (setq list (sort list :key (compose #'length #'cdr) :reverse t))
+ (setq list (sort list :key (compf length cdr) :reverse t))
;; Call the handler in its car before removing each URL from
;; URLs.
(let ((handler (caar list))
(intern function))))
(defvar ad-advice-class-completion-table
- (mapcar (lambda (class) (list (symbol-name class)))
- ad-advice-classes))
+ (mapcar (compf list symbol-name) ad-advice-classes))
(defun ad-read-advice-class (function &optional prompt default)
"Read a valid advice class with completion from the minibuffer.
(or (byte-opt--return-p then)
(byte-opt--every #'byte-opt--return-p else))))
(`(,(or 'and 'or) . ,exps)
- (not (byte-opt--every (lambda (exp) (not (byte-opt--return-p exp))) exps)))
+ (not (byte-opt--every (compf not byte-opt--return-p) exps)))
(`(while ,exp . ,exps)
(and (not (byte-compile-trueconstp exp))
(byte-opt--every #'byte-opt--return-p exps)))
(put 'byte-compile-warnings 'safe-local-variable
(lambda (v)
(or (symbolp v)
- (null (delq nil (mapcar (lambda (x) (not (symbolp x))) v))))))
+ (null (delq nil (mapcar (compf not symbolp) v))))))
;;;###autoload
(defun byte-compile-warning-enabled-p (warning &optional symbol)
jump-table test-objects body tag default-tag)
;; TODO: Once :linear-search is implemented for `make-hash-table'
;; set it to t for cond forms with a small number of cases.
- (let ((nvalues (apply #'+ (mapcar (lambda (case) (length (car case)))
- cases))))
+ (let ((nvalues (apply #'+ (mapcar (compf length car) cases))))
(setq jump-table (make-hash-table
:test test
:size nvalues)))
(let* ((data (garbage-collect)))
;; Let's create the chart!
(chart-bar-quickie 'vertical "Emacs Runtime Storage Usage"
- (mapcar (lambda (x) (symbol-name (car x))) data)
+ (mapcar (compf symbol-name car) data)
"Storage Items"
(mapcar (lambda (x) (* (nth 1 x) (nth 2 x)))
data)
(or checkdoc-common-verbs-regexp
(setq checkdoc-common-verbs-regexp
(concat "\\<\\("
- (mapconcat (lambda (e) (concat (car e)))
+ (mapconcat (compf concat car)
checkdoc-common-verbs-wrong-voice "\\|")
"\\)\\>"))))
name 'custom-icon))
(defun icon-spec-keywords (spec)
- (seq-drop-while (lambda (e) (not (keywordp e))) (cdr spec)))
+ (seq-drop-while (compf not keywordp) (cdr spec)))
(defun icon-spec-values (spec)
- (seq-take-while (lambda (e) (not (keywordp e))) (cdr spec)))
+ (seq-take-while (compf not keywordp) (cdr spec)))
(defun iconp (object)
"Return nil if OBJECT is not an icon.
(progress-reporter-done progress))
;; First group per output file.
- (dolist (fdefs (seq-group-by (lambda (x) (expand-file-name (car x)))
- defs))
+ (dolist (fdefs (seq-group-by (compf expand-file-name car) defs))
(let ((loaddefs-file (car fdefs))
hash)
(with-temp-buffer
Instead of the actual function to remove, FUNCTION can also be the `name'
of the piece of advice."
(interactive
- (let* ((pred (lambda (sym) (advice--p (advice--symbol-function sym))))
+ (let* ((pred (compf advice--p advice--symbol-function))
(default (when-let* ((f (function-called-at-point))
((funcall pred f)))
(symbol-name f)))
(require 'rx)
(defconst reb-rx-font-lock-keywords
(let ((constituents (mapcar #'symbol-name rx--builtin-forms))
- (syntax (mapcar (lambda (rec) (symbol-name (car rec)))
- rx--syntax-codes))
+ (syntax (mapcar (compf symbol-name car) rx--syntax-codes))
(categories (mapcar (lambda (rec)
(symbol-name (car rec)))
rx--categories)))
(minibuffer-with-setup-hook
(lambda ()
(setq minibuffer-action
- (cons (compose action #'intern) "trace"))
+ (cons (compf [action] intern) "trace"))
(setq minibuffer-alternative-action
- (cons (compose #'untrace-function #'intern) "untrace")))
+ (cons (compf untrace-function intern) "untrace")))
(completing-read
(format-prompt prompt default)
(completion-table-with-metadata
(advice-remove function trace-advice-name))
(put 'untrace-function 'minibuffer-action
- (cons (compose #'untrace-function #'intern) "untrace"))
+ (cons (compf untrace-function intern) "untrace"))
(defun untrace-all ()
"Untraces all currently traced functions."
;; How 'bout we lookup other tables than the env?
;; E.g. we could accept bookmark names as well!
(if (memq system-type '(windows-nt ms-dos))
- (lambda (var) (getenv (upcase var)))
+ (compf getenv upcase)
t)))
(defun setenv-internal (env variable value keep-empty)
modes)
(setq out (cl-sort out #'< :key #'car))
(pcase as-type
- ('strings (mapcar (lambda (o) (char-to-string (car o))) out))
+ ('strings (mapcar (compf char-to-string car) out))
('string (apply #'string (mapcar #'car out)))
((and (pred natnump) c)
(let (keys vals)
(pop-to-buffer-same-window value))))
(put 'find-file 'minibuffer-action
- (cons (lambda (file) (display-buffer (find-file-noselect file)))
+ (cons (compf display-buffer find-file-noselect)
"find"))
(defun find-file-other-window (filename &optional wildcards)
nil)))
;; Sort the entries from nearest dir to furthest dir.
(setq items (sort (nreverse items)
- :key (lambda (x) (length (car-safe x))) :reverse t))
+ :key (compf length car-safe) :reverse t))
;; Filter out duplicates, preferring the settings from the nearest dir
;; and from the first hook function.
(let ((seen nil))
(intern
(gnus-completing-read
"Add to category"
- (mapcar (lambda (cat) (symbol-name (car cat)))
- gnus-category-alist)
+ (mapcar (compf symbol-name car) gnus-category-alist)
t))
current-prefix-arg))
(let ((cat (assq category gnus-category-alist))
(ignore-errors
(equal
(sort (mapcar
- (lambda (x) (downcase (cadr x)))
+ (compf downcase cadr)
(mail-extract-address-components from t))
#'string<)
(sort (mapcar
- (lambda (x) (downcase (cadr x)))
+ (compf downcase cadr)
(mail-extract-address-components reply-to t))
#'string<))))
(gnus-article-hide-header "reply-to")))))
(mm-enable-external t))
(if (not (stringp method))
(gnus-mime-view-part-as-type
- nil (lambda (type) (stringp (mailcap-mime-info type))))
+ nil (compf stringp mailcap-mime-info))
(when handle
(mm-display-part handle nil t))))))
(let ((article narticle))
(message-mail nil nil nil nil
(if dont-pop
- (lambda (buf) (set-buffer (gnus-get-buffer-create buf)))))
+ (compf set-buffer gnus-get-buffer-create)))
(let ((inhibit-read-only t))
(erase-buffer))
(if (not (gnus-request-restore-buffer article group))
(gnus-string-or
(gnus-completing-read
"Search engine type"
- (mapcar (lambda (elem) (symbol-name (car elem)))
- nnweb-type-definition)
+ (mapcar (compf symbol-name car) nnweb-type-definition)
t nil 'gnus-group-web-type-history)
default-type))
(search
(cddar thread)))
(setq gnus-tmp-gathered
(nconc (mapcar
- (lambda (h) (mail-header-number (car h)))
+ (compf mail-header-number car)
(cddar thread))
gnus-tmp-gathered))
(setq thread (cons (list (caar thread)
;; We print adopted articles with empty subject fields.
(setq gnus-tmp-gathered
(nconc (mapcar
- (lambda (h) (mail-header-number (car h)))
+ (compf mail-header-number car)
(cddar thread))
gnus-tmp-gathered))
(setq gnus-tmp-level -1))
((not (memq number gnus-newsgroup-limit))
(setq gnus-tmp-gathered
(nconc (mapcar
- (lambda (h) (mail-header-number (car h)))
+ (compf mail-header-number car)
(cdar thread))
gnus-tmp-gathered))
(setq gnus-tmp-new-adopts (if (cdar thread)
(message "%s (%s): "
prompt
(concat
- (mapconcat (lambda (s) (char-to-string (car s)))
- choice ", ")
+ (mapconcat (compf char-to-string car) choice ", ")
", ?"))
(setq tchar (read-char))
(when (not (assq tchar choice))
(:fontset . "Fontset")
(:extend . "Extend")
(:inherit . "Inherit")))
- (max-width (apply #'max (mapcar (lambda (x) (length (cdr x)))
- attrs))))
+ (max-width (apply #'max (mapcar (compf length cdr) attrs))))
(dolist (a attrs)
(let ((attr (face-attribute face (car a) frame)))
(insert (make-string (- max-width (length (cdr a))) ?\s)
(memq source modes))
(push source modes))))
(let* ((names (mapcar
- (compose (apply-partially #'string-replace "-mode" "")
- #'symbol-name)
+ (compf (apply-partially #'string-replace "-mode" "")
+ symbol-name)
modes))
(max (seq-max (cons 0 (mapcar #'string-width names))))
(choices
((eq active-map (current-local-map)) 'local)
(t (car (rassq active-map minor-mode-map-alist)))))
pm))))
- (let* ((m (seq-max (cons 0 (mapcar (compose #'string-width
- #'key-description
- #'car)
+ (let* ((m (seq-max (cons 0 (mapcar (compf string-width key-description car)
help--complete-keys-alist))))
(bindings (mapcar
(pcase-lambda (`(,e ,b . ,s))
nil)
(put 'where-is 'minibuffer-action
- (cons (lambda (cmd) (where-is (intern cmd)))
- "show keys"))
+ (cons (compf where-is intern) "show keys"))
(defun help-key-description (key untranslated)
(let ((string (help--key-description-fontified key)))
(let ((textre
(if (> (length string) 80)
(regexp-quote string)
- (mapconcat (lambda (c) (regexp-quote (string c))) string
+ (mapconcat (compf regexp-quote string) string
"\\(?:\n\\(?:[:a-f0-9]+ \\)+ \\)?"))))
(if (string-match "\\` ?\\([a-f0-9]+ \\)*[a-f0-9]+ ?\\'" string)
(concat textre "\\|"
(cond
((equal color "unspecified-fg") (setq color "black"))
((equal color "unspecified-bg") (setq color "white")))
- (let ((white (mapcar (lambda (I) (float (1+ I))) (hfy-color-vals "white")))
- (rgb16 (mapcar (lambda (I) (float (1+ I))) (hfy-color-vals color))))
+ (let ((white (mapcar (compf float 1+) (hfy-color-vals "white")))
+ (rgb16 (mapcar (compf float 1+) (hfy-color-vals color))))
(if rgb16
;;(apply #'format "rgb(%d, %d, %d)"
;; Use #rrggbb instead, it is smaller
(when (image-get-display-property)
(image-toggle-display-text)
;; Update image display.
- (mapc (lambda (window) (redraw-frame (window-frame window)))
+ (mapc (compf redraw-frame window-frame)
(get-buffer-window-list (current-buffer) 'nomini 'visible))
(image-toggle-display-image)))
If Emacs is compiled without ImageMagick support, this does nothing."
(when (fboundp 'imagemagick-types)
- (let* ((types (mapcar (lambda (type) (downcase (symbol-name type)))
+ (let* ((types (mapcar (compf downcase symbol-name)
(imagemagick-filter-types)))
(re (if types (concat "\\." (regexp-opt types) "\\'")))
(ama-elt (car (member (cons imagemagick--file-regexp 'image-mode)
(info-pop-to-buffer file-or-node buffer))
(put 'info 'minibuffer-action
- (cons (lambda (f) (save-selected-window (info f))) "info"))
+ (cons (compf save-selected-window info) "info"))
(defun info-setup (file-or-node buffer)
"Display Info node FILE-OR-NODE in BUFFER."
(generate-new-buffer-name "*info*")))))
(put 'info-display-manual 'minibuffer-action
- (cons (lambda (m) (save-selected-window (info-display-manual m)))
+ (cons (compf save-selected-window info-display-manual)
"display"))
(defun info--filter-manual-names (names)
INITIAL-INPUT, if non-nil, is a string inserted in the minibuffer initially.
See the documentation of the function `completing-read' for the detailed
meanings of these arguments."
- (let* ((table (mapcar (lambda (x) (list (symbol-name x))) charset-list))
+ (let* ((table (mapcar (compf list symbol-name) charset-list))
(charset (completing-read prompt table
nil t initial-input 'charset-history
default-value)))
The generated map can be set for the current Quail package by the
function `quail-install-map' (which see)."
- (let ((state-alist (mapcar (lambda (x) (list (car x))) table))
+ (let ((state-alist (mapcar (compf list car) table))
tail elt)
;; STATE-ALIST is an alist of states vs the corresponding sub Quail
;; map. It is now initialized to ((STATE-0) (STATE-1) ...).
(eq mail-names t))
(setq mail-names
(sort (append (if (consp mail-aliases)
- (mapcar
- (lambda (a) (list (car a)))
- mail-aliases))
+ (mapcar (compf list car) mail-aliases))
(if (consp mail-local-names)
mail-local-names)
(or directory
;; language environments. See
;; https://lists.gnu.org/archive/html/emacs-devel/2007-03/msg01760.html.
(with-case-table ascii-case-table
- (mapcar (lambda (s) (intern (downcase s)))
+ (mapcar (compf intern downcase)
(split-string (substring line 4) "[ ]")))))
(when (= (length name) 1)
(setq name (car name)))
(mapconcat #'car alist ", ")
"? ("
(mapconcat
- (lambda (elt) (char-to-string (cdr elt))) alist "/")
+ (compf char-to-string cdr) alist "/")
") "))
(p prompt)
event)
;; query for confirmation
(if query-p
- (let* ((query-alist (mapcar (lambda (entry) (list (cdr entry)))
+ (let* ((query-alist (mapcar (compf list cdr)
sc-attributions))
(minibuffer-local-completion-map
sc-minibuffer-local-completion-map)
(if completion-lazy-hilit
(prog1 comps (setq completion-lazy-hilit-fn hilit-fn))
(setq completion-lazy-hilit-fn nil)
- (mapcar (compose hilit-fn #'copy-sequence) comps))))
+ (mapcar (compf [hilit-fn] copy-sequence) comps))))
;;; Partial-completion-mode style completion.
(if-let ((neg (get-text-property 0 'negated desc)))
(minibuffer--add-completions-predicate (cdr neg) (car neg))
(minibuffer--add-completions-predicate
- (compose #'not fn)
+ (compf not [fn])
(propertize (concat "-(" desc ")") 'negated (cons desc fn)))))
(user-error "`%s' is not a description of a current predicate" desc))
;; Negate the entire predicate.
(setq dir (file-name-as-directory (expand-file-name dir)))
(dired-noselect
(cons dir
- (mapcar (compose (lambda (file) (file-relative-name file dir))
- #'directory-file-name)
+ (mapcar (compf (lambda (file) (file-relative-name file dir))
+ directory-file-name)
(seq-filter #'file-exists-p
(mapcar (lambda (file) (expand-file-name file dir))
files))))))
"Use a saved search for querying Mairix."
(interactive)
(let* ((completions
- (mapcar (lambda (el) (list (car el))) mairix-saved-searches))
+ (mapcar (compf list car) mairix-saved-searches))
(search (completing-read "Name of search: " completions))
(query (assoc search mairix-saved-searches))
(folder (nth 2 query)))
(shell-command-to-string (concat program " list --all -q")))
;; Ignore header line.
(lines (cdr (split-string raw-list "\n")))
- (first-words (mapcar (lambda (line) (car (split-string line)))
+ (first-words (mapcar (compf car split-string)
lines))
(machines (seq-take-while (lambda (name) name) first-words)))
(mapcar (lambda (m) (list nil m)) machines))))
(header-arg (or header-arg
(completing-read
"Header Arg: "
- (mapcar
- (lambda (header-spec) (symbol-name (car header-spec)))
- headers))))
+ (mapcar (compf symbol-name car) headers))))
(vals (cdr (assoc (intern header-arg) headers)))
(value (or value
(cond
(mapcar #'symbol-name
(delete-dups
(append (mapcar #'car org-babel-load-languages)
- (mapcar (lambda (el) (intern (car el)))
+ (mapcar (compf intern car)
org-src-lang-modes)))))))
(body (delete-and-extract-region
(if (org-region-active-p) (mark) (point)) (point))))
"[S]catter [f]unction "
(and org-agenda-bulk-custom-functions
(format " Custom: [%s]"
- (mapconcat (lambda (f) (char-to-string (car f)))
+ (mapconcat (compf char-to-string car)
org-agenda-bulk-custom-functions
"")))))
(catch 'exit
"Summary: "
(delete-dups
(cons '("") ;Allow empty operator.
- (mapcar (lambda (x) (list (car x)))
+ (mapcar (compf list car)
(append
org-columns-summary-types
org-columns-summary-types-default))))
(let ((lst (pcomplete-uniquify-list
(or (remq
nil
- (mapcar (lambda (x) (org-string-nw-p (car x)))
+ (mapcar (compf org-string-nw-p car)
org-current-tag-alist))
(mapcar #'car (org-get-buffer-tags))))))
(dolist (tag (org-get-tags nil t))
;; Call costly `org-export-table-cell-address' only if
;; absolutely necessary, i.e., if one
;; of :fmt :efmt :hfmt has a "plist type" value.
- ,(and (cl-some (lambda (v) (integerp (car-safe v)))
+ ,(and (cl-some (compf integerp car-safe)
(list efmt hfmt fmt))
'(1+ (cdr (org-export-table-cell-address cell info))))))
(when contents
"Check whether `org-structure-template-alist' is set up correctly.
In particular, check if the Org 9.2 format is used as opposed to
previous format."
- (let ((elm (cl-remove-if-not (lambda (x) (listp (cdr x)))
+ (let ((elm (cl-remove-if-not (compf listp cdr)
(or (symbol-value checklist)
org-structure-template-alist))))
(when elm
function is passed as a collection function to `completing-read',
which see."
(let ((completion-ignore-case nil) ;tags are case-sensitive
- (confirm (lambda (x) (stringp (car x))))
+ (confirm (compf stringp car))
(prefix "")
begin)
(when (string-match "^\\(.*[-+:&,|]\\)\\([^-+:&,|]*\\)$" string)
(concat "text/html;charset=" charset)))
(let ((viewport-options
- (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell)))
+ (cl-remove-if-not (compf org-string-nw-p cadr)
(plist-get info :html-viewport))))
(if viewport-options
(org-html--build-meta-entry "name" "viewport"
;; cells. Actually used references are extracted from
;; `:internal-references', with references as strings removed. See
;; `org-export-get-reference' for details.
- (cl-remove-if (lambda (pair) (stringp (car pair)))
+ (cl-remove-if (compf stringp car)
(plist-get info :internal-references)))
;; Return output unchanged.
output)
(lambda (a b) (> (cl-second a) (cl-second b)))))
(decipher-insert-frequency-counts freq-list total-chars)
;; Display letters in order of frequency:
- (insert ?\n (mapconcat (lambda (a) (char-to-string (car a)))
+ (insert ?\n (mapconcat (compf char-to-string car)
freq-list nil)
"\n\n")
;; Display list of digrams in order of frequency:
The children alist inherits the sorting order of PROCESS-ALIST.
The list of children does not include grandchildren."
;; The PPIDs inherit the sorting order of PROCESS-ALIST.
- (let ((process-tree (mapcar (lambda (a) (list (car a))) process-alist))
+ (let ((process-tree (mapcar (compf list car) process-alist))
ppid)
(dolist (process process-alist)
(setq ppid (cdr (assq 'ppid (cdr process))))
(add-hook 'flymake-diagnostic-functions
#'elisp-flymake-byte-compile nil t)
(add-hook 'refactor-backend-functions #'elisp-refactor-backend nil t)
- (add-hook 'context-menu-functions #'elisp-context-menu 10 t))
+ (add-hook 'context-menu-functions #'elisp-context-menu 10 t)
+ (alist-set "compf" prettify-symbols-alist ?∘ #'equal))
;; Font-locking support.
(pcase (read (current-buffer))
(`(,(and head (pred symbolp)) . ,tail)
(list (symbol-name head)
- (mapcar (compose
+ (mapcar (compf
(apply-partially #'concat "arg")
- #'number-to-string)
+ number-to-string)
(number-sequence 1 (length tail)))))
(_ (rec (cdr ps))))))))
(cl-sort
(mapcar (lambda (o) (overlay-get o 'flymake-diagnostic)) src-ovs)
#'>
- :key (lambda (d) (flymake--severity (flymake-diagnostic-type d)))))
+ :key (compf flymake--severity flymake-diagnostic-type)))
(summary
(concat
" "
;; Syntax-symbol returns the symbol of the *first* element
;; in the syntactical analysis result list, syntax-point
;; returns the buffer position of same
- (syntax-symbol (lambda (x) (c-langelem-sym (car x))))
- (syntax-point (lambda (x) (c-langelem-pos (car x)))))
+ (syntax-symbol (compf c-langelem-sym car))
+ (syntax-point (compf c-langelem-pos car)))
(setq f (file-name-sans-extension (file-truename f)))
;; Search through classpath list for an entry that is
;; contained in f
"Set `hide-ifdef-env' to the define list specified by NAME."
(interactive
(list (completing-read "Use define list: "
- (mapcar (lambda (x) (symbol-name (car x)))
+ (mapcar (compf symbol-name car)
hide-ifdef-define-alist)
nil t)))
(if (stringp name) (setq name (intern name)))
(defvar mixal-font-lock-keywords
`(("^\\([A-Z0-9a-z]+\\)"
(1 mixal-font-lock-label-face))
- (,(regexp-opt (mapcar (lambda (x) (symbol-name (car x)))
+ (,(regexp-opt (mapcar (compf symbol-name car)
mixal-operation-codes-alist) 'words)
. mixal-font-lock-operation-code-face)
(,(regexp-opt mixal-assembly-pseudoinstructions 'words)
(define-button-type 'octave-help-function
'follow-link t
- 'action (lambda (b) (octave-help (button-label b))))
+ 'action (compf octave-help button-label))
(defvar octave-help-mode-map
(let ((map (make-sparse-keymap)))
(read (current-buffer))
(end-of-file
(warn "Failed to read the projects list file due to unexpected EOF")))))))
- (unless (seq-every-p
- (lambda (elt) (stringp (car-safe elt)))
- project--list)
+ (unless (seq-every-p (compf stringp car-safe) project--list)
(warn "Contents of %s are in wrong format, resetting"
project-list-file)
(setq project--list nil))))
(defsubst project--update-roots-cache ()
(setq project--roots-cache
- (mapcar (compose #'expand-file-name #'car) project--list)))
+ (mapcar (compf expand-file-name car) project--list)))
(defun project--remember-dir (root &optional no-write)
"Add project root ROOT to the front of the project list.
(defun refactor-completing-read-operation (operations)
(intern (completing-read "Refactor operation: "
- (mapcar (compose #'symbol-name #'cadr)
+ (mapcar (compf symbol-name cadr)
operations)
nil t)))
(defun refactor-query-apply-edits (edits)
"Suggest applying each edit in EDITS in turn."
- (let ((change-group (mapcan (compose #'prepare-change-group #'car) edits))
+ (let ((change-group (mapcan (compf prepare-change-group car) edits))
(undo-outer-limit nil)
(undo-limit most-positive-fixnum)
(undo-strong-limit most-positive-fixnum)
;; Maybe there could be a separate variable that lists
;; the shells, used here and to construct i-mode-alist.
;; But the following is probably good enough:
- (append (mapcar (lambda (e) (symbol-name (car e)))
- sh-ancestor-alist)
+ (append (mapcar (compf symbol-name car) sh-ancestor-alist)
'("csh" "rc" "sh"))
nil nil nil nil sh-shell-file)
(eq executable-query 'function)
(format-prompt prompt default)
(completion-table-dynamic
(lambda (&rest _)
- (mapcar (compose #'symbol-name #'car) sql-product-alist)))
+ (mapcar (compf symbol-name car) sql-product-alist)))
nil t nil 'sql-product-history default)))
(defun sql-add-product (product display &rest plist)
"Connection: "
(completion-table-dynamic
(lambda (&rest _)
- (mapcar (compose #'symbol-name #'car)
+ (mapcar (compf symbol-name car)
sql-connection-alist)))
nil t nil 'sql-connection-history)
current-prefix-arg)
:type 'sexp)
;;;###autoload (put 'which-func-format 'risky-local-variable t)
-(defvar which-func-imenu-joiner-function (lambda (x) (car (last x)))
+(defvar which-func-imenu-joiner-function (compf car last)
"Function to join together multiple levels of imenu nomenclature.
Called with a single argument, a list of strings giving the names
of the menus we had to traverse to get to the item. Returns a
(save-window-excursion
(set-window-configuration stored-window-config)
(concat
- (mapconcat (lambda (w) (buffer-name (window-buffer w)))
+ (mapconcat (compf buffer-name window-buffer)
(window-list (selected-frame)) ", ")
(unless (eq current-frame window-config-frame)
" in another frame"))))
(interactive
(list (get-buffer
(read-buffer "Select next-error buffer: " nil nil
- (lambda (b) (next-error-buffer-p (cdr b)))))))
+ (compf next-error-buffer-p cdr)))))
(setq next-error-last-buffer buffer))
(defalias 'goto-next-locus 'next-error)
(setting-constant nil))) ;E.g. for enable-multibyte-characters.
lvars)
- (setq mark-ring (mapcar (lambda (mk) (copy-marker (marker-position mk)))
+ (setq mark-ring (mapcar (compf copy-marker marker-position)
mark-ring))
;; Run any hooks (typically set up by the major mode
(unless (assq (car plist) alist)
(push (cons (car plist) "") alist))
(setq plist (cddr plist)))
- (mapcar (compose #'symbol-name #'car) alist))
+ (mapcar (compf symbol-name car) alist))
'((category . text-property)
(affixation-function . read-text-property-affixation)))
nil nil nil
(setq pairs (cdr (cdr pairs))))
(macroexp-progn (nreverse expr))))
+(defmacro compf (&rest funs)
+ "Expand to the function composition of FUNS, outermost function first.
+
+For example, (compf car cdr) expands to (lambda (x) (car (cdr x))),
+which does the same as `cadr'.
+
+FUNS may contain symbols which refer to functions, such as `car' and
+`cdr' in the example above, and it can also contain `lambda' functions
+and other forms which evaluate to function values. To refer to a local
+variable VAR that is bound to a function, wrap VAR in a vector, as in:
+
+ (let ((foo (lambda (...) ...)))
+ (compf ignore [foo] always))
+
+If FUNS is empty, expand to `identity'."
+ (cond
+ ((null funs) '#'identity)
+ ((length= funs 1)
+ (let ((fun (car funs)))
+ (cond
+ ((symbolp fun) `#',fun) ; Function name.
+ ((vectorp fun) (aref fun 0)) ; Local variable reference.
+ (t fun)))) ; `lambda' and other forms.
+ (t
+ (let* ((x (gensym "x")) (arg x))
+ (dolist (fun (reverse funs))
+ (setq arg
+ (cond
+ ((symbolp fun) `(,fun ,arg))
+ ((vectorp fun) `(funcall ,(aref fun 0) ,arg))
+ (t `(funcall ,fun ,arg)))))
+ `(lambda (,x) ,arg)))))
+
(defmacro defvar-local (var val &optional docstring)
"Define VAR as a buffer-local variable with default value VAL.
Like `defvar' but additionally marks the variable as being automatically
;; Now `frame' should be "the function from which we were called".
(pcase (cons frame nextframe)
;; No subr calls `interactive-p', so we can rule that out.
- (`((,_ ,(pred (lambda (f) (subr-primitive-p (indirect-function f)))) . ,_) . ,_) nil)
+ (`((,_ ,(pred (compf subr-primitive-p indirect-function)) . ,_) . ,_) nil)
;; In case #<subr funcall-interactively> without going through the
;; `funcall-interactively' symbol (bug#3984).
(`(,_ . (t ,(pred (lambda (f)
,(funcall setter val)
,val)))))
-(defun compose (&rest funs)
- "Return the function composition of FUNS.
-
-For example, (compose #\\='car #\\='car #\\='cdr) returns a function
-that does the same thing as `caadr'."
- (if funs
- (lambda (x)
- (funcall (car funs) (funcall (apply #'compose (cdr funs)) x)))
- #'identity))
-
(defsubst plusp (number) "Return t if NUMBER is positive." (> number 0))
(defsubst minusp (number) "Return t if NUMBER is negative." (< number 0))
(defun reftex-index-select-phrases-macro (&optional delay)
"Offer a list of possible index macros and have the user select one."
(let* ((prompt (concat "Select macro: ["
- (mapconcat (lambda (x) (char-to-string (car x)))
+ (mapconcat (compf char-to-string car)
reftex-index-phrases-macro-data "")
"] "))
(help (concat "Select an indexing macro\n========================\n"
(reftex-this-word "-a-zA-Z0-9_*.:")))
(label (completing-read (format-prompt "Label" default)
docstruct
- (lambda (x) (stringp (car x))) t nil nil
+ (compf stringp car) t nil nil
default))
(selection (assoc label docstruct))
(where (progn
(lambda (a b) (< (downcase (car a)) (downcase (car b))))))
(setq reftex-query-index-macro-prompt
(concat "Index macro: ["
- (mapconcat (lambda (x) (char-to-string (car x)))
+ (mapconcat (compf char-to-string car)
reftex-key-to-index-macro-alist "")
"]"))
(setq i 0
"\\)[{ \t]+\\([^} \t\n\r]+\\)"))
(section-re
(concat wbol reftex-section-pre-regexp "\\("
- (mapconcat (lambda (x) (regexp-quote (car x)))
+ (mapconcat (compf regexp-quote car)
reftex-section-levels-all "\\|")
"\\)" reftex-section-post-regexp))
(appendix-re (concat wbol "\\(\\\\appendix\\)"))
(defun tex-summarize-command (cmd)
(if (not (stringp cmd)) ""
(mapconcat #'identity
- (mapcar (lambda (s) (car (split-string s)))
+ (mapcar (compf car split-string)
(split-string cmd "\\s-*\\(?:;\\|&&\\)\\s-*"))
"&")))
(defun vc-dir-marked-files ()
"Return the list of marked files."
(mapcar
- (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem)))
+ (compf expand-file-name vc-dir-fileinfo->name)
(ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked)))
(defun vc-dir-marked-only-files-and-states ()
(intern
(completing-read
"Use VC backend: "
- (mapcar (lambda (b) (list (symbol-name b)))
- vc-handled-backends)
+ (mapcar (compf list symbol-name) vc-handled-backends)
nil t nil nil)))))
(unless backend
(setq backend (vc-responsible-backend dir)))
(revision-downcase (downcase revision)))
(if (member
revision-downcase
- (mapcar (lambda (arg) (downcase (symbol-name arg)))
- vc-handled-backends))
+ (mapcar (compf downcase symbol-name) vc-handled-backends))
(let ((vsym (intern-soft revision-downcase)))
(dolist (file files) (vc-transfer-file file vsym)))
(dolist (file files)
(revision-downcase (downcase revision)))
(if (member
revision-downcase
- (mapcar (lambda (arg) (downcase (symbol-name arg)))
- vc-handled-backends))
+ (mapcar (compf downcase symbol-name) vc-handled-backends))
(let ((vsym (intern revision-downcase)))
(dolist (file files) (vc-transfer-file file vsym)))
(vc-checkin ready-for-commit backend nil nil revision)))))))
(t (bury-buffer-internal buffer)))))
(put 'quit-windows-on 'minibuffer-action
- (cons (lambda (b) (save-selected-window (quit-windows-on b)))
+ (cons (compf save-selected-window quit-windows-on)
"quit windows showing buffer"))
\f