emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r115584: apropos.el (apropos-words-to-regexp): Fix a


From: Chong Yidong
Subject: [Emacs-diffs] trunk r115584: apropos.el (apropos-words-to-regexp): Fix algorithm.
Date: Wed, 18 Dec 2013 04:46:52 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115584
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/13946
author: Shigeru Fukaya <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Wed 2013-12-18 12:46:49 +0800
message:
  apropos.el (apropos-words-to-regexp): Fix algorithm.
  
  * apropos.el (apropos-words-to-regexp): Fix algorithm.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/apropos.el                apropos.el-20091113204419-o5vbwnq5f7feedwu-273
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-18 03:25:52 +0000
+++ b/lisp/ChangeLog    2013-12-18 04:46:49 +0000
@@ -1,3 +1,7 @@
+2013-12-18  Shigeru Fukaya <address@hidden>
+
+       * apropos.el (apropos-words-to-regexp): Fix algorithm (Bug#13946).
+
 2013-12-18  Glenn Morris  <address@hidden>
 
        * Makefile.in (BYTE_COMPILE_FLAGS): Set load-prefer-newer to t.

=== modified file 'lisp/apropos.el'
--- a/lisp/apropos.el   2013-08-04 20:18:11 +0000
+++ b/lisp/apropos.el   2013-12-18 04:46:49 +0000
@@ -341,16 +341,21 @@
 
 
 (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)


reply via email to

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