* fundamental-mode-hook
@ 2007-02-08 0:38 Lennart Borgman (gmail)
2007-02-08 10:06 ` fundamental-mode-hook Karl Fogel
2007-02-08 19:46 ` fundamental-mode-hook Richard Stallman
0 siblings, 2 replies; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-08 0:38 UTC (permalink / raw)
To: Emacs Devel
The elisp manual
(info "(elisp) Major Mode Conventions")
says that
Each major mode should have a normal "mode hook" named
`MODENAME-mode-hook'.
fundamental-mode does not have such a hook.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 10:06 ` fundamental-mode-hook Karl Fogel
@ 2007-02-08 1:13 ` Lennart Borgman (gmail)
2007-02-08 19:46 ` fundamental-mode-hook Richard Stallman
2007-02-08 1:30 ` fundamental-mode-hook Juanma Barranquero
1 sibling, 1 reply; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-08 1:13 UTC (permalink / raw)
To: kfogel; +Cc: Emacs Devel
Karl Fogel wrote:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
>> The elisp manual
>>
>> (info "(elisp) Major Mode Conventions")
>>
>> says that
>>
>> Each major mode should have a normal "mode hook" named
>> `MODENAME-mode-hook'.
>>
>> fundamental-mode does not have such a hook.
>
> Do you have a use in mind for such a hook, or is the inconsistency
> just bugging you? (Not a facetious question, I'm honestly trying to
> figure out if the situation is a problem or not.)
>
> In simple.el, fundamental-mode's definition is pretty tiny:
>
> (defun fundamental-mode ()
> "Major mode not specialized for anything in particular.
> Other major modes are defined by comparison with this one."
> (interactive)
> (kill-all-local-variables)
> (unless delay-mode-hooks
> (run-hooks 'after-change-major-mode-hook)))
>
> Hmm, for one thing, I'm not sure why it doesn't just say
>
> (delay-mode-hooks 'after-change-major-mode-hook)
>
> instead of checking the variable delay-mode-hooks manually. Aside
> from that, it would be pretty easy to stick a run-hooks call in there,
> but would it really help anyone do anything they couldn't do before?
I am not sure what to answer at the moment. I just found this
inconsistency when I tried to check if a function was a major mode
function. I tested to see if the hook variable existed (probably not the
best way, but that is what I did).
I then remembered that there are no hook for new buffers. Are they not
set up in fundamental-mode?
BTW, there are more major modes missing this hook: Info-mode, xml-mode
is what I have noticed so far.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 10:06 ` fundamental-mode-hook Karl Fogel
2007-02-08 1:13 ` fundamental-mode-hook Lennart Borgman (gmail)
@ 2007-02-08 1:30 ` Juanma Barranquero
2007-02-08 1:40 ` fundamental-mode-hook Lennart Borgman (gmail)
1 sibling, 1 reply; 19+ messages in thread
From: Juanma Barranquero @ 2007-02-08 1:30 UTC (permalink / raw)
To: kfogel; +Cc: Lennart Borgman (gmail), Emacs Devel
On 2/8/07, Karl Fogel <kfogel@red-bean.com> wrote:
> (Not a facetious question, I'm honestly trying to
> figure out if the situation is a problem or not.)
http://lists.gnu.org/archive/html/help-gnu-emacs/2007-02/msg00042.html
> Hmm, for one thing, I'm not sure why it doesn't just say
>
> (delay-mode-hooks 'after-change-major-mode-hook)
>
> instead of checking the variable delay-mode-hooks manually.
http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg00886.html
/L/e/k/t/u
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 1:30 ` fundamental-mode-hook Juanma Barranquero
@ 2007-02-08 1:40 ` Lennart Borgman (gmail)
2007-02-08 15:36 ` fundamental-mode-hook Karl Fogel
0 siblings, 1 reply; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-08 1:40 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: kfogel, Emacs Devel
Juanma Barranquero wrote:
> On 2/8/07, Karl Fogel <kfogel@red-bean.com> wrote:
>
>> (Not a facetious question, I'm honestly trying to
>> figure out if the situation is a problem or not.)
>
> http://lists.gnu.org/archive/html/help-gnu-emacs/2007-02/msg00042.html
>
>> Hmm, for one thing, I'm not sure why it doesn't just say
>>
>> (delay-mode-hooks 'after-change-major-mode-hook)
>>
>> instead of checking the variable delay-mode-hooks manually.
>
> http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg00886.html
I thought that a hook like (the now non-existent) fundamental-mode-hook
was meant for adding things for minor mode for example.
I can not really understand the rational for not having it. There can
still be minor mode active in a buffer with in fundamental-mode, or?
(And currently Info is incorrect.)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 0:38 fundamental-mode-hook Lennart Borgman (gmail)
@ 2007-02-08 10:06 ` Karl Fogel
2007-02-08 1:13 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 1:30 ` fundamental-mode-hook Juanma Barranquero
2007-02-08 19:46 ` fundamental-mode-hook Richard Stallman
1 sibling, 2 replies; 19+ messages in thread
From: Karl Fogel @ 2007-02-08 10:06 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: Emacs Devel
"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> The elisp manual
>
> (info "(elisp) Major Mode Conventions")
>
> says that
>
> Each major mode should have a normal "mode hook" named
> `MODENAME-mode-hook'.
>
> fundamental-mode does not have such a hook.
Do you have a use in mind for such a hook, or is the inconsistency
just bugging you? (Not a facetious question, I'm honestly trying to
figure out if the situation is a problem or not.)
In simple.el, fundamental-mode's definition is pretty tiny:
(defun fundamental-mode ()
"Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one."
(interactive)
(kill-all-local-variables)
(unless delay-mode-hooks
(run-hooks 'after-change-major-mode-hook)))
Hmm, for one thing, I'm not sure why it doesn't just say
(delay-mode-hooks 'after-change-major-mode-hook)
instead of checking the variable delay-mode-hooks manually. Aside
from that, it would be pretty easy to stick a run-hooks call in there,
but would it really help anyone do anything they couldn't do before?
-Karl
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 1:40 ` fundamental-mode-hook Lennart Borgman (gmail)
@ 2007-02-08 15:36 ` Karl Fogel
2007-02-08 18:25 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 19:45 ` fundamental-mode-hook Richard Stallman
0 siblings, 2 replies; 19+ messages in thread
From: Karl Fogel @ 2007-02-08 15:36 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: Juanma Barranquero, Emacs Devel
"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> Juanma Barranquero wrote:
> I thought that a hook like (the now non-existent)
> fundamental-mode-hook was meant for adding things for minor mode for
> example.
>
> I can not really understand the rational for not having it. There can
> still be minor mode active in a buffer with in fundamental-mode, or?
>
> (And currently Info is incorrect.)
I've added the hook now. Thanks, Juanma Barranquero, for the timely
archive pointers!
2007-02-08 Karl Fogel <kfogel@red-bean.com>
* emacs/lisp/simple.el (fundamental-mode-hook): Declare new hook.
(fundamental-mode): Run the new dedicated hook, and don't run
after-change-major-mode-hooks manually anymore.
$ cvs ci -F msg simple.el ChangeLog
/cvsroot/emacs/emacs/lisp/simple.el,v <-- simple.el
new revision: 1.844; previous revision: 1.843
/cvsroot/emacs/emacs/lisp/ChangeLog,v <-- ChangeLog
new revision: 1.10663; previous revision: 1.10662
Mailing notification to emacs-commit@gnu.org... sent.
Mailing diffs to emacs-diffs@gnu.org... 2 sent.
$
-Karl
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 15:36 ` fundamental-mode-hook Karl Fogel
@ 2007-02-08 18:25 ` Lennart Borgman (gmail)
2007-02-08 19:45 ` fundamental-mode-hook Richard Stallman
1 sibling, 0 replies; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-08 18:25 UTC (permalink / raw)
To: kfogel; +Cc: Juanma Barranquero, Emacs Devel
Karl Fogel wrote:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
>> Juanma Barranquero wrote:
>> I thought that a hook like (the now non-existent)
>> fundamental-mode-hook was meant for adding things for minor mode for
>> example.
>>
>> I can not really understand the rational for not having it. There can
>> still be minor mode active in a buffer with in fundamental-mode, or?
>>
>> (And currently Info is incorrect.)
>
> I've added the hook now. Thanks, Juanma Barranquero, for the timely
> archive pointers!
>
> 2007-02-08 Karl Fogel <kfogel@red-bean.com>
>
> * emacs/lisp/simple.el (fundamental-mode-hook): Declare new hook.
> (fundamental-mode): Run the new dedicated hook, and don't run
> after-change-major-mode-hooks manually anymore.
>
> $ cvs ci -F msg simple.el ChangeLog
> /cvsroot/emacs/emacs/lisp/simple.el,v <-- simple.el
> new revision: 1.844; previous revision: 1.843
> /cvsroot/emacs/emacs/lisp/ChangeLog,v <-- ChangeLog
> new revision: 1.10663; previous revision: 1.10662
> Mailing notification to emacs-commit@gnu.org... sent.
> Mailing diffs to emacs-diffs@gnu.org... 2 sent.
> $
Thanks. I just recompiled from CVS and tested. I can find the hook, but
it does not seem to be run. Or I am doing something bad. This is what I
used for testing:
(defun temp-fund()
(message "temp-fund here")
(sit-for 2))
(temp-fund)
(add-hook 'fundamental-mode-hook 'temp-fund)
(get-buffer-create "Test fund")
(with-temp-buffer
(message "%s, major-mode=%s" (current-buffer) major-mode))
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 15:36 ` fundamental-mode-hook Karl Fogel
2007-02-08 18:25 ` fundamental-mode-hook Lennart Borgman (gmail)
@ 2007-02-08 19:45 ` Richard Stallman
2007-02-09 5:56 ` fundamental-mode-hook Karl Fogel
1 sibling, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2007-02-08 19:45 UTC (permalink / raw)
To: kfogel; +Cc: lekktu, lennart.borgman, emacs-devel
Fundamental mode is not supposed to run a hook, it is supposed
to make the global definitions of Emacs show through.
So please take out that change.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 1:13 ` fundamental-mode-hook Lennart Borgman (gmail)
@ 2007-02-08 19:46 ` Richard Stallman
2007-02-08 22:29 ` fundamental-mode-hook Lennart Borgman (gmail)
0 siblings, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2007-02-08 19:46 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: kfogel, emacs-devel
I am not sure what to answer at the moment. I just found this
inconsistency when I tried to check if a function was a major mode
function. I tested to see if the hook variable existed (probably not the
best way, but that is what I did).
That approach won't work in general. A major mode hook variable does
not have to "exist" in any sense unless the user chooses to put on
a hook. Some major modes defvar the hook variable, but some don't.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 0:38 fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 10:06 ` fundamental-mode-hook Karl Fogel
@ 2007-02-08 19:46 ` Richard Stallman
2007-02-08 22:44 ` fundamental-mode-hook Lennart Borgman (gmail)
1 sibling, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2007-02-08 19:46 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: emacs-devel
Each major mode should have a normal "mode hook" named
`MODENAME-mode-hook'.
fundamental-mode does not have such a hook.
Fundamental mode is an exception to many of these conventions.
I will update the manual.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 19:46 ` fundamental-mode-hook Richard Stallman
@ 2007-02-08 22:29 ` Lennart Borgman (gmail)
2007-02-08 22:50 ` fundamental-mode-hook Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-08 22:29 UTC (permalink / raw)
To: rms; +Cc: kfogel, emacs-devel
Richard Stallman wrote:
> I am not sure what to answer at the moment. I just found this
> inconsistency when I tried to check if a function was a major mode
> function. I tested to see if the hook variable existed (probably not the
> best way, but that is what I did).
>
> That approach won't work in general. A major mode hook variable does
> not have to "exist" in any sense unless the user chooses to put on
> a hook. Some major modes defvar the hook variable, but some don't.
Yes, thanks, that is what I thought. What is the right way to find out
if a function is a major mode?
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 19:46 ` fundamental-mode-hook Richard Stallman
@ 2007-02-08 22:44 ` Lennart Borgman (gmail)
2007-02-09 14:23 ` fundamental-mode-hook Richard Stallman
0 siblings, 1 reply; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-08 22:44 UTC (permalink / raw)
To: rms; +Cc: emacs-devel
Richard Stallman wrote:
> Each major mode should have a normal "mode hook" named
> `MODENAME-mode-hook'.
>
> fundamental-mode does not have such a hook.
>
> Fundamental mode is an exception to many of these conventions.
> I will update the manual.
I thought a fundamental mode hook was a good solution to the problem
that there is no "new buffer" hook. But a special hook would perhaps be
better.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 22:29 ` fundamental-mode-hook Lennart Borgman (gmail)
@ 2007-02-08 22:50 ` Stefan Monnier
2007-02-08 23:03 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 22:55 ` fundamental-mode-hook Edward O'Connor
2007-02-09 14:23 ` fundamental-mode-hook Richard Stallman
2 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2007-02-08 22:50 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: kfogel, rms, emacs-devel
> Yes, thanks, that is what I thought. What is the right way to find out if
> a function is a major mode?
- look at its doc
- look at its code
- try it
- ...
I tried to get all major modes to use a standard macro
(define-derived-mode), but Richard didn't like some parts of it and it
all dies. Still, all major modes defined with define-derived-mode have the
`derived-mode-parent' property.
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 22:29 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 22:50 ` fundamental-mode-hook Stefan Monnier
@ 2007-02-08 22:55 ` Edward O'Connor
2007-02-08 23:05 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-09 14:23 ` fundamental-mode-hook Richard Stallman
2 siblings, 1 reply; 19+ messages in thread
From: Edward O'Connor @ 2007-02-08 22:55 UTC (permalink / raw)
To: emacs-devel
Lennart asked:
> What is the right way to find out if a function is a major mode?
Kevin Rodgers posted the following function to g.e.h or somewhere
similar some number of years ago. It's just a heuristic, but it works
well enough for my purposes.
,----
| (defun kr-major-mode-p (symbol)
| "Return non-nil if SYMBOL is a major mode."
| (and (fboundp symbol)
| (let ((function-name (symbol-name symbol)))
| (and (string-match "-mode\\'" function-name)
| (not (string-match "\\`turn-\\(on\\|off\\)-"
| function-name))))
| (not (assq symbol minor-mode-alist))))
`----
Ted
--
Edward O'Connor
hober0@gmail.com
Ense petit placidam sub libertate quietem.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 22:50 ` fundamental-mode-hook Stefan Monnier
@ 2007-02-08 23:03 ` Lennart Borgman (gmail)
0 siblings, 0 replies; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-08 23:03 UTC (permalink / raw)
To: Stefan Monnier; +Cc: kfogel, rms, emacs-devel
Stefan Monnier wrote:
>> Yes, thanks, that is what I thought. What is the right way to find out if
>> a function is a major mode?
>
> - look at its doc
> - look at its code
> - try it
> - ...
Some of it could be done from elisp of course, but it seems complicated
... ;-)
> I tried to get all major modes to use a standard macro
> (define-derived-mode), but Richard didn't like some parts of it and it
> all dies. Still, all major modes defined with define-derived-mode have the
> `derived-mode-parent' property.
Seems easier. Combining that with the code that checks if it is a minor
mode ...
But something even easier would be nice.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 22:55 ` fundamental-mode-hook Edward O'Connor
@ 2007-02-08 23:05 ` Lennart Borgman (gmail)
0 siblings, 0 replies; 19+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-08 23:05 UTC (permalink / raw)
To: Edward O'Connor; +Cc: emacs-devel
Edward O'Connor wrote:
> Lennart asked:
>
>> What is the right way to find out if a function is a major mode?
>
> Kevin Rodgers posted the following function to g.e.h or somewhere
> similar some number of years ago. It's just a heuristic, but it works
> well enough for my purposes.
>
> ,----
> | (defun kr-major-mode-p (symbol)
> | "Return non-nil if SYMBOL is a major mode."
> | (and (fboundp symbol)
> | (let ((function-name (symbol-name symbol)))
> | (and (string-match "-mode\\'" function-name)
> | (not (string-match "\\`turn-\\(on\\|off\\)-"
> | function-name))))
> | (not (assq symbol minor-mode-alist))))
> `----
Thanks, looks useful.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 19:45 ` fundamental-mode-hook Richard Stallman
@ 2007-02-09 5:56 ` Karl Fogel
0 siblings, 0 replies; 19+ messages in thread
From: Karl Fogel @ 2007-02-09 5:56 UTC (permalink / raw)
To: rms; +Cc: lekktu, lennart.borgman, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> Fundamental mode is not supposed to run a hook, it is supposed
> to make the global definitions of Emacs show through.
> So please take out that change.
Done; thanks for updating the manual.
-Karl
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 22:29 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 22:50 ` fundamental-mode-hook Stefan Monnier
2007-02-08 22:55 ` fundamental-mode-hook Edward O'Connor
@ 2007-02-09 14:23 ` Richard Stallman
2 siblings, 0 replies; 19+ messages in thread
From: Richard Stallman @ 2007-02-09 14:23 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: kfogel, emacs-devel
Yes, thanks, that is what I thought. What is the right way to find out
if a function is a major mode?
I think there is no reliable way.
In a future version we could add a way.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: fundamental-mode-hook
2007-02-08 22:44 ` fundamental-mode-hook Lennart Borgman (gmail)
@ 2007-02-09 14:23 ` Richard Stallman
0 siblings, 0 replies; 19+ messages in thread
From: Richard Stallman @ 2007-02-09 14:23 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: emacs-devel
I thought a fundamental mode hook was a good solution to the problem
that there is no "new buffer" hook. But a special hook would perhaps be
better.
Creating a buffer does not call `fundamental-mode', so adding a
fundamental-mode-hook wouldn't do this anyway. Buffer creation
happens at a rather low level, but it can call Lisp code.
Adding a hook for that makes me worry, because I know that I hesitated
to do so, but I don't remember any specific reason why it was bad,
and it does call a function to help initialize UCS.
I don't want to consider such a change now.
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2007-02-09 14:23 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-08 0:38 fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 10:06 ` fundamental-mode-hook Karl Fogel
2007-02-08 1:13 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 19:46 ` fundamental-mode-hook Richard Stallman
2007-02-08 22:29 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 22:50 ` fundamental-mode-hook Stefan Monnier
2007-02-08 23:03 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 22:55 ` fundamental-mode-hook Edward O'Connor
2007-02-08 23:05 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-09 14:23 ` fundamental-mode-hook Richard Stallman
2007-02-08 1:30 ` fundamental-mode-hook Juanma Barranquero
2007-02-08 1:40 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 15:36 ` fundamental-mode-hook Karl Fogel
2007-02-08 18:25 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-08 19:45 ` fundamental-mode-hook Richard Stallman
2007-02-09 5:56 ` fundamental-mode-hook Karl Fogel
2007-02-08 19:46 ` fundamental-mode-hook Richard Stallman
2007-02-08 22:44 ` fundamental-mode-hook Lennart Borgman (gmail)
2007-02-09 14:23 ` fundamental-mode-hook Richard Stallman
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.