emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BUG+patch: line-move-1 ignores buffer-invisibility-spec


From: Max Mikhanosha
Subject: BUG+patch: line-move-1 ignores buffer-invisibility-spec
Date: Wed, 31 Aug 2011 00:20:07 -0400
User-agent: Wanderlust/2.15.3 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.3.50 (x86_64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO)

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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]