emacs-devel
[Top][All Lists]
Advanced

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

Re: Apropos commands and regexps


From: Kim F. Storm
Subject: Re: Apropos commands and regexps
Date: 13 May 2002 21:26:18 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50

Alex Schroeder <address@hidden> writes:

> address@hidden (Kai Großjohann) writes:
> 
> > address@hidden (Kim F. Storm) writes:
> >
> >> E.g. C-h a open file RET  would find any matching
> >>
> >>         open.*file and file.*open
> >
> > Way cool!
> 
> 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...


> 
> Von:Alex Schroeder (address@hidden)
> Betrifft:Re: Emacs Boolean Help
> Newsgroups:gnu.emacs.gnus
> Datum:2000-08-17 10:07:22 PST
> 
> (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)))
> 
> (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 "\\|")))
> 
> ;; thanks to Christoph Conrad <address@hidden>
> (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)))
> 

-- 
Kim F. Storm <address@hidden> http://www.cua.dk




reply via email to

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