[OS X Emacs] add delimiters to major mode
Jack Repenning
jrepenning at collab.net
Fri Feb 11 19:08:51 EST 2011
On Feb 10, 2011, at 11:57 PM, Marinos K wrote:
> How can I add some delimiters to what a major mode considers as such ??
>
> I want to do this on some other file (not the one that defines this
> major mode)
There are two parts to your question:
1. How does one modify the "syntax table" (which is what defines stuff like this)?
Ans: (modify-syntax-entry ...). See the documentation (C-h f modify-syntax-entry); it's largish, too large to paste into list email like this.
2. How does one modify a given major mode's behavior?
Ans: that depends on the mode. Most of them define a "hook", a variable that can hold a list of functions to run when the mode is entered. Some also define "load-hooks" and others as well. Check the documentation for your mode of interest (C-h the-mode-name). So, for example, "C-h emacs-lisp-mode" says a bunch of stuff, ending with
Entry to this mode calls the value of `emacs-lisp-mode-hook'
if that value is non-nil.
There's a function, add-hook that ... well ... does what you think it does ;-). So in ~/.Aquamacs/Preferences.el, do
(defun my-whatever-mode-hook
(modify-syntax-entry ?< '(>'))
(add-hook 'whatever-mode-hook 'my-whatever-mode-hook)
to make <...> act like a parenthesized expression in whatever-mode
More information about the MacOSX-Emacs
mailing list