* Querying available mode hooks in a given mode
@ 2014-04-13 2:46 Grant Rettke
2014-04-13 4:54 ` Eric Abrahamsen
0 siblings, 1 reply; 7+ messages in thread
From: Grant Rettke @ 2014-04-13 2:46 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
My goal is to, after a mode has been entered, to check whether a
particular hook exists. If it does or
does not exist, then I will run some handler code.
In an attempt to find a may to check for what hooks exist, I read the
manual, specifically the hooks
section, and didn't see what are obvious places to look.
Any idea where I should start?
Regards,
Grant Rettke | AAAS, ACM, AMA, COG, FSF, IEEE, Sigma Xi
grettke@acm.org | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Querying available mode hooks in a given mode
2014-04-13 2:46 Querying available mode hooks in a given mode Grant Rettke
@ 2014-04-13 4:54 ` Eric Abrahamsen
2014-04-14 1:52 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2014-04-13 4:54 UTC (permalink / raw)
To: help-gnu-emacs
Grant Rettke <gcr@wisdomandwonder.com> writes:
> Hi,
>
> My goal is to, after a mode has been entered, to check whether a
> particular hook exists. If it does or
> does not exist, then I will run some handler code.
>
> In an attempt to find a may to check for what hooks exist, I read the
> manual, specifically the hooks
> section, and didn't see what are obvious places to look.
>
> Any idea where I should start?
>
> Regards,
>
> Grant Rettke | AAAS, ACM, AMA, COG, FSF, IEEE, Sigma Xi
> grettke@acm.org | http://www.wisdomandwonder.com/
> “Wisdom begins in wonder.” --Socrates
> ((λ (x) (x x)) (λ (x) (x x)))
> “Life has become immeasurably better since I have been forced to stop
> taking it seriously.” --Thompson
Unless the mode author is straying pretty far from accepted practice,
you can usually see all the hooks by doing C-h v, then typing
modeprefix--hook, and hitting TAB. That should give you a *Completion*
buffer with all the matching variables.
Eric
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Querying available mode hooks in a given mode
2014-04-13 4:54 ` Eric Abrahamsen
@ 2014-04-14 1:52 ` Stefan Monnier
2014-04-14 8:44 ` Eric Abrahamsen
2014-04-14 19:09 ` Grant Rettke
0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2014-04-14 1:52 UTC (permalink / raw)
To: help-gnu-emacs
>> My goal is to, after a mode has been entered, to check whether
>> a particular hook exists. If it does or does not exist, then I will
>> run some handler code.
Can you give a concrete example?
> Unless the mode author is straying pretty far from accepted practice,
> you can usually see all the hooks by doing C-h v, then typing
> modeprefix--hook, and hitting TAB. That should give you a *Completion*
> buffer with all the matching variables.
Actually, some hooks may exist without appearing there.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Querying available mode hooks in a given mode
2014-04-14 1:52 ` Stefan Monnier
@ 2014-04-14 8:44 ` Eric Abrahamsen
2014-04-14 19:09 ` Grant Rettke
1 sibling, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2014-04-14 8:44 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> My goal is to, after a mode has been entered, to check whether
>>> a particular hook exists. If it does or does not exist, then I will
>>> run some handler code.
>
> Can you give a concrete example?
>
>> Unless the mode author is straying pretty far from accepted practice,
>> you can usually see all the hooks by doing C-h v, then typing
>> modeprefix--hook, and hitting TAB. That should give you a *Completion*
>> buffer with all the matching variables.
>
> Actually, some hooks may exist without appearing there.
Hey, there were a lot of weasel words in my answer! It was definitely
meant as a "reasonable place to start".
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Querying available mode hooks in a given mode
2014-04-14 1:52 ` Stefan Monnier
2014-04-14 8:44 ` Eric Abrahamsen
@ 2014-04-14 19:09 ` Grant Rettke
2014-04-14 19:27 ` Stefan Monnier
1 sibling, 1 reply; 7+ messages in thread
From: Grant Rettke @ 2014-04-14 19:09 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Hi Stefan et al,
On Sun, Apr 13, 2014 at 8:52 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>>> My goal is to, after a mode has been entered, to check whether
>>> a particular hook exists. If it does or does not exist, then I will
>>> run some handler code.
>
> Can you give a concrete example?
Yes, it follows.
When I use Emacs Speaks Statistics [http://ess.r-project.org/], I like
all of my file buffers to be saved before evaluating any code in them,
so I wrote advice for 9 functions that provides this behavior. After
sharing that with the ESS list, one of the maintainers communicated to
me that in the development version of ESS there is a new hook that
will run when any of those 9 functions is called.
Since I'm on the MELPA version which behind that mainline dev version,
I wanted to write myself some code in my Emacs init file that upon
entering ESS mode would check if that hook exists, and it it does,
display a reminder to myself that I may migrate my code over to this
simpler approach.
Forgive my failures as a story teller; that is why I wanted to write that code.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Querying available mode hooks in a given mode
2014-04-14 19:09 ` Grant Rettke
@ 2014-04-14 19:27 ` Stefan Monnier
2014-04-14 19:29 ` Grant Rettke
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2014-04-14 19:27 UTC (permalink / raw)
To: help-gnu-emacs
> When I use Emacs Speaks Statistics [http://ess.r-project.org/], I like
> all of my file buffers to be saved before evaluating any code in them,
> so I wrote advice for 9 functions that provides this behavior. After
> sharing that with the ESS list, one of the maintainers communicated to
> me that in the development version of ESS there is a new hook that
> will run when any of those 9 functions is called.
You can probably use (boundp 'ess-foo-bar-hook) to test if the hook
is available. But that will only give the right answer after loading
the file which does (defvar ess-foo-bar-hook ...) or equivalent.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Querying available mode hooks in a given mode
2014-04-14 19:27 ` Stefan Monnier
@ 2014-04-14 19:29 ` Grant Rettke
0 siblings, 0 replies; 7+ messages in thread
From: Grant Rettke @ 2014-04-14 19:29 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
On Mon, Apr 14, 2014 at 2:27 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
> You can probably use (boundp 'ess-foo-bar-hook) to test if the hook
> is available. But that will only give the right answer after loading
> the file which does (defvar ess-foo-bar-hook ...) or equivalent.
Understood and thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-04-14 19:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-13 2:46 Querying available mode hooks in a given mode Grant Rettke
2014-04-13 4:54 ` Eric Abrahamsen
2014-04-14 1:52 ` Stefan Monnier
2014-04-14 8:44 ` Eric Abrahamsen
2014-04-14 19:09 ` Grant Rettke
2014-04-14 19:27 ` Stefan Monnier
2014-04-14 19:29 ` Grant Rettke
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.