From: Shigeru Fukaya Date: Wed, 18 Dec 2013 04:46:49 +0000 (+0800) Subject: apropos.el (apropos-words-to-regexp): Fix algorithm. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~352 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ba874b6430893be55d48840a901aac4e64a4befc;p=emacs.git apropos.el (apropos-words-to-regexp): Fix algorithm. * apropos.el (apropos-words-to-regexp): Fix algorithm. Fixes: debbugs:13946 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 96410c6c929..fa79352e7a2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2013-12-18 Shigeru Fukaya + + * apropos.el (apropos-words-to-regexp): Fix algorithm (Bug#13946). + 2013-12-18 Glenn Morris * Makefile.in (BYTE_COMPILE_FLAGS): Set load-prefer-newer to t. diff --git a/lisp/apropos.el b/lisp/apropos.el index 7a1a6f6a75a..b7c5aaddcb1 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -341,16 +341,21 @@ before finding a label." (defun apropos-words-to-regexp (words wild) - "Make regexp matching any two of the words in WORDS." - (concat "\\(" - (mapconcat 'identity words "\\|") - "\\)" - (if (cdr words) - (concat wild - "\\(" - (mapconcat 'identity words "\\|") - "\\)") - ""))) + "Make regexp matching any two of the words in WORDS. +WILD should be a subexpression matching wildcards between matches." + (setq words (delete-dups (copy-sequence words))) + (if (null (cdr words)) + (car words) + (mapconcat + (lambda (w) + (concat "\\(?:" w "\\)" ;; parens for synonyms + wild "\\(?:" + (mapconcat 'identity + (delq w (copy-sequence words)) + "\\|") + "\\)")) + words + "\\|"))) ;;;###autoload (defun apropos-read-pattern (subject)