unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@fencepost.gnu.org>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: line-move-finish (simple.el) hangs on invisible&intangible text.
Date: Sat, 20 Apr 2002 07:50:39 -0400	[thread overview]
Message-ID: <E16ytO3-0006CA-00@fencepost.gnu.org> (raw)
In-Reply-To: <20020419122441.1A89.LEKTU@terra.es> (message from Juanma Barranquero on Fri, 19 Apr 2002 12:32:15 +0200)

> Date: Fri, 19 Apr 2002 12:32:15 +0200
> From: Juanma Barranquero <lektu@terra.es>
> 
> line-move-finish calls line-move-to-column to set the cursor to the
> desired column, and that function does:
> 
>   (if (zerop col)
>       (beginning-of-line)
>     (move-to-column col))
> 
> That's why it works from column 0 and not others. In my system, puting
> the cursor at the beginning of a line that only contains i&i characters
> and evaling
> 
>  (beginning-of-line)
> 
> does not move the cursor, while evaling
> 
>  (move-to-column 0)
> 
> moves it. Doesn't that happen on your system?

Yes, it does.

The following tentative change (not installed) detects a possible
infloop and breaks out of it with the last good position it found,
hopefully without breaking anything else.  I will install this if
people who understand more than I do the intricacies of the invisible
and intangible properties take a good look at the patch and approve
it.

Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.537
diff -c -r1.537 simple.el
*** lisp/simple.el	19 Apr 2002 00:05:22 -0000	1.537
--- lisp/simple.el	20 Apr 2002 11:32:46 -0000
***************
*** 2633,2676 ****
    nil)
  
  (defun line-move-finish (column opoint)
!   (let ((repeat t))
      (while repeat
        ;; Set REPEAT to t to repeat the whole thing.
        (setq repeat nil)
  
        ;; Move to the desired column.
        (line-move-to-column column)
! 
!       (let ((new (point))
! 	    (line-beg (save-excursion (beginning-of-line) (point)))
! 	    (line-end (save-excursion (end-of-line) (point))))
! 
! 	;; Process intangibility within a line.
! 	;; Move to the chosen destination position from above,
! 	;; with intangibility processing enabled.
! 
! 	(goto-char (point-min))
! 	(let ((inhibit-point-motion-hooks nil))
! 	  (goto-char new)
! 
! 	  ;; If intangibility moves us to a different (later) place
! 	  ;; in the same line, use that as the destination.
! 	  (if (<= (point) line-end)
! 	      (setq new (point))))
! 
! 	;; Now move to the updated destination, processing fields
! 	;; as well as intangibility.
! 	(goto-char opoint)
! 	(let ((inhibit-point-motion-hooks nil))
! 	  (goto-char
! 	   (constrain-to-field new opoint nil t
! 			       'inhibit-line-move-field-capture)))
! 
! 	;; If intangibility processing moved us to a different line,
! 	;; retry everything within that new line.
! 	(when (or (< (point) line-beg) (> (point) line-end))
! 	  ;; Repeat the intangibility and field processing.
! 	  (setq repeat t))))))
  
  (defun line-move-to-column (col)
    "Try to find column COL, considering invisibility.
--- 2633,2681 ----
    nil)
  
  (defun line-move-finish (column opoint)
!   (let ((repeat t)
! 	(prev-new -1)
! 	last-good-point)
      (while repeat
        ;; Set REPEAT to t to repeat the whole thing.
        (setq repeat nil)
  
        ;; Move to the desired column.
+       (setq last-good-point (point))
        (line-move-to-column column)
!       (if (= (point) prev-new)
! 	  (goto-char last-good-point)
! 	(let ((new (point))
! 	      (line-beg (save-excursion (beginning-of-line) (point)))
! 	      (line-end (save-excursion (end-of-line) (point))))
! 
! 	  (setq prev-new new)
! 	  ;; Process intangibility within a line.
! 	  ;; Move to the chosen destination position from above,
! 	  ;; with intangibility processing enabled.
! 
! 	  (goto-char (point-min))
! 	  (let ((inhibit-point-motion-hooks nil))
! 	    (goto-char new)
! 
! 	    ;; If intangibility moves us to a different (later) place
! 	    ;; in the same line, use that as the destination.
! 	    (if (<= (point) line-end)
! 		(setq new (point))))
! 
! 	  ;; Now move to the updated destination, processing fields
! 	  ;; as well as intangibility.
! 	  (goto-char opoint)
! 	  (let ((inhibit-point-motion-hooks nil))
! 	    (goto-char
! 	     (constrain-to-field new opoint nil t
! 				 'inhibit-line-move-field-capture)))
! 
! 	  ;; If intangibility processing moved us to a different line,
! 	  ;; retry everything within that new line.
! 	  (when (or (< (point) line-beg) (> (point) line-end))
! 	    ;; Repeat the intangibility and field processing.
! 	    (setq repeat t)))))))
  
  (defun line-move-to-column (col)
    "Try to find column COL, considering invisibility.

  parent reply	other threads:[~2002-04-20 11:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17 14:48 line-move-finish (simple.el) hangs on invisible&intangible text Juanma Barranquero
2002-04-18 18:44 ` Richard Stallman
2002-04-19  8:46   ` Juanma Barranquero
2002-04-19  9:59     ` Eli Zaretskii
2002-04-19 10:32       ` Juanma Barranquero
2002-04-19 13:06         ` Eli Zaretskii
2002-04-19 13:40           ` Juanma Barranquero
2002-04-19 14:32             ` Eli Zaretskii
2002-04-19 14:49               ` Juanma Barranquero
2002-04-19 15:04             ` Robert J. Chassell
2002-04-20 11:50         ` Eli Zaretskii [this message]
2002-04-21  1:32           ` Juanma Barranquero
2002-04-21  6:06             ` Eli Zaretskii
2002-04-21 17:05               ` Juanma Barranquero
2002-04-21 15:19                 ` Eli Zaretskii
2002-04-22  7:47                 ` Richard Stallman
2002-04-22 10:09                   ` Juanma Barranquero
  -- strict thread matches above, loose matches on Subject: below --
2002-04-19 16:08 Christoph Conrad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E16ytO3-0006CA-00@fencepost.gnu.org \
    --to=eliz@fencepost.gnu.org \
    --cc=eliz@is.elta.co.il \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).