From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alexander Asteroth Newsgroups: gmane.emacs.devel Subject: Re: elisp code to list interactive functions Date: Thu, 04 Nov 2021 17:14:13 +0100 Message-ID: <874k8r7vai.fsf@condor.l7> References: <874k8sz67e.fsf@h-brs.de> <878ry4mf0u.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17027"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 27.1 Cc: Robert Pluim , Emacs developers To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 04 17:54:23 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mig0N-0004Bz-5y for ged-emacs-devel@m.gmane-mx.org; Thu, 04 Nov 2021 17:54:23 +0100 Original-Received: from localhost ([::1]:57986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mig0L-0002HZ-Ev for ged-emacs-devel@m.gmane-mx.org; Thu, 04 Nov 2021 12:54:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifNk-0000H8-AU for emacs-devel@gnu.org; Thu, 04 Nov 2021 12:14:28 -0400 Original-Received: from sv-2s11.infcs.de ([194.95.66.48]:51470 helo=ux-2s-mailproxy.inf.h-brs.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mifNf-0001wG-Sz for emacs-devel@gnu.org; Thu, 04 Nov 2021 12:14:26 -0400 Original-Received: from gyps.l7 (p5797302f.dip0.t-ipconnect.de [87.151.48.47]) (authenticated bits=0) by ux-2s-mailproxy.inf.h-brs.de (8.15.2/8.15.2/Debian-8ska0) with ESMTPSA id 1A4GEIfG029953 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 4 Nov 2021 17:14:18 +0100 Original-Received: from condor.h-brs.de (localhost [IPv6:::1]) by gyps.l7 (Postfix) with ESMTPS id 9EC2B382175; Thu, 4 Nov 2021 17:14:13 +0100 (CET) In-reply-to: X-Auth: by SMTP AUTH @ ux-2s11 X-MIMEDefang-Info-ge: Gescannt in Inf@FH-BRS, Regeln s. MiniFAQ E-Mail/Mailscanner X-Scanned-By: MIMEDefang @ FB02 @ H-BRS Received-SPF: pass client-ip=194.95.66.48; envelope-from=alexander.asteroth@h-brs.de; helo=ux-2s-mailproxy.inf.h-brs.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 04 Nov 2021 12:51:41 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:278685 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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=3D`emacsclient -e '(aa/show-interactive-commands)' | sed 's/\= " \"/)\\\\n(/g' | sed 's/\"//g'` > echo -e $BUFFERS=20 > else > emacsclient -ne "$1" >/dev/null > i3-msg -q '[class=3D"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,r= un' -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 : >> >> >>>>> On Thu, 04 Nov 2021 09:08:26 +0100, Alexander Asteroth said: >> >> Alexander> Dear all, >> Alexander> I don't know if I'm right here but I don't find a group t= hat is devoted >> Alexander> to elisp programming. I'm trying to write a little funtio= n that I can >> Alexander> call from emacsclient to get a list of interactive functi= ons >> 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 . I'm sure there must be a very simp= le solution to >> Alexander> this but somehow I get lost in the code in simple.el on m= y 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) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFQBAEBCgA6FiEEXU8UwBfdlxG/YNXXLg/GxGpHPCwFAmGEBtUcHGFsZXhhbmRl ci5hc3Rlcm90aEBoLWJycy5kZQAKCRAuD8bEakc8LIgwCACAtIR8nAfTYmcZJcEh 3vJrjiwms72/dw1sohPKyLraO0HFWX3/PeBTHi3Xo7Lu+Vu2mKXTJQ2ddUpWkPL3 ksQhvbNjvGERzh2iPNyb8bo7fEfyRg8TwcWa9k2OVAZyfm/ROwFVYo2cXaAjapTl ZXRmTzNCPBx89Psr7ucKVxyHdCmwNNU7o+7DzjPSouconCNLxPRr8UnmjR69QBRq zFT6Ttrf3TSbqsnY1LQ+gL8NPs96RmVMQAbzhJUYjTk4f/HLmQk1BZ1quAY/LFsq gTsIBPlDh+3xMoxPwpkLe42746C9hvQ9cYYQvV/H/WufhXAOeXBXMEXupIGG0rq/ Vev/ =4HEX -----END PGP SIGNATURE----- --=-=-=--