From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry OReilly Newsgroups: gmane.emacs.bugs Subject: bug#15045: Point jumps inappropriately around time of Semantic lexing Date: Fri, 25 Oct 2013 15:15:48 -0400 Message-ID: References: <837gfvua2r.fsf@gnu.org> <87y58bs9x4.fsf@engster.org> <83zjsrs3k2.fsf@gnu.org> <87pptmsv4z.fsf@engster.org> <83siyira0w.fsf@gnu.org> <87vc3drhuv.fsf@engster.org> <83haexrgjn.fsf@gnu.org> <83ppr7pr6c.fsf@gnu.org> <83li1upkfx.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b33d176f847dd04e995937f X-Trace: ger.gmane.org 1382728578 18882 80.91.229.3 (25 Oct 2013 19:16:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Oct 2013 19:16:18 +0000 (UTC) Cc: 15045@debbugs.gnu.org, David Engster , Eric Ludlam To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 25 21:16:19 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VZmrq-0004th-Pt for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Oct 2013 21:16:19 +0200 Original-Received: from localhost ([::1]:60563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZmrq-0003KZ-A6 for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Oct 2013 15:16:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZmrg-0003Ja-PF for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 15:16:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZmra-0007C5-HE for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 15:16:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58167) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZmra-0007C1-DK for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 15:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VZmra-0008Vs-0o for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 15:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Barry OReilly Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Oct 2013 19:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15045 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15045-submit@debbugs.gnu.org id=B15045.138272855832712 (code B ref 15045); Fri, 25 Oct 2013 19:16:01 +0000 Original-Received: (at 15045) by debbugs.gnu.org; 25 Oct 2013 19:15:58 +0000 Original-Received: from localhost ([127.0.0.1]:43953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VZmrU-0008VX-OK for submit@debbugs.gnu.org; Fri, 25 Oct 2013 15:15:57 -0400 Original-Received: from mail-ob0-f180.google.com ([209.85.214.180]:47713) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VZmrS-0008VI-E1 for 15045@debbugs.gnu.org; Fri, 25 Oct 2013 15:15:55 -0400 Original-Received: by mail-ob0-f180.google.com with SMTP id wo20so1359315obc.39 for <15045@debbugs.gnu.org>; Fri, 25 Oct 2013 12:15:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ELcHijWg6H0NpBW1uOI1hT+LQ/dymDIEQptM4M33Lko=; b=phG0pr1A/cHJPA4pifzTbzgCeEdQXe2ogJR+dWnGqYB2MF0Mzyy05i4BU1Nomq9btY 6Rb23qwzcLtXXgwi7SWKEzY8YvuYba6JPkf/kO4OwqXRrPLkpY9O9JY8Oj3m8dyB0VYc uBDdutA9UbLCYqC9Cfj81Rtv28idoW0r6mV3i/DZs9l0WzjwM+C+OuKmgGw40hfErh5V 8xA2J/5CCRD3ebk0Xk/SZq7+LFk+plBnb7QVeLZF67ZcdDfypiDnA3snNs6fE5GXMjaA +iMOK4YJu1Mp09GazvEeK6xz1m5hnXrGpNGyG5MBYkCY8XCRD3YhFEEv0im4JvRzAGJ5 O9ZQ== X-Received: by 10.60.93.67 with SMTP id cs3mr4311829oeb.12.1382728548760; Fri, 25 Oct 2013 12:15:48 -0700 (PDT) Original-Received: by 10.76.156.103 with HTTP; Fri, 25 Oct 2013 12:15:48 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:79659 Archived-At: --047d7b33d176f847dd04e995937f Content-Type: text/plain; charset=ISO-8859-1 In terms of solving the issue of how Semantic calls accept-process-output, here are two proposals: 1: Per David Engster: > If you look in the `define-lex' macro, you see that it calls > `semantic-throw-on-input' after each identified token. The problem is > that it does not restore the cursor position before that, so I guess the > fix is simply to change this call to > > (save-excursion > (goto-char starting-position) > (semantic-throw-on-input 'lex)) Here's a patch to implement the basic idea. My debugging indicates accept-process-output can be called when lexing other buffers, so I saved off the marker rather than just position. That said, I have never personally witnessed point unexpectedly redisplayed in another buffer -- only within the same buffer. That could be a consequence of how it interacts with the jit-lock-deferred-fontify idle timer. (I have confirmed with my debug statements that Semantic is the outer timer and jit-lock-deferred-fontify is the inner timer which redisplays.) Please let me know if this fix is suitable. diff --git a/lisp/cedet/semantic/fw.el b/lisp/cedet/semantic/fw.el index 825cdc9..869d183 100644 --- a/lisp/cedet/semantic/fw.el +++ b/lisp/cedet/semantic/fw.el @@ -369,6 +369,8 @@ later installation should be done in MODE hook." ;; (defvar semantic-current-input-throw-symbol nil "The current throw symbol for `semantic-exit-on-input'.") +(defvar semantic--on-input-start-marker nil + "The marker when starting a semantic-exit-on-input form.") (defmacro semantic-exit-on-input (symbol &rest forms) "Using SYMBOL as an argument to `throw', execute FORMS. @@ -376,7 +378,8 @@ If FORMS includes a call to `semantic-throw-on-input', then if a user presses any key during execution, this form macro will exit with the value passed to `semantic-throw-on-input'. If FORMS completes, then the return value is the same as `progn'." - `(let ((semantic-current-input-throw-symbol ,symbol)) + `(let ((semantic-current-input-throw-symbol ,symbol) + (semantic--on-input-start-marker (point-marker))) (catch ,symbol ,@forms))) (put 'semantic-exit-on-input 'lisp-indent-function 1) @@ -387,7 +390,16 @@ FROM is an indication of where this function is called from as a value to pass to `throw'. It is recommended to use the name of the function calling this one." `(when (and semantic-current-input-throw-symbol - (or (input-pending-p) (accept-process-output))) + (or (input-pending-p) + (save-excursion + ;; Timers might run during accept-process-output. + ;; If they redisplay, point must be where the user + ;; expects. (Bug#15045) + (set-buffer (marker-buffer + semantic--on-input-start-marker)) + (goto-char (marker-position + semantic--on-input-start-marker)) + (accept-process-output)))) (throw semantic-current-input-throw-symbol ,from))) ^L 2: Extend accept-process-output to allow suppressing timer_check. Actually, there's an input arg already for that, but only applicable if the PROCESS arg is non nil. --047d7b33d176f847dd04e995937f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
In terms of solving the issue of how Semantic calls
acc= ept-process-output, here are two proposals:

1: Per David Engster:
> If you look in the `define-lex' macro, you see that it calls<= br> > `semantic-throw-on-input' after each identified token. The problem= is
> that it does not restore the cursor position before that, so I = guess the
> fix is simply to change this call to
>
> =A0= =A0=A0 =A0=A0 (save-excursion
> =A0=A0=A0 =A0=A0=A0=A0 (goto-char starting-position)
> =A0=A0=A0= =A0=A0=A0=A0 (semantic-throw-on-input 'lex))

Here's a patch= to implement the basic idea. My debugging indicates
accept-process-outp= ut can be called when lexing other buffers, so I
saved off the marker rather than just position.

That said, I have ne= ver personally witnessed point unexpectedly
redisplayed in another buffe= r -- only within the same buffer. That
could be a consequence of how it = interacts with the
jit-lock-deferred-fontify idle timer. (I have confirmed with my debug
st= atements that Semantic is the outer timer and
jit-lock-deferred-fontify = is the inner timer which redisplays.)

Please let me know if this fix= is suitable.

diff --git a/lisp/cedet/semantic/fw.el b/lisp/cedet/semantic/fw.el
i= ndex 825cdc9..869d183 100644
--- a/lisp/cedet/semantic/fw.el
+++ b/li= sp/cedet/semantic/fw.el
@@ -369,6 +369,8 @@ later installation should be= done in MODE hook."
=A0;;
=A0(defvar semantic-current-input-throw-symbol nil
=A0=A0 "= ;The current throw symbol for `semantic-exit-on-input'.")
+(def= var semantic--on-input-start-marker nil
+=A0 "The marker when start= ing a semantic-exit-on-input form.")
=A0
=A0(defmacro semantic-exit-on-input (symbol &rest forms)
=A0= =A0 "Using SYMBOL as an argument to `throw', execute FORMS.
@@ = -376,7 +378,8 @@ If FORMS includes a call to `semantic-throw-on-input',= then
=A0if a user presses any key during execution, this form macro
=A0will e= xit with the value passed to `semantic-throw-on-input'.
=A0If FORMS = completes, then the return value is the same as `progn'."
-=A0 = `(let ((semantic-current-input-throw-symbol ,symbol))
+=A0 `(let ((semantic-current-input-throw-symbol ,symbol)
+=A0=A0=A0=A0= =A0=A0=A0=A0 (semantic--on-input-start-marker (point-marker)))
=A0=A0=A0= =A0=A0 (catch ,symbol
=A0=A0=A0=A0=A0=A0=A0 ,@forms)))
=A0(put 's= emantic-exit-on-input 'lisp-indent-function 1)
@@ -387,7 +390,16 @@ FROM is an indication of where this function is called= from as a value
=A0to pass to `throw'.=A0 It is recommended to use = the name of the function
=A0calling this one."
=A0=A0 `(when (an= d semantic-current-input-throw-symbol
-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (or (input-pending-p) (accept-proc= ess-output)))
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (or (input-pendin= g-p)
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (save-excursio= n
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;; Timers m= ight run during accept-process-output.
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 ;; If they redisplay, point must be where the u= ser
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;; expects. (Bug= #15045)
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (set-= buffer (marker-buffer
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 semantic--on-input-start-m= arker))
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (goto= -char (marker-position
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 semantic--on-input-start-marker))
+=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (accept-process-output))))
= =A0=A0=A0=A0=A0 (throw semantic-current-input-throw-symbol ,from)))
=A0<= br>=A0^L

2: Extend accept-process-output to allow suppressing timer_= check.
Actually, there's an input arg already for that, but only applicableif the PROCESS arg is non nil.

--047d7b33d176f847dd04e995937f--