From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: drkm Newsgroups: gmane.emacs.help Subject: Re: Query Major Mode Date: Fri, 22 Jul 2005 00:59:03 +0200 Organization: None Message-ID: References: <20050721183342.GE2692@johnsons-web.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1121987110 6862 80.91.229.2 (21 Jul 2005 23:05:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Jul 2005 23:05:10 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 22 01:05:06 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Dvk5X-0006eU-4V for geh-help-gnu-emacs@m.gmane.org; Fri, 22 Jul 2005 01:04:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dvk7d-00033X-QF for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Jul 2005 19:06:33 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!skynet.be!newspost001!tjb!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (windows-nt) Cancel-Lock: sha1:E+7IKqdMVLwWhXdZVTGld8+NSEY= Original-Lines: 32 Original-NNTP-Posting-Host: 7583fffb.news.skynet.be Original-X-Trace: 1121986788 news.skynet.be 28108 81.241.206.237:1696 Original-X-Complaints-To: usenet-abuse@skynet.be Original-Xref: shelby.stanford.edu gnu.emacs.help:132556 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:28074 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28074 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