* Undesired point moves while compiling
@ 2005-11-02 4:26 Brad Howes
2005-11-02 6:22 ` Juri Linkov
0 siblings, 1 reply; 7+ messages in thread
From: Brad Howes @ 2005-11-02 4:26 UTC (permalink / raw)
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. A search of the list archives
shows that David Abrahams reported what appears to be the same
behavior I'm having:
http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg00029.html
But no solution was posted in the thread.
I've compiled from the CVS source, running on Mac OS X 10.4.2. I have
an older Emacs version of 21.3.50 which does not have this problem.
Thanks!
Brad
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Undesired point moves while compiling
2005-11-02 4:26 Undesired point moves while compiling Brad Howes
@ 2005-11-02 6:22 ` Juri Linkov
2005-11-02 17:55 ` Brad Howes
2005-11-07 15:34 ` Richard M. Stallman
0 siblings, 2 replies; 7+ messages in thread
From: Juri Linkov @ 2005-11-02 6:22 UTC (permalink / raw)
Cc: emacs-devel
> 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/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Undesired point moves while compiling
2005-11-02 6:22 ` Juri Linkov
@ 2005-11-02 17:55 ` Brad Howes
2005-11-05 9:47 ` Juri Linkov
2005-11-07 15:34 ` Richard M. Stallman
1 sibling, 1 reply; 7+ messages in thread
From: Brad Howes @ 2005-11-02 17:55 UTC (permalink / raw)
Cc: emacs-devel
> 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'?
Excellent suggestion! Inserting a `save-excursion' between the
`with-current-buffer' and `save-restriction' (line 710) in the routine
`compilation-internal-error-properties' fixed my problem. Thanks!
Brad
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Undesired point moves while compiling
2005-11-02 17:55 ` Brad Howes
@ 2005-11-05 9:47 ` Juri Linkov
2005-11-05 23:43 ` Richard M. Stallman
2005-11-06 4:02 ` Miles Bader
0 siblings, 2 replies; 7+ messages in thread
From: Juri Linkov @ 2005-11-05 9:47 UTC (permalink / raw)
Cc: emacs-devel
>> 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'?
>
> Excellent suggestion! Inserting a `save-excursion' between the
> `with-current-buffer' and `save-restriction' (line 710) in the routine
> `compilation-internal-error-properties' fixed my problem. Thanks!
After looking more at this function I still can't decide if its current
behavior is intentional or not. Someone might want to call `next-error'
on the first message, sit back and see how the cursor jumps around in the
source buffer.
But really I don't think this is useful. Perhaps this should be
changed in CVS to save point?
Index: lisp/progmodes/compile.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v
retrieving revision 1.388
diff -c -w -b -r1.388 compile.el
*** lisp/progmodes/compile.el 16 Oct 2005 14:12:50 -0000 1.388
--- lisp/progmodes/compile.el 5 Nov 2005 09:44:18 -0000
***************
*** 707,712 ****
--- 707,713 ----
(setq marker (nth 3 (cadr marker-line))
marker-line (or (car marker-line) 1))
(with-current-buffer (marker-buffer marker)
+ (save-excursion
(save-restriction
(widen)
(goto-char (marker-position marker))
***************
*** 724,730 ****
(compilation-move-to-column
col compilation-error-screen-columns)
(forward-to-indentation 0))
! (setq marker (list (point-marker))))))
(setq loc (compilation-assq line (cdr file-struct)))
(if end-line
--- 725,731 ----
(compilation-move-to-column
col compilation-error-screen-columns)
(forward-to-indentation 0))
! (setq marker (list (point-marker)))))))
(setq loc (compilation-assq line (cdr file-struct)))
(if end-line
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Undesired point moves while compiling
2005-11-05 9:47 ` Juri Linkov
@ 2005-11-05 23:43 ` Richard M. Stallman
2005-11-06 4:02 ` Miles Bader
1 sibling, 0 replies; 7+ messages in thread
From: Richard M. Stallman @ 2005-11-05 23:43 UTC (permalink / raw)
Cc: howes, emacs-devel
After looking more at this function I still can't decide if its current
behavior is intentional or not. Someone might want to call `next-error'
on the first message, sit back and see how the cursor jumps around in the
source buffer.
I could try to think about it, if you explain to me in a
self-contained way what the issue is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Undesired point moves while compiling
2005-11-05 9:47 ` Juri Linkov
2005-11-05 23:43 ` Richard M. Stallman
@ 2005-11-06 4:02 ` Miles Bader
1 sibling, 0 replies; 7+ messages in thread
From: Miles Bader @ 2005-11-06 4:02 UTC (permalink / raw)
Cc: Brad Howes, emacs-devel
2005/11/5, Juri Linkov <juri@jurta.org>:
> After looking more at this function I still can't decide if its current
> behavior is intentional or not. Someone might want to call `next-error'
> on the first message, sit back and see how the cursor jumps around in the
> source buffer.
Intentional or not, it's extremely annoying behavior everytime I've
encountered it. [Indeed, the new compile mode has had _many_
intentional "features" that basically sucked, and were changed.]
-Miles
--
Do not taunt Happy Fun Ball.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Undesired point moves while compiling
2005-11-02 6:22 ` Juri Linkov
2005-11-02 17:55 ` Brad Howes
@ 2005-11-07 15:34 ` Richard M. Stallman
1 sibling, 0 replies; 7+ messages in thread
From: Richard M. Stallman @ 2005-11-07 15:34 UTC (permalink / raw)
Cc: bradhowes, emacs-devel
I've concluded that adding save-excursion there is correct.
Since that function's job is to look at the situation and compute
data that represents facts, it should not permanently alter point.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-11-07 15:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-02 4:26 Undesired point moves while compiling Brad Howes
2005-11-02 6:22 ` Juri Linkov
2005-11-02 17:55 ` Brad Howes
2005-11-05 9:47 ` Juri Linkov
2005-11-05 23:43 ` Richard M. Stallman
2005-11-06 4:02 ` Miles Bader
2005-11-07 15:34 ` Richard M. Stallman
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.