From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#11774: [O] bug#11774: bug#11774: org-mode causes undo boundaries to be lost Date: Wed, 18 Jul 2012 09:21:42 -0400 Message-ID: References: <20120703095729.GA6651@c3po> <4FF30D50.8010009@os.inf.tu-dresden.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1342617799 27044 80.91.229.3 (18 Jul 2012 13:23:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 18 Jul 2012 13:23:19 +0000 (UTC) Cc: Bastien , 11774-done@debbugs.gnu.org, Martin Pohlack , Toby Cubitt To: Samuel Wales Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 18 15:23:18 2012 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 1SrUDk-000130-8s for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 15:23:16 +0200 Original-Received: from localhost ([::1]:48541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUDj-0001ZF-Ht for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 09:23:15 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUDd-0001L0-Bi for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 09:23:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrUDY-0000T0-Aj for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 09:23:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38193) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUDR-0000Ip-6t; Wed, 18 Jul 2012 09:22:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SrUJK-0001EQ-Fh; Wed, 18 Jul 2012 09:29:02 -0400 Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: bug-gnu-emacs@gnu.org, emacs-orgmode@gnu.org Resent-Date: Wed, 18 Jul 2012 13:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 11774 X-GNU-PR-Package: emacs,org-mode X-GNU-PR-Keywords: Mail-Followup-To: 11774@debbugs.gnu.org, monnier@IRO.UMontreal.CA Original-Received: via spool by 11774-done@debbugs.gnu.org id=D11774.13426180824654 (code D ref 11774); Wed, 18 Jul 2012 13:29:02 +0000 Original-Received: (at 11774-done) by debbugs.gnu.org; 18 Jul 2012 13:28:02 +0000 Original-Received: from localhost ([127.0.0.1]:47737 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrUIL-0001Cz-Nm for submit@debbugs.gnu.org; Wed, 18 Jul 2012 09:28:02 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:36035) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrUIF-0001Ci-86 for 11774-done@debbugs.gnu.org; Wed, 18 Jul 2012 09:27:58 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q6IDLh8S004732; Wed, 18 Jul 2012 09:21:44 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 15DBDAECAF; Wed, 18 Jul 2012 09:21:42 -0400 (EDT) In-Reply-To: (Samuel Wales's message of "Tue, 3 Jul 2012 17:18:50 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4282=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4282> : streams <786702> : uri <1168477> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:62097 Archived-At: >>> self-insert-command. Even just turning that magic 20 number into a >>> variable would help. >> Providing it as a variable would be very easy, indeed. > Maybe the user should be able to set undo boundaries and > have them work after self-insert-command? Dunno, I'm > not familiar with internals enough to opine. I installed the patch below which makes self-insert-command more careful to only remove undo boundaries that were auto-added. So (add-hook 'post-self-insert-hook #'undo-boundary 'append) should give you pretty much the behavior you were looking for. Stefan === modified file 'src/ChangeLog' --- src/ChangeLog 2012-07-18 05:44:36 +0000 +++ src/ChangeLog 2012-07-18 13:17:22 +0000 @@ -1,3 +1,10 @@ +2012-07-18 Stefan Monnier + + * lisp.h (last_undo_boundary): Declare new var. + * keyboard.c (command_loop_1): Set it. + * cmds.c (Fself_insert_command): Use it to only remove boundaries that + were auto-added by the command loop (bug#11774). + 2012-07-18 Dmitry Antipov Return more descriptive data from Fgarbage_collect. === modified file 'src/cmds.c' --- src/cmds.c 2012-06-16 12:24:15 +0000 +++ src/cmds.c 2012-07-18 13:08:43 +0000 @@ -296,7 +296,10 @@ if (remove_boundary && CONSP (BVAR (current_buffer, undo_list)) - && NILP (XCAR (BVAR (current_buffer, undo_list)))) + && NILP (XCAR (BVAR (current_buffer, undo_list))) + /* Only remove auto-added boundaries, not boundaries + added be explicit calls to undo-boundary. */ + && EQ (BVAR (current_buffer, undo_list), last_undo_boundary)) /* Remove the undo_boundary that was just pushed. */ BVAR (current_buffer, undo_list) = XCDR (BVAR (current_buffer, undo_list)); === modified file 'src/keyboard.c' --- src/keyboard.c 2012-07-12 03:45:46 +0000 +++ src/keyboard.c 2012-07-18 13:13:31 +0000 @@ -1318,6 +1318,9 @@ } #endif +/* The last boundary auto-added to buffer-undo-list. */ +Lisp_Object last_undo_boundary; + /* FIXME: This is wrong rather than test window-system, we should call a new set-selection, which will then dispatch to x-set-selection, or tty-set-selection, or w32-set-selection, ... */ @@ -1565,7 +1568,13 @@ #endif if (NILP (KVAR (current_kboard, Vprefix_arg))) /* FIXME: Why? --Stef */ + { + Lisp_Object undo = BVAR (current_buffer, undo_list); Fundo_boundary (); + last_undo_boundary + = (EQ (undo, BVAR (current_buffer, undo_list)) + ? Qnil : BVAR (current_buffer, undo_list)); + } Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil); #ifdef HAVE_WINDOW_SYSTEM === modified file 'src/lisp.h' --- src/lisp.h 2012-07-18 05:44:36 +0000 +++ src/lisp.h 2012-07-18 13:05:33 +0000 @@ -2921,7 +2921,7 @@ extern void syms_of_search (void); extern void clear_regexp_cache (void); -/* Defined in minibuf.c */ +/* Defined in minibuf.c. */ extern Lisp_Object Qcompletion_ignore_case; extern Lisp_Object Vminibuffer_list; @@ -2930,25 +2930,25 @@ extern void init_minibuf_once (void); extern void syms_of_minibuf (void); -/* Defined in callint.c */ +/* Defined in callint.c. */ extern Lisp_Object Qminus, Qplus; extern Lisp_Object Qwhen; extern Lisp_Object Qcall_interactively, Qmouse_leave_buffer_hook; extern void syms_of_callint (void); -/* Defined in casefiddle.c */ +/* Defined in casefiddle.c. */ extern Lisp_Object Qidentity; extern void syms_of_casefiddle (void); extern void keys_of_casefiddle (void); -/* Defined in casetab.c */ +/* Defined in casetab.c. */ extern void init_casetab_once (void); extern void syms_of_casetab (void); -/* Defined in keyboard.c */ +/* Defined in keyboard.c. */ extern Lisp_Object echo_message_buffer; extern struct kboard *echo_kboard; @@ -2956,6 +2956,7 @@ extern Lisp_Object Qdisabled, QCfilter; extern Lisp_Object Qup, Qdown, Qbottom; extern Lisp_Object Qtop; +extern Lisp_Object last_undo_boundary; extern int input_pending; extern Lisp_Object menu_bar_items (Lisp_Object); extern Lisp_Object tool_bar_items (Lisp_Object, int *); @@ -2976,13 +2977,13 @@ extern void syms_of_keyboard (void); extern void keys_of_keyboard (void); -/* Defined in indent.c */ +/* Defined in indent.c. */ extern ptrdiff_t current_column (void); extern void invalidate_current_column (void); extern int indented_beyond_p (ptrdiff_t, ptrdiff_t, EMACS_INT); extern void syms_of_indent (void); -/* Defined in frame.c */ +/* Defined in frame.c. */ extern Lisp_Object Qonly; extern Lisp_Object Qvisible; extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); @@ -2995,7 +2996,7 @@ extern void frames_discard_buffer (Lisp_Object); extern void syms_of_frame (void); -/* Defined in emacs.c */ +/* Defined in emacs.c. */ extern char **initial_argv; extern int initial_argc; #if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)