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

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

Re: Doing things only in a particular mode


From: John Mastro
Subject: Re: Doing things only in a particular mode
Date: Mon, 24 Aug 2015 10:32:48 -0700

> 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



reply via email to

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