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

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

Re: turning line mode on/off with defun not working


From: Emanuel Berg
Subject: Re: turning line mode on/off with defun not working
Date: Fri, 06 Dec 2013 22:35:23 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Wes James <comptekki@gmail.com> writes:

> Thank you.  I appreciate this.

In that case, let me tell you some more. Those
interactive defuns are handy for situations unforeseen,
when you suddenly need them. But for certain modes, you
know you always want it (or you know you never want
it). In those cases you can set (or unset)
automatically upon invocation, with hooks. Those hooks
do the job for you in 99% of the cases, and in the 1%
case, you still have those interactive defuns to set it
manually.

So to enable line-number-mode for C and C++
programming, it may look like this:

(setq c-mode-hook 'lines)
(setq c++-mode-hook (lambda () (lines) (abbrev-mode 0)))

In C++, I also disable abbrev-mode (for some reason),
but it is only a good thing because as you see,
enabling line-number-mode looks somewhat
different. Note that the above are for my lines stuff -
to use the actual functions directly, probably you need
(lambda () (line-number-mode 1)) for the modes where
you want it.

Also, those hooks can be examined like any
variables. You can examine your hooks with C-h v, and
if they are not nil, instead of setq (so not to
overwrite what's there), use add-hook (and then *quote*
the mode, like this 'c-mode-hook).

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


reply via email to

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