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

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

Re: Add "Local Variables" automatically


From: Mathias Dahl
Subject: Re: Add "Local Variables" automatically
Date: Thu, 25 Jan 2007 08:59:00 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (windows-nt)

"Fred" <fred@mayot.net> writes:

> Hi,
> Is there a way of adding automatically (with a keybinding) this text
> // Local Variables:
> // mode:c++
> // tab-width:3
> // c-basic-offset:3
> // indent-tabs-mode:nil
> // End:
> at the end of a buffer if not already present and then pass to
> c++-mode. I'm sure it is possible but I don't know elisp? Can someone
> help me?

You could use an abbrev for that:

M-x define-global-abbrev RET
my_local_var_text RET
Paste or type the text you want here. To enter a newline, type C-q
first. End with RET.

To use it you have to enable abbrev-mode. You can use M-x
customize-option RET abbrev-mode RET to do that.

Or, simply define a command:

(defun insert-my-local-var-text ()
 (interactive)
 (insert "// Local Variables:
// mode:c++
// tab-width:3
// c-basic-offset:3
// indent-tabs-mode:nil
// End:
"))

Save that in your .emacs file.

/Mathias


reply via email to

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