* bug#22583: 25.1.50; find-function-search-for-symbol don't call find-function-after-hook
@ 2016-02-07 15:18 Tino Calancha
2016-02-08 5:01 ` Dmitry Gutov
2016-02-18 0:52 ` bug#22583: 25.1.50; find-library " Tino Calancha
0 siblings, 2 replies; 10+ messages in thread
From: Tino Calancha @ 2016-02-07 15:18 UTC (permalink / raw
To: 22583
[-- Attachment #1: Type: text/plain, Size: 672 bytes --]
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
[-- Attachment #2: Type: text/plain, Size: 1207 bytes --]
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))))))))
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-function-search-for-symbol don't call find-function-after-hook
2016-02-07 15:18 bug#22583: 25.1.50; find-function-search-for-symbol don't call find-function-after-hook Tino Calancha
@ 2016-02-08 5:01 ` Dmitry Gutov
2016-02-08 12:50 ` Tino Calancha
2016-02-18 0:52 ` bug#22583: 25.1.50; find-library " Tino Calancha
1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Gutov @ 2016-02-08 5:01 UTC (permalink / raw
To: Tino Calancha, 22583
On 02/07/2016 05:18 PM, Tino Calancha wrote:
> 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.
find-function-search-for-symbol is a querying function. It can be used
by different consumers, e.g. xref-location-marker. I'm not sure the user
would want find-function-after-hook to run in every such case.
Maybe help-variable-def's button definition's help-function should run
the hook explicitly instead.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-function-search-for-symbol don't call find-function-after-hook
2016-02-08 5:01 ` Dmitry Gutov
@ 2016-02-08 12:50 ` Tino Calancha
0 siblings, 0 replies; 10+ messages in thread
From: Tino Calancha @ 2016-02-08 12:50 UTC (permalink / raw
To: Dmitry Gutov; +Cc: Tino Calancha, 22583
[-- Attachment #1: Type: text/plain, Size: 425 bytes --]
>find-function-search-for-symbol is a querying function. It can be used by different consumers, e.g. xref-location-marker.
>I'm not sure the user would want find-function-after-hook to run in every such case.
Right: the hook may be unnecessary called many times. Not good.
>Maybe help-variable-def's button definition's help-function should run the hook explicitly instead.
Thanks for the tip. This way looks more sensible.
[-- Attachment #2: Type: text/plain, Size: 830 bytes --]
diff --git a/help-mode.el b/help-mode.el
index 22e5386..9c512bd 100644
--- a/help-mode.el
+++ b/help-mode.el
@@ -202,6 +202,7 @@ The format is (FUNCTION ARGS...).")
(let ((location
(find-function-search-for-symbol fun type file)))
(pop-to-buffer (car location))
+ (run-hooks 'find-function-after-hook)
(if (cdr location)
(goto-char (cdr location))
(message "Unable to find location in file"))))
@@ -231,6 +232,7 @@ The format is (FUNCTION ARGS...).")
(setq file (help-C-file-name var 'var)))
(let ((location (find-variable-noselect var file)))
(pop-to-buffer (car location))
+ (run-hooks 'find-function-after-hook)
(if (cdr location)
(goto-char (cdr location))
(message "Unable to find location in file"))))
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-library don't call find-function-after-hook
2016-02-07 15:18 bug#22583: 25.1.50; find-function-search-for-symbol don't call find-function-after-hook Tino Calancha
2016-02-08 5:01 ` Dmitry Gutov
@ 2016-02-18 0:52 ` Tino Calancha
2016-02-21 23:27 ` Dmitry Gutov
1 sibling, 1 reply; 10+ messages in thread
From: Tino Calancha @ 2016-02-18 0:52 UTC (permalink / raw
To: 22583
[-- Attachment #1: Type: text/plain, Size: 255 bytes --]
IMO, for consistency, find-function-after-hook should be
also run by find-library.
For instance, as mentioned above, i set this hook to always
open source code on read-only buffers.
If find-library don't run the hook, it may open a file in
writable mode.
[-- Attachment #2: Type: text/plain, Size: 718 bytes --]
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 0575ce4..b04a9d2 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -283,7 +283,11 @@ LIBRARY should be a string (the name of the library)."
"Library name: ")
table nil nil nil nil def))))
(let ((buf (find-file-noselect (find-library-name library))))
- (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
+ (condition-case nil
+ (prog1
+ (switch-to-buffer buf)
+ (run-hooks 'find-function-after-hook))
+ (error (pop-to-buffer buf)))))
;;;###autoload
(defun find-function-search-for-symbol (symbol type library)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-library don't call find-function-after-hook
2016-02-18 0:52 ` bug#22583: 25.1.50; find-library " Tino Calancha
@ 2016-02-21 23:27 ` Dmitry Gutov
2016-02-22 0:00 ` John Wiegley
2016-02-22 17:19 ` Tino Calancha
0 siblings, 2 replies; 10+ messages in thread
From: Dmitry Gutov @ 2016-02-21 23:27 UTC (permalink / raw
To: Tino Calancha, 22583, John Wiegley
On 02/18/2016 02:52 AM, Tino Calancha wrote:
>
> IMO, for consistency, find-function-after-hook should be
> also run by find-library.
> For instance, as mentioned above, i set this hook to always
> open source code on read-only buffers.
> If find-library don't run the hook, it may open a file in
> writable mode.
Sounds good to me.
Tino, could you resend these as one patch, using 'git format-patch' as
described in CONTRIBUTE, with an appropriate commit message (which means
using ChangeLog-style description, as also described in CONTRIBUTE).
John, would you say it's okay for emacs-25?
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-library don't call find-function-after-hook
2016-02-21 23:27 ` Dmitry Gutov
@ 2016-02-22 0:00 ` John Wiegley
2016-02-22 0:04 ` Dmitry Gutov
2016-02-22 17:19 ` Tino Calancha
1 sibling, 1 reply; 10+ messages in thread
From: John Wiegley @ 2016-02-22 0:00 UTC (permalink / raw
To: Dmitry Gutov; +Cc: Tino Calancha, 22583
[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]
>>>>> Dmitry Gutov <dgutov@yandex.ru> writes:
> Tino, could you resend these as one patch, using 'git format-patch' as
> described in CONTRIBUTE, with an appropriate commit message (which means
> using ChangeLog-style description, as also described in CONTRIBUTE).
> John, would you say it's okay for emacs-25?
At this point, qualification for inclusion into emacs-25 is fairly strict (now
clarifying for the sake of future discussion):
- It should *not* result in any changes to the NEWS file, APIs, or existing
documentation. Not unless we missed something major.
- If it fixes new behavior -- so, it hasn't been out in the wild yet -- then
just fix it if you think it's not destabilizing.
- If it corrects old behavior, sufficient testing is needed to ensure that
this "right" behavior does not lead to surprising behavior after two
pretests have already been out.
Be very cautious with changes at this point, since they won't have had the
benefit of those pretests. Especially if it's a breakage that has been broken
for a long time, I say it can stay broken until 25.2. But if we're smoothing
out new code before it hits the streets, there is still a little time for
that.
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 629 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-library don't call find-function-after-hook
2016-02-22 0:00 ` John Wiegley
@ 2016-02-22 0:04 ` Dmitry Gutov
2016-02-22 17:01 ` John Wiegley
0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Gutov @ 2016-02-22 0:04 UTC (permalink / raw
To: John Wiegley; +Cc: Tino Calancha, 22583
On 02/22/2016 02:00 AM, John Wiegley wrote:
> At this point, qualification for inclusion into emacs-25 is fairly strict (now
> clarifying for the sake of future discussion):
Thanks, this is useful (especially the item 2), but could you also
answer the question for this particular patch?
Like, I don't know if these changes should be reflected in the NEWS, or
existing documentation.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-library don't call find-function-after-hook
2016-02-22 0:04 ` Dmitry Gutov
@ 2016-02-22 17:01 ` John Wiegley
0 siblings, 0 replies; 10+ messages in thread
From: John Wiegley @ 2016-02-22 17:01 UTC (permalink / raw
To: Dmitry Gutov; +Cc: Tino Calancha, 22583
>>>>> Dmitry Gutov <dgutov@yandex.ru> writes:
> On 02/22/2016 02:00 AM, John Wiegley wrote:
>> At this point, qualification for inclusion into emacs-25 is fairly strict
>> (now clarifying for the sake of future discussion):
> Thanks, this is useful (especially the item 2), but could you also answer
> the question for this particular patch?
> Like, I don't know if these changes should be reflected in the NEWS, or
> existing documentation.
I'm not really sure about this particular change, not having followed the
whole thread. Let me read it through today and get back to you.
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-library don't call find-function-after-hook
2016-02-21 23:27 ` Dmitry Gutov
2016-02-22 0:00 ` John Wiegley
@ 2016-02-22 17:19 ` Tino Calancha
2016-04-25 17:27 ` Lars Magne Ingebrigtsen
1 sibling, 1 reply; 10+ messages in thread
From: Tino Calancha @ 2016-02-22 17:19 UTC (permalink / raw
To: 22583; +Cc: Tino Calancha, John Wiegley, Dmitry Gutov
[-- Attachment #1: Type: text/plain, Size: 251 bytes --]
> Tino, could you resend these as one patch, using 'git format-patch' as
> described in CONTRIBUTE, with an appropriate commit message (which means
> using ChangeLog-style description, as also described in CONTRIBUTE).
Attached the requested patch.
[-- Attachment #2: Type: text/plain, Size: 2149 bytes --]
From de28333e8797c5693876d8321c7c9f3255a13965 Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Tue, 23 Feb 2016 01:52:00 +0900
Subject: [PATCH] ; Run find-function-after-hook after find a symbol
Run the hook when visiting the source code with find-library,
describe-variable and describe-function (Bug#22583).
* lisp/emacs-lisp/find-func.el (find-library):
* lisp/help-mode.el (help-function-def, help-variable-def):
Run the hook inside the help-function of the buttons.
---
lisp/emacs-lisp/find-func.el | 6 +++++-
lisp/help-mode.el | 2 ++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 0575ce4..b04a9d2 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -283,7 +283,11 @@ find-library
"Library name: ")
table nil nil nil nil def))))
(let ((buf (find-file-noselect (find-library-name library))))
- (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
+ (condition-case nil
+ (prog1
+ (switch-to-buffer buf)
+ (run-hooks 'find-function-after-hook))
+ (error (pop-to-buffer buf)))))
;;;###autoload
(defun find-function-search-for-symbol (symbol type library)
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index e0f3351..f66fbb7 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -202,6 +202,7 @@ 'help-function-def
(let ((location
(find-function-search-for-symbol fun type file)))
(pop-to-buffer (car location))
+ (run-hooks 'find-function-after-hook)
(if (cdr location)
(goto-char (cdr location))
(message "Unable to find location in file"))))
@@ -231,6 +232,7 @@ 'help-variable-def
(setq file (help-C-file-name var 'var)))
(let ((location (find-variable-noselect var file)))
(pop-to-buffer (car location))
+ (run-hooks 'find-function-after-hook)
(if (cdr location)
(goto-char (cdr location))
(message "Unable to find location in file"))))
--
2.7.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#22583: 25.1.50; find-library don't call find-function-after-hook
2016-02-22 17:19 ` Tino Calancha
@ 2016-04-25 17:27 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 10+ messages in thread
From: Lars Magne Ingebrigtsen @ 2016-04-25 17:27 UTC (permalink / raw
To: Tino Calancha; +Cc: John Wiegley, 22583, Dmitry Gutov
Tino Calancha <f92capac@gmail.com> writes:
>> Tino, could you resend these as one patch, using 'git format-patch'
>> as described in CONTRIBUTE, with an appropriate commit message
>> (which means using ChangeLog-style description, as also described in
>> CONTRIBUTE).
> Attached the requested patch.
Thanks; applied to the trunk.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-04-25 17:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-07 15:18 bug#22583: 25.1.50; find-function-search-for-symbol don't call find-function-after-hook Tino Calancha
2016-02-08 5:01 ` Dmitry Gutov
2016-02-08 12:50 ` Tino Calancha
2016-02-18 0:52 ` bug#22583: 25.1.50; find-library " Tino Calancha
2016-02-21 23:27 ` Dmitry Gutov
2016-02-22 0:00 ` John Wiegley
2016-02-22 0:04 ` Dmitry Gutov
2016-02-22 17:01 ` John Wiegley
2016-02-22 17:19 ` Tino Calancha
2016-04-25 17:27 ` Lars Magne Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.