Subject: bug#22583: 25.1.50; find-function-search-for-symbol don't call find-function-after-hook

From: Tino Calancha <[email-masked]>
Date: Mon, 8 Feb 2016 00:18:13 +0900 (JST)

Hi emacs,

when calling find-function or find-variable
find-function-after-hook is run.
In the ther hand, find-function-search-for-symbol
don't run this hook.

For example,
I set find-function-after-hook to always visit source code
in a read-only buffer. This work for find-function/variable.

But sometimes, you call describe-function/describe-variable,
and, after reading the doc. string you decide to take a look
in the implementation. In that cases the buffer may not be
in read-only mode because find-function-after-hook is not called.

In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.29)
Repository revision: 90c647b97f0e62ca8bc2fc1d27f0170136277fb7

diff --git a/find-func.el b/find-func.el
index 0575ce4..e05f75c 100644
--- a/find-func.el
+++ b/find-func.el
@@ -302,7 +302,10 @@ The search is done in the source for library LIBRARY."
   (while (and (symbolp symbol) (get symbol 'definition-name))
     (setq symbol (get symbol 'definition-name)))
   (if (string-match "\\`src/\\(.*\\.\\(c\\|m\\)\\)\\'" library)
-      (find-function-C-source symbol (match-string 1 library) type)
+      (let* ((buf-pos (find-function-C-source symbol (match-string 1 library) type))
+             (buf     (car buf-pos)))
+        (when buf (with-current-buffer buf
+                    (run-hooks 'find-function-after-hook))) buf-pos)
     (when (string-match "\\.el\\(c\\)\\'" library)
       (setq library (substring library 0 (match-beginning 1))))
     ;; Strip extension from .emacs.el to make sure symbol is searched in
@@ -340,6 +343,7 @@ The search is done in the source for library LIBRARY."
                                "\\_>")
                        nil t)))
 		(progn
+                  (run-hooks 'find-function-after-hook)
 		  (beginning-of-line)
 		  (cons (current-buffer) (point)))
 	      (cons (current-buffer) nil))))))))