unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* BUG+patch: line-move-1 ignores buffer-invisibility-spec
@ 2011-08-31  4:20 Max Mikhanosha
  2011-08-31  4:28 ` Max Mikhanosha
  0 siblings, 1 reply; 2+ messages in thread
From: Max Mikhanosha @ 2011-08-31  4:20 UTC (permalink / raw)
  To: emacs-devel

I had started using egg (the fancy vc-git replacement) and had noticed
that sometimes point jumps all over the place weirdly inside Egg
buffers. For example pressing down arrow on the very first change in
500 line diff, would jump to the end of the buffer.

After debugging it, it seems that Egg is using unique 'invisible text
property for every diff hunk text in the buffer, and sets
`buffer-invisibility-spec' to nil initially. It has the command to
show/hide diff hunks, which it accomplishes by adding/removing that
hunk's unique 'invisible property value to `buffer-invisibility-spec'
variable.

So far so good, but I was wondering why `next-line' function sometimes
skips the text that is not hidden. After debugging it, much to my
surprise, it appears that line-move-1 function in simple.el,
completely ignores `buffer-invisibility-spec' and skips any text with
non-NIL 'invisible property.

I had found the correct code to skip invisible text that takes
`buffer-invisibility-spec' into account in the forward-visual-line
function.

After changing the line-move-1 invisibility code to be the same, it had
fixed my problem with point jumping erratically in Egg buffers.

This is for Emacs 23, but Emacs 24 simple.el appears to have the same
problem.

Patch pasted below

=== modified file 'lisp/simple.el'
*** lisp/simple.el	2011-02-17 07:43:53 +0000
--- lisp/simple.el	2011-08-31 03:51:26 +0000
***************
*** 4254,4261 ****
  	      (while (and (> arg 0) (not done))
  		;; If the following character is currently invisible,
  		;; skip all characters with that same `invisible' property value.
! 		(while (and (not (eobp)) (invisible-p (point)))
! 		  (goto-char (next-char-property-change (point))))
  		;; Move a line.
  		;; We don't use `end-of-line', since we want to escape
  		;; from field boundaries occurring exactly at point.
--- 4254,4272 ----
  	      (while (and (> arg 0) (not done))
  		;; If the following character is currently invisible,
  		;; skip all characters with that same `invisible' property value.
!                 (while (and (not (eobp))
!                             (let ((prop
!                                    (get-char-property (point) 'invisible)))
!                               (if (eq buffer-invisibility-spec t)
!                                   prop
!                                 (or (memq prop buffer-invisibility-spec)
!                                     (assq prop buffer-invisibility-spec)))))
!                   (goto-char
!                    (if (get-text-property (point) 'invisible)
!                        (or (next-single-property-change (point) 'invisible)
!                            (point-max))
!                      (next-overlay-change (point)))))
! 
  		;; Move a line.
  		;; We don't use `end-of-line', since we want to escape
  		;; from field boundaries occurring exactly at point.
***************
*** 4309,4320 ****
  		    (setq done t))))
  		(unless done
  		  (setq arg (1+ arg))
! 		  (while (and ;; Don't move over previous invis lines
! 			  ;; if our target is the middle of this line.
! 			  (or (zerop (or goal-column temporary-goal-column))
! 			      (< arg 0))
! 			  (not (bobp)) (invisible-p (1- (point))))
! 		    (goto-char (previous-char-property-change (point))))))))
  	  ;; This is the value the function returns.
  	  (= arg 0))
  
--- 4320,4337 ----
  		    (setq done t))))
  		(unless done
  		  (setq arg (1+ arg))
!                   (while (and (not (bobp))
!                               (let ((prop
!                                      (get-char-property (1- (point)) 'invisible)))
!                                 (if (eq buffer-invisibility-spec t)
!                                     prop
!                                   (or (memq prop buffer-invisibility-spec)
!                                       (assq prop buffer-invisibility-spec)))))
!                     (goto-char
!                      (if (get-text-property (1- (point)) 'invisible)
!                          (or (previous-single-property-change (point) 'invisible)
!                              (point-min))
!                        (previous-overlay-change (point)))))))))
  	  ;; This is the value the function returns.
  	  (= arg 0))
  
***************
*** 4352,4360 ****
  	     (save-excursion
  	       ;; Like end-of-line but ignores fields.
  	       (skip-chars-forward "^\n")
! 	       (while (and (not (eobp)) (invisible-p (point)))
! 		 (goto-char (next-char-property-change (point)))
! 		 (skip-chars-forward "^\n"))
  	       (point))))
  
  	;; Move to the desired column.
--- 4369,4387 ----
  	     (save-excursion
  	       ;; Like end-of-line but ignores fields.
  	       (skip-chars-forward "^\n")
!                (while (and (not (eobp))
!                            (let ((prop
!                                   (get-char-property (point) 'invisible)))
!                              (if (eq buffer-invisibility-spec t)
!                                  prop
!                                (or (memq prop buffer-invisibility-spec)
!                                    (assq prop buffer-invisibility-spec)))))
!                  (goto-char
!                   (if (get-text-property (point) 'invisible)
!                       (or (next-single-property-change (point) 'invisible)
!                           (point-max))
!                     (next-overlay-change (point))))
!                  (skip-chars-forward "^\n"))
  	       (point))))
  
  	;; Move to the desired column.






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

* Re: BUG+patch: line-move-1 ignores buffer-invisibility-spec
  2011-08-31  4:20 BUG+patch: line-move-1 ignores buffer-invisibility-spec Max Mikhanosha
@ 2011-08-31  4:28 ` Max Mikhanosha
  0 siblings, 0 replies; 2+ messages in thread
From: Max Mikhanosha @ 2011-08-31  4:28 UTC (permalink / raw)
  To: emacs-devel

Oops please disregard this bug report.

Apparently I had some really old piece of code (library called APEL)
loaded, which had a definition of (invisible-p) function in it, which ignored
the buffer-invisibility-spec.

At Wed, 31 Aug 2011 00:20:07 -0400,
Max Mikhanosha wrote:
> 
> I had started using egg (the fancy vc-git replacement) and had noticed
> that sometimes point jumps all over the place weirdly inside Egg
> buffers. For example pressing down arrow on the very first change in
> 500 line diff, would jump to the end of the buffer.
> 
> After debugging it, it seems that Egg is using unique 'invisible text
> property for every diff hunk text in the buffer, and sets
> `buffer-invisibility-spec' to nil initially. It has the command to
> show/hide diff hunks, which it accomplishes by adding/removing that
> hunk's unique 'invisible property value to `buffer-invisibility-spec'
> variable.
> 
> So far so good, but I was wondering why `next-line' function sometimes
> skips the text that is not hidden. After debugging it, much to my
> surprise, it appears that line-move-1 function in simple.el,
> completely ignores `buffer-invisibility-spec' and skips any text with
> non-NIL 'invisible property.
> 
> I had found the correct code to skip invisible text that takes
> `buffer-invisibility-spec' into account in the forward-visual-line
> function.
> 
> After changing the line-move-1 invisibility code to be the same, it had
> fixed my problem with point jumping erratically in Egg buffers.
> 
> This is for Emacs 23, but Emacs 24 simple.el appears to have the same
> problem.
> 
> Patch pasted below
> 
> === modified file 'lisp/simple.el'
> *** lisp/simple.el	2011-02-17 07:43:53 +0000
> --- lisp/simple.el	2011-08-31 03:51:26 +0000
> ***************
> *** 4254,4261 ****
>   	      (while (and (> arg 0) (not done))
>   		;; If the following character is currently invisible,
>   		;; skip all characters with that same `invisible' property value.
> ! 		(while (and (not (eobp)) (invisible-p (point)))
> ! 		  (goto-char (next-char-property-change (point))))
>   		;; Move a line.
>   		;; We don't use `end-of-line', since we want to escape
>   		;; from field boundaries occurring exactly at point.
> --- 4254,4272 ----
>   	      (while (and (> arg 0) (not done))
>   		;; If the following character is currently invisible,
>   		;; skip all characters with that same `invisible' property value.
> !                 (while (and (not (eobp))
> !                             (let ((prop
> !                                    (get-char-property (point) 'invisible)))
> !                               (if (eq buffer-invisibility-spec t)
> !                                   prop
> !                                 (or (memq prop buffer-invisibility-spec)
> !                                     (assq prop buffer-invisibility-spec)))))
> !                   (goto-char
> !                    (if (get-text-property (point) 'invisible)
> !                        (or (next-single-property-change (point) 'invisible)
> !                            (point-max))
> !                      (next-overlay-change (point)))))
> ! 
>   		;; Move a line.
>   		;; We don't use `end-of-line', since we want to escape
>   		;; from field boundaries occurring exactly at point.
> ***************
> *** 4309,4320 ****
>   		    (setq done t))))
>   		(unless done
>   		  (setq arg (1+ arg))
> ! 		  (while (and ;; Don't move over previous invis lines
> ! 			  ;; if our target is the middle of this line.
> ! 			  (or (zerop (or goal-column temporary-goal-column))
> ! 			      (< arg 0))
> ! 			  (not (bobp)) (invisible-p (1- (point))))
> ! 		    (goto-char (previous-char-property-change (point))))))))
>   	  ;; This is the value the function returns.
>   	  (= arg 0))
>   
> --- 4320,4337 ----
>   		    (setq done t))))
>   		(unless done
>   		  (setq arg (1+ arg))
> !                   (while (and (not (bobp))
> !                               (let ((prop
> !                                      (get-char-property (1- (point)) 'invisible)))
> !                                 (if (eq buffer-invisibility-spec t)
> !                                     prop
> !                                   (or (memq prop buffer-invisibility-spec)
> !                                       (assq prop buffer-invisibility-spec)))))
> !                     (goto-char
> !                      (if (get-text-property (1- (point)) 'invisible)
> !                          (or (previous-single-property-change (point) 'invisible)
> !                              (point-min))
> !                        (previous-overlay-change (point)))))))))
>   	  ;; This is the value the function returns.
>   	  (= arg 0))
>   
> ***************
> *** 4352,4360 ****
>   	     (save-excursion
>   	       ;; Like end-of-line but ignores fields.
>   	       (skip-chars-forward "^\n")
> ! 	       (while (and (not (eobp)) (invisible-p (point)))
> ! 		 (goto-char (next-char-property-change (point)))
> ! 		 (skip-chars-forward "^\n"))
>   	       (point))))
>   
>   	;; Move to the desired column.
> --- 4369,4387 ----
>   	     (save-excursion
>   	       ;; Like end-of-line but ignores fields.
>   	       (skip-chars-forward "^\n")
> !                (while (and (not (eobp))
> !                            (let ((prop
> !                                   (get-char-property (point) 'invisible)))
> !                              (if (eq buffer-invisibility-spec t)
> !                                  prop
> !                                (or (memq prop buffer-invisibility-spec)
> !                                    (assq prop buffer-invisibility-spec)))))
> !                  (goto-char
> !                   (if (get-text-property (point) 'invisible)
> !                       (or (next-single-property-change (point) 'invisible)
> !                           (point-max))
> !                     (next-overlay-change (point))))
> !                  (skip-chars-forward "^\n"))
>   	       (point))))
>   
>   	;; Move to the desired column.
> 
> 
> 



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

end of thread, other threads:[~2011-08-31  4:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-31  4:20 BUG+patch: line-move-1 ignores buffer-invisibility-spec Max Mikhanosha
2011-08-31  4:28 ` Max Mikhanosha

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).