From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: Re: undo after repeatedly calling 'repeat' leaves cursor in the wrong place Date: Thu, 04 Oct 2007 10:27:22 +0200 Message-ID: <4704A3EA.3010902@gmx.at> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040602000304050102050302" X-Trace: sea.gmane.org 1191486516 21480 80.91.229.12 (4 Oct 2007 08:28:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 4 Oct 2007 08:28:36 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org To: Chris Moore Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 04 10:28:33 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IdM4P-00033s-F7 for ged-emacs-devel@m.gmane.org; Thu, 04 Oct 2007 10:28:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IdM4K-0003Q9-NI for ged-emacs-devel@m.gmane.org; Thu, 04 Oct 2007 04:28:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IdM4F-0003N4-A8 for emacs-devel@gnu.org; Thu, 04 Oct 2007 04:28:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IdM4E-0003Lb-AI for emacs-devel@gnu.org; Thu, 04 Oct 2007 04:28:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IdM4E-0003LF-17 for emacs-devel@gnu.org; Thu, 04 Oct 2007 04:28:22 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IdM4D-0002rD-MY for emacs-devel@gnu.org; Thu, 04 Oct 2007 04:28:21 -0400 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IdM3N-0002k5-6y for emacs-pretest-bug@gnu.org; Thu, 04 Oct 2007 04:27:29 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1IdM4A-0002qe-Gu for emacs-pretest-bug@gnu.org; Thu, 04 Oct 2007 04:28:21 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1IdM49-0002qS-UI for emacs-pretest-bug@gnu.org; Thu, 04 Oct 2007 04:28:18 -0400 Original-Received: (qmail invoked by alias); 04 Oct 2007 08:28:15 -0000 Original-Received: from N786P000.adsl.highway.telekom.at (EHLO [62.47.42.32]) [62.47.42.32] by mail.gmx.net (mp004) with SMTP; 04 Oct 2007 10:28:15 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/1cFRfyvX16M41qw95BWqJ2bR9l11OP9v4wx6+cH mJAY7KuwikF6U1 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: X-Y-GMX-Trusted: 0 X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:80224 gmane.emacs.pretest.bugs:20068 Archived-At: This is a multi-part message in MIME format. --------------040602000304050102050302 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > Type > "x C-x z z z z C-x u" > (to insert an 'x', repeat the insert 4 times, then undo the last of the 4) > > Before the "C-x u" there were 5 'x's with the cursor after them all. > After the "C-x u" there are 4 'x's, as expected, but the cursor is on > the 2nd one, whereas I would expect it to be after the 4th one. > > If "C-x z" is used in full each time, instead of just hitting 'z' over > and over, then the undo works as expected. Could you please try the attached patch - against EMACS_22_BASE - and tell whether it does the right thing. --------------040602000304050102050302 Content-Type: text/plain; name="repeat-undo.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="repeat-undo.patch" *** undo.c Wed Jul 25 07:15:32 2007 --- undo.c Thu Oct 4 10:04:52 2007 *************** *** 53,60 **** an undo-boundary. */ Lisp_Object pending_boundary; /* Record point as it was at beginning of this command (if necessary) ! And prepare the undo info for recording a change. PT is the position of point that will naturally occur as a result of the undo record that will be added just after this command terminates. */ --- 53,64 ---- an undo-boundary. */ Lisp_Object pending_boundary; + /* Nonzero means do not record point in record_point. */ + + int undo_inhibit_record_point; + /* Record point as it was at beginning of this command (if necessary) ! and prepare the undo info for recording a change. PT is the position of point that will naturally occur as a result of the undo record that will be added just after this command terminates. */ *************** *** 64,69 **** --- 68,81 ---- { int at_boundary; + /* Don't record position of pt when undo_inhibit_record_point holds. + This should avoid inserting a position record in buffer-undo-list + when last_point_position has not been set up correctly by + command_loop_1, for example, when running a repeat-repeat-char + event. */ + if (undo_inhibit_record_point) + return; + /* Allocate a cons cell to be the undo boundary after this command. */ if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); *************** *** 719,724 **** --- 731,740 ---- Garbage collection is inhibited around the call to this function, so it must make sure not to do a lot of consing. */); Vundo_outer_limit_function = Qnil; + + DEFVAR_BOOL ("undo-inhibit-record-point", &undo_inhibit_record_point, + doc: /* Non-nil means do not record `point' in `buffer-undo-list'. */); + undo_inhibit_record_point = 0; } /* arch-tag: d546ee01-4aed-4ffb-bb8b-eefaae50d38a *** repeat.el Wed Aug 29 10:36:26 2007 --- repeat.el Thu Oct 4 10:13:58 2007 *************** *** 200,205 **** --- 200,213 ---- (defvar repeat-previous-repeated-command nil "The previous repeated command.") + ;; The following variable counts repeated self-insertions. The idea is + ;; that repeating a self-insertion command and subsequently undoing it + ;; should have nearly the same effect as if the characters were inserted + ;; manually. The basic difference is that we leave in one undo-boundary + ;; between the original insertion and its first repetition. + (defvar repeat-undo-count nil + "Number of self-insertions since last `undo-boundary'.") + ;;;###autoload (defun repeat (repeat-arg) "Repeat most recently executed command. *************** *** 293,303 **** --- 301,323 ---- (i 0)) ;; Run pre- and post-command hooks for self-insertion too. (run-hooks 'pre-command-hook) + (cond + ((not repeat-undo-count)) + ((< repeat-undo-count 20) + ;; Don't make an undo-boundary for 20 repetitions just + ;; as the command loop does. + (setq repeat-undo-count (1+ repeat-undo-count))) + (t + ;; Make an undo-boundary now. + (undo-boundary) + (setq repeat-undo-count 1))) (while (< i count) (repeat-self-insert insertion) (setq i (1+ i))) (run-hooks 'post-command-hook))) (let ((indirect (indirect-function last-repeatable-command))) + ;; Make each repetition undo separately. + (undo-boundary) (if (or (stringp indirect) (vectorp indirect)) ;; Bind real-last-command so that executing the macro does *************** *** 314,325 **** ;; (only 32 repetitions are possible given the default value of 200 for ;; max-lisp-eval-depth), but if I now locally disable the repeat char I ;; can iterate indefinitely here around a single level of recursion. ! (let (repeat-on-final-keystroke) (setq real-last-command 'repeat) ! (while (eq (read-event) repeat-repeat-char) ! ;; Make each repetition undo separately. ! (undo-boundary) ! (repeat repeat-arg)) (setq unread-command-events (list last-input-event)))))) (defun repeat-self-insert (string) --- 334,353 ---- ;; (only 32 repetitions are possible given the default value of 200 for ;; max-lisp-eval-depth), but if I now locally disable the repeat char I ;; can iterate indefinitely here around a single level of recursion. ! (let (repeat-on-final-keystroke ! ;; Bind `undo-inhibit-record-point' to t in order to avoid ! ;; recording point in `buffer-undo-list' here. We have to ! ;; do this since the command loop does not set the last ! ;; position of point thus confusing the point recording ! ;; mechanism when inserting or deleting text. ! (undo-inhibit-record-point t)) (setq real-last-command 'repeat) ! (setq repeat-undo-count 1) ! (unwind-protect ! (while (eq (read-event) repeat-repeat-char) ! (repeat repeat-arg)) ! ;; Make sure `repeat-undo-count' is reset. ! (setq repeat-undo-count nil)) (setq unread-command-events (list last-input-event)))))) (defun repeat-self-insert (string) --------------040602000304050102050302 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------040602000304050102050302--