comparison lisp/help-fns.el @ 85464:b8519672d451

(describe-variable-custom-version-info): New function to return variable's version or package version note. (describe-variable): Use it, display result.
author John Paul Wallington <jpw@pobox.com>
date Sat, 20 Oct 2007 01:50:38 +0000
parents 364b2ff35290
children 494608f8dd24 4b09bb044f38
comparison
equal deleted inserted replaced
85463:771c063a16df 85464:b8519672d451
453 (save-match-data 453 (save-match-data
454 (when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str)) 454 (when (and str (string-match "\\`\\W*\\(.*?\\)\\W*\\'" str))
455 (setq sym (intern-soft (match-string 1 str))) 455 (setq sym (intern-soft (match-string 1 str)))
456 (and (or any-symbol (boundp sym)) sym))))) 456 (and (or any-symbol (boundp sym)) sym)))))
457 0)) 457 0))
458
459 (defun describe-variable-custom-version-info (variable)
460 (let ((custom-version (get variable 'custom-version))
461 (cpv (get variable 'custom-package-version))
462 (output nil))
463 (if custom-version
464 (setq output
465 (format "This variable was introduced, or its default value was changed, in\nversion %s of Emacs.\n"
466 custom-version))
467 (when cpv
468 (let* ((package (car-safe cpv))
469 (version (car (cdr-safe cpv)))
470 (pkg-versions (assq package customize-package-emacs-version-alist))
471 (emacsv (cdr (assoc version pkg-versions))))
472 (if (and package version)
473 (setq output
474 (format (concat "This variable was introduced, or its default value was changed, in\nversion %s of the %s package"
475 (if emacsv
476 (format " that is part of Emacs %s" emacsv))
477 ".\n")
478 version package))))))
479 output))
458 480
459 ;;;###autoload 481 ;;;###autoload
460 (defun describe-variable (variable &optional buffer frame) 482 (defun describe-variable (variable &optional buffer frame)
461 "Display the full documentation of VARIABLE (a symbol). 483 "Display the full documentation of VARIABLE (a symbol).
462 Returns the documentation as a string, also. 484 Returns the documentation as a string, also.
644 (if extra-line (terpri)) 666 (if extra-line (terpri))
645 (princ "Documentation:\n") 667 (princ "Documentation:\n")
646 (with-current-buffer standard-output 668 (with-current-buffer standard-output
647 (insert (or doc "Not documented as a variable.")))) 669 (insert (or doc "Not documented as a variable."))))
648 ;; Make a link to customize if this variable can be customized. 670 ;; Make a link to customize if this variable can be customized.
649 (if (custom-variable-p variable) 671 (when (custom-variable-p variable)
650 (let ((customize-label "customize")) 672 (let ((customize-label "customize"))
673 (terpri)
674 (terpri)
675 (princ (concat "You can " customize-label " this variable."))
676 (with-current-buffer standard-output
677 (save-excursion
678 (re-search-backward
679 (concat "\\(" customize-label "\\)") nil t)
680 (help-xref-button 1 'help-customize-variable variable))))
681 ;; Note variable's version or package version
682 (let ((output (describe-variable-custom-version-info variable)))
683 (when output
651 (terpri) 684 (terpri)
652 (terpri) 685 (terpri)
653 (princ (concat "You can " customize-label " this variable.")) 686 (princ output))))
654 (with-current-buffer standard-output 687
655 (save-excursion
656 (re-search-backward
657 (concat "\\(" customize-label "\\)") nil t)
658 (help-xref-button 1 'help-customize-variable variable)))))
659 (print-help-return-message) 688 (print-help-return-message)
660 (save-excursion 689 (save-excursion
661 (set-buffer standard-output) 690 (set-buffer standard-output)
662 ;; Return the text we displayed. 691 ;; Return the text we displayed.
663 (buffer-string)))))))) 692 (buffer-string))))))))