Skip to content

Instantly share code, notes, and snippets.

@wrightmikea
Last active March 15, 2021 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrightmikea/4c6bfc57a72a5dd1d1b85993924d177e to your computer and use it in GitHub Desktop.
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
;; 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