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

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

Re: Query Major Mode


From: drkm
Subject: Re: Query Major Mode
Date: Fri, 22 Jul 2005 00:59:03 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (windows-nt)

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


reply via email to

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