emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elisp code to list interactive functions


From: Alexander Asteroth
Subject: Re: elisp code to list interactive functions
Date: Thu, 04 Nov 2021 17:14:13 +0100
User-agent: mu4e 1.4.15; emacs 27.1

Even better. That way one require statement becomes unnecessary.

Thanks,

        Alex

PS: Now in i3wm I can bind this to something like S-x to either start
programs or run interactive emacs commands (and focus emacs). Similar
behaviour as I had bound S-x to in EXWM :-)

The emacs code now looks like this:

> (defun aa/show-interactive-commands ()
>   (interactive)
>   (seq-sort-by #'length #'<
>              (cl-loop for symbol being the symbols
>                       when (commandp symbol)
>                       collect (symbol-name symbol))))

and I can call it from a script like:

> #!/bin/bash

> if [ $# -eq 0 ]
> then
>     BUFFERS=`emacsclient -e '(aa/show-interactive-commands)' | sed 's/\" 
> \"/)\\\\n(/g' | sed 's/\"//g'`
>     echo -e $BUFFERS 
> else
>     emacsclient -ne "$1" >/dev/null
>     i3-msg -q '[class="Emacs"] focus'
> fi

Which in turn is bound in i3 to Super-x to call

> bindsym Mod4+x exec "rofi -modi 'M-x:~/bin/emacs-interactive-command.sh,run' 
> -combi-modi M-x,run -show combi"


On Do, Nov 04 2021, 12:51:28, Philipp Stephani wrote:

> Am Do., 4. Nov. 2021 um 10:44 Uhr schrieb Robert Pluim <rpluim@gmail.com>:
>>
>> >>>>> On Thu, 04 Nov 2021 09:08:26 +0100, Alexander Asteroth 
>> >>>>> <alexander.asteroth@h-brs.de> said:
>>
>>     Alexander> Dear all,
>>     Alexander> I don't know if I'm right here but I don't find a group that 
>> is devoted
>>     Alexander> to elisp programming. I'm trying to write a little funtion 
>> that I can
>>     Alexander> call from emacsclient to get a list of interactive functions
>>     Alexander> available. The result shoud be a list of strings or just one 
>> string,
>>     Alexander> more or less what the *Completions* buffer displays when 
>> pressing
>>     Alexander> M-x followed by <TAB>. I'm sure there must be a very simple 
>> solution to
>>     Alexander> this but somehow I get lost in the code in simple.el on my 
>> search for
>>     Alexander> it.
>>
>> You mean something like this?
>>
>> (all-completions ""
>>                #'help--symbol-completion-table
>>                (lambda (f)
>>                  (commandp f)))
>>
>> (that returns quite a few things)
>
>
> That's using an internal function, which should not be used outside
> help.el and can go away at any time. But the following should also
> work:
> (cl-loop for symbol being the symbols
>    when (commandp symbol)
>    collect symbol)

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]