Skip to content

Commit

Permalink
Collect most commands in one section
Browse files Browse the repository at this point in the history
Now all commands are found in the "Commands" section, with the
exception of `transient--default-infix-command' and boring commands
that wrap around certain built-in commands, found in the "Popup
Navigation" and "Popup Isearch" sections.

Also rearrange the "Commands" section and split it into sub-sections.
  • Loading branch information
tarsius committed Nov 21, 2023
1 parent c885d12 commit 413f76a
Showing 1 changed file with 49 additions and 38 deletions.
87 changes: 49 additions & 38 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,7 @@ prefix argument and pivot to `transient-update'."
(put 'transient--do-minus 'transient-color 'transient-red)

;;; Commands
;;;; Noop

(defun transient-noop ()
"Do nothing at all."
Expand Down Expand Up @@ -2703,11 +2704,7 @@ Please open an issue and post the shown command log." :error)))
this-original-command
'transient-enable-popup-navigation))

(defun transient-suspend ()
"Suspend the current transient.
It can later be resumed using `transient-resume', while no other
transient is active."
(interactive))
;;;; Core

(defun transient-quit-all ()
"Exit all transients without saving the transient stack."
Expand All @@ -2731,7 +2728,41 @@ transient is active."
(interactive)
(setq transient--showp t))

(defvar transient-resume-mode)
(defun transient-push-button ()
"Invoke the suffix command represented by this button."
(interactive))

;;;; Suspend

(defun transient-suspend ()
"Suspend the current transient.
It can later be resumed using `transient-resume', while no other
transient is active."
(interactive))

(define-minor-mode transient-resume-mode
"Auxiliary minor-mode used to resume a transient after viewing help.")

(defun transient-resume ()
"Resume a previously suspended stack of transients."
(interactive)
(cond (transient--stack
(let ((winconf transient--restore-winconf))
(kill-local-variable 'transient--restore-winconf)
(when transient-resume-mode
(transient-resume-mode -1)
(quit-window))
(when winconf
(set-window-configuration winconf)))
(transient--stack-pop))
(transient-resume-mode
(kill-local-variable 'transient--restore-winconf)
(transient-resume-mode -1)
(quit-window))
(t
(message "No suspended transient command"))))

;;;; Help

(defun transient-help (&optional interactive)
"Show help for the active transient or one of its suffixes.\n\n(fn)"
Expand All @@ -2755,6 +2786,8 @@ transient is active."
"Type \\`q' to resume transient command."))
t))))

;;;; Level

(defun transient-set-level (&optional command level)
"Set the level of the transient or one of its suffix commands."
(interactive
Expand Down Expand Up @@ -2815,6 +2848,8 @@ transient is active."
(setq transient--all-levels-p (not transient--all-levels-p))
(setq transient--refreshp t))

;;;; Value

(defun transient-set ()
"Set active transient's value for this Emacs session."
(interactive)
Expand Down Expand Up @@ -2861,34 +2896,20 @@ transient is active."
(oset obj value (nth pos hst))
(mapc #'transient-init-value transient--suffixes))))

(defun transient-push-button ()
"Invoke the suffix command represented by this button."
(interactive))

(defun transient-resume ()
"Resume a previously suspended stack of transients."
(interactive)
(cond (transient--stack
(let ((winconf transient--restore-winconf))
(kill-local-variable 'transient--restore-winconf)
(when transient-resume-mode
(transient-resume-mode -1)
(quit-window))
(when winconf
(set-window-configuration winconf)))
(transient--stack-pop))
(transient-resume-mode
(kill-local-variable 'transient--restore-winconf)
(transient-resume-mode -1)
(quit-window))
(t
(message "No suspended transient command"))))
;;;; Auxiliary

(defun transient-toggle-common ()
"Toggle whether common commands are permanently shown."
(interactive)
(setq transient-show-common-commands (not transient-show-common-commands)))

(defun transient-toggle-debug ()
"Toggle debugging statements for transient commands."
(interactive)
(setq transient--debug (not transient--debug))
(message "Debugging transient %s"
(if transient--debug "enabled" "disabled")))

(transient-define-suffix transient-echo-arguments (arguments)
"Show the transient's active ARGUMENTS in the echo area.
Intended for use in prefixes used for demonstration purposes,
Expand Down Expand Up @@ -4042,16 +4063,6 @@ Suffixes on levels %s and %s are unavailable.\n"
(propertize (format ">=%s" (1+ level))
'face 'transient-disabled-suffix))))))

(define-minor-mode transient-resume-mode
"Auxiliary minor-mode used to resume a transient after viewing help.")

(defun transient-toggle-debug ()
"Toggle debugging statements for transient commands."
(interactive)
(setq transient--debug (not transient--debug))
(message "Debugging transient %s"
(if transient--debug "enabled" "disabled")))

;;; Popup Navigation

(defun transient-scroll-up (&optional arg)
Expand Down

0 comments on commit 413f76a

Please sign in to comment.