all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help debugging erratic cursor movement
@ 2016-06-09 10:03 Bastian Beischer
  2016-06-09 18:51 ` Tomas Nordin
  0 siblings, 1 reply; 7+ messages in thread
From: Bastian Beischer @ 2016-06-09 10:03 UTC (permalink / raw)
  To: Help-Gnu-Emacs

Dear all,

I'm trying to debug a problem I'm having for a while. I'm using GNU
Emacs 25.0.94.1 in combination with various extensions.

The problem I'm having is the following: When developing code my
cursor sometimes moves erratically while I'm inserting characters. An
example is:

int main() {
  int a = <INSERT 0 HERE>
}

so I'm expecting:

int main() {
  int a = 0
}

but instead the cursor sometimes moves upwards and the '0' is not
inserted in the proper place. Instead it's inserted somewhere above
(it's always above, typically some place close to the start of the
function, sometimes it's the beginning of the file, not 100% sure
here), so the result is:

int0 main() {
  int a=
}

You can see how this is very annoying... Unfortunately this does not
happen every time so it cannot be easily reproduced. It seems to
depend on how fast I type, among other things which I haven't figured
out, yet. I'm suspecting that some function is run based on a timer
which moves point and is supposed to move point back, but then my
self-insert-command interrupts the timer and the '0' is inserted in
the wrong place. But that's only an idea. I don't think the issue
appears in vanilla emacs, and I'm not yet sure which of my extensions
is causing it so I don't know where to report a bug at this point. It
may even be some function of my own, or some customization that I did
which is causing the problem.

My question is if anybody has any idea how to debug this problem? What
I've already tried is to add a function to post-command-hook which
logs all the commands:

(defvar last-post-command-position 0
  "Holds the cursor position from the last run of post-command-hooks.")

(make-variable-buffer-local 'last-post-command-position)

(setq log-buffer (find-file "~/command.log"))

(defun my-command-log-hook ()
  "Log movement commands"
  (let ((prevbuf (current-buffer))
        (lastpos last-post-command-position)
        (currentpos (point))
        (cmd this-command))
    (with-current-buffer log-buffer
      (goto-char (point-max))
      (insert (format "%s: <%20s>: %5d -> %5d: %s\n"
(current-time-string) prevbuf lastpos currentpos cmd))))
  (setq last-post-command-position (point)))

(add-hook 'post-command-hook 'my-command-log-hook)

This writes all commands to a log file. Unfortunately I don't see any
other commands than 'self-insert-command' when the problem happens:

Thu Jun  9 11:57:06 2016: <  AnalysisParticle.C>:  4594 ->  4595:
self-insert-command
Thu Jun  9 11:57:06 2016: <  AnalysisParticle.C>:  4595 ->  4596:
self-insert-command
Thu Jun  9 11:57:06 2016: <  AnalysisParticle.C>:  4596 ->  4597:
self-insert-command
Thu Jun  9 11:57:06 2016: <  AnalysisParticle.C>:  4597 ->  4598:
self-insert-command
Thu Jun  9 11:57:06 2016: <  AnalysisParticle.C>:  4598 ->  4599:
self-insert-command
Thu Jun  9 11:57:06 2016: <  AnalysisParticle.C>:  4599 ->  4600:
self-insert-command
Thu Jun  9 11:57:06 2016: <  AnalysisParticle.C>:  4600 ->  4601:
self-insert-command
Thu Jun  9 11:57:06 2016: <  AnalysisParticle.C>:  4601 ->  3853:
self-insert-command

You can see how point moved to position 3853 in the last line, even
though I ran regular self-insert-command.

Is there someway I can use the emacs debugger to set a breakpoint on
some function (goto-char ?). Does anybody have any other ideas?

Thanks a lot for your help!

Cheers
Bastian

-- 
Bastian Beischer
RWTH Aachen University of Technology

@RWTH Aachen
Office: 28 C 203
Phone: +49-241-80-27205
E-mail: beischer@physik.rwth-aachen.de
Address: I. Physikalisches Institut B, Sommerfeldstr. 14, D-52074 Aachen

@CERN
Office: Bdg 32-4-B12
Phone: +41-22-76-75750
E-mail: bastian.beischer@cern.ch
Address: CERN, CH-1211 Geneve 23



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

* Re: Help debugging erratic cursor movement
  2016-06-09 10:03 Help debugging erratic cursor movement Bastian Beischer
@ 2016-06-09 18:51 ` Tomas Nordin
  2016-06-09 22:01   ` Bastian Beischer
       [not found]   ` <mailman.1246.1465512570.1216.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 7+ messages in thread
From: Tomas Nordin @ 2016-06-09 18:51 UTC (permalink / raw)
  To: Bastian Beischer; +Cc: Help-Gnu-Emacs


Bastian Beischer writes:

> happen every time so it cannot be easily reproduced. It seems to
> depend on how fast I type, among other things which I haven't figured

You don't happen to have something like key-chord.el loaded?
http://emacsrocks.com/e07.html

Try and figure out a way to reproduce the problem and then mock out
extension by extension and see with which one you get the problem. It
seems to me there must be something that is watching out for how fast
two keys come next to each-other.



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

* Re: Help debugging erratic cursor movement
  2016-06-09 18:51 ` Tomas Nordin
@ 2016-06-09 22:01   ` Bastian Beischer
  2016-06-09 23:20     ` John Mastro
       [not found]   ` <mailman.1246.1465512570.1216.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Bastian Beischer @ 2016-06-09 22:01 UTC (permalink / raw)
  To: Tomas Nordin; +Cc: Help-Gnu-Emacs

Thanks Tomas,



On Thu, Jun 9, 2016 at 8:51 PM, Tomas Nordin <tomasn@posteo.net> wrote:
>
> Bastian Beischer writes:
>
>> happen every time so it cannot be easily reproduced. It seems to
>> depend on how fast I type, among other things which I haven't figured
>
> You don't happen to have something like key-chord.el loaded?
> http://emacsrocks.com/e07.html

No I don't have key-chord.el loaded.

>
> Try and figure out a way to reproduce the problem and then mock out
> extension by extension and see with which one you get the problem. It
> seems to me there must be something that is watching out for how fast
> two keys come next to each-other.

Unfortunately I still don't have recipe to reproduce the issue. I
learned about 'debug-on-entry', though. Unfortunately the piece of
code that is causing the problem does not call goto-char (inferred by
using '(debug-on-entry 'goto-char)' and waiting for bug to happen ->
no debug backtrace) :-(

I'll try to load different components of my setup one-by-one to see
which one is causing it. My best guess at the moment would be
semantic-highlight-func-highlight-current-tag which is part of my
post-command-hook. This would explain why the jump is usually to the
start of a function...

-- 
Bastian Beischer
RWTH Aachen University of Technology

@RWTH Aachen
Office: 28 C 203
Phone: +49-241-80-27205
E-mail: beischer@physik.rwth-aachen.de
Address: I. Physikalisches Institut B, Sommerfeldstr. 14, D-52074 Aachen

@CERN
Office: Bdg 32-4-B12
Phone: +41-22-76-75750
E-mail: bastian.beischer@cern.ch
Address: CERN, CH-1211 Geneve 23



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

* Re: Help debugging erratic cursor movement
  2016-06-09 22:01   ` Bastian Beischer
@ 2016-06-09 23:20     ` John Mastro
  0 siblings, 0 replies; 7+ messages in thread
From: John Mastro @ 2016-06-09 23:20 UTC (permalink / raw)
  To: Help-Gnu-Emacs; +Cc: Bastian Beischer, Tomas Nordin

Bastian Beischer <bastian.beischer@rwth-aachen.de> wrote:
> Unfortunately I still don't have recipe to reproduce the issue. I
> learned about 'debug-on-entry', though. Unfortunately the piece of
> code that is causing the problem does not call goto-char (inferred by
> using '(debug-on-entry 'goto-char)' and waiting for bug to happen ->
> no debug backtrace) :-(

If the problem function is compiled, it may use `goto-char' but still
not trigger `debug-on-entry', because the compiled code would use the
goto-char bytecode instruction rather than the actual function.

You can get around this by using C-M-x on the defun of any functions you
consider candidates. That will cause Emacs to interpret those functions
rather than running their bytecode. (You could even do that for whole
source files by using `eval-buffer').

        John



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

* Re: Help debugging erratic cursor movement
       [not found]   ` <mailman.1246.1465512570.1216.help-gnu-emacs@gnu.org>
@ 2016-06-10  7:37     ` Joost Kremers
  2016-06-10 12:34       ` Tassilo Horn
  0 siblings, 1 reply; 7+ messages in thread
From: Joost Kremers @ 2016-06-10  7:37 UTC (permalink / raw)
  To: help-gnu-emacs

Bastian Beischer wrote:
> I'll try to load different components of my setup one-by-one to see
> which one is causing it. My best guess at the moment would be
> semantic-highlight-func-highlight-current-tag which is part of my
> post-command-hook. This would explain why the jump is usually to the
> start of a function...

If that's your suspicion, why not simply remove that function from your
post-command-hook and see what happens?


-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

* Re: Help debugging erratic cursor movement
  2016-06-10  7:37     ` Joost Kremers
@ 2016-06-10 12:34       ` Tassilo Horn
  2016-06-10 20:33         ` Bastian Beischer
  0 siblings, 1 reply; 7+ messages in thread
From: Tassilo Horn @ 2016-06-10 12:34 UTC (permalink / raw)
  To: help-gnu-emacs

Joost Kremers <joost.m.kremers@gmail.com> writes:

>> I'll try to load different components of my setup one-by-one to see
>> which one is causing it. My best guess at the moment would be
>> semantic-highlight-func-highlight-current-tag which is part of my
>> post-command-hook. This would explain why the jump is usually to the
>> start of a function...
>
> If that's your suspicion, why not simply remove that function from
> your post-command-hook and see what happens?

I think some weeks ago there was a thread on emacs-devel about such a
problem which has been fixed [1].  So it might be possible that just
updating your snapshot will already solve that issue.

Bye,
Tassilo

[1] A quick search revealed this:

    http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22287
    https://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00029.html



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

* Re: Help debugging erratic cursor movement
  2016-06-10 12:34       ` Tassilo Horn
@ 2016-06-10 20:33         ` Bastian Beischer
  0 siblings, 0 replies; 7+ messages in thread
From: Bastian Beischer @ 2016-06-10 20:33 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Help-Gnu-Emacs

On Fri, Jun 10, 2016 at 2:34 PM, Tassilo Horn <tsdh@gnu.org> wrote:
> Joost Kremers <joost.m.kremers@gmail.com> writes:
>
>>> I'll try to load different components of my setup one-by-one to see
>>> which one is causing it. My best guess at the moment would be
>>> semantic-highlight-func-highlight-current-tag which is part of my
>>> post-command-hook. This would explain why the jump is usually to the
>>> start of a function...
>>
>> If that's your suspicion, why not simply remove that function from
>> your post-command-hook and see what happens?
>
> I think some weeks ago there was a thread on emacs-devel about such a
> problem which has been fixed [1].  So it might be possible that just
> updating your snapshot will already solve that issue.

Thank you so much Tassilo. This sounds exactly like my problem. My
emacs-25 snapshot was recent, but I'm using cedet from it's upstream
repository, which does not contain the fix. I have backported the
cedet change in the emacs-25 branch to my local checkout of the cedet
repository. Let's see if this really fixes the problem.

>
> Bye,
> Tassilo
>
> [1] A quick search revealed this:
>
>     http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22287
>     https://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00029.html
>



-- 
Bastian Beischer
RWTH Aachen University of Technology

@RWTH Aachen
Office: 28 C 203
Phone: +49-241-80-27205
E-mail: beischer@physik.rwth-aachen.de
Address: I. Physikalisches Institut B, Sommerfeldstr. 14, D-52074 Aachen

@CERN
Office: Bdg 32-4-B12
Phone: +41-22-76-75750
E-mail: bastian.beischer@cern.ch
Address: CERN, CH-1211 Geneve 23



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

end of thread, other threads:[~2016-06-10 20:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-09 10:03 Help debugging erratic cursor movement Bastian Beischer
2016-06-09 18:51 ` Tomas Nordin
2016-06-09 22:01   ` Bastian Beischer
2016-06-09 23:20     ` John Mastro
     [not found]   ` <mailman.1246.1465512570.1216.help-gnu-emacs@gnu.org>
2016-06-10  7:37     ` Joost Kremers
2016-06-10 12:34       ` Tassilo Horn
2016-06-10 20:33         ` Bastian Beischer

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.