emacs-devel
[Top][All Lists]
Advanced

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

Re: Undesired point moves while compiling


From: Juri Linkov
Subject: Re: Undesired point moves while compiling
Date: Wed, 02 Nov 2005 08:22:07 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

> I've got a bizarre problem related to the compilation-mode. When I
> start a compile, everything works fine unless I execute 'next-error'
> while the compile is in progress, at which point the point/cursor
> jumps around in my source code window.

The easiest way to debug this problem is the following:
put a breakpoint on `compilation-internal-error-properties',
and in emacs/etc/ directory type:

  M-x compile RET echo TODO:10: error; sleep 15s; echo TODO:21: error; sleep 
1500s; echo TODO:33: error RET

After the first line appears in the Compilation buffer, execute
'next-error' on it.  When the second line arrives, fontification
calls `compilation-internal-error-properties'.

There is special code in this function that uses beginning-of-line to
move point in the source buffer during fontification.  But I don't know
is this intentional or not.  Or maybe `save-excursion' is missing
around `save-restriction'?

Below is the code that moves point in `compilation-internal-error-properties':

    ...
    (if (not (and marker (marker-buffer marker)))
        (setq marker nil)               ; no valid marker for this file
      (setq loc (or line 1))            ; normalize no linenumber to line 1
      (catch 'marker                    ; find nearest loc, at least one exists
        (dolist (x (nthcdr 3 file-struct))      ; loop over remaining lines
          (if (> (car x) loc)           ; still bigger
              (setq marker-line x)
            (if (> (- (or (car marker-line) 1) loc)
                   (- loc (car x)))     ; current line is nearer
                (setq marker-line x))
            (throw 'marker t))))
      (setq marker (nth 3 (cadr marker-line))
            marker-line (or (car marker-line) 1))
      (with-current-buffer (marker-buffer marker)
        (save-restriction
          (widen)
          (goto-char (marker-position marker))
          (when (or end-col end-line)
            (beginning-of-line (- (or end-line line) marker-line -1))
            (if (or (null end-col) (< end-col 0))
                (end-of-line)
              (compilation-move-to-column
               end-col compilation-error-screen-columns))
            (setq end-marker (list (point-marker))))
          (beginning-of-line (if end-line
           ================= <--- point is moved here
                                 (- line end-line -1)
                               (- loc marker-line -1)))
          (if col
              (compilation-move-to-column
               col compilation-error-screen-columns)
            (forward-to-indentation 0))
          (setq marker (list (point-marker))))))
    ...

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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