From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: How to get a list of all commands with given prefix? Date: Tue, 18 Mar 2014 16:25:53 -0700 (PDT) Message-ID: <06caca3d-1b40-407b-87f3-0ce7327d3c85@default> References: <87lhw7mlrg.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1395185222 24604 80.91.229.3 (18 Mar 2014 23:27:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Mar 2014 23:27:02 +0000 (UTC) To: Thorsten Jolitz , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 19 00:27:10 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WQ3PZ-0002us-EK for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Mar 2014 00:27:09 +0100 Original-Received: from localhost ([::1]:37854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQ3PY-00058L-PD for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Mar 2014 19:27:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQ3OY-00045B-LZ for help-gnu-emacs@gnu.org; Tue, 18 Mar 2014 19:26:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQ3OQ-0001Oh-2V for help-gnu-emacs@gnu.org; Tue, 18 Mar 2014 19:26:06 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:48146) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQ3OP-0001Od-Sb for help-gnu-emacs@gnu.org; Tue, 18 Mar 2014 19:25:58 -0400 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s2INPsJC026878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Mar 2014 23:25:55 GMT Original-Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s2INPsk3017801 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 18 Mar 2014 23:25:54 GMT Original-Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s2INPrD5025639; Tue, 18 Mar 2014 23:25:53 GMT In-Reply-To: <87lhw7mlrg.fsf@gmail.com> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6680.5000 (x86)] X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96596 Archived-At: > 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.)