* how to tell if a mode has a given parent?
@ 2006-07-22 15:44 Drew Adams
2006-07-24 16:00 ` Kevin Rodgers
0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2006-07-22 15:44 UTC (permalink / raw)
How can I determine, in Emacs Lisp, whether a given buffer's mode is derived
from some other mode? For example, shell-mode is derived from comint-mode.
What's a good way, by program, to tell if, say, comint-mode is a parent
(ancestor, really) of the current mode?
Shell mode is derived from comint mode using define-derived-mode (in Emacs
22), so there must be some way to access its ancestry.
I would also like, if possible, a way to do this in versions of Emacs that
don't have define-derived-mode. For example, in Emacs 20, shell mode is
similarly defined in terms of comint mode, but it doesn't use
define-derived-mode to do that - it simply calls comint-mode. Is there a
way, in a shell-mode buffer, to tell that the current mode is derived from
comint mode?
Check the keymap in some way? This sort of works, but it seems fragile and
kludgy. It depends on the child mode not replacing the binding of
`comint-send-input'.
(where-is-internal 'comint-send-input
(keymap-parent (current-local-map)))
I'm sure there must be an easy, clean way to do this - what is it?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to tell if a mode has a given parent?
2006-07-22 15:44 Drew Adams
@ 2006-07-24 16:00 ` Kevin Rodgers
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2006-07-24 16:00 UTC (permalink / raw)
Drew Adams wrote:
> How can I determine, in Emacs Lisp, whether a given buffer's mode is derived
> from some other mode? For example, shell-mode is derived from comint-mode.
> What's a good way, by program, to tell if, say, comint-mode is a parent
> (ancestor, really) of the current mode?
>
> Shell mode is derived from comint mode using define-derived-mode (in Emacs
> 22), so there must be some way to access its ancestry.
In Shell mode: (derived-mode-p 'comint-mode)
> I would also like, if possible, a way to do this in versions of Emacs that
> don't have define-derived-mode. For example, in Emacs 20, shell mode is
> similarly defined in terms of comint mode, but it doesn't use
> define-derived-mode to do that - it simply calls comint-mode. Is there a
> way, in a shell-mode buffer, to tell that the current mode is derived from
> comint mode?
Not for the general case.
> Check the keymap in some way? This sort of works, but it seems fragile and
> kludgy. It depends on the child mode not replacing the binding of
> `comint-send-input'.
>
> (where-is-internal 'comint-send-input
> (keymap-parent (current-local-map)))
>
> I'm sure there must be an easy, clean way to do this - what is it?
Maybe you could check whether the keymap parent is the local keymap
of a true comint buffer.
--
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-07-24 16:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.4354.1153642988.9609.help-gnu-emacs@gnu.org>
2006-07-23 12:18 ` how to tell if a mode has a given parent? Johan Bockgård
2006-07-23 18:56 ` Drew Adams
2006-07-22 15:44 Drew Adams
2006-07-24 16:00 ` Kevin Rodgers
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.