[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
Re: How to go to next line on the screen instead of going to next line in the text?
Thu, 5 Jun 2008 08:05:27 -0700 (PDT)
On Jun 5, 12:41 am, Kevin Rodgers <address@hidden> wrote:
> 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.
thanks for your reply.
> So if you only want it on in Tex modes, put longlines-mode on
> tex-mode-hook only.
This was what I did.
If I only put (add-hook 'tex-mode-hook 'longlines-mode) and there is
no sentence like (add-hook 'text-mode-hook 'longlines-mode),
then nothing happened: the longlines-mode is not turned on.
> 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