From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: Doing things only in a particular mode Date: Mon, 24 Aug 2015 10:32:48 -0700 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1440437607 28103 80.91.229.3 (24 Aug 2015 17:33:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Aug 2015 17:33:27 +0000 (UTC) Cc: Colin Yates To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 24 19:33:26 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZTvcc-00068p-0M for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Aug 2015 19:33:26 +0200 Original-Received: from localhost ([::1]:55789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTvcb-00072O-97 for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Aug 2015 13:33:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTvcL-00070f-OX for help-gnu-emacs@gnu.org; Mon, 24 Aug 2015 13:33:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTvcK-0002B6-Th for help-gnu-emacs@gnu.org; Mon, 24 Aug 2015 13:33:09 -0400 Original-Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:34622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTvcK-0002AJ-PT for help-gnu-emacs@gnu.org; Mon, 24 Aug 2015 13:33:08 -0400 Original-Received: by oiey141 with SMTP id y141so84804138oie.1 for ; Mon, 24 Aug 2015 10:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=udtrkdrJ0NTWejmcvjP5eLb0wqx/aSf5hn2MycRCIuY=; b=T0P3ZODmLtFYEr8KSkY/xpry63vih0xrkhfZcKHV1q5hDsRey1nt2qcjBlszYk3Enn SPVXBsIxCRUNpBLTDEow4ldLmsbDOCt/GMLwsDhL+PX3mXqoH3b7iDlWG6lSpjNaJ2OV vILgktVFGCUxVOYlabhbNddYQ+jvkzcH4QBFrdSFzUIJAdUhovhY1+PYiEdartdlMwCo 6lSMAoqH2U0ShDPR3HT2dTHMJZYO8JlTy1GUb1CLoX7WR8YimMsEiMwziDFt0DOhnpjI lQWrJDj9zOaMY0/M0IygSHwPwgjvgrpPNmi2GNip+hbcHH5R4iwkTZW2p+vMxz4+Qxe6 4T+A== X-Received: by 10.202.91.87 with SMTP id p84mr21177115oib.80.1440437587859; Mon, 24 Aug 2015 10:33:07 -0700 (PDT) Original-Received: by 10.76.168.70 with HTTP; Mon, 24 Aug 2015 10:32:48 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::22f X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106804 Archived-At: > Do you have any idea about the more generic emacs question? > Specifically, how do I achieve the following: > > (when (= MAJOR_MODE "mu4e-headers") > (do this) > (and do that)) There will usually be a `foo-mode-hook' for any mode `foo', so you would create a function to perform you configuration and add it to that hook. There's also an `after-change-major-mode-hook', where you can add functions that you want to be run after the major mode changes. However, in practice I've never needed to use it. As an aside, the value of `major-mode' is a symbol, so `=' won't work for the equality comparison (unlike in Clojure, `=' isn't very polymorphic; it can only compare numbers or markers). Either `eq' (equivalent to Clojure's `identical?') or `equal' (the closest to Clojure's `=', though not equivalent) would work. -- john