help-gnu-emacs
[Top][All Lists]
Advanced

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

Help debugging erratic cursor movement


From: Bastian Beischer
Subject: Help debugging erratic cursor movement
Date: Thu, 9 Jun 2016 12:03:14 +0200

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



reply via email to

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