* How to get a list of all commands with given prefix?
@ 2014-03-18 17:58 Thorsten Jolitz
2014-03-18 18:03 ` Jambunathan K
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Thorsten Jolitz @ 2014-03-18 17:58 UTC (permalink / raw)
To: help-gnu-emacs
Hi List,
I wonder how I can easily get a list of all interactive commands with a
given prefix 'foo-' in a program (non-interactively)?
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-18 17:58 How to get a list of all commands with given prefix? Thorsten Jolitz
@ 2014-03-18 18:03 ` Jambunathan K
2014-03-19 0:09 ` Thorsten Jolitz
2014-03-18 18:16 ` Jambunathan K
2014-03-18 23:25 ` Drew Adams
2 siblings, 1 reply; 14+ messages in thread
From: Jambunathan K @ 2014-03-18 18:03 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: help-gnu-emacs
Thorsten Jolitz <tjolitz@gmail.com> writes:
> Hi List,
>
> I wonder how I can easily get a list of all interactive commands with a
> given prefix 'foo-' in a program (non-interactively)?
Use this as a starter.
(require 'cl)
(remove-if-not 'commandp obarray)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-18 18:03 ` Jambunathan K
@ 2014-03-19 0:09 ` Thorsten Jolitz
2014-03-19 15:27 ` Jambunathan K
0 siblings, 1 reply; 14+ messages in thread
From: Thorsten Jolitz @ 2014-03-19 0:09 UTC (permalink / raw)
To: help-gnu-emacs
Jambunathan K <kjambunathan@gmail.com> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> Hi List,
>>
>> I wonder how I can easily get a list of all interactive commands with a
>> given prefix 'foo-' in a program (non-interactively)?
>
>
> Use this as a starter.
>
> (require 'cl)
> (remove-if-not 'commandp obarray)
thanks, that brought me on the right track. So its really easy to get
a list of the impressive number of org-mode commands:
#+begin_src emacs-lisp
(setq org-cmds nil)
(defun omm-get-org-cmd-syms (s)
"Return a list of all symbols in obarray that are Org commands."
(and (commandp s)
(string-match "\\(^org-\\|^orgtbl-\\)" (symbol-name s))
(push s org-cmds)))
(mapatoms 'omm-get-org-cmd-syms)
(length org-cmds)
#+end_src
#+results:
: 639
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-19 0:09 ` Thorsten Jolitz
@ 2014-03-19 15:27 ` Jambunathan K
2014-03-19 8:03 ` Thorsten Jolitz
2014-03-19 8:14 ` Thorsten Jolitz
0 siblings, 2 replies; 14+ messages in thread
From: Jambunathan K @ 2014-03-19 15:27 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: help-gnu-emacs
Thorsten Jolitz <tjolitz@gmail.com> writes:
> thanks, that brought me on the right track. So its really easy to get
> a list of the impressive number of org-mode commands:
I believe, for a complete list, you may have to explicitly "load" all
the files that are part of Org. Otherwise, you are likely to miss out
on commands that are part of an un-loaded file.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-19 15:27 ` Jambunathan K
@ 2014-03-19 8:03 ` Thorsten Jolitz
2014-03-19 8:14 ` Thorsten Jolitz
1 sibling, 0 replies; 14+ messages in thread
From: Thorsten Jolitz @ 2014-03-19 8:03 UTC (permalink / raw)
To: help-gnu-emacs
Jambunathan K <kjambunathan@gmail.com> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> thanks, that brought me on the right track. So its really easy to get
>> a list of the impressive number of org-mode commands:
>
> I believe, for a complete list, you may have to explicitly "load" all
> the files that are part of Org. Otherwise, you are likely to miss out
> on commands that are part of an un-loaded file.
I think I do that anyway in my init file:
,--------------------------------------------
| ;; load elisp libraries while Emacs is idle
| (if (try-require 'idle-require)
| (progn
| (setq idle-require-symbols
| '(w3m org)) ...))
`--------------------------------------------
but I have to check if my settings really load all files of the Org
package.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-19 15:27 ` Jambunathan K
2014-03-19 8:03 ` Thorsten Jolitz
@ 2014-03-19 8:14 ` Thorsten Jolitz
2014-03-19 8:28 ` Jambunathan K
1 sibling, 1 reply; 14+ messages in thread
From: Thorsten Jolitz @ 2014-03-19 8:14 UTC (permalink / raw)
To: help-gnu-emacs
Jambunathan K <kjambunathan@gmail.com> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> thanks, that brought me on the right track. So its really easy to get
>> a list of the impressive number of org-mode commands:
>
> I believe, for a complete list, you may have to explicitly "load" all
> the files that are part of Org. Otherwise, you are likely to miss out
> on commands that are part of an un-loaded file.
I probably don't want the symbols from all that ob-xyz.el files, what I
get is 183 commands with keybindings - might that be a complete list of
the Org core commands?
#+begin_src emacs-lisp
;; 183
(length
'((org-ctrl-c-ret . "C-c RET")
(org-shiftup . "M-p")
(org-open-line . "C-o")
(org-reveal . "C-c C-r")
(org-ctrl-c-ctrl-c . "C-c C-c")
(org-clock-in . "C-c C-x TAB")
(org-metaright . "C-c C-x r")
(org-preview-latex-fragment . "C-c C-x C-l")
(org-shiftmetaleft . "C-c C-x L")
(org-toggle-fixed-width-section . "C-c :")
(org-babel-switch-to-session . "C-c C-v C-z")
(org-delete-backward-char . "DEL")
(org-beginning-of-line . "C-a")
(org-table-sum . "C-c +")
(org-columns . "C-c C-x C-c")
(org-agenda-set-restriction-lock . "C-c C-x <")
(org-table-toggle-formula-debugger . "C-c {")
(org-babel-mark-block . "C-c C-v C-M-h")
(org-insert-all-links . "C-c C-M-l")
(org-babel-insert-header-arg . "C-c C-v j")
(org-list-make-subtree . "C-c C-*")
(org-mobile-pull . "C-c C-x RET g")
(org-babel-execute-subtree . "C-c C-v s")
(org-paste-special . "C-c C-x C-y")
(org-babel-check-src-block . "C-c C-v c")
(org-self-insert-command . "SPC..~")
(org-toggle-tags-groups . "C-c C-x q")
(org-table-blank-field . "C-c SPC")
(org-archive-to-archive-sibling . "C-c C-x A")
(org-toggle-checkbox . "C-c C-x C-b")
(org-previous-link . "C-c C-x C-p")
(org-time-stamp . "C-c .")
(org-shiftcontrolleft . "M-S--")
(org-demote-subtree . "C-c C->")
(org-insert-link . "C-c C-l")
(org-attach . "C-c C-a")
(org-timer . "C-c C-x .")
(org-clone-subtree-with-time-shift . "C-c C-x c")
(org-clock-goto . "C-c C-x C-j")
(org-mobile-push . "C-c C-x RET p")
(org-update-statistics-cookies . "C-c #")
(org-shiftmetaright . "C-c C-x R")
(org-shiftmetadown . "C-c C-x D")
(org-return-indent . "C-j")
(org-toggle-inline-images . "C-c C-x C-v")
(org-copy-visible . "C-c C-x v")
(org-babel-goto-named-src-block . "C-c C-v g")
(org-timer-start . "C-c C-x 0")
(org-babel-goto-named-result . "C-c C-v C-r")
(org-clock-modify-effort-estimate . "C-c C-x C-e")
(org-clock-display . "C-c C-x C-d")
(org-shiftleft . "M--")
(org-backward-element . "M-{")
(org-babel-tangle-file . "C-c C-v f")
(org-feed-goto-inbox . "C-c C-x G")
(org-archive-subtree . "C-c $")
(org-toggle-time-stamp-overlays . "C-c C-x C-t")
(org-metaleft . "C-c C-x l")
(org-resolve-clocks . "C-c C-x C-z")
(org-table-copy-down . "<S-return>")
(org-add-note . "C-c C-z")
(org-end-of-line . "C-e")
(org-metaup . "C-c C-x u")
(org-ctrl-c-star . "C-c *")
(org-set-property . "C-c C-x p")
(org-deadline . "C-c C-d")
(org-insert-todo-heading . "C-c C-x M")
(org-shiftcontroldown . "<C-S-down>")
(org-goto . "C-c C-j")
(org-babel-demarcate-block . "C-c C-v d")
(org-open-at-point . "C-c C-o")
(org-babel-execute-buffer . "C-c C-v b")
(org-babel-load-in-session . "C-c C-v l")
(org-babel-expand-src-block . "C-c C-v v")
(org-shiftcontrolup . "<C-S-up>")
(org-babel-switch-to-session-with-code . "C-c C-v z")
(org-babel-sha1-hash . "C-c C-v a")
(org-footnote-action . "C-c C-x f")
(org-narrow-to-element . "C-x n e")
(org-clock-in-last . "C-c C-x C-x")
(org-narrow-to-subtree . "C-x n s")
(org-copy-special . "C-c C-x M-w")
(org-clock-report . "C-c C-x C-r")
(org-narrow-to-block . "C-x n b")
(org-todo . "C-c C-t")
(org-insert-drawer . "C-c C-x d")
(org-next-link . "C-c C-x C-n")
(org-shiftcontrolright . "M-S-+")
(org-refile . "C-c C-w")
(org-shiftdown . "M-n")
(org-toggle-comment . "C-c ;")
(org-forward-paragraph . "<C-down>")
(org-copy . "C-c M-w")
(org-metadown . "<M-down>")
(org-cut-special . "C-c C-x C-w")
(org-kill-line . "C-k")
(org-forward-element . "M-}")
(org-return . "RET")
(org-babel-previous-src-block . "C-c C-v C-p")
(org-redisplay-inline-images . "C-c C-x C-M-v")
(org-mark-ring-goto . "C-c &")
(org-table-create-or-convert-from-region . "C-c |")
(org-dblock-update . "C-c C-x C-u")
(org-set-property-and-value . "C-c C-x P")
(org-toggle-ordered-property . "C-c C-x o")
(org-insert-todo-heading-respect-content . "<C-S-return>")
(org-babel-tangle . "C-c C-v t")
(org-archive-subtree-default . "C-c C-x C-a")
(org-priority . "C-c ,")
(org-babel-open-src-block-result . "C-c C-v C-o")
(org-down-element . "C-c C-_")
(org-table-field-info . "C-c ?")
(org-edit-special . "C-c '")
(org-schedule . "C-c C-s")
(org-timer-set-timer . "C-c C-x ;")
(org-cycle . "TAB")
(org-babel-view-src-block-info . "C-c C-v I")
(org-reload . "C-c C-x !")
(org-babel-execute-maybe . "C-c C-v C-e")
(org-insert-heading . "M-RET")
(org-sparse-tree . "C-c /")
(org-table-rotate-recalc-marks . "C-#")
(org-previous-block . "C-c M-b")
(org-match-sparse-tree . "C-c \\\\")
(org-force-self-insert . "|")
(org-tree-to-indirect-buffer . "C-c C-x b")
(org-table-eval-formula . "C-c =")
(org-next-block . "C-c M-f")
(org-toggle-pretty-entities . "C-c C-x \\\\")
(org-emphasize . "C-c C-x C-f")
(org-table-toggle-coordinate-overlays . "C-c }")
(org-feed-update-all . "C-c C-x g")
(org-yank . "C-y")
(org-kill-note-or-show-branches . "C-c C-k")
(org-mark-element . "M-h")
(org-backward-paragraph . "<C-up>")
(org-advertized-archive-subtree . "C-c C-x C-s")
(org-clock-out . "C-c C-x C-o")
(org-mark-subtree . "C-c @")
(org-transpose-words . "M-t")
(org-promote-subtree . "C-c C-<")
(org-shiftright . "M-+")
(org-meta-return . "C-c C-x m")
(org-timer-item . "C-c C-x -")
(org-agenda-remove-restriction-lock . "C-c C-x >")
(org-time-stamp-inactive . "C-c !")
(org-set-effort . "C-c C-x e")
(org-delete-char . "C-d")
(org-insert-heading-respect-content . "<C-return>")
(org-capture . "C-c r")
(org-set-tags-command . "C-c C-q")
(org-date-from-calendar . "C-c <")
(org-goto-calendar . "C-c >")
(org-evaluate-time-range . "C-c C-y")
(org-cycle-agenda-files . "C-'")
(org-export-dispatch . "C-c C-e")
(org-backward-sentence . "M-a")
(org-shiftmetaup . "C-c C-x U")
(org-transpose-element . "C-M-t")
(org-babel-goto-src-block-head . "C-c C-v C-u")
(org-sort . "C-c ^")
(org-insert-columns-dblock . "C-c C-x i")
(org-forward-heading-same-level . "C-c C-f")
(org-babel-do-key-sequence-in-edit-buffer . "C-c C-v x")
(org-agenda . "C-c a")
(org-comment-dwim . "M-;")
(org-inc-effort . "C-c C-x E")
(org-force-cycle-archived . "<C-tab>")
(org-clock-cancel . "C-c C-x C-q")
(org-toggle-archive-tag . "C-c C-x a")
(org-table-create-with-table\\.el . "C-c ~")
(org-mark-ring-push . "C-c %")
(org-insert-last-stored-link . "C-c M-l")
(org-shifttab . "<backtab>")
(org-babel-next-src-block . "C-c C-v C-n")
(org-forward-sentence . "M-e")
(org-backward-heading-same-level . "C-c C-b")
(org-babel-describe-bindings . "C-c C-v h")
(org-babel-lob-ingest . "C-c C-v i")
(org-up-element . "C-c C-^")
(org-ctrl-c-minus . "C-c -")
(org-table-edit-field . "C-c `")
(org-reftex-citation . "C-c C-x [")))
#+end_src
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-19 8:14 ` Thorsten Jolitz
@ 2014-03-19 8:28 ` Jambunathan K
2014-03-19 8:29 ` Jambunathan K
0 siblings, 1 reply; 14+ messages in thread
From: Jambunathan K @ 2014-03-19 8:28 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: help-gnu-emacs
Thorsten Jolitz <tjolitz@gmail.com> writes:
> I probably don't want the symbols from all that ob-xyz.el files, what
> I get is 183 commands with keybindings - might that be a complete list
> of the Org core commands?
I have no personal use for all the list of commands.
But a good way to verify the comprehensiveness of your list, is to run a
rgrep for the search string `interactive' on "some subset of files" that
is of interest to you. (One of the ways this can be done, is to you
mark some selected files in a dired buffer and run a grep on those
shortlisted files. This is a good task to discover some of the useful
but less used Emacs features.)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-19 8:28 ` Jambunathan K
@ 2014-03-19 8:29 ` Jambunathan K
0 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2014-03-19 8:29 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: help-gnu-emacs
Jambunathan K <kjambunathan@gmail.com> writes:
> But a good way to verify the comprehensiveness of your list, is to run a
> rgrep for the search string `interactive' on "some subset of files" that
> is of interest to you.
and cross check the hit count with the number that you get with your
little snippet.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-18 17:58 How to get a list of all commands with given prefix? Thorsten Jolitz
2014-03-18 18:03 ` Jambunathan K
@ 2014-03-18 18:16 ` Jambunathan K
2014-03-19 7:59 ` Alex Bennée
2014-03-18 23:25 ` Drew Adams
2 siblings, 1 reply; 14+ messages in thread
From: Jambunathan K @ 2014-03-18 18:16 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: help-gnu-emacs
Thorsten Jolitz <tjolitz@gmail.com> writes:
> I wonder how I can easily get a list of all interactive commands with a
> given prefix 'foo-' in a program (non-interactively)?
If you are adventurous you can use the completion mechanism to give the
shortlisted candidates for you. You have to fill in the holes yourself.
If you are having very recent Emacs, experiment with
M-x icomplete-mode
`completion-category-overrides' is a good place to get an idea what sort
of "shortlisting" that completion mechanism offer by default.
Take a look at icomplete.el, minibuffer.el.
These are only pointers. You can fill in the details on your own.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-18 18:16 ` Jambunathan K
@ 2014-03-19 7:59 ` Alex Bennée
2014-03-19 8:23 ` Thorsten Jolitz
0 siblings, 1 reply; 14+ messages in thread
From: Alex Bennée @ 2014-03-19 7:59 UTC (permalink / raw)
To: Jambunathan K; +Cc: help-gnu-emacs, Thorsten Jolitz
Jambunathan K <kjambunathan@gmail.com> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> I wonder how I can easily get a list of all interactive commands with a
>> given prefix 'foo-' in a program (non-interactively)?
>
> If you are adventurous you can use the completion mechanism to give the
> shortlisted candidates for you. You have to fill in the holes yourself.
>
> If you are having very recent Emacs, experiment with
>
> M-x icomplete-mode
>
<snip>
There is also a useful helm completion mode called helm-descbinds which
I often use to find both interactive commands bound to keys in given
modes. There is also helm-apropos for more general searching through
defined functions and variables.
--
Alex Bennée
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-19 7:59 ` Alex Bennée
@ 2014-03-19 8:23 ` Thorsten Jolitz
2014-03-19 10:02 ` Michael Heerdegen
0 siblings, 1 reply; 14+ messages in thread
From: Thorsten Jolitz @ 2014-03-19 8:23 UTC (permalink / raw)
To: help-gnu-emacs
Alex Bennée <kernel-hacker@bennee.com> writes:
> Jambunathan K <kjambunathan@gmail.com> writes:
>
>> Thorsten Jolitz <tjolitz@gmail.com> writes:
>>
>>> I wonder how I can easily get a list of all interactive commands with a
>>> given prefix 'foo-' in a program (non-interactively)?
>>
>> If you are adventurous you can use the completion mechanism to give the
>> shortlisted candidates for you. You have to fill in the holes yourself.
>>
>> If you are having very recent Emacs, experiment with
>>
>> M-x icomplete-mode
>>
> <snip>
>
> There is also a useful helm completion mode called helm-descbinds which
> I often use to find both interactive commands bound to keys in given
> modes. There is also helm-apropos for more general searching through
> defined functions and variables.
Although I just started with it, I find helm really amazing for
interactive use. helm-apropos is great, did not know that, very good
replacement for doing
,-------------------
| C-h f RET foo- TAB
`-------------------
But I don't seem to have helm-descbinds - is that an extra package?
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: How to get a list of all commands with given prefix?
2014-03-18 17:58 How to get a list of all commands with given prefix? Thorsten Jolitz
2014-03-18 18:03 ` Jambunathan K
2014-03-18 18:16 ` Jambunathan K
@ 2014-03-18 23:25 ` Drew Adams
2014-03-19 1:07 ` Thorsten Jolitz
2 siblings, 1 reply; 14+ messages in thread
From: Drew Adams @ 2014-03-18 23:25 UTC (permalink / raw)
To: Thorsten Jolitz, help-gnu-emacs
> I wonder how I can easily get a list of all interactive commands with a
> given prefix 'foo-' in a program (non-interactively)?
(defun foo (prefix &optional msgp)
(interactive "sPrefix: \np")
(let ((cmds ()))
(mapatoms
(lambda (symb) (when (and (commandp symb)
(string-match-p
(format "\\`%s" (regexp-quote prefix))
(symbol-name symb)))
(push symb cmds))))
(when msgp (pp-eval-expression 'cmds))))
(Interactive only so you can check it.)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: How to get a list of all commands with given prefix?
2014-03-18 23:25 ` Drew Adams
@ 2014-03-19 1:07 ` Thorsten Jolitz
0 siblings, 0 replies; 14+ messages in thread
From: Thorsten Jolitz @ 2014-03-19 1:07 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
>> I wonder how I can easily get a list of all interactive commands with a
>> given prefix 'foo-' in a program (non-interactively)?
>
> (defun foo (prefix &optional msgp)
> (interactive "sPrefix: \np")
> (let ((cmds ()))
> (mapatoms
> (lambda (symb) (when (and (commandp symb)
> (string-match-p
> (format "\\`%s" (regexp-quote prefix))
> (symbol-name symb)))
> (push symb cmds))))
> (when msgp (pp-eval-expression 'cmds))))
>
> (Interactive only so you can check it.)
Ups, while I was writing my extended solution yours sit here for more
than an hour already ...
Well, I post mine anyway, it has one additional feature - it stores all
Org commands with their keybindings, if they have one, as an alist in a
global variable:
#+begin_src emacs-lisp
;; usage examples:
(setq omm-org-cmds-with-key-bindings nil)
(defun omm-get-org-cmd-syms-with-key-bindings (s)
"Store a list of symbols/keys pairs in obarray that are Org commands."
(and (commandp s)
(string-match "\\(^org-\\|^orgtbl-\\)" (symbol-name s))
(with-temp-buffer
(org-mode)
(let ((cmd-key (substitute-command-keys
(concat "\\[" (symbol-name s) "]"))))
(push
(cons s
(if (string-match "^M-x " cmd-key) nil cmd-key))
omm-org-cmds-with-key-bindings)))))
(mapatoms 'omm-get-org-cmd-syms-with-key-bindings)
(nth 20 omm-org-cmds-with-key-bindings)
#+end_src
#+results:
: (org-clock-in . C-c C-x TAB)
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-03-19 15:27 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-18 17:58 How to get a list of all commands with given prefix? Thorsten Jolitz
2014-03-18 18:03 ` Jambunathan K
2014-03-19 0:09 ` Thorsten Jolitz
2014-03-19 15:27 ` Jambunathan K
2014-03-19 8:03 ` Thorsten Jolitz
2014-03-19 8:14 ` Thorsten Jolitz
2014-03-19 8:28 ` Jambunathan K
2014-03-19 8:29 ` Jambunathan K
2014-03-18 18:16 ` Jambunathan K
2014-03-19 7:59 ` Alex Bennée
2014-03-19 8:23 ` Thorsten Jolitz
2014-03-19 10:02 ` Michael Heerdegen
2014-03-18 23:25 ` Drew Adams
2014-03-19 1:07 ` Thorsten Jolitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).