comparison lisp/help-mode.el @ 52876:64833a41c107

(help-xref-symbol-regexp): Treat newlines as whitespace. (help-make-xrefs): Only make cross-references for faces if preceded or followed by the word `face'. Do not make a cross-reference for variables without variable documentation, unless preceded by the word `variable'. Update doc string accordingly.
author Luc Teirlinck <teirllm@auburn.edu>
date Sun, 19 Oct 2003 03:58:43 +0000
parents 695cf19ef79e
children 80f69b7f19c1
comparison
equal deleted inserted replaced
52875:34db8be1fba8 52876:64833a41c107
211 (defconst help-xref-symbol-regexp 211 (defconst help-xref-symbol-regexp
212 (purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|" 212 (purecopy (concat "\\(\\<\\(\\(variable\\|option\\)\\|"
213 "\\(function\\|command\\)\\|" 213 "\\(function\\|command\\)\\|"
214 "\\(face\\)\\|" 214 "\\(face\\)\\|"
215 "\\(symbol\\)\\|" 215 "\\(symbol\\)\\|"
216 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)\\s-+\\)?" 216 "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)"
217 "[ \t\n]+\\)?"
217 ;; Note starting with word-syntax character: 218 ;; Note starting with word-syntax character:
218 "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'")) 219 "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'"))
219 "Regexp matching doc string references to symbols. 220 "Regexp matching doc string references to symbols.
220 221
221 The words preceding the quoted symbol can be used in doc strings to 222 The words preceding the quoted symbol can be used in doc strings to
276 277
277 Find cross-reference information in a buffer and activate such cross 278 Find cross-reference information in a buffer and activate such cross
278 references for selection with `help-follow'. Cross-references have 279 references for selection with `help-follow'. Cross-references have
279 the canonical form `...' and the type of reference may be 280 the canonical form `...' and the type of reference may be
280 disambiguated by the preceding word(s) used in 281 disambiguated by the preceding word(s) used in
281 `help-xref-symbol-regexp'. 282 `help-xref-symbol-regexp'. Faces only get cross-referenced if
283 preceded or followed by the word `face'. Variables without
284 variable documentation do not get cross-referenced, unless
285 preceded by the word `variable'.
282 286
283 If the variable `help-xref-mule-regexp' is non-nil, find also 287 If the variable `help-xref-mule-regexp' is non-nil, find also
284 cross-reference information related to multilingual environment 288 cross-reference information related to multilingual environment
285 \(e.g., coding-systems). This variable is also used to disambiguate 289 \(e.g., coding-systems). This variable is also used to disambiguate
286 the type of reference as the same way as `help-xref-symbol-regexp'. 290 the type of reference as the same way as `help-xref-symbol-regexp'.
340 (while (re-search-forward help-xref-symbol-regexp nil t) 344 (while (re-search-forward help-xref-symbol-regexp nil t)
341 (let* ((data (match-string 8)) 345 (let* ((data (match-string 8))
342 (sym (intern-soft data))) 346 (sym (intern-soft data)))
343 (if sym 347 (if sym
344 (cond 348 (cond
345 ((match-string 3) ; `variable' &c 349 ((match-string 3) ; `variable' &c
346 (and (boundp sym) ; `variable' doesn't ensure 350 (and (boundp sym) ; `variable' doesn't ensure
347 ; it's actually bound 351 ; it's actually bound
348 (help-xref-button 8 'help-variable sym))) 352 (help-xref-button 8 'help-variable sym)))
349 ((match-string 4) ; `function' &c 353 ((match-string 4) ; `function' &c
350 (and (fboundp sym) ; similarly 354 (and (fboundp sym) ; similarly
351 (help-xref-button 8 'help-function sym))) 355 (help-xref-button 8 'help-function sym)))
352 ((match-string 5) ; `face' 356 ((match-string 5) ; `face'
353 (and (facep sym) 357 (and (facep sym)
354 (help-xref-button 8 'help-face sym))) 358 (help-xref-button 8 'help-face sym)))
355 ((match-string 6)) ; nothing for `symbol' 359 ((match-string 6)) ; nothing for `symbol'
356 ((match-string 7) 360 ((match-string 7)
357 ;; this used: 361 ;;; this used:
358 ;; #'(lambda (arg) 362 ;;; #'(lambda (arg)
359 ;; (let ((location 363 ;;; (let ((location
360 ;; (find-function-noselect arg))) 364 ;;; (find-function-noselect arg)))
361 ;; (pop-to-buffer (car location)) 365 ;;; (pop-to-buffer (car location))
362 ;; (goto-char (cdr location)))) 366 ;;; (goto-char (cdr location))))
363 (help-xref-button 8 'help-function-def sym)) 367 (help-xref-button 8 'help-function-def sym))
364 ((and (boundp sym) (fboundp sym)) 368 ((and (boundp sym) (fboundp sym))
365 ;; We can't intuit whether to use the 369 ;; We can't intuit whether to use the
366 ;; variable or function doc -- supply both. 370 ;; variable or function doc -- supply both.
367 (help-xref-button 8 'help-symbol sym)) 371 (help-xref-button 8 'help-symbol sym))
368 ((boundp sym) 372 ((and
373 (boundp sym)
374 (documentation-property sym
375 'variable-documentation))
369 (help-xref-button 8 'help-variable sym)) 376 (help-xref-button 8 'help-variable sym))
370 ((fboundp sym) 377 ((fboundp sym)
371 (help-xref-button 8 'help-function sym)) 378 (help-xref-button 8 'help-function sym))
372 ((facep sym) 379 ((facep sym)
373 (help-xref-button 8 'help-face sym))))))) 380 (if (save-match-data (looking-at "[ \t\n]+face\\W"))
381 (help-xref-button 8 'help-face sym))))))))
374 ;; An obvious case of a key substitution: 382 ;; An obvious case of a key substitution:
375 (save-excursion 383 (save-excursion
376 (while (re-search-forward 384 (while (re-search-forward
377 ;; Assume command name is only word characters 385 ;; Assume command name is only word characters
378 ;; and dashes to get things like `use M-x foo.'. 386 ;; and dashes to get things like `use M-x foo.'.