From 6c8499b941f044f78163f6f62f5782b75cc2ffc3 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sat, 26 Jul 1997 22:22:59 +0000 Subject: [PATCH] (line-move): If intangibility moves us to a different line, adjust the hpos nicely in that line. --- lisp/simple.el | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index d4166977cb5..00bf4c5d967 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1906,7 +1906,7 @@ Outline mode sets this." ;; for intermediate positions. (let ((inhibit-point-motion-hooks t) (opoint (point)) - new) + new line-end line-beg) (unwind-protect (progn (if (not (or (eq last-command 'next-line) @@ -1973,25 +1973,42 @@ Outline mode sets this." ;; If we are moving into some intangible text, ;; look for following text on the same line which isn't intangible ;; and move there. + (setq line-end (save-excursion (end-of-line) (point))) + (setq line-beg (save-excursion (beginning-of-line) (point))) (let ((after (and (< new (point-max)) (get-char-property new 'intangible))) (before (and (> new (point-min)) - (get-char-property (1- new) 'intangible))) - line-end) - (when (and before (eq before after)) - (setq line-end (save-excursion (end-of-line) (point))) + (get-char-property (1- new) 'intangible)))) + (when (and before (eq before after) + (not (bolp))) (goto-char (point-min)) (let ((inhibit-point-motion-hooks nil)) (goto-char new)) (if (<= new line-end) (setq new (point))))) - ;; Remember where we moved to, go back home, - ;; then do the motion over again - ;; in just one step, with intangibility and point-motion hooks - ;; enabled this time. + ;; NEW is where we want to move to. + ;; LINE-BEG and LINE-END are the beginning and end of the line. + ;; Move there in just one step, from our starting position, + ;; with intangibility and point-motion hooks enabled this time. (goto-char opoint) (setq inhibit-point-motion-hooks nil) - (goto-char new))) + (goto-char new) + ;; If intangibility processing moved us to a different line, + ;; readjust the horizontal position within the line we ended up at. + (when (or (< (point) line-beg) (> (point) line-end)) + (setq new (point)) + (setq inhibit-point-motion-hooks t) + (setq line-end (save-excursion (end-of-line) (point))) + (beginning-of-line) + (setq line-beg (point)) + (let ((buffer-invisibility-spec nil)) + (move-to-column (or goal-column temporary-goal-column))) + (if (<= (point) line-end) + (setq new (point))) + (goto-char (point-min)) + (setq inhibit-point-motion-hooks nil) + (goto-char new) + ))) nil) ;;; Many people have said they rarely use this feature, and often type -- 2.39.2