summaryrefslogtreecommitdiff
path: root/helm-command.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2015-06-03 21:54:24 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2015-06-03 21:54:24 +0200
commit9834be5bcbed66a1a97a7f07dc256ba08f7b8c4f (patch)
tree84507fde715de6594639b2be6e3c60960c06780e /helm-command.el
parent486b97448612ef902bd80fad474817056bcacce1 (diff)
Add some basics functions to list helm commands (#1044).
* helm-command.el (helm-cmd--get-current-function-name, helm-cmd--get-preconfigured-commands): New. (helm-M-x-read-extended-command): Allow using something else than obbaray.
Diffstat (limited to 'helm-command.el')
-rw-r--r--helm-command.el24
1 files changed, 21 insertions, 3 deletions
diff --git a/helm-command.el b/helm-command.el
index e17d2a0b..f86bb288 100644
--- a/helm-command.el
+++ b/helm-command.el
@@ -143,10 +143,28 @@ fuzzy matching is running its own sort function with a different algorithm."
(with-helm-window
(helm-display-mode-line (helm-get-current-source) 'force))))
-(defun helm-M-x-read-extended-command ()
+(defun helm-cmd--get-current-function-name ()
+ (save-excursion
+ (beginning-of-defun)
+ (cadr (split-string (buffer-substring-no-properties
+ (point-at-bol) (point-at-eol))))))
+
+(defun helm-cmd--get-preconfigured-commands (helm-directory)
+ (cl-loop with results
+ for f in (directory-files helm-directory t ".*\\.el\\'")
+ do (with-current-buffer (find-file-noselect f)
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "Preconfigured helm" nil t)
+ (push (helm-get-current-function-name) results))))
+ finally return results))
+
+(defun helm-M-x-read-extended-command (&optional collection)
"Read command name to invoke in `helm-M-x'.
Helm completion is not provided when executing or defining
-kbd macros."
+kbd macros.
+Optional arg COLLECTION is to allow using another COLLECTION
+than the default which is OBARRAY."
(if (or defining-kbd-macro executing-kbd-macro)
(if helm-mode
(unwind-protect
@@ -194,7 +212,7 @@ kbd macros."
(user-error msg))
(setq current-prefix-arg nil)
(helm-comp-read
- "M-x " obarray
+ "M-x " (or collection obarray)
:test 'commandp
:requires-pattern helm-M-x-requires-pattern
:name "Emacs Commands"