Subject: Re: 25.0.50; substitute-command-keys suggests M-x instead of key binding
From: Paul Eggert <[email-masked]>
To: Tassilo Horn <[email-masked]>
Cc: [email-masked]
Date: Sat, 5 Sep 2015 08:54:21 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks for the recipe involving only built-in commands, which made it easy for 
me to see the bug.  I installed the attached patch and am marking the bug as fixed.
From 089722365776406bfc64d7947f1c04180dfc1530 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sat, 5 Sep 2015 08:50:34 -0700
Subject: [PATCH] Fix describe-function keybinding confusion

* lisp/help-fns.el (describe-function-1): Compute signature
in the original buffer, not in standard-output, so that
substitute-command-keys uses the proper keybindings.
This fixes Bug#21412, introduced in commit
2015-06-11T10:23:[email-masked].
---
 lisp/help-fns.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index a1d121c..f5c7eb3 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -614,9 +614,9 @@ FILE is the file where FUNCTION was probably defined."
 	     (autoload-do-load real-def))
 
         (help-fns--key-bindings function)
-        (with-current-buffer standard-output
-	  (let ((doc (help-fns--signature function doc-raw sig-key
-                                          real-function nil)))
+        (let ((doc (help-fns--signature function doc-raw sig-key
+                                        real-function nil)))
+          (with-current-buffer standard-output
 	    (run-hook-with-args 'help-fns-describe-function-functions function)
 	    (insert "\n"
 		    (or doc "Not documented."))))))))
-- 
2.1.0