Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I associate a minor mode to a particular file or a set of files based on extension?

Tags:

emacs

clojure

Currently, every time I open a text file in emacs, I have to M-x longlines-mode in order to get my line-wrapping turned on. Likewise in clojure, I have to M-x paredit-mode (although it does automatically set the major modes to text and clojure, respectively).

I am hazy on the difference between major and minor modes, but I'm thinking the above-mentioned modes are minor. Is there a way to:

  1. configure emacs to open all clojure (*.clj) files with paredit-mode automatically?
  2. configure a particular file (say, notes.txt) to open with longlines-mode. I have tried adding -^- mode: longlines -^- or -^- mode: longlines-mode -^- as suggested in other threads, but it doesn't seem to work. I can't search for documentation on the -^- syntax because I don't know what it's called.
like image 795
jk. Avatar asked Feb 20 '11 18:02

jk.


1 Answers

I have this in my .emacs file

(require 'clojure-mode)
(defun turn-on-paredit () (paredit-mode 1))
(add-hook 'clojure-mode-hook 'turn-on-paredit)
like image 115
FCeccon Avatar answered Sep 17 '22 15:09

FCeccon