[Top][All Lists]

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

Re: How to go to next line on the screen instead of going to next line i

From: Kevin Rodgers
Subject: Re: How to go to next line on the screen instead of going to next line in the text?
Date: Wed, 04 Jun 2008 23:41:46 -0600
User-agent: Thunderbird (Macintosh/20080421)

xz wrote:
which means, if I only want turn on this longlines-mode when editing
latex/tex file, then I add the following to .emacs:
(add-hook 'tex-mode-hook 'longlines-mode)

Is that correct?
But it seems not working......

I mean it works when I add
(add-hook 'text-mode-hook 'longlines-mode)

while it does work if I only add
(add-hook 'tex-mode-hook 'longlines-mode)

Here's the second way:
(add-hook 'find-file-hook 'longlines-mode)
(add-hook 'find-file-not-found-functions 'longlines-mode)

Many text-editing (major) modes besides Text mode call text-mode-hook,
including Plain Tex, LaTex, and SliTex modes (try `M-x
apropos-documentation RET text-mode-hook RET').  And the various Tex
modes then call tex-mode-hook, and then their specific mode hook
(e.g. plain-tex-mode-hook).

Since longlines-mode toggles Long Lines (minor) mode, having the
function on both text-mode-hook and tex-mode-hook turns it on and then
off in a Tex buffer.

So if you only want it on in Tex modes, put longlines-mode on
tex-mode-hook only.  Or if you want it on in all text editing modes
(including Tex modes), put longlines-mode on text-mode-hook only.

If you'd rather avoid having to remember all that, it's better to use a
function on those hooks that unconditionally turns it on.  Many minor
modes have turn-on-foo-mode and turn-off-foo-mode convenience functions
for that purpose, but you can fake it with an anonymous function:

    (add-hook 'text-mode-hook (lambda () (longlines-mode 1)))
    (add-hook 'tex-mode-hook (lambda () (longlines-mode 1)))

or define your own convenience function and use that instead:

    (defun turn-on-longlines-mode ()
      "Turn on Long Lines mode."
      (longlines-mode 1))
    (add-hook 'text-mode-hook 'turn-on-longlines-mode)
    (add-hook 'tex-mode-hook 'turn-on-longlines-mode)

Kevin Rodgers
Denver, Colorado, USA

reply via email to

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