Subject: bug#13105: closed (Re: bug#13105: [PATCH] describe-variable shows name of the wrong buffer)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 21 Dec 2012 03:41:17 +0000

Your bug report

#13105: [PATCH] describe-variable shows name of the wrong buffer

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
13105: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13105
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#13105: [PATCH] describe-variable shows name of the wrong buffer
From: Chong Yidong <[email-masked]>
To: Kelly Dean <[email-masked]>
Cc: [email-masked]
Date: Fri, 21 Dec 2012 11:39:38 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Kelly Dean <[email-masked]> writes:

> On 24.2, describe-variable shows the name of the current buffer, even
> if passed a different buffer.
> Apply the attached descfunorvar.patch (see my post to emacs-devel,
> "Unify fn and var help to make learning elisp a little easier" for
> details) to 24.2. Then do emacs -Q, then
> C-SPC C-h o mark-active RET

I committed a slightly simpler fix.  Thanks.

Subject: [PATCH] describe-variable shows name of the wrong buffer
From: Kelly Dean <[email-masked]>
To: [email-masked]
Date: Thu, 6 Dec 2012 10:54:04 -0800 (PST)
List-Id: <debbugs-submit.debbugs.gnu.org>

On 24.2, describe-variable shows the name of the current buffer, even if passed a different buffer.
Apply the attached descfunorvar.patch (see my post to emacs-devel, "Unify fn and var help to make learning elisp a little easier" for details) to 24.2. Then do emacs -Q, then
C-SPC C-h o mark-active RET

It says, "Its value is t
Local in buffer *Help*"

It should say, "Its value is t
Local in buffer *scratch*"

The attached helpfnsbug.patch fixes the bug.
--- emacs-24.2/lisp/help-fns.el
+++ emacs-24.2/lisp/help-fns.el
@@ -897,6 +897,37 @@

 ;;;###autoload
+(defun describe-function-or-variable (symbol &optional buffer frame)
+  "Display the full documentation of the function or variable SYMBOL.
+If SYMBOL is a variable and has a buffer-local value in BUFFER or FRAME
+\(default to the current buffer and current frame), it is displayed along
+with the global value."
+  (interactive
+   (let* ((v-or-f (variable-at-point))
+	 (found (symbolp v-or-f))
+	 (v-or-f (if found v-or-f (function-called-at-point)))
+	 (found (or found v-or-f))
+	 (enable-recursive-minibuffers t)
+	 val)
+     (setq val (completing-read (if found
+				    (format
+				     "Describe function or variable (default %s): " v-or-f)
+				  "Describe function or variable: ")
+				obarray
+				(lambda (vv)
+				  (or (fboundp vv)
+				      (get vv 'variable-documentation)
+				      (and (boundp vv) (not (keywordp vv)))))
+				t nil nil
+				(if found (symbol-name v-or-f))))
+     (list (if (equal val "")
+	       v-or-f (intern val)))))
+  (if (not (symbolp symbol)) (message "You didn't specify a function or variable")
+    (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
+    (unless (frame-live-p frame) (setq frame (selected-frame)))
+    (help-xref-interned symbol buffer frame)))
+
+;;;###autoload
 (defun describe-syntax (&optional buffer)
   "Describe the syntax specifications in the syntax table of BUFFER.
 The descriptions are inserted in a help buffer, which is then displayed.
--- emacs-24.2/lisp/help-mode.el
+++ emacs-24.2/lisp/help-mode.el
@@ -627,10 +627,13 @@
 
 
 ;; Additional functions for (re-)creating types of help buffers.
-(defun help-xref-interned (symbol)
+
+;;;###autoload
+(defun help-xref-interned (symbol &optional buffer frame)
   "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL.
 Both variable, function and face documentation are extracted into a single
-help buffer."
+help buffer. If SYMBOL is a variable, include buffer-local value for optional
+BUFFER or FRAME."
   (with-current-buffer (help-buffer)
     ;; Push the previous item on the stack before clobbering the output buffer.
     (help-setup-xref nil nil)
@@ -646,7 +649,7 @@
 			  (get symbol 'variable-documentation))
 		  ;; Don't record the current entry in the stack.
 		  (setq help-xref-stack-item nil)
-		  (describe-variable symbol))))
+		  (describe-variable symbol buffer frame))))
       (cond
        (sdoc
 	;; We now have a help buffer on the variable.
--- emacs-24.2/lisp/help.el
+++ emacs-24.2/lisp/help.el
@@ -90,6 +90,7 @@
     (define-key map "k" 'describe-key)
     (define-key map "l" 'view-lossage)
     (define-key map "m" 'describe-mode)
+    (define-key map "o" 'describe-function-or-variable)
     (define-key map "n" 'view-emacs-news)
     (define-key map "p" 'finder-by-keyword)
     (define-key map "P" 'describe-package)
@@ -215,6 +216,7 @@
 m           Display documentation of current minor modes and current major mode,
               including their special commands.
 n           Display news of recent Emacs changes.
+o SYMBOL    Display the given function or variable's documentation and value.
 p TOPIC     Find packages matching a given topic keyword.
 r           Display the Emacs manual in Info mode.
 s           Display contents of current syntax table, plus explanations.
--- emacs-24.2/lisp/help-fns.el	2012-08-22 22:33:42.000000000 -0700
+++ emacs-24.2/lisp/help-fns.el.new2	2012-12-04 14:15:45.296692483 -0700
@@ -742,7 +742,7 @@
                 (princ (format "%socal in buffer %s; "
                                (if (get variable 'permanent-local)
                                    "Permanently l" "L")
-                               (buffer-name))))
+                               (with-current-buffer buffer (buffer-name)))))
                ((framep locus)
                 (princ (format "It is a frame-local variable; ")))
                ((terminal-live-p locus)