update packages

This commit is contained in:
2021-01-08 19:32:30 +01:00
parent ce8f24d28a
commit f5649dceab
467 changed files with 26642 additions and 22487 deletions

View File

@@ -1,11 +1,11 @@
(define-package "transient" "20200622.2050" "Transient commands"
(define-package "transient" "20210103.1546" "Transient commands"
'((emacs "25.1"))
:commit "73694be44a802cac89bfe0798e2a4aeb79e39ead" :keywords
'("bindings")
:authors
:commit "90e640fe8fa3f309c7cf347501e86ca5cd0bd85e" :authors
'(("Jonas Bernoulli" . "jonas@bernoul.li"))
:maintainer
'("Jonas Bernoulli" . "jonas@bernoul.li")
:keywords
'("bindings")
:url "https://github.com/magit/transient")
;; Local Variables:
;; no-byte-compile: t

View File

@@ -1,10 +1,11 @@
;;; transient.el --- Transient commands -*- lexical-binding: t; -*-
;; Copyright (C) 2018-2020 Free Software Foundation, Inc.
;; Copyright (C) 2018-2021 Free Software Foundation, Inc.
;; Author: Jonas Bernoulli <jonas@bernoul.li>
;; Homepage: https://github.com/magit/transient
;; Package-Requires: ((emacs "25.1"))
;; Package-Version: 0
;; Keywords: bindings
;; This file is part of GNU Emacs.
@@ -56,6 +57,14 @@
(eval-when-compile
(require 'subr-x))
(and (require 'async-bytecomp nil t)
(let ((pkgs (bound-and-true-p async-bytecomp-allowed-packages)))
(if (consp pkgs)
(cl-intersection '(all magit transient) pkgs)
(memq pkgs '(all t))))
(fboundp 'async-bytecomp-package-mode)
(async-bytecomp-package-mode 1))
(declare-function info 'info)
(declare-function Man-find-section 'man)
(declare-function Man-next-section 'man)
@@ -81,6 +90,19 @@
(define-obsolete-variable-alias 'post-transient-hook
'transient-exit-hook "Transient 0.3.0")
(defmacro transient--with-emergency-exit (&rest body)
(declare (indent defun))
`(condition-case err
(let ((debugger #'transient--exit-and-debug))
,(macroexp-progn body))
((debug error)
(transient--emergency-exit)
(signal (car err) (cdr err)))))
(defun transient--exit-and-debug (&rest args)
(transient--emergency-exit)
(apply #'debug args))
;;; Options
(defgroup transient nil
@@ -269,7 +291,7 @@ used."
:type 'boolean)
(defcustom transient-force-fixed-pitch nil
"Whether to force used of monospaced font in popup buffer.
"Whether to force use of monospaced font in the popup buffer.
Even if you use a proportional font for the `default' face,
you might still want to use a monospaced font in transient's
@@ -466,13 +488,13 @@ These faces are only used if `transient-semantic-coloring'
(insert-file-contents file)
(read (current-buffer))))))
(defun transient--pp-to-file (object file)
(defun transient--pp-to-file (list file)
(make-directory (file-name-directory file) t)
(setq object (cl-sort object #'string< :key #'car))
(setq list (cl-sort (copy-sequence list) #'string< :key #'car))
(with-temp-file file
(let ((print-level nil)
(print-length nil))
(pp object (current-buffer)))))
(pp list (current-buffer)))))
(defvar transient-values
(transient--read-file-contents transient-values-file)
@@ -525,6 +547,7 @@ If `transient-save-history' is nil, then do nothing."
(command :initarg :command)
(level :initarg :level)
(variable :initarg :variable :initform nil)
(init-value :initarg :init-value)
(value) (default-value :initarg :value)
(scope :initarg :scope :initform nil)
(history :initarg :history :initform nil)
@@ -534,7 +557,8 @@ If `transient-save-history' is nil, then do nothing."
(info-manual :initarg :info-manual :initform nil)
(transient-suffix :initarg :transient-suffix :initform nil)
(transient-non-suffix :initarg :transient-non-suffix :initform nil)
(incompatible :initarg :incompatible :initform nil))
(incompatible :initarg :incompatible :initform nil)
(suffix-description :initarg :suffix-description :initform nil))
"Transient prefix command.
Each transient prefix command consists of a command, which is
@@ -636,7 +660,10 @@ slot is non-nil."
(argument :initarg :argument)
(shortarg :initarg :shortarg)
(value :initform nil)
(init-value :initarg :init-value)
(unsavable :initarg :unsavable :initform nil)
(multi-value :initarg :multi-value :initform nil)
(always-read :initarg :always-read :initform nil)
(allow-empty :initarg :allow-empty :initform nil)
(history-key :initarg :history-key :initform nil)
(reader :initarg :reader :initform nil)
@@ -675,9 +702,11 @@ They become the value of this this argument.")
;;;; Group
(defclass transient-group (transient-child)
((suffixes :initarg :suffixes :initform nil)
(hide :initarg :hide :initform nil)
(description :initarg :description :initform nil))
((suffixes :initarg :suffixes :initform nil)
(hide :initarg :hide :initform nil)
(description :initarg :description :initform nil)
(setup-children :initarg :setup-children)
(pad-keys :initarg :pad-keys))
"Abstract superclass of all group classes."
:abstract t)
@@ -869,7 +898,9 @@ example, sets a variable use `transient-define-infix' instead.
(setq class v)
(push k keys)
(push v keys))))
(while (vectorp (car args))
(while (let ((arg (car args)))
(or (vectorp arg)
(and arg (symbolp arg))))
(push (pop args) suffixes))
(list (if (eq (car-safe class) 'quote)
(cadr class)
@@ -881,6 +912,12 @@ example, sets a variable use `transient-define-infix' instead.
(defun transient--parse-child (prefix spec)
(cl-etypecase spec
(symbol (let ((value (symbol-value spec)))
(if (and (listp value)
(or (listp (car value))
(vectorp (car value))))
(cl-mapcan (lambda (s) (transient--parse-child prefix s)) value)
(transient--parse-child prefix value))))
(vector (when-let ((c (transient--parse-group prefix spec))) (list c)))
(list (when-let ((c (transient--parse-suffix prefix spec))) (list c)))
(string (list spec))))
@@ -929,6 +966,15 @@ example, sets a variable use `transient-define-infix' instead.
(error "Need command, got %S" car))
((symbolp car)
(setq args (plist-put args :command pop)))
((and (commandp car)
(not (stringp car)))
(let ((cmd pop)
(sym (intern (format "transient:%s:%s"
prefix
(or (plist-get args :description)
(plist-get args :key))))))
(defalias sym cmd)
(setq args (plist-put args :command sym))))
((or (stringp car)
(and car (listp car)))
(let ((arg pop))
@@ -950,8 +996,7 @@ example, sets a variable use `transient-define-infix' instead.
((not (string-suffix-p "=" arg))
(setq class 'transient-switch))
(t
(setq class 'transient-option)
(setq args (plist-put args :reader 'read-string))))))
(setq class 'transient-option)))))
(t
(error "Needed command or argument, got %S" car)))
(while (keywordp car)
@@ -1013,10 +1058,22 @@ example, sets a variable use `transient-define-infix' instead.
(t
(when (and (listp suffix)
(listp elt))
;; Both suffixes are key bindings; not heading strings.
(let ((key (transient--spec-key suf)))
(if (equal (transient--kbd key)
(transient--kbd (transient--spec-key elt)))
(setq action 'replace)
;; We must keep `mem' until after we have inserted
;; behind it, which `transient-remove-suffix' does
;; not allow us to do.
(let ((spred (transient--suffix-predicate suf))
(epred (transient--suffix-predicate elt)))
;; If both suffixes have a predicate and they
;; are not identical, then the probability is
;; high that we want to keep both.
(when (or (not spred)
(not epred)
(equal spred epred))
(setq action 'replace)))
(transient-remove-suffix prefix key))))
(cl-ecase action
(insert (setcdr mem (cons elt (cdr mem)))
@@ -1277,11 +1334,13 @@ probably use this instead:
(get COMMAND 'transient--suffix)"
(when command
(cl-check-type command command))
(if transient--prefix
(if (or transient--prefix
transient-current-prefix)
(cl-find-if (lambda (obj)
(eq (transient--suffix-command obj)
(or command this-original-command)))
transient--suffixes)
(or transient--suffixes
transient-current-suffixes))
(when-let ((obj (get (or command this-command) 'transient--suffix))
(obj (clone obj)))
(transient-init-scope obj)
@@ -1329,7 +1388,7 @@ then just return it. Otherwise return the symbol whose
(define-key map (kbd "C-q") 'transient-quit-all)
(define-key map (kbd "C-z") 'transient-suspend)
(define-key map (kbd "C-v") 'transient-scroll-up)
(define-key map (kbd "M-v") 'transient-scroll-down)
(define-key map (kbd "C-M-v") 'transient-scroll-down)
(define-key map [next] 'transient-scroll-up)
(define-key map [prior] 'transient-scroll-down)
map)
@@ -1353,8 +1412,9 @@ edited using the same functions as used for transients.")
(define-key map (kbd "C-t") 'transient-show)
(define-key map (kbd "?") 'transient-help)
(define-key map (kbd "C-h") 'transient-help)
(define-key map (kbd "M-p") 'transient-history-prev)
(define-key map (kbd "M-n") 'transient-history-next)
;; Also bound to "C-x p" and "C-x n" in transient-common-commands.
(define-key map (kbd "C-M-p") 'transient-history-prev)
(define-key map (kbd "C-M-n") 'transient-history-next)
map)
"Top-level keymap used by all transients.")
@@ -1387,8 +1447,8 @@ edited using the same functions as used for transients.")
["Value commands"
("C-x s " "Set" transient-set)
("C-x C-s" "Save" transient-save)
("M-p " "Previous value" transient-history-prev)
("M-n " "Next value" transient-history-next)]
("C-x p " "Previous value" transient-history-prev)
("C-x n " "Next value" transient-history-next)]
["Sticky commands"
;; Like `transient-sticky-map' except that
;; "C-g" has to be bound to a different command.
@@ -1490,7 +1550,6 @@ of the corresponding object.")
(when-let ((conflict (and transient-detect-key-conflicts
(transient--lookup-key map kbd))))
(unless (eq cmd conflict)
(transient--emergency-exit)
(error "Cannot bind %S to %s and also %s"
(string-trim key)
cmd conflict)))
@@ -1571,58 +1630,76 @@ be nil and PARAMS may be (but usually is not) used to set e.g. the
This function is also called internally in which case LAYOUT and
EDIT may be non-nil."
(transient--debug 'setup)
(cond
((not name)
;; Switching between regular and edit mode.
(transient--pop-keymap 'transient--transient-map)
(transient--pop-keymap 'transient--redisplay-map)
(setq name (oref transient--prefix command))
(setq params (list :scope (oref transient--prefix scope))))
((not (or layout ; resuming parent/suspended prefix
transient-current-command)) ; entering child prefix
(transient--stack-zap)) ; replace suspended prefix, if any
(edit
;; Returning from help to edit.
(setq transient--editp t)))
(transient--init-objects name layout params)
(transient--history-init transient--prefix)
(setq transient--predicate-map (transient--make-predicate-map))
(setq transient--transient-map (transient--make-transient-map))
(setq transient--redisplay-map (transient--make-redisplay-map))
(setq transient--original-window (selected-window))
(setq transient--original-buffer (current-buffer))
(transient--redisplay)
(transient--init-transient)
(transient--suspend-which-key-mode))
(when (and (>= (minibuffer-depth) 1) transient--prefix)
(error "Cannot invoke %s while minibuffer is active %s"
this-command "on behalf of another prefix command"))
(transient--with-emergency-exit
(cond
((not name)
;; Switching between regular and edit mode.
(transient--pop-keymap 'transient--transient-map)
(transient--pop-keymap 'transient--redisplay-map)
(setq name (oref transient--prefix command))
(setq params (list :scope (oref transient--prefix scope))))
((not (or layout ; resuming parent/suspended prefix
transient-current-command)) ; entering child prefix
(transient--stack-zap)) ; replace suspended prefix, if any
(edit
;; Returning from help to edit.
(setq transient--editp t)))
(transient--init-objects name layout params)
(transient--history-init transient--prefix)
(setq transient--predicate-map (transient--make-predicate-map))
(setq transient--transient-map (transient--make-transient-map))
(setq transient--redisplay-map (transient--make-redisplay-map))
(setq transient--original-window (selected-window))
(setq transient--original-buffer (current-buffer))
(transient--redisplay)
(transient--init-transient)
(transient--suspend-which-key-mode)))
(cl-defgeneric transient-setup-children (group children)
"Setup the CHILDREN of GROUP.
If the value of the `setup-children' slot is non-nil, then call
that function with CHILDREN as the only argument and return the
value. Otherwise return CHILDREN as is."
(if (slot-boundp group 'setup-children)
(funcall (oref group setup-children) children)
children))
(defun transient--init-objects (name layout params)
(setq transient--prefix
(let ((proto (get name 'transient--prefix)))
(apply #'clone proto
:prototype proto
:level (or (alist-get
t (alist-get name transient-levels))
transient-default-level)
params)))
(transient-init-value transient--prefix)
(setq transient--layout
(or layout
(let ((levels (alist-get name transient-levels)))
(cl-mapcan (lambda (c) (transient--init-child levels c))
(append (get name 'transient--layout)
(and (not transient--editp)
(get 'transient-common-commands
'transient--layout)))))))
(setq transient--suffixes
(cl-labels ((s (def)
(cond
((stringp def) nil)
((listp def) (cl-mapcan #'s def))
((transient-group--eieio-childp def)
(cl-mapcan #'s (oref def suffixes)))
((transient-suffix--eieio-childp def)
(list def)))))
(cl-mapcan #'s transient--layout))))
(setq transient--prefix (transient--init-prefix name params))
(setq transient--layout (or layout (transient--init-suffixes name)))
(setq transient--suffixes (transient--flatten-suffixes transient--layout)))
(defun transient--init-prefix (name &optional params)
(let ((obj (let ((proto (get name 'transient--prefix)))
(apply #'clone proto
:prototype proto
:level (or (alist-get t (alist-get name transient-levels))
transient-default-level)
params))))
(transient-init-value obj)
obj))
(defun transient--init-suffixes (name)
(let ((levels (alist-get name transient-levels)))
(cl-mapcan (lambda (c) (transient--init-child levels c))
(append (get name 'transient--layout)
(and (not transient--editp)
(get 'transient-common-commands
'transient--layout))))))
(defun transient--flatten-suffixes (layout)
(cl-labels ((s (def)
(cond
((stringp def) nil)
((listp def) (cl-mapcan #'s def))
((transient-group--eieio-childp def)
(cl-mapcan #'s (oref def suffixes)))
((transient-suffix--eieio-childp def)
(list def)))))
(cl-mapcan #'s layout)))
(defun transient--init-child (levels spec)
(cl-etypecase spec
@@ -1637,7 +1714,7 @@ EDIT may be non-nil."
(when (transient--use-suffix-p obj)
(when-let ((suffixes
(cl-mapcan (lambda (c) (transient--init-child levels c))
children)))
(transient-setup-children obj children))))
(oset obj suffixes suffixes)
(list obj)))))))
@@ -1732,6 +1809,20 @@ EDIT may be non-nil."
(apply #'derived-mode-p if-not-derived))))
(t default)))
(defun transient--suffix-predicate (spec)
(let ((plist (nth 2 spec)))
(seq-some (lambda (prop)
(when-let ((pred (plist-get plist prop)))
(list prop pred)))
'( :if :if-not
:if-nil :if-non-nil
:if-mode :if-not-mode
:if-derived :if-not-derived
:inapt-if :inapt-if-not
:inapt-if-nil :inapt-if-non-nil
:inapt-if-mode :inapt-if-not-mode
:inapt-if-derived :inapt-if-not-derived))))
;;; Flow-Control
(defun transient--init-transient ()
@@ -1949,29 +2040,15 @@ EDIT may be non-nil."
(defun transient--emergency-exit ()
"Exit the current transient command after an error occurred.
Beside being used with `condition-case', this function also has
to be a member of `debugger-mode-hook', else the debugger would
be unusable and exiting it by pressing \"q\" would fail because
the transient command would still be active and that key would
either be unbound or do something else.
When no transient is active (i.e. when `transient--prefix') is
nil, then do nothing."
(transient--debug 'emergency-exit)
(when transient--prefix
(setq transient--stack nil)
(setq transient--exitp t)
(transient--pre-exit)
(transient--post-command)))
(add-hook 'debugger-mode-hook 'transient--emergency-exit)
(defmacro transient--with-emergency-exit (&rest body)
(declare (indent defun))
`(condition-case nil
,(macroexp-progn body)
(error (transient--emergency-exit))))
;;; Pre-Commands
(defun transient--do-stay ()
@@ -2275,6 +2352,20 @@ abstract `transient-infix' class must implement this function.
Non-infix suffix commands usually don't have a value."
nil)
(cl-defmethod transient-init-value :around ((obj transient-prefix))
"If bound, then call OBJ's `init-value' function.
Otherwise call the primary method according to objects class."
(if (slot-boundp obj 'init-value)
(funcall (oref obj init-value) obj)
(cl-call-next-method obj)))
(cl-defmethod transient-init-value :around ((obj transient-infix))
"If bound, then call OBJ's `init-value' function.
Otherwise call the primary method according to objects class."
(if (slot-boundp obj 'init-value)
(funcall (oref obj init-value) obj)
(cl-call-next-method obj)))
(cl-defmethod transient-init-value ((obj transient-prefix))
(if (slot-boundp obj 'value)
(oref obj value)
@@ -2356,9 +2447,10 @@ limited number of possible values should you replace this with a
simple method that does not handle history. (E.g. for a command
line switch the only possible values are \"use it\" and \"don't use
it\", in which case it is pointless to preserve history.)"
(with-slots (value multi-value allow-empty choices) obj
(with-slots (value multi-value always-read allow-empty choices) obj
(if (and value
(not multi-value)
(not always-read)
transient--prefix)
(oset obj value nil)
(let* ((overriding-terminal-local-map nil)
@@ -2391,7 +2483,8 @@ it\", in which case it is pointless to preserve history.)"
((and (equal value "\"\"") allow-empty)
(setq value "")))
(when value
(when (bound-and-true-p ivy-mode)
(when (and (bound-and-true-p ivy-mode)
(stringp (car transient--history)))
(set-text-properties 0 (length (car transient--history)) nil
(car transient--history)))
(setf (alist-get history-key transient-history)
@@ -2506,10 +2599,7 @@ prompt."
"Set the value of infix object OBJ to value.")
(cl-defmethod transient-infix-set ((obj transient-infix) value)
"Set the value of infix object OBJ to value.
This implementation should be suitable for almost all infix
commands."
"Set the value of infix object OBJ to value."
(oset obj value value))
(cl-defmethod transient-infix-set :around ((obj transient-argument) value)
@@ -2552,16 +2642,22 @@ If the current command was invoked from the transient prefix
command PREFIX, then return the active infix arguments. If
the current command was not invoked from PREFIX, then return
the set, saved or default value for PREFIX."
(delq nil (mapcar 'transient-infix-value (transient-suffixes prefix))))
(defun transient-suffixes (prefix)
"Return the suffix objects of the transient prefix command PREFIX."
(if (eq transient-current-command prefix)
(delq nil (mapcar 'transient-infix-value transient-current-suffixes))
(let ((transient--prefix nil)
(transient--layout nil)
(transient--suffixes nil))
(transient--init-objects prefix nil nil)
(delq nil (mapcar 'transient-infix-value transient--suffixes)))))
transient-current-suffixes
(let ((transient--prefix (transient--init-prefix prefix)))
(transient--flatten-suffixes
(transient--init-suffixes prefix)))))
(defun transient-get-value ()
(delq nil (mapcar 'transient-infix-value transient-current-suffixes)))
(delq nil (mapcar (lambda (obj)
(and (or (not (slot-exists-p obj 'unsavable))
(not (oref obj unsavable)))
(transient-infix-value obj)))
transient-current-suffixes)))
(cl-defgeneric transient-infix-value (obj)
"Return the value of the suffix object OBJ.
@@ -2610,7 +2706,7 @@ contribute to the value of the transient."
nil)
(cl-defmethod transient-infix-value ((obj transient-files))
"Return (concat ARGUMENT VALUE) or nil.
"Return (cons ARGUMENT VALUE) or nil.
ARGUMENT and VALUE are the values of the respective slots of OBJ.
If VALUE is nil, then return nil. VALUE may be the empty string,
@@ -2618,6 +2714,25 @@ which is not the same as nil."
(when-let ((value (oref obj value)))
(cons (oref obj argument) value)))
;;;; Utilities
(defun transient-arg-value (arg args)
"Return the value of ARG as it appears in ARGS.
For a switch return a boolean. For an option return the value as
a string, using the empty string for the empty value, or nil if
the option does not appear in ARGS."
(if (string-match-p "=\\'" arg)
(save-match-data
(when-let ((match (let ((re (format "\\`%s\\(?:=\\(.+\\)\\)?\\'"
(substring arg 0 -1))))
(cl-find-if (lambda (a)
(and (stringp a)
(string-match re a)))
args))))
(or (match-string 1 match) "")))
(and (member arg args) t)))
;;; History
(cl-defgeneric transient--history-key (obj)
@@ -2751,12 +2866,14 @@ have a history of their own.")
(insert desc ?\n)))
(cl-defmethod transient--insert-group ((group transient-row))
(transient--maybe-pad-keys group)
(dolist (suffix (oref group suffixes))
(insert (transient-format suffix))
(insert " "))
(insert ?\n))
(cl-defmethod transient--insert-group ((group transient-column))
(transient--maybe-pad-keys group)
(dolist (suffix (oref group suffixes))
(let ((str (transient-format suffix)))
(insert str)
@@ -2767,6 +2884,7 @@ have a history of their own.")
(let* ((columns
(mapcar
(lambda (column)
(transient--maybe-pad-keys column group)
(let ((rows (mapcar 'transient-format (oref column suffixes))))
(when-let ((desc (transient-format-description column)))
(push desc rows))
@@ -2789,9 +2907,11 @@ have a history of their own.")
(let* ((subgroups (oref group suffixes))
(n (length subgroups)))
(dotimes (s n)
(transient--insert-group (nth s subgroups))
(when (< s (1- n))
(insert ?\n)))))
(let ((subgroup (nth s subgroups)))
(transient--maybe-pad-keys subgroup group)
(transient--insert-group subgroup)
(when (< s (1- n))
(insert ?\n))))))
(cl-defgeneric transient-format (obj)
"Format and return OBJ for display.
@@ -2946,6 +3066,9 @@ is nil, then use \"(BUG: no description)\" as the description.
If the OBJ's `key' is currently unreachable, then apply the face
`transient-unreachable' to the complete string."
(let ((desc (or (cl-call-next-method obj)
(and (slot-boundp transient--prefix 'suffix-description)
(funcall (oref transient--prefix suffix-description)
obj))
(propertize "(BUG: no description)" 'face 'error))))
(if (transient--key-unreachable-p obj)
(propertize desc 'face 'transient-unreachable)
@@ -3009,6 +3132,34 @@ If the OBJ's `key' is currently unreachable, then apply the face
(let ((val (lookup-key keymap key)))
(and val (not (integerp val)) val)))
(defun transient--maybe-pad-keys (group &optional parent)
(when-let ((pad (if (slot-boundp group 'pad-keys)
(oref group pad-keys)
(and parent
(slot-boundp parent 'pad-keys)
(oref parent pad-keys)))))
(let ((width (apply #'max
(cons (if (integerp pad) pad 0)
(mapcar (lambda (suffix)
(length (oref suffix key)))
(oref group suffixes))))))
(dolist (suffix (oref group suffixes))
(oset suffix key
(truncate-string-to-width (oref suffix key) width nil ?\s))))))
(defun transient-command-summary-or-name (obj)
"Return the summary or name of the command represented by OBJ.
If the command has a doc-string, then return the first line of
that, else its name.
Intended to be temporarily used as the `:suffix-description' of
a prefix command, while porting a regular keymap to a transient."
(let ((command (transient--suffix-symbol (oref obj command))))
(if-let ((doc (documentation command)))
(propertize (car (split-string doc "\n")) 'face 'font-lock-doc-face)
(propertize (symbol-name command) 'face 'font-lock-function-name-face))))
;;; Help
(cl-defgeneric transient-show-help (obj)
@@ -3381,6 +3532,18 @@ we stop there."
(push (funcall function (car acc) elt) acc))
(nreverse acc)))
(defun transient-plist-to-alist (plist)
(let (alist)
(while plist
(push (cons (let* ((symbol (pop plist))
(name (symbol-name symbol)))
(if (eq (aref name 0) ?:)
(intern (substring name 1))
symbol))
(pop plist))
alist))
(nreverse alist)))
;;; Font-Lock
(defconst transient-font-lock-keywords
@@ -3398,6 +3561,37 @@ we stop there."
(font-lock-add-keywords 'emacs-lisp-mode transient-font-lock-keywords)
;;; Auxiliary Classes
;;;; `transient-lisp-variable'
(defclass transient-lisp-variable (transient-variable)
((reader :initform transient-lisp-variable--reader)
(always-read :initform t)
(set-value :initarg :set-value :initform set))
"[Experimental] Class used for Lisp variables.")
(cl-defmethod transient-init-value ((obj transient-lisp-variable))
(oset obj value (symbol-value (oref obj variable))))
(cl-defmethod transient-infix-set ((obj transient-lisp-variable) value)
(funcall (oref obj set-value)
(oref obj variable)
(oset obj value value)))
(cl-defmethod transient-format-description ((obj transient-lisp-variable))
(or (oref obj description)
(symbol-name (oref obj variable))))
(cl-defmethod transient-format-value ((obj transient-lisp-variable))
(propertize (prin1-to-string (oref obj value))
'face 'transient-value))
(cl-defmethod transient-prompt ((obj transient-lisp-variable))
(format "Set %s: " (oref obj variable)))
(defun transient-lisp-variable--reader (prompt initial-input _history)
(read--expression prompt initial-input))
;;; _
(provide 'transient)
;; Local Variables:

View File

@@ -1,7 +1,7 @@
This is transient.info, produced by makeinfo version 6.5 from
transient.texi.
Copyright (C) 2018-2020 Jonas Bernoulli <jonas@bernoul.li>
Copyright (C) 2018-2021 Jonas Bernoulli <jonas@bernoul.li>
You can redistribute this document and/or modify it under the terms
of the GNU General Public License as published by the Free Software
@@ -44,9 +44,9 @@ reading a new value in the minibuffer.
Calling a suffix command usually causes the transient to be exited
but suffix commands can also be configured to not exit the transient.
This manual is for Transient version 0.2.0 (v0.2.0-8-gc94cff7+1).
This manual is for Transient version 0.2.0 (v0.2.0-73-gf086cb62+1).
Copyright (C) 2018-2020 Jonas Bernoulli <jonas@bernoul.li>
Copyright (C) 2018-2021 Jonas Bernoulli <jonas@bernoul.li>
You can redistribute this document and/or modify it under the terms
of the GNU General Public License as published by the Free Software
@@ -430,12 +430,14 @@ value is saved to its history. These values can be cycled through the
same way one can cycle through the history of commands that read
user-input in the minibuffer.
M-p (transient-history-prev)
C-M-p (transient-history-prev)
C-x p (transient-history-prev)
This command switches to the previous value used for the active
transient.
M-n (transient-history-next)
C-M-n (transient-history-next)
C-x n (transient-history-next)
This command switches to the next value used for the active
transient.
@@ -975,9 +977,9 @@ constructor of that class.
These predicates can also be used on individual suffixes and are
only documented once, see *note Predicate Slots::.
Finally the value of :hide, if non-nil, is a predicate that
controls whether the group is hidden by default. The key bindings
for suffixes of a hidden group should all use the same prefix key.
The value of :hide, if non-nil, is a predicate that controls
whether the group is hidden by default. The key bindings for
suffixes of a hidden group should all use the same prefix key.
Pressing that prefix key should temporarily show the group and its
suffixes, which assumes that a predicate like this is used:
@@ -985,6 +987,17 @@ constructor of that class.
(eq (car transient--redisplay-key)
?\C-c)) ; the prefix key shared by all bindings
• The value of :setup-children, if non-nil, is a function that
takes two arguments the group object itself and a list of children.
The children are given as a, potentially empty, list consisting of
either group or suffix specifications. It can make arbitrary
changes to the children including constructing new children from
scratch. Also see transient-setup-children.
• The boolean :pad-keys argument controls whether keys of all
suffixes contained in a group are right padded, effectively
aligning the descriptions.
The ELEMENTs are either all subgroups (vectors), or all suffixes
(lists) and strings. (At least currently no group type exists that
would allow mixing subgroups with commands at the same level, though in
@@ -995,6 +1008,13 @@ lists that specify commands and strings. Strings are inserted verbatim.
The empty string can be used to insert gaps between suffixes, which is
particularly useful if the suffixes are outlined as a table.
Variables are supported inside group specifications. For example in
place of a direct subgroup specification, a variable can be used whose
value is a vector that qualifies as a group specification. Likewise a
variable can be used where a suffix specification is expected. Lists of
group or suffix specifications are also supported. Indirect
specifications are resolved when the transient prefix is being defined.
The form of suffix specifications is documented in the next node.

@@ -1042,11 +1062,18 @@ transient.
The next element is either a command or an argument. This is the
only argument that is mandatory in all cases.
• COMMAND is a symbol that is bound as a function, which has to be a
command. Any command will do; it does not need to have an object
associated with it (as would be the case if
transient-define-suffix or transient-define-infix were used to
define it).
Usually COMMAND is a symbol that is bound as a function, which has
to be defined or at least autoloaded as a command by the time the
containing prefix command is invoked.
Any command will do; it does not need to have an object associated
with it (as would be the case if transient-define-suffix or
transient-define-infix were used to define it).
The command can also be a closure or lambda expression, but that
should only be used for dynamic transients whose suffixes are
defined when the prefix command is invoked. See information about
the :setup-children function in *note Group Specifications::.
As mentioned above, the object that is associated with a command
can be used to set the default for certain values that otherwise
@@ -1171,7 +1198,7 @@ The preferred way of doing that is to call the transient-args
function, which for infix arguments serves about the same purpose as
prefix-arg serves for prefix arguments.
-- Function: transient-args &optional prefix
-- Function: transient-args prefix
This function returns the value of the transient prefix command
PREFIX.
@@ -1181,6 +1208,21 @@ function, which for infix arguments serves about the same purpose as
current command was not invoked from PREFIX, then it returns the
set, saved or default value for PREFIX.
-- Function: transient-arg-value arg args
This function return the value of ARG as it appears in ARGS.
For a switch a boolean is returned. For an option the value is
returned as a string, using the empty string for the empty value,
or nil if the option does not appear in ARGS.
-- Function: transient-suffixes prefix
This function returns the suffixes of the transient prefix command
PREFIX. This is a list of objects. This function should only be
used if you need the objects (as opposed to just their values) and
if the current command is not being invoked from PREFIX.
-- Variable: transient-current-suffixes
The suffixes of the transient from which this suffix command was
@@ -1459,6 +1501,20 @@ File: transient.info, Node: Group Methods, Next: Prefix Classes, Prev: Group
6.2 Group Methods
=================
-- Function: transient-setup-children group children
This generic function can be used to setup the children or a group.
The default implementation usually just returns the children
unchanged, but if the setup-children slot of GROUP is non-nil,
then it calls that function with CHILDREN as the only argument and
returns the value.
The children are given as a, potentially empty, list consisting of
either group or suffix specifications. These functions can make
arbitrary changes to the children including constructing new
children from scratch.
-- Function: transient--insert-group group
This generic function formats the group and its elements and
@@ -1776,10 +1832,25 @@ They are defined here anyway to allow sharing certain methods.
shortarg The short argument, e.g. -v.
value The value. Should not be accessed directly.
init-value Function that is responsable for setting the objects
value. If bound, then this is called with the object as the only
argument. Usually this is not bound, in which case the objects
primary transient-init-value method is called instead.
unsavable Whether the value of the suffix is not saved as part of
the prefixes.
multi-value For options, whether the option can have multiple
values. If non-nil, then default to use
completing-read-multiple.
always-read For options, whether to read a value on every
invocation. If this is nil, then options that have a value are
simply unset and have to be invoked a second time to set a new
value.
allow-empty For options, whether the empty string is a valid
value.
@@ -2242,18 +2313,20 @@ Appendix B Keystroke Index
(line 26)
* C-h: Getting Help for Suffix Commands.
(line 10)
* C-M-n: Using History. (line 17)
* C-M-p: Using History. (line 11)
* C-q: Aborting and Resuming Transients.
(line 36)
* C-x C-s: Saving Values. (line 25)
* C-x l: Enabling and Disabling Suffixes.
(line 49)
* C-x n: Using History. (line 18)
* C-x p: Using History. (line 12)
* C-x s: Saving Values. (line 20)
* C-x t: Common Suffix Commands.
(line 16)
* C-z: Aborting and Resuming Transients.
(line 42)
* M-n: Using History. (line 16)
* M-p: Using History. (line 11)
* M-x transient-resume: Aborting and Resuming Transients.
(line 55)
@@ -2268,8 +2341,10 @@ Appendix C Command Index
* transient-help: Getting Help for Suffix Commands.
(line 10)
* transient-history-next: Using History. (line 16)
* transient-history-next: Using History. (line 17)
* transient-history-next <1>: Using History. (line 18)
* transient-history-prev: Using History. (line 11)
* transient-history-prev <1>: Using History. (line 12)
* transient-quit-all: Aborting and Resuming Transients.
(line 36)
* transient-quit-one: Aborting and Resuming Transients.
@@ -2308,9 +2383,11 @@ Appendix D Function Index
* transient--do-suspend: Transient State. (line 144)
* transient--do-warn: Transient State. (line 121)
* transient--history-init: Prefix Classes. (line 10)
* transient--insert-group: Group Methods. (line 6)
* transient--insert-group: Group Methods. (line 20)
* transient-append-suffix: Modifying Existing Transients.
(line 47)
* transient-arg-value: Using Infix Arguments.
(line 32)
* transient-args: Using Infix Arguments.
(line 22)
* transient-define-argument: Defining Suffix and Infix Commands.
@@ -2350,10 +2427,13 @@ Appendix D Function Index
(line 51)
* transient-scroll-down: Other Commands. (line 18)
* transient-scroll-up: Other Commands. (line 12)
* transient-setup-children: Group Methods. (line 6)
* transient-show-help: Suffix Format Methods.
(line 30)
* transient-suffix-put: Modifying Existing Transients.
(line 65)
* transient-suffixes: Using Infix Arguments.
(line 40)

File: transient.info, Node: Variable Index, Prev: Function Index, Up: Top
@@ -2365,11 +2445,11 @@ Appendix E Variable Index
* Menu:
* transient-current-command: Using Infix Arguments.
(line 47)
(line 62)
* transient-current-prefix: Using Infix Arguments.
(line 41)
(line 56)
* transient-current-suffixes: Using Infix Arguments.
(line 32)
(line 47)
* transient-default-level: Enabling and Disabling Suffixes.
(line 38)
* transient-detect-key-conflicts: Other Options. (line 137)
@@ -2377,8 +2457,8 @@ Appendix E Variable Index
* transient-enable-popup-navigation: Other Options. (line 28)
* transient-force-fixed-pitch: Other Options. (line 151)
* transient-highlight-mismatched-keys: Other Options. (line 96)
* transient-history-file: Using History. (line 33)
* transient-history-limit: Using History. (line 38)
* transient-history-file: Using History. (line 35)
* transient-history-limit: Using History. (line 40)
* transient-levels-file: Enabling and Disabling Suffixes.
(line 44)
* transient-mode-line-format: Other Options. (line 71)
@@ -2393,46 +2473,46 @@ Appendix E Variable Index

Tag Table:
Node: Top751
Node: Introduction3673
Node: Usage9460
Node: Invoking Transients9794
Node: Aborting and Resuming Transients10826
Node: Common Suffix Commands13485
Node: Saving Values15239
Ref: Saving Values-Footnote-116497
Node: Using History16767
Node: Getting Help for Suffix Commands18308
Node: Enabling and Disabling Suffixes19701
Node: Other Commands22991
Node: Other Options23947
Node: Modifying Existing Transients31071
Node: Defining New Commands34473
Node: Defining Transients34809
Node: Binding Suffix and Infix Commands37240
Node: Group Specifications38094
Node: Suffix Specifications41426
Node: Defining Suffix and Infix Commands45001
Node: Using Infix Arguments48199
Node: Transient State50419
Node: Classes and Methods56292
Node: Group Classes58506
Node: Group Methods60422
Node: Prefix Classes61068
Node: Suffix Classes62160
Node: Suffix Methods64404
Node: Suffix Value Methods64725
Node: Suffix Format Methods67485
Node: Prefix Slots68937
Node: Suffix Slots71412
Node: Predicate Slots74263
Node: Related Abstractions and Packages75511
Node: Comparison With Prefix Keys and Prefix Arguments75798
Node: Comparison With Other Packages86110
Node: FAQ90300
Node: Keystroke Index94034
Node: Command Index95668
Node: Function Index97455
Node: Variable Index101612
Node: Introduction3675
Node: Usage9462
Node: Invoking Transients9796
Node: Aborting and Resuming Transients10828
Node: Common Suffix Commands13487
Node: Saving Values15241
Ref: Saving Values-Footnote-116499
Node: Using History16769
Node: Getting Help for Suffix Commands18408
Node: Enabling and Disabling Suffixes19801
Node: Other Commands23091
Node: Other Options24047
Node: Modifying Existing Transients31171
Node: Defining New Commands34573
Node: Defining Transients34909
Node: Binding Suffix and Infix Commands37340
Node: Group Specifications38194
Node: Suffix Specifications42523
Node: Defining Suffix and Infix Commands46481
Node: Using Infix Arguments49679
Node: Transient State52511
Node: Classes and Methods58384
Node: Group Classes60598
Node: Group Methods62514
Node: Prefix Classes63763
Node: Suffix Classes64855
Node: Suffix Methods67099
Node: Suffix Value Methods67420
Node: Suffix Format Methods70180
Node: Prefix Slots71632
Node: Suffix Slots74107
Node: Predicate Slots77633
Node: Related Abstractions and Packages78881
Node: Comparison With Prefix Keys and Prefix Arguments79168
Node: Comparison With Other Packages89480
Node: FAQ93670
Node: Keystroke Index97404
Node: Command Index99184
Node: Function Index101117
Node: Variable Index105621

End Tag Table