From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Query Major Mode Date: Thu, 21 Jul 2005 12:58:24 -0700 Message-ID: References: <20050721193258.GF2692@johnsons-web.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1121977298 15699 80.91.229.2 (21 Jul 2005 20:21:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Jul 2005 20:21:38 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 21 22:21:36 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DvhXc-0004FZ-E5 for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Jul 2005 22:21:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DvhZi-0006Wz-Td for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Jul 2005 16:23:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DvhVy-0005Ky-DD for help-gnu-emacs@gnu.org; Thu, 21 Jul 2005 16:19:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DvhVm-0005CH-SF for help-gnu-emacs@gnu.org; Thu, 21 Jul 2005 16:19:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DvhVh-00058X-EJ for help-gnu-emacs@gnu.org; Thu, 21 Jul 2005 16:19:13 -0400 Original-Received: from [141.146.126.229] (helo=agminet02.oracle.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DvhLI-0003Ro-Q6 for help-gnu-emacs@gnu.org; Thu, 21 Jul 2005 16:08:28 -0400 Original-Received: from agminet02.oracle.com (localhost [127.0.0.1]) by agminet02.oracle.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id j6LJwQL8031409 for ; Thu, 21 Jul 2005 14:58:27 -0500 Original-Received: from rgmsgw301.us.oracle.com (rgmsgw301.us.oracle.com [138.1.186.50]) by agminet02.oracle.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id j6LJwQ4j031392 for ; Thu, 21 Jul 2005 14:58:26 -0500 Original-Received: from rgmsgw301.us.oracle.com (localhost [127.0.0.1]) by rgmsgw301.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id j6LJwQUl012702 for ; Thu, 21 Jul 2005 13:58:26 -0600 Original-Received: from dradamslap (dradams-lap.us.oracle.com [130.35.177.126]) by rgmsgw301.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with SMTP id j6LJwPQK012695 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 21 Jul 2005 13:58:25 -0600 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 In-reply-to: <20050721193258.GF2692@johnsons-web.com> Importance: Normal X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE 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:28060 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28060 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) )) Wrap your conditions in parens, define your `previous-*' routines, and you should be more or less good to go. IOW, you query the major mode programmatically via variable `major-mode', just as you have done - it's not pseudocode; it's code. `M-x apropos RET major' shows you variable `major-mode'. See node "Major Modes" in the Elisp manual (info: `C-h i') for lots of info on major modes. (I wonder why they picked that name for the node?)