aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-07-11 18:07:01 +0000
committerChong Yidong2008-07-11 18:07:01 +0000
commit4efebb82ef8b4894c6161d33495cbb3e428cba42 (patch)
tree789767a9980167ec2b0abfb7bb706737a20404d1
parent4d1d41073faaee4a693520b82506801829fd0646 (diff)
downloademacs-4efebb82ef8b4894c6161d33495cbb3e428cba42.tar.gz
emacs-4efebb82ef8b4894c6161d33495cbb3e428cba42.zip
(line-move-visual): Obey goal-column and no-error arg.
(track-eol, temporary-goal-column): Update docstring. (move-end-of-line, move-beginning-of-line): Bind line-move-visual to nil. (line-move-visual): New var. (line-move-visual): New function. (line-move): Call line-move-visual.
-rw-r--r--lisp/simple.el54
1 files changed, 44 insertions, 10 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 20165ea7f33..c4b47993456 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3871,7 +3871,8 @@ to use and more reliable (no dependence on goal column, etc.)."
3871(defcustom track-eol nil 3871(defcustom track-eol nil
3872 "*Non-nil means vertical motion starting at end of line keeps to ends of lines. 3872 "*Non-nil means vertical motion starting at end of line keeps to ends of lines.
3873This means moving to the end of each line moved onto. 3873This means moving to the end of each line moved onto.
3874The beginning of a blank line does not count as the end of a line." 3874The beginning of a blank line does not count as the end of a line.
3875This has no effect when `line-move-visual' is non-nil."
3875 :type 'boolean 3876 :type 'boolean
3876 :group 'editing-basics) 3877 :group 'editing-basics)
3877 3878
@@ -3884,9 +3885,12 @@ The beginning of a blank line does not count as the end of a line."
3884 3885
3885(defvar temporary-goal-column 0 3886(defvar temporary-goal-column 0
3886 "Current goal column for vertical motion. 3887 "Current goal column for vertical motion.
3887It is the column where point was 3888It is the column where point was at the start of the current run
3888at the start of current run of vertical motion commands. 3889of vertical motion commands. It is a floating point number when
3889When the `track-eol' feature is doing its job, the value is `most-positive-fixnum'.") 3890moving by visual lines via `line-move-visual'; this is the
3891x-position, in pixels, divided by the default column width. When
3892the `track-eol' feature is doing its job, the value is
3893`most-positive-fixnum'.")
3890 3894
3891(defcustom line-move-ignore-invisible t 3895(defcustom line-move-ignore-invisible t
3892 "*Non-nil means \\[next-line] and \\[previous-line] ignore invisible lines. 3896 "*Non-nil means \\[next-line] and \\[previous-line] ignore invisible lines.
@@ -3894,6 +3898,12 @@ Outline mode sets this."
3894 :type 'boolean 3898 :type 'boolean
3895 :group 'editing-basics) 3899 :group 'editing-basics)
3896 3900
3901(defvar line-move-visual t
3902 "When non-nil, `line-move' moves point by visual lines.
3903This movement is based on where the cursor is displayed on the
3904screen, instead of relying on buffer contents alone. It takes
3905into account variable-width characters and line continuation.")
3906
3897;; Returns non-nil if partial move was done. 3907;; Returns non-nil if partial move was done.
3898(defun line-move-partial (arg noerror to-end) 3908(defun line-move-partial (arg noerror to-end)
3899 (if (< arg 0) 3909 (if (< arg 0)
@@ -3966,7 +3976,30 @@ Outline mode sets this."
3966 (not executing-kbd-macro) 3976 (not executing-kbd-macro)
3967 (line-move-partial arg noerror to-end)) 3977 (line-move-partial arg noerror to-end))
3968 (set-window-vscroll nil 0 t) 3978 (set-window-vscroll nil 0 t)
3969 (line-move-1 arg noerror to-end))) 3979 (if line-move-visual
3980 (line-move-visual arg noerror)
3981 (line-move-1 arg noerror to-end))))
3982
3983;; Display-based alternative to line-move-1.
3984;; Arg says how many lines to move. The value is t if we can move the
3985;; specified number of lines.
3986(defun line-move-visual (arg &optional noerror)
3987 (unless (and (floatp temporary-goal-column)
3988 (or (memq last-command '(next-line previous-line))
3989 ;; In case we're called from some other command.
3990 (eq last-command this-command)))
3991 (setq temporary-goal-column
3992 (/ (car (nth 2 (posn-at-point))) 1.0 (frame-char-width))))
3993 (let ((moved (vertical-motion
3994 (cons (or goal-column
3995 (truncate temporary-goal-column))
3996 arg))))
3997 (or (= arg moved)
3998 (unless noerror
3999 (signal (if (< arg 0)
4000 'beginning-of-buffer
4001 'end-of-buffer)
4002 nil)))))
3970 4003
3971;; This is the guts of next-line and previous-line. 4004;; This is the guts of next-line and previous-line.
3972;; Arg says how many lines to move. 4005;; Arg says how many lines to move.
@@ -4230,7 +4263,8 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
4230 (while (not done) 4263 (while (not done)
4231 (let ((newpos 4264 (let ((newpos
4232 (save-excursion 4265 (save-excursion
4233 (let ((goal-column 0)) 4266 (let ((goal-column 0)
4267 (line-move-visual nil))
4234 (and (line-move arg t) 4268 (and (line-move arg t)
4235 (not (bobp)) 4269 (not (bobp))
4236 (progn 4270 (progn
@@ -4245,9 +4279,8 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
4245 (backward-char 1) 4279 (backward-char 1)
4246 (if (and (> (point) newpos) (not (eobp)) 4280 (if (and (> (point) newpos) (not (eobp))
4247 (not (eq (following-char) ?\n))) 4281 (not (eq (following-char) ?\n)))
4248 ;; If we skipped something intangible 4282 ;; If we skipped something intangible and now we're not
4249 ;; and now we're not really at eol, 4283 ;; really at eol, keep going.
4250 ;; keep going.
4251 (setq arg 1) 4284 (setq arg 1)
4252 (setq done t))))))) 4285 (setq done t)))))))
4253 4286
@@ -4267,7 +4300,8 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
4267 4300
4268 ;; Move by lines, if ARG is not 1 (the default). 4301 ;; Move by lines, if ARG is not 1 (the default).
4269 (if (/= arg 1) 4302 (if (/= arg 1)
4270 (line-move (1- arg) t)) 4303 (let ((line-move-visual nil))
4304 (line-move (1- arg) t)))
4271 4305
4272 ;; Move to beginning-of-line, ignoring fields and invisibles. 4306 ;; Move to beginning-of-line, ignoring fields and invisibles.
4273 (skip-chars-backward "^\n") 4307 (skip-chars-backward "^\n")