[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1e38ed4 146/399: counsel.el (counsel-minor): Add command t
From: |
Oleh Krehel |
Subject: |
[elpa] master 1e38ed4 146/399: counsel.el (counsel-minor): Add command to toggle minor mode |
Date: |
Sat, 20 Jul 2019 14:57:12 -0400 (EDT) |
branch: master
commit 1e38ed4897381b575375ed8041b09cb8b81f98f2
Author: Iku Iwasa <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-minor): Add command to toggle minor mode
Like counsel-package, disabled minor modes are prefixed with "+" and
enabled minor modes are prefixed with "-".
By selecting one of them, the mode is called interactively. As a result,
toggle the minor mode enability.
Fixes #2000
---
counsel.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/counsel.el b/counsel.el
index 9b592a0..b7fea9a 100644
--- a/counsel.el
+++ b/counsel.el
@@ -5338,6 +5338,58 @@ specified by the `blddir' property."
:action #'counsel-compile--action
:caller 'counsel-compile))
+;;** `counsel-minor'
+(defun counsel--minor-candidates ()
+ "Return completion alist for `counsel-minor'.
+
+The alist element is cons of minor mode string with its lighter
+and minor mode symbol."
+ (delq nil
+ (mapcar
+ (lambda (mode)
+ (when (and (boundp mode) (commandp mode))
+ (let ((lighter (alist-get mode minor-mode-alist)))
+ (cons (concat
+ (if (symbol-value mode) "-" "+")
+ (symbol-name mode)
+ (propertize
+ (if lighter
+ (format " \"%s\""
+ (format-mode-line (cons t lighter)))
+ "")
+ 'face font-lock-string-face))
+ mode))))
+ minor-mode-list)))
+
+;;;###autoload
+(defun counsel-minor ()
+ "Enable or disable minor mode.
+
+Disabled minor modes are prefixed with \"+\", and
+selecting one of these will enable it.
+Enabled minor modes are prefixed with \"-\", and
+selecting one of these will enable it.
+
+Additional actions:\\<ivy-minibuffer-map>
+
+ \\[ivy-dispatching-done] d: Go to minor mode definition
+ \\[ivy-dispatching-done] h: Describe minor mode"
+
+ (interactive)
+ (ivy-read "Minor modes (enable +mode or disable -mode): "
+ (counsel--minor-candidates)
+ :require-match t
+ :sort t
+ :action (lambda (x)
+ (call-interactively (cdr x)))))
+
+(cl-pushnew '(counsel-minor . "^+") ivy-initial-inputs-alist :key #'car)
+
+(ivy-set-actions
+ 'counsel-minor
+ `(("d" ,(lambda (x) (find-function (cdr x))) "definition")
+ ("h" ,(lambda (x) (describe-function (cdr x))) "help")))
+
;;* `counsel-mode'
(defvar counsel-mode-map
(let ((map (make-sparse-keymap)))
- [elpa] master cd41f70 153/399: ivy-test.el: Add inhibit-message, (continued)
- [elpa] master cd41f70 153/399: ivy-test.el: Add inhibit-message, Oleh Krehel, 2019/07/20
- [elpa] master 1df4ccf 154/399: ivy.el (ivy-occur-revert-buffer): Add swiper-isearch, Oleh Krehel, 2019/07/20
- [elpa] master 4f1bbc1 151/399: swiper.el (swiper-isearch-function): Full point history for DEL, Oleh Krehel, 2019/07/20
- [elpa] master 0bf94f8 156/399: ivy.el (ivy--occur-press-update-window): Add swiper-isearch, Oleh Krehel, 2019/07/20
- [elpa] master 0d2ab52 157/399: swiper.el (swiper--isearch-occur-cands): Faster version, Oleh Krehel, 2019/07/20
- [elpa] master 1bf56c3 165/399: swiper.el (swiper--query-replace-setup): Fix for ivy--regex-ignore-order, Oleh Krehel, 2019/07/20
- [elpa] master 4492054 167/399: ivy.el (ivy--recompute-index): Speed up, Oleh Krehel, 2019/07/20
- [elpa] master 11b0007 158/399: swiper.el (swiper--action): Simplify, Oleh Krehel, 2019/07/20
- [elpa] master 1ebbb5f 136/399: swiper.el (swiper-isearch): Set swiper-min-highlight to 1, Oleh Krehel, 2019/07/20
- [elpa] master b34bf45 140/399: counsel.el (counsel-dired): Add, Oleh Krehel, 2019/07/20
- [elpa] master 1e38ed4 146/399: counsel.el (counsel-minor): Add command to toggle minor mode,
Oleh Krehel <=
- [elpa] master 2098d27 148/399: swiper.el: Set up occur for swiper-isearch, Oleh Krehel, 2019/07/20
- [elpa] master dceecd8 155/399: swiper.el (swiper-occur): Adapt to swiper-isearch, Oleh Krehel, 2019/07/20
- [elpa] master f38bb51 161/399: ivy.el (ivy--prompt-selectable-p): Allow to select "", Oleh Krehel, 2019/07/20
- [elpa] master 1b13ee8 162/399: ivy.el (ivy--use-selectable-prompt): Cache ivy--prompt-selected-p, Oleh Krehel, 2019/07/20
- [elpa] master 92ec03c 163/399: ivy-test.el (ivy-use-selectable-prompt): Add tests, Oleh Krehel, 2019/07/20
- [elpa] master b2693d1 160/399: counsel.el (counsel-locate-db-path): New defcustom, Oleh Krehel, 2019/07/20
- [elpa] master 44ea8b5 166/399: counsel.el (counsel-git-grep-cmd-function): Add, Oleh Krehel, 2019/07/20
- [elpa] master 502eae6 159/399: counsel.el (counsel--call): Rename to counsel--command, Oleh Krehel, 2019/07/20
- [elpa] master 115efb7 170/399: ivy.el (ivy--sorted-files): Work around all-completions returning $$, Oleh Krehel, 2019/07/20
- [elpa] master 6c858c1 168/399: ivy.el (ivy--filter): Improve performance with :matcher, Oleh Krehel, 2019/07/20