branch: master commit ae70443692509534e64fea8e66a24daa2587d1ec Author: Marat Safin <jei...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
counsel.el (counsel-major): Add Fixes #378 --- counsel.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/counsel.el b/counsel.el index 87d3636..8586c28 100644 --- a/counsel.el +++ b/counsel.el @@ -5824,6 +5824,20 @@ Additional actions:\\<ivy-minibuffer-map> `(("d" ,(lambda (x) (find-function (cdr x))) "definition") ("h" ,(lambda (x) (describe-function (cdr x))) "help"))) +;;;###autoload +(defun counsel-major () + (interactive) + (ivy-read "Major modes: " obarray + :predicate (lambda (f) + (and (commandp f) (string-match "-mode$" (symbol-name f)) + (or (and (autoloadp (symbol-function f)) + (let ((doc-split (help-split-fundoc (documentation f) f))) + ;; major mode starters have no arguments + (and doc-split (null (cdr (read (car doc-split))))))) + (null (help-function-arglist f))))) + :action (lambda (mode) (funcall (intern mode))) + :caller 'counsel-major)) + ;;* `counsel-mode' (defvar counsel-mode-map (let ((map (make-sparse-keymap)))