Last active
March 15, 2021 03:54
-
-
Save wrightmikea/4c6bfc57a72a5dd1d1b85993924d177e to your computer and use it in GitHub Desktop.
Emacs-SF - Additional Elisp related to 2021 March 5th Demo of (magit) transient by Mike Wright
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Emacs-SF - Additional Elisp related to 2021 March 5th Demo of (magit) transient by Mike Wright | |
;; in the following two examples, the call to invoke grep is replaced with a message displaying arguments instead. | |
;; 1 of 2 - the long way (18 non-blank lines of code) | |
(progn | |
(defun my-grep-function (&optional args) | |
(interactive | |
(list (transient-args 'my-grep-transient))) | |
(message "args %s" args)) | |
(define-infix-argument my-grep-transient:--regexp () | |
:description "Pattern" | |
:class 'transient-option | |
:shortarg "-e" | |
:argument "--regexp=") | |
(define-transient-command my-grep-transient () | |
"First (longer) Grep Menu" | |
["Arguments" | |
("-i" "Ignore" "--ignore-case") | |
("-v" "Invert" "--invert-match") | |
(my-grep-transient:--regexp)] | |
["Actions" | |
("g" "Grep" my-grep-function)]) | |
(my-grep-transient)) | |
;; 2 of 2 -simplified (13 non-blank lines of code) | |
(progn | |
(defun my-grep2-function (&optional args) | |
(interactive | |
(list (transient-args 'my-grep2-transient))) | |
(message "args %s" args)) | |
(define-transient-command my-grep2-transient () | |
"Second (simpler) Grep Menu" | |
["Arguments" | |
("-i" "Ignore" "--ignore-case") | |
("-v" "Invert" "--invert-match") | |
("-e" "Pattern" "--regexp=")] ;; | |
["Actions" | |
("g" "Grep" my-grep2-function)]) | |
(my-grep2-transient)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment