From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Apropos commands and regexps Date: 13 May 2002 21:26:18 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: <5x3cwv97dx.fsf@kfs2.cua.dk> References: <5xg00y41zj.fsf@kfs2.cua.dk> <87held70yy.fsf@emacswiki.org> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1021352212 29977 127.0.0.1 (14 May 2002 04:56:52 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 14 May 2002 04:56:52 +0000 (UTC) Cc: Kai.Grossjohann@cs.uni-dortmund.de (Kai =?iso-8859-1?q?Gro=DFjohann?=), emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 177UMm-0007nO-00 for ; Tue, 14 May 2002 06:56:52 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 177UXe-0002qO-00 for ; Tue, 14 May 2002 07:08:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 177UMu-0007Mi-00; Tue, 14 May 2002 00:57:00 -0400 Original-Received: from fepd.post.tele.dk ([195.41.46.149]) by fencepost.gnu.org with smtp (Exim 3.34 #1 (Debian)) id 177KZY-0000rr-00 for ; Mon, 13 May 2002 14:29:24 -0400 Original-Received: from kfs2.cua.dk.cua.dk ([80.62.38.68]) by fepD.post.tele.dk (InterMail vM.4.01.03.23 201-229-121-123-20010418) with SMTP id <20020513182535.ZKE7393.fepD.post.tele.dk@kfs2.cua.dk.cua.dk>; Mon, 13 May 2002 20:25:35 +0200 Original-To: Alex Schroeder In-Reply-To: <87held70yy.fsf@emacswiki.org> Original-Lines: 65 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:3891 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:3891 Alex Schroeder writes: > Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Gro=DFjohann) writes: >=20 > > storm@cua.dk (Kim F. Storm) writes: > > > >> E.g. C-h a open file RET would find any matching > >> > >> open.*file and file.*open > > > > Way cool! >=20 > I posted a similar thing in elisp some time back. Searching for it on > Google returned this: Interesting... However, my proposal is to make keyword matching the default (alternative) behaviour for all apropos commands. Your "all permutations" seems useful -- but I wonder whether it is overkill... If a user is searching for some command which does something "useful", it is already quite hard to guess the terms emacs may be using to accomplish a given task (e.g. some novice users may search for "change file" when they really should look for "switch buffer"). So my idea of just searching for any entry matching at least two keywords will find all the entries found by searching for all combinations - and it may find some entries the user didn't think about... >=20 > Von:Alex Schroeder (asc@bsiag.com) > Betrifft:Re: Emacs Boolean Help > Newsgroups:gnu.emacs.gnus > Datum:2000-08-17 10:07:22 PST >=20 > (defun ed-apropos (keywords) > "Search for KEYWORDS. > This uses `apropos'. All the keywords must match. > KEYWORDS can be a comma-separated list." > (interactive "sKeywords: (comma-separated) ") > (apropos (my-csv-string-to-regexp keywords))) >=20 > (defun my-csv-string-to-regexp (str) > "Translate comma separated values into regexp. > A,B,C turns into \\(A.*B.*C\\|A.*C.*B\\|B.*A.*C\\|B.*C.*A\\|C.*A.*B\\|C.*= B.*A\\) > (let* ((l (perms (split-string str ",\\s-*")))) > (mapconcat (function (lambda (n) > (mapconcat 'identity n ".*"))) l "\\|"))) >=20 > ;; thanks to Christoph Conrad > (require 'cl) > (defun perms (l) > (if (null l) > (list '()) > (mapcan #'(lambda( a ) > (mapcan #'(lambda( p ) > (list (cons a p))) > (perms (remove* a l :count 1)))) > l))) >=20 --=20 Kim F. Storm http://www.cua.dk