-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement more suffix classes, esp. for lisp variables/options #116
Comments
A suffix class for minor-mode toggles with the current state indicator would be very welcome too. |
A simple implementation of that: (defun demo-minor-mode-description (obj)
(let* ((mode (oref obj command))
(lighter (cadr (assq mode minor-mode-alist))))
(when (and lighter (symbolp lighter))
(setq lighter (symbol-value lighter)))
(format
;; Personally I would just use the mode name, even if there is a lighter.
;; Other users might want to see the mode docstring instead/also.
(if lighter "%s %s (%s)" "%s %s")
(or lighter mode)
(cond ((symbol-value mode)
(format
(propertize "[%s|%s]" 'face 'transient-delimiter)
(propertize "on" 'face 'transient-value)
(propertize "off" 'face 'transient-infix-value)))
((format
(propertize "[%s|%s]" 'face 'transient-delimiter)
(propertize "on" 'face 'transient-infix-value)
(propertize "off" 'face '((:foreground "red") transient-value)))))
mode)))
(transient-define-prefix demo ()
:transient-suffix 'transient--do-stay
[("a" outline-minor-mode :description demo-minor-mode-description)])
;; (demo) It seems to me that the main complication is having to decide how to present the information. And that different users will have different opinions on what would be best, which makes it unappealing to add this to Transient itself. One problem with the above is that one has to add (defclass transient-minor-mode-command (transient-suffix)
())
(cl-defmethod transient-format-description ((obj transient-minor-mode-command))
(with-current-buffer transient--current-buffer
... as above...))
(transient-define-prefix demo ()
:transient-suffix 'transient--do-stay
;; Hurray! We don't have to specify :description. Oh no! We have to specify :class.
[("a" outline-minor-mode :class transient-minor-mode-command)]) |
An idea that might be worth considering, is adding a (transient-define-prefix demo ()
:transient-suffix 'transient--do-stay
:suffix-class 'transient-minor-mode-command
[("a" outline-minor-mode)
("b" another-minor-mode)]) Then again, we might want to generate the list of minor-mode suffixes, instead of hardcoding them, at which point having to specify the :class or :description slot for each suffix doesn't matter anymore. I might something like this to my |
When tackling this issue, also consider whether adding something like |
No description provided.
The text was updated successfully, but these errors were encountered: