[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: visual-line-mode
From: |
Stefan Monnier |
Subject: |
Re: visual-line-mode |
Date: |
Sun, 29 Jun 2008 10:01:22 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
> I expect emacs primitives will need improvement to work for the
> word-wrapping case (and display-time line-prefixes which I've hacked up
> locally), so perhaps they can be improved to work better in general too.
After looking a bit more at the various visual line movement packages,
and remembering that I've just added a `cols' arg to vertical-motion,
I believe the patch below provides basically the behavior we want.
As it turns out, it doesn't work right with word-wrapping because
posn-at-point returns funny X positions. Probably the same underlying
bug causes sometimes mouse-clicks to place point elsewhere than under
the mouse.
Stefan
=== modified file 'lisp/simple.el'
--- lisp/simple.el 2008-06-21 02:48:08 +0000
+++ lisp/simple.el 2008-06-29 13:36:08 +0000
@@ -4030,6 +4030,16 @@
(t
(set-window-vscroll nil (frame-char-height) t)))))))
+(defvar line-move-visual t)
+
+(defun line-move-visual (arg)
+ (unless (and (floatp temporary-goal-column)
+ (or (memq last-command '(next-line previous-line))
+ ;; In case we're called from some other command.
+ (eq last-command this-command)))
+ (setq temporary-goal-column
+ (/ (car (nth 2 (posn-at-point))) 1.0 (frame-char-width))))
+ (vertical-motion (cons (truncate temporary-goal-column) arg)))
;; This is like line-move-1 except that it also performs
;; vertical scrolling of tall images if appropriate.
@@ -4046,7 +4056,9 @@
(not executing-kbd-macro)
(line-move-partial arg noerror to-end))
(set-window-vscroll nil 0 t)
- (line-move-1 arg noerror to-end)))
+ (if line-move-visual
+ (line-move-visual arg)
+ (line-move-1 arg noerror to-end))))
;; This is the guts of next-line and previous-line.
;; Arg says how many lines to move.
- visual-line-mode, David Reitter, 2008/06/29
- Re: visual-line-mode, Miles Bader, 2008/06/29
- Re: visual-line-mode, Miles Bader, 2008/06/29
- Re: visual-line-mode,
Stefan Monnier <=
- Re: visual-line-mode, Chong Yidong, 2008/06/29
- Re: visual-line-mode, Miles Bader, 2008/06/29
- Re: visual-line-mode, Chong Yidong, 2008/06/29
- Re: visual-line-mode, Miles Bader, 2008/06/30
- Re: visual-line-mode, Miles Bader, 2008/06/30
- Re: visual-line-mode, Miles Bader, 2008/06/30
- Re: visual-line-mode, Miles Bader, 2008/06/30
- Re: visual-line-mode, Chong Yidong, 2008/06/30
- Re: visual-line-mode, Chong Yidong, 2008/06/30
Re: visual-line-mode, David Reitter, 2008/06/30