comparison lisp/apropos.el @ 67212:51e8cdc7d8a8

(apropos-parse-pattern): Doc fix. Set apropos-regexp directly, rather than expecting callers to do so. (apropos-command, apropos, apropos-value, apropos-documentation): Simplify calls to apropos-parse-pattern.
author Kim F. Storm <storm@cua.dk>
date Tue, 29 Nov 2005 23:52:59 +0000
parents 1a91d2217086
children 61ed6a33ffff
comparison
equal deleted inserted replaced
67211:6eba479e6fab 67212:51e8cdc7d8a8
299 (split-string pattern "[ \t]+") 299 (split-string pattern "[ \t]+")
300 pattern))) 300 pattern)))
301 301
302 (defun apropos-parse-pattern (pattern) 302 (defun apropos-parse-pattern (pattern)
303 "Rewrite a list of words to a regexp matching all permutations. 303 "Rewrite a list of words to a regexp matching all permutations.
304 If PATTERN is a string, that means it is already a regexp." 304 If PATTERN is a string, that means it is already a regexp.
305 This updates variables `apropos-pattern', `apropos-pattern-quoted',
306 `apropos-regexp', `apropos-words', and `apropos-all-words-regexp'."
305 (setq apropos-words nil 307 (setq apropos-words nil
306 apropos-all-words nil) 308 apropos-all-words nil)
307 (if (consp pattern) 309 (if (consp pattern)
308 ;; We don't actually make a regexp matching all permutations. 310 ;; We don't actually make a regexp matching all permutations.
309 ;; Instead, for e.g. "a b c", we make a regexp matching 311 ;; Instead, for e.g. "a b c", we make a regexp matching
323 (setq s a)) 325 (setq s a))
324 (setq syn nil)) 326 (setq syn nil))
325 (setq syn (cdr syn)))) 327 (setq syn (cdr syn))))
326 (setq apropos-words (cons s apropos-words) 328 (setq apropos-words (cons s apropos-words)
327 apropos-all-words (cons a apropos-all-words)))) 329 apropos-all-words (cons a apropos-all-words))))
328 (setq apropos-all-words-regexp (apropos-words-to-regexp apropos-all-words ".+")) 330 (setq apropos-all-words-regexp
329 (apropos-words-to-regexp apropos-words ".*?")) 331 (apropos-words-to-regexp apropos-all-words ".+"))
332 (setq apropos-regexp
333 (apropos-words-to-regexp apropos-words ".*?")))
330 (setq apropos-pattern-quoted (regexp-quote pattern) 334 (setq apropos-pattern-quoted (regexp-quote pattern)
331 apropos-all-words-regexp pattern 335 apropos-all-words-regexp pattern
332 apropos-pattern pattern))) 336 apropos-pattern pattern
337 apropos-regexp pattern)))
333 338
334 339
335 (defun apropos-calc-scores (str words) 340 (defun apropos-calc-scores (str words)
336 "Return apropos scores for string STR matching WORDS. 341 "Return apropos scores for string STR matching WORDS.
337 Value is a list of offsets of the words into the string." 342 Value is a list of offsets of the words into the string."
440 while a list of strings is used as a word list." 445 while a list of strings is used as a word list."
441 (interactive (list (apropos-read-pattern 446 (interactive (list (apropos-read-pattern
442 (if (or current-prefix-arg apropos-do-all) 447 (if (or current-prefix-arg apropos-do-all)
443 "command or function" "command")) 448 "command or function" "command"))
444 current-prefix-arg)) 449 current-prefix-arg))
445 (setq apropos-regexp (apropos-parse-pattern pattern)) 450 (apropos-parse-pattern pattern)
446 (let ((message 451 (let ((message
447 (let ((standard-output (get-buffer-create "*Apropos*"))) 452 (let ((standard-output (get-buffer-create "*Apropos*")))
448 (print-help-return-message 'identity)))) 453 (print-help-return-message 'identity))))
449 (or do-all (setq do-all apropos-do-all)) 454 (or do-all (setq do-all apropos-do-all))
450 (setq apropos-accumulator 455 (setq apropos-accumulator
506 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also 511 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also
507 show unbound symbols and key bindings, which is a little more 512 show unbound symbols and key bindings, which is a little more
508 time-consuming. Returns list of symbols and documentation found." 513 time-consuming. Returns list of symbols and documentation found."
509 (interactive (list (apropos-read-pattern "symbol") 514 (interactive (list (apropos-read-pattern "symbol")
510 current-prefix-arg)) 515 current-prefix-arg))
511 (setq apropos-regexp (apropos-parse-pattern pattern)) 516 (apropos-parse-pattern pattern)
512 (apropos-symbols-internal 517 (apropos-symbols-internal
513 (apropos-internal apropos-regexp 518 (apropos-internal apropos-regexp
514 (and (not do-all) 519 (and (not do-all)
515 (not apropos-do-all) 520 (not apropos-do-all)
516 (lambda (symbol) 521 (lambda (symbol)
575 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also looks 580 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also looks
576 at the function and at the names and values of properties. 581 at the function and at the names and values of properties.
577 Returns list of symbols and values found." 582 Returns list of symbols and values found."
578 (interactive (list (apropos-read-pattern "value") 583 (interactive (list (apropos-read-pattern "value")
579 current-prefix-arg)) 584 current-prefix-arg))
580 (setq apropos-regexp (apropos-parse-pattern pattern)) 585 (apropos-parse-pattern pattern)
581 (or do-all (setq do-all apropos-do-all)) 586 (or do-all (setq do-all apropos-do-all))
582 (setq apropos-accumulator ()) 587 (setq apropos-accumulator ())
583 (let (f v p) 588 (let (f v p)
584 (mapatoms 589 (mapatoms
585 (lambda (symbol) 590 (lambda (symbol)
621 documentation that is not stored in the documentation file and show key 626 documentation that is not stored in the documentation file and show key
622 bindings. 627 bindings.
623 Returns list of symbols and documentation found." 628 Returns list of symbols and documentation found."
624 (interactive (list (apropos-read-pattern "documentation") 629 (interactive (list (apropos-read-pattern "documentation")
625 current-prefix-arg)) 630 current-prefix-arg))
626 (setq apropos-regexp (apropos-parse-pattern pattern)) 631 (apropos-parse-pattern pattern)
627 (or do-all (setq do-all apropos-do-all)) 632 (or do-all (setq do-all apropos-do-all))
628 (setq apropos-accumulator () apropos-files-scanned ()) 633 (setq apropos-accumulator () apropos-files-scanned ())
629 (let ((standard-input (get-buffer-create " apropos-temp")) 634 (let ((standard-input (get-buffer-create " apropos-temp"))
630 (apropos-sort-by-scores apropos-documentation-sort-by-scores) 635 (apropos-sort-by-scores apropos-documentation-sort-by-scores)
631 f v sf sv) 636 f v sf sv)