help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to tell if a mode has a given parent?


From: Drew Adams
Subject: how to tell if a mode has a given parent?
Date: Sat, 22 Jul 2006 08:44:52 -0700

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?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]