]> code.delx.au - gnu-emacs/blobdiff - lisp/help-fns.el
*** empty log message ***
[gnu-emacs] / lisp / help-fns.el
index f62fadc22b53b571042a04ab228c2fdf2f8a4abb..97591deb81b19e20c50948b7b1a3338e2f9efde2 100644 (file)
@@ -1,7 +1,7 @@
 ;;; help-fns.el --- Complex help functions
 
 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001,
-;;   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help, internal
       (message "You didn't specify a function")
     (help-setup-xref (list #'describe-function function) (interactive-p))
     (save-excursion
-      (with-output-to-temp-buffer (help-buffer)
+      (with-help-window (help-buffer)
        (prin1 function)
        ;; Use " is " instead of a colon so that
        ;; it is easier to get out the function name using forward-sexp.
        (princ " is ")
        (describe-function-1 function)
-       (print-help-return-message)
        (with-current-buffer standard-output
          ;; Return the text we displayed.
          (buffer-string))))))
@@ -249,9 +248,12 @@ face (according to `face-differs-from-default-p')."
        src-file
       file-name)))
 
+(declare-function ad-get-advice-info "advice" (function))
+
 ;;;###autoload
 (defun describe-function-1 (function)
-  (let* ((advised (and (featurep 'advice) (ad-get-advice-info function)))
+  (let* ((advised (and (symbolp function) (featurep 'advice)
+                      (ad-get-advice-info function)))
         ;; If the function is advised, use the symbol that has the
         ;; real definition, if that symbol is already set up.
         (real-function
@@ -456,6 +458,28 @@ If ANY-SYMBOL is non-nil, don't insist the symbol be bound."
              (and (or any-symbol (boundp sym)) sym)))))
       0))
 
+(defun describe-variable-custom-version-info (variable)
+  (let ((custom-version (get variable 'custom-version))
+       (cpv (get variable 'custom-package-version))
+       (output nil))
+    (if custom-version
+       (setq output
+             (format "This variable was introduced, or its default value was changed, in\nversion %s of Emacs.\n"
+                     custom-version))
+      (when cpv
+       (let* ((package (car-safe cpv))
+              (version (car (cdr-safe cpv)))
+              (pkg-versions (assq package customize-package-emacs-version-alist))
+              (emacsv (cdr (assoc version pkg-versions))))
+         (if (and package version)
+             (setq output
+                   (format (concat "This variable was introduced, or its default value was changed, in\nversion %s of the %s package"
+                                   (if emacsv
+                                       (format " that is part of Emacs %s" emacsv))
+                                   ".\n")
+                           version package))))))
+    output))
+
 ;;;###autoload
 (defun describe-variable (variable &optional buffer frame)
   "Display the full documentation of VARIABLE (a symbol).
@@ -495,7 +519,7 @@ it is displayed along with the global value."
                    locus (variable-binding-locus variable)))))
        (help-setup-xref (list #'describe-variable variable buffer)
                         (interactive-p))
-       (with-output-to-temp-buffer (help-buffer)
+       (with-help-window (help-buffer)
          (with-current-buffer buffer
            (prin1 variable)
            ;; Make a hyperlink to the library if appropriate.  (Don't
@@ -646,17 +670,23 @@ it is displayed along with the global value."
              (with-current-buffer standard-output
                (insert (or doc "Not documented as a variable."))))
            ;; Make a link to customize if this variable can be customized.
-           (if (custom-variable-p variable)
-               (let ((customize-label "customize"))
+           (when (custom-variable-p variable)
+             (let ((customize-label "customize"))
+               (terpri)
+               (terpri)
+               (princ (concat "You can " customize-label " this variable."))
+               (with-current-buffer standard-output
+                 (save-excursion
+                   (re-search-backward
+                    (concat "\\(" customize-label "\\)") nil t)
+                   (help-xref-button 1 'help-customize-variable variable))))
+             ;; Note variable's version or package version
+             (let ((output (describe-variable-custom-version-info variable)))
+               (when output
                  (terpri)
                  (terpri)
-                 (princ (concat "You can " customize-label " this variable."))
-                 (with-current-buffer standard-output
-                   (save-excursion
-                     (re-search-backward
-                      (concat "\\(" customize-label "\\)") nil t)
-                     (help-xref-button 1 'help-customize-variable variable)))))
-           (print-help-return-message)
+                 (princ output))))
+
            (save-excursion
              (set-buffer standard-output)
              ;; Return the text we displayed.
@@ -671,7 +701,7 @@ BUFFER defaults to the current buffer."
   (interactive)
   (setq buffer (or buffer (current-buffer)))
   (help-setup-xref (list #'describe-syntax buffer) (interactive-p))
-  (with-output-to-temp-buffer (help-buffer)
+  (with-help-window (help-buffer)
     (let ((table (with-current-buffer buffer (syntax-table))))
       (with-current-buffer standard-output
        (describe-vector table 'internal-describe-syntax-value)
@@ -696,7 +726,7 @@ BUFFER should be a buffer or a buffer name."
   (interactive)
   (setq buffer (or buffer (current-buffer)))
   (help-setup-xref (list #'describe-categories buffer) (interactive-p))
-  (with-output-to-temp-buffer (help-buffer)
+  (with-help-window (help-buffer)
     (let ((table (with-current-buffer buffer (category-table))))
       (with-current-buffer standard-output
        (describe-vector table 'help-describe-category-set)