aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/apropos.el21
1 files changed, 15 insertions, 6 deletions
diff --git a/lisp/apropos.el b/lisp/apropos.el
index e40f94ccb8c..7cbda3cb678 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -373,9 +373,11 @@ kind of objects to search."
373 (user-error "No word list given")) 373 (user-error "No word list given"))
374 pattern))) 374 pattern)))
375 375
376(defun apropos-parse-pattern (pattern) 376(defun apropos-parse-pattern (pattern &optional multiline-p)
377 "Rewrite a list of words to a regexp matching all permutations. 377 "Rewrite a list of words to a regexp matching all permutations.
378If PATTERN is a string, that means it is already a regexp. 378If PATTERN is a string, that means it is already a regexp.
379MULTILINE-P, if non-nil, means produce a regexp that will match
380the words even if separated by newlines.
379This updates variables `apropos-pattern', `apropos-pattern-quoted', 381This updates variables `apropos-pattern', `apropos-pattern-quoted',
380`apropos-regexp', `apropos-words', and `apropos-all-words-regexp'." 382`apropos-regexp', `apropos-words', and `apropos-all-words-regexp'."
381 (setq apropos-words nil 383 (setq apropos-words nil
@@ -386,6 +388,9 @@ This updates variables `apropos-pattern', `apropos-pattern-quoted',
386 ;; any combination of two or more words like this: 388 ;; any combination of two or more words like this:
387 ;; (a|b|c).*(a|b|c) which may give some false matches, 389 ;; (a|b|c).*(a|b|c) which may give some false matches,
388 ;; but as long as it also gives the right ones, that's ok. 390 ;; but as long as it also gives the right ones, that's ok.
391 ;; (Actually, when MULTILINE-P is non-nil, instead of '.' we
392 ;; use a trick that would find a match even if the words are
393 ;; on different lines.
389 (let ((words pattern)) 394 (let ((words pattern))
390 (setq apropos-pattern (mapconcat 'identity pattern " ") 395 (setq apropos-pattern (mapconcat 'identity pattern " ")
391 apropos-pattern-quoted (regexp-quote apropos-pattern)) 396 apropos-pattern-quoted (regexp-quote apropos-pattern))
@@ -402,9 +407,13 @@ This updates variables `apropos-pattern', `apropos-pattern-quoted',
402 (setq apropos-words (cons s apropos-words) 407 (setq apropos-words (cons s apropos-words)
403 apropos-all-words (cons a apropos-all-words)))) 408 apropos-all-words (cons a apropos-all-words))))
404 (setq apropos-all-words-regexp 409 (setq apropos-all-words-regexp
405 (apropos-words-to-regexp apropos-all-words ".+")) 410 (apropos-words-to-regexp apropos-all-words
411 ;; The [^b-a] trick matches any
412 ;; character including a newline.
413 (if multiline-p "[^b-a]+?" ".+")))
406 (setq apropos-regexp 414 (setq apropos-regexp
407 (apropos-words-to-regexp apropos-words ".*?"))) 415 (apropos-words-to-regexp apropos-words
416 (if multiline-p "[^b-a]*?" ".*?"))))
408 (setq apropos-pattern-quoted (regexp-quote pattern) 417 (setq apropos-pattern-quoted (regexp-quote pattern)
409 apropos-all-words-regexp pattern 418 apropos-all-words-regexp pattern
410 apropos-pattern pattern 419 apropos-pattern pattern
@@ -787,7 +796,7 @@ Returns list of symbols and values found."
787 (interactive (list (apropos-read-pattern "value") 796 (interactive (list (apropos-read-pattern "value")
788 current-prefix-arg)) 797 current-prefix-arg))
789 (setq apropos--current (list #'apropos-value pattern do-all)) 798 (setq apropos--current (list #'apropos-value pattern do-all))
790 (apropos-parse-pattern pattern) 799 (apropos-parse-pattern pattern t)
791 (or do-all (setq do-all apropos-do-all)) 800 (or do-all (setq do-all apropos-do-all))
792 (setq apropos-accumulator ()) 801 (setq apropos-accumulator ())
793 (let (f v p) 802 (let (f v p)
@@ -827,7 +836,7 @@ Optional arg BUFFER (default: current buffer) is the buffer to check."
827 (interactive (list (apropos-read-pattern "value of buffer-local variable"))) 836 (interactive (list (apropos-read-pattern "value of buffer-local variable")))
828 (unless buffer (setq buffer (current-buffer))) 837 (unless buffer (setq buffer (current-buffer)))
829 (setq apropos--current (list #'apropos-local-value pattern buffer)) 838 (setq apropos--current (list #'apropos-local-value pattern buffer))
830 (apropos-parse-pattern pattern) 839 (apropos-parse-pattern pattern t)
831 (setq apropos-accumulator ()) 840 (setq apropos-accumulator ())
832 (let ((var nil)) 841 (let ((var nil))
833 (mapatoms 842 (mapatoms
@@ -869,7 +878,7 @@ Returns list of symbols and documentation found."
869 (interactive (list (apropos-read-pattern "documentation") 878 (interactive (list (apropos-read-pattern "documentation")
870 current-prefix-arg)) 879 current-prefix-arg))
871 (setq apropos--current (list #'apropos-documentation pattern do-all)) 880 (setq apropos--current (list #'apropos-documentation pattern do-all))
872 (apropos-parse-pattern pattern) 881 (apropos-parse-pattern pattern t)
873 (or do-all (setq do-all apropos-do-all)) 882 (or do-all (setq do-all apropos-do-all))
874 (setq apropos-accumulator () apropos-files-scanned ()) 883 (setq apropos-accumulator () apropos-files-scanned ())
875 (let ((standard-input (get-buffer-create " apropos-temp")) 884 (let ((standard-input (get-buffer-create " apropos-temp"))