all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Is there a way to move to next line in wrapped text?
@ 2004-01-06 18:52 Jeff
  2004-01-06 19:37 ` Marco Parrone (marc0)
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jeff @ 2004-01-06 18:52 UTC (permalink / raw)


Hi;

I've been using emacs for programming for quite years. Works great.
Recently I've been trying to use it for html and other straight text
editing and keep running into one annoying feature: when I do Ctrl-p or
Ctrl-n to move up or down a line, it goes to the next line in terms of
linefeeds, not in terms of wrapped text. Are there keybindings I don't
know about that will move up and down to the next 'literal' line in the
window? (regardless of where linefeeds are?). If not, is there some other
way to do this?

Thanks
-Jeff

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is there a way to move to next line in wrapped text?
  2004-01-06 18:52 Is there a way to move to next line in wrapped text? Jeff
@ 2004-01-06 19:37 ` Marco Parrone (marc0)
  2004-01-06 20:12   ` Benjamin Rutt
  2004-01-07  0:53 ` Stefan Monnier
  2004-01-07 15:58 ` Eric Eide
  2 siblings, 1 reply; 8+ messages in thread
From: Marco Parrone (marc0) @ 2004-01-06 19:37 UTC (permalink / raw)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeff on Tue, 06 Jan 2004 18:52:40 GMT writes:

> I've been using emacs for programming for quite years. Works great.
> Recently I've been trying to use it for html and other straight text
> editing and keep running into one annoying feature: when I do Ctrl-p or
> Ctrl-n to move up or down a line, it goes to the next line in terms of
> linefeeds, not in terms of wrapped text. Are there keybindings I don't
> know about that will move up and down to the next 'literal' line in the
> window? (regardless of where linefeeds are?). If not, is there some other
> way to do this?

You can use `C-u 79 C-f' and `C-u 79 C-b' for example if you are
working in an 80 columns terminal.

Or you can define 2 new functions and 2 new keybindings in your
~/.emacs to do it.

The functions will look like

(defun forward-79-chars ()
  (interactive)
  (forward-char 79))

(defun backward-79-chars ()
  (interactive)
  (backward-char 79))

- -- 
Marco Parrone (marc0) - marc0@autistici.org
F7D4 527B DE97 4090 657B  6E4E 8B63 1167 (4507 0AD6)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/+w5Ei2MRZ0UHCtYRAtkYAJ4ucwNZuGaKzwrc3aN20tNzxzXfQACfYi5l
vCTRG66BGJEWMoxjEpCvzBE=
=r5VV
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is there a way to move to next line in wrapped text?
  2004-01-06 19:37 ` Marco Parrone (marc0)
@ 2004-01-06 20:12   ` Benjamin Rutt
  2004-01-06 21:50     ` Jeff
  0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Rutt @ 2004-01-06 20:12 UTC (permalink / raw)


marc0@autistici.org (Marco Parrone (marc0)) writes:

> (defun forward-79-chars ()
>   (interactive)
>   (forward-char 79))
>
> (defun backward-79-chars ()
>   (interactive)
>   (backward-char 79))

You can replace 79 in code above with something like (window-width),
which will also work if you have any non-80-column windows around.
-- 
Benjamin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is there a way to move to next line in wrapped text?
  2004-01-06 20:12   ` Benjamin Rutt
@ 2004-01-06 21:50     ` Jeff
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff @ 2004-01-06 21:50 UTC (permalink / raw)


On Tue, 06 Jan 2004 15:12:06 -0500, Benjamin Rutt wrote:

> marc0@autistici.org (Marco Parrone (marc0)) writes:
> 
>> (defun forward-79-chars ()
>>   (interactive)
>>   (forward-char 79))
>>
>> (defun backward-79-chars ()
>>   (interactive)
>>   (backward-char 79))
> 
> You can replace 79 in code above with something like (window-width),
> which will also work if you have any non-80-column windows around.

Damn, you guys are good. It works _exactly_ the way I want (I bound C-M-p
and n and used (window-width). 

Thanks!

-Jeff

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is there a way to move to next line in wrapped text?
  2004-01-06 18:52 Is there a way to move to next line in wrapped text? Jeff
  2004-01-06 19:37 ` Marco Parrone (marc0)
@ 2004-01-07  0:53 ` Stefan Monnier
  2004-01-07 15:58 ` Eric Eide
  2 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2004-01-07  0:53 UTC (permalink / raw)


> I've been using emacs for programming for quite years. Works great.
> Recently I've been trying to use it for html and other straight text
> editing and keep running into one annoying feature: when I do Ctrl-p or
> Ctrl-n to move up or down a line, it goes to the next line in terms of
> linefeeds, not in terms of wrapped text. Are there keybindings I don't
> know about that will move up and down to the next 'literal' line in the
> window? (regardless of where linefeeds are?). If not, is there some other
> way to do this?

There are elisp functions to do that, although I can't remember their names
offhand (and they don't work right in Emacs-21 with non-fixed-with text).
Check screen-lines.el (or some such name) for a package that provides
navigation based on those functions.


        Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is there a way to move to next line in wrapped text?
  2004-01-06 18:52 Is there a way to move to next line in wrapped text? Jeff
  2004-01-06 19:37 ` Marco Parrone (marc0)
  2004-01-07  0:53 ` Stefan Monnier
@ 2004-01-07 15:58 ` Eric Eide
  2004-01-08 22:34   ` leo
  2 siblings, 1 reply; 8+ messages in thread
From: Eric Eide @ 2004-01-07 15:58 UTC (permalink / raw)


"Jeff" == Jeff <jeffrey@cunningham.net> writes:

	Jeff> [...] when I do Ctrl-p or Ctrl-n to move up or down a line, it
	Jeff> goes to the next line in terms of linefeeds, not in terms of
	Jeff> wrapped text.  Are there keybindings I don't know about that will
	Jeff> move up and down to the next 'literal' line in the window?
	Jeff> (regardless of where linefeeds are?). If not, is there some other
	Jeff> way to do this?

The `scroll-in-place' package can help you with this.  Get it from:

	<http://www.cs.utah.edu/~eeide/emacs/scroll-in-place.el.gz>

Or if you are using XEmacs, you can get it as part of the XEmacs distribution.

Load the `scroll-in-place' package into your Emacs session, and then you can
use

	C-u 1 C-v	to move the cursor down screen one line ("scroll up")
	C-u 1 M-v	to move the cursor up one screen line ("scroll down")

Of course, `C-u 1 PgDown' and `C-u 1 PgUp' work just as well.

The keys `C-u 1' tell the scrolling commands how many lines to move, and it
turns out that the `scroll-in-place' commands remember the number of lines you
want to scroll, across a sequence of scrolling commands.  In other words, you
don't have to type `C-u 1' every time.  As long as you keep doing C-v and M-v
without interruption, you'll keep moving by the same distance each time.

To make one-line scrolling more convenient, you might want to define you own
one-line scrolling commands and bind them to keys --- something like this:

(defun scroll-down-one-line (arg)
  "Scroll down one line, or number of lines specified by prefix arg."
  (interactive "P")
    (let ((scroll-default-lines 1))
      (scroll-down-in-place arg)))

(global-set-key "\C-c\C-v" 'scroll-down-one-line)

The documentation in the `scroll-in-place.el' file comments (in the "advanced
customization" section) go into more detail about writing your own scrolling
commands.

Eric.

-- 
-------------------------------------------------------------------------------
Eric Eide <eeide@cs.utah.edu>  .         University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is there a way to move to next line in wrapped text?
  2004-01-07 15:58 ` Eric Eide
@ 2004-01-08 22:34   ` leo
  2004-01-09  0:36     ` Eric Eide
  0 siblings, 1 reply; 8+ messages in thread
From: leo @ 2004-01-08 22:34 UTC (permalink / raw)



"Eric Eide" <eeide@cs.utah.edu> wrote in message
news:ywroetf7nty.fsf@ioka.flux.utah.edu...
> "Jeff" == Jeff <jeffrey@cunningham.net> writes:
>
> Jeff> [...] when I do Ctrl-p or Ctrl-n to move up or down a line, it
> Jeff> goes to the next line in terms of linefeeds, not in terms of
> Jeff> wrapped text.  Are there keybindings I don't know about that will
> Jeff> move up and down to the next 'literal' line in the window?
> Jeff> (regardless of where linefeeds are?). If not, is there some other
> Jeff> way to do this?
>
> The `scroll-in-place' package can help you with this.  Get it from:
>
> <http://www.cs.utah.edu/~eeide/emacs/scroll-in-place.el.gz>

i had a look at the package, beacuse i'm annoyed at this jump by lines
behaviour of next-line and previous-line.

but does `scroll-in-place' help with next-line/previous-line as well. i
guess it only help for scrolling, doen't it?

cheers, leo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is there a way to move to next line in wrapped text?
  2004-01-08 22:34   ` leo
@ 2004-01-09  0:36     ` Eric Eide
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Eide @ 2004-01-09  0:36 UTC (permalink / raw)


"leo" == leo <halloleo@noospaam.myrealbox.com> writes:

	leo> i had a look at the [`scroll-in-place'] package, beacuse i'm
	leo> annoyed at this jump by lines behaviour of next-line and
	leo> previous-line.
	leo> 
	leo> but does `scroll-in-place' help with next-line/previous-line as
	leo> well.  i guess it only help for scrolling, doen't it?

Well, I guess it depends on your point of view.

You're right that the `scroll-in-place' package is primarily intended as a
replacement for Emacs' scrolling commands, not its point-motion (i.e., cursor
motion) commands.  But in many ways, the scrolling and point-motion commands
aren't all that different.  Scrolling command often change the location of
point, and conversely, point-motion commands sometimes cause the window to
scroll.

As a practical matter, I wouldn't (and don't) use `scroll-in-place' to replace
point-motion commands in general.  When I invoke one of those commands, I
expect point to move from its current screen position.  But when I scroll, I
want to "move" by having the text move beneath point, as if I had picked up my
pen and moved the paper under it.

Whether one moves the pen or the paper, the effect is similar (but not the
same).  The original question was about how to conveniently cause point to be
located within a long line, and my answer describes a way that "moves the
paper."  But I wouldn't always move the paper --- it's too hard to write that
way :-).

Eric.

-- 
-------------------------------------------------------------------------------
Eric Eide <eeide@cs.utah.edu>  .         University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-01-09  0:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-06 18:52 Is there a way to move to next line in wrapped text? Jeff
2004-01-06 19:37 ` Marco Parrone (marc0)
2004-01-06 20:12   ` Benjamin Rutt
2004-01-06 21:50     ` Jeff
2004-01-07  0:53 ` Stefan Monnier
2004-01-07 15:58 ` Eric Eide
2004-01-08 22:34   ` leo
2004-01-09  0:36     ` Eric Eide

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.