GNU bug report logs -
#13946
24.3; [PATCH] fix of apropos with words
Previous Next
Reported by: Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Date: Wed, 13 Mar 2013 15:24:02 UTC
Severity: normal
Tags: patch
Found in version 24.3
Done: Chong Yidong <cyd <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hello,
`apropos' family with plural words returns unexpected symbols and are
annoying. It is because `apropos-words-to-regexp' doesn't work as
documented/expected.
The following is revised `apropos-words-to-regexp'.
(defun apropos-words-to-regexp (words wild)
"Make regexp matching any two of the words in WORDS."
(if (null (cdr words))
(car words)
;; assure all words are independent objects for delq
(setq words (mapcar 'copy-sequence words))
(mapconcat
(lambda (w)
(concat "\\(?:" w "\\)" ;; parens for synonyms
wild
"\\(?:"
(mapconcat
'identity
(delete-dups (delq w (copy-sequence words)))
"\\|")
"\\)"))
(delete-dups (copy-sequence words))
"\\|")))
results:
(apropos-words-to-regexp '("A" "B") ".*?")
"\\(?:A\\).*?\\(?:B\\)\\|\\(?:B\\).*?\\(?:A\\)"
(apropos-words-to-regexp '("A" "B" "C") ".*?")
"\\(?:A\\).*?\\(?:B\\|C\\)\\|\\(?:B\\).*?\\(?:A\\|C\\)\\|\\(?:C\\).*?\\(?:A\\|B\\)"
(apropos-words-to-regexp '("A" "B" "B") ".*?")
"\\(?:A\\).*?\\(?:B\\)\\|\\(?:B\\).*?\\(?:A\\|B\\)"
(apropos-words-to-regexp '("A" "A" "B" "C" "C") ".*?")
"\\(?:A\\).*?\\(?:A\\|B\\|C\\)\\|\\(?:B\\).*?\\(?:A\\|C\\)\\|\\(?:C\\).*?\\(?:A\\|B\\|C\\)"
Additionally, in `apropos-parse-pattern', ".+" passed to
`apropos-words-to-regexp' wolud be better if ".+?".
Regards,
Shigeru.
This bug report was last modified 11 years and 160 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.