unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: drkm <usenet@fgeorges.org>
Subject: Re: Query Major Mode
Date: Fri, 22 Jul 2005 00:59:03 +0200	[thread overview]
Message-ID: <uvf33pxzc.fsf@fgeorges.org> (raw)
In-Reply-To: mailman.1216.1121974434.20277.help-gnu-emacs@gnu.org

Tim Johnson writes:

> (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)
>   ))

  You can also use something like:

    (defvar previous-subroutine-function 'previous-subroutine-default
      "...")
    (make-variable-buffer-local 'previous-subroutine-function)

    (defun previous-subroutine ()
      "..."
      (funcall previous-subroutine-function ...))

    (defun previous-python-subroutine ()
      ...)
    (add-hook 'python-mode-hook (lambda ()
                                  (setq previous-subroutine-function
                                        previous-python-subroutine)))

    ;; ...

  You can be interested in the mechanism CEDET provides to
overload functions in a per-mode basis.  Cfr. the documentation:
(info "(semantic-langdev)Semantic Overload Mechanism").

--drkm

  parent reply	other threads:[~2005-07-21 22:59 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 [this message]
2005-07-22  5:51     ` Tim X
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=uvf33pxzc.fsf@fgeorges.org \
    --to=usenet@fgeorges.org \
    /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).