From: Tim X <timx@spamto.devnul.com>
Subject: Re: Query Major Mode
Date: 22 Jul 2005 15:51:50 +1000 [thread overview]
Message-ID: <87r7drl761.fsf@tiger.rapttech.com.au> (raw)
In-Reply-To: mailman.1216.1121974434.20277.help-gnu-emacs@gnu.org
Tim Johnson <tim@johnsons-web.com> 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!
next prev parent reply other threads:[~2005-07-22 5:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-21 18:33 Query Major Mode Tim Johnson
2005-07-21 18:45 ` Drew Adams
2005-07-21 19:32 ` Tim Johnson
2005-07-21 19:46 ` Peter Dyballa
2005-07-21 20:03 ` Tim Johnson
2005-07-21 19:58 ` Drew Adams
2005-07-21 22:55 ` Kevin Rodgers
[not found] ` <mailman.1216.1121974434.20277.help-gnu-emacs@gnu.org>
2005-07-21 22:59 ` drkm
2005-07-22 5:51 ` Tim X [this message]
2005-07-21 18:45 ` Peter Dyballa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r7drl761.fsf@tiger.rapttech.com.au \
--to=timx@spamto.devnul.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).