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

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.