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

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

Re: Query Major Mode


From: Tim X
Subject: Re: Query Major Mode
Date: 22 Jul 2005 15:51:50 +1000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

Tim Johnson <address@hidden> writes:

> > There are lots of ways, depending on what you mean by query.  Does `C-h m'
> > do what you want?
>  
>   Oops! Poorly phrased question. My apologies. What I would like to
>   do is perform this query programmatically. 
> 
>   Is that possible?
> 
>   Now perhaps I should elaborate in case I am barking up the wrong
>   tree and there is a better way:
> 
>   Let's suppose I want to write a subroutine that first, queries
>   the major mode, and then calls the appropriate subroutine for
>   the mode.
> 
>   *pseudo-code* example:
> 
> (defun previous-subroutine ()
>   (cond
>     (eq major-mode "python")(previous-python-subroutine)
>     (eq major-mode "C")(previous-C-subroutine)
>     (eq major-mode "rebol")(previous-rebol-subroutine)
>   ))
> 
>   ;; and then keymap of course.
> 

You pseudo code pretty much has all the elements you need - there is a
variable called major-mode which you can use to do something based on
the mode you are in. However, I would suggest you check out using mode
hooks instead. Nearly all modes have a 'hook' you can set to do things
in a mode when it is loaded - this is the normal place to put mode
specific customizations. Many modes have multiple hooks that are run
at different times e.g. before loading the mode code, after loadinig
it etc. 

Tim


-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!


reply via email to

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