From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#23632: 25.1.50; Gratuitous undo boundary in latex-insert-block Date: Sat, 28 May 2016 16:22:43 +0800 Message-ID: <87shx23830.fsf@gmail.com> References: <87lh2vo7s6.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1464423807 23357 80.91.229.3 (28 May 2016 08:23:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 May 2016 08:23:27 +0000 (UTC) To: 23632@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 28 10:23:17 2016 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 1b6ZWc-0000ku-KV for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 May 2016 10:23:14 +0200 Original-Received: from localhost ([::1]:52630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6ZWb-0000Ow-Jl for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 May 2016 04:23:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6ZWT-0000IS-ME for bug-gnu-emacs@gnu.org; Sat, 28 May 2016 04:23:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6ZWQ-0003QG-EE for bug-gnu-emacs@gnu.org; Sat, 28 May 2016 04:23:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6ZWQ-0003QC-A8 for bug-gnu-emacs@gnu.org; Sat, 28 May 2016 04:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b6ZWQ-0008Pb-6W for bug-gnu-emacs@gnu.org; Sat, 28 May 2016 04:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Chong Yidong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 May 2016 08:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23632 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 23632-submit@debbugs.gnu.org id=B23632.146442378032314 (code B ref 23632); Sat, 28 May 2016 08:23:02 +0000 Original-Received: (at 23632) by debbugs.gnu.org; 28 May 2016 08:23:00 +0000 Original-Received: from localhost ([127.0.0.1]:43162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6ZWO-0008P7-Eb for submit@debbugs.gnu.org; Sat, 28 May 2016 04:23:00 -0400 Original-Received: from mail-pf0-f195.google.com ([209.85.192.195]:33010) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6ZWM-0008Op-DD for 23632@debbugs.gnu.org; Sat, 28 May 2016 04:22:58 -0400 Original-Received: by mail-pf0-f195.google.com with SMTP id b124so15468463pfb.0 for <23632@debbugs.gnu.org>; Sat, 28 May 2016 01:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=037o14RqfHxQdHWgi8n6rInoELwbQZqvFGB9oIWiuKw=; b=jAhw19PyFnJYIWLbn0CoorlLs7ASa/y1QUyKvwfEAxqSyff1zS44K7ljVA68hO+F2C xf9kHPPRvrj1GYOUt4O+GrSMkB4QHRqrlRLkg9BEo3KO5xGKunq0bbCDCACjnrl5Bs/E GssFCa4kklquvwiL++OwtyQl9PD76oi9emQcOp6mPIyBQXne1w7rkRmDv2Zw6UepIhNI WOJW7l5VnWVpwTCv18iYhPtvdHRNSQwhCEkzwgSWUVhfffcWAAHQO7JLLXY8OeRR9JCL R/4UUMZW983KKtfzNeTZ4am5rfG6irG2tCPzHtDXt6XybA7sP+aMluC+f/MNwmrUakMp L0nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=037o14RqfHxQdHWgi8n6rInoELwbQZqvFGB9oIWiuKw=; b=LPb++5Dv/SUK8uhN01A4dK78ohrOKUXpSZbp3Tck7FkHJLoK8rf2Lyz1eNReNvlgYc Pe0mrvcEL7sNJ5vwOn+D2Wd/cdJ5RJSAsJpt7zF9ntQPeDWVuzdmg81NrH4tKSfeNxzz hXOuzgo7+sZFcBj0j9Rx/AA4/JoVpUk6QR+++Pu/WOpUpulPFvvymzl8sdHspP+MR+Kb bknn7Wk93h0uugcrZgASb9N3eMmV3XqKRWXb016YQ547pfGrEvz5V/6pcPZGUIYsolQ0 NHvgNFyOtZnVrO+cLsMqk2C6XaS07IGgg6bq7zXUynA2vRCEZOEm5nJdRYb6ajDoW4rO GH3g== X-Gm-Message-State: ALyK8tIgAu2ZYE2lOW+KueFqaGDqg3IeELa3GM/10845t0SNBd3wnpxLOvCtJrJQUjJ1pQ== X-Received: by 10.98.35.93 with SMTP id j90mr29380290pfj.10.1464423772248; Sat, 28 May 2016 01:22:52 -0700 (PDT) Original-Received: from ulysses ([155.69.188.43]) by smtp.gmail.com with ESMTPSA id hk7sm33369344pad.25.2016.05.28.01.22.48 for <23632@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 May 2016 01:22:50 -0700 (PDT) In-Reply-To: <87lh2vo7s6.fsf@gmail.com> (Chong Yidong's message of "Fri, 27 May 2016 23:11:21 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:118796 Archived-At: > The attached patch, which gets rid of the undo boundary, seems to fix > this: Actually, the previous patch does not DTRT: if you switch back to the original buffer from the minibuffer, and make further editing changes, those changes would get lost because buffer-undo-list is temporarily rebound. Here is a different patch, which works by removing the undo boundary in buffer-undo-list if there's one. It also tweaks HTML mode and Texinfo mode, which have similar issues. It defines a new function `undo-amalgamate', split off from `undo-auto-amalgamate', for convenience. diff --git a/lisp/simple.el b/lisp/simple.el index e257062..decd737 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2939,18 +2939,17 @@ undo-auto-amalgamate ;; Amalgamate all buffers that have changed. (dolist (b (cdr undo-auto--last-boundary-cause)) (when (buffer-live-p b) - (with-current-buffer - b - (when - ;; The head of `buffer-undo-list' is nil. - ;; `car-safe' doesn't work because - ;; `buffer-undo-list' need not be a list! - (and (listp buffer-undo-list) - (not (car buffer-undo-list))) - (setq buffer-undo-list - (cdr buffer-undo-list)))))) + (with-current-buffer b + (undo-amalgamate)))) (setq undo-auto--last-boundary-cause 0))))) +(defun undo-amalgamate () + "Amalgamate undo in the current buffer." + ;; `car-safe' doesn't work as `buffer-undo-list' need not be a list! + (and (listp buffer-undo-list) + (null (car buffer-undo-list)) + (pop buffer-undo-list))) + (defun undo-auto--undoable-change () "Called after every undoable buffer change." (add-to-list 'undo-auto--undoably-changed-buffers (current-buffer)) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 990c09b..51b7241 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -700,11 +700,15 @@ sgml-tag `sgml-transformation-function' to `upcase'." (funcall (or skeleton-transformation-function 'identity) (setq sgml-tag-last - (completing-read - (if (> (length sgml-tag-last) 0) - (format "Tag (default %s): " sgml-tag-last) - "Tag: ") - sgml-tag-alist nil nil nil 'sgml-tag-history sgml-tag-last))) + ;; Avoid creating an undo boundary. + (prog1 + (completing-read + (if (> (length sgml-tag-last) 0) + (format "Tag (default %s): " sgml-tag-last) + "Tag: ") + sgml-tag-alist nil nil nil + 'sgml-tag-history sgml-tag-last) + (undo-amalgamate)))) ?< str | (("") -1 '(undo-boundary) (identity "<")) | ; see comment above `(("") '(setq v2 (sgml-attributes ,str t)) ?> diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index b38b147..8b7d98f 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -1539,10 +1539,13 @@ 'tex-latex-block (define-skeleton latex-insert-block "Create a matching pair of lines \\begin{NAME} and \\end{NAME} at point. Puts point on a blank line between them." - (let ((choice (completing-read (format "LaTeX block name [%s]: " - latex-block-default) - (latex-complete-envnames) - nil nil nil nil latex-block-default))) + (let* ((buffer-undo-list t) + (choice (prog1 + (completing-read (format "LaTeX block name [%s]: " + latex-block-default) + (latex-complete-envnames) + nil nil nil nil latex-block-default) + (undo-amalgamate)))) (setq latex-block-default choice) (unless (or (member choice latex-standard-block-names) (member choice latex-block-names)) diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index ed6022f..fd411e2 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el @@ -653,9 +653,12 @@ texinfo-insert-block "Create a matching pair @ .. @end at point. Puts point on a blank line between them." (setq texinfo-block-default - (completing-read (format "Block name [%s]: " texinfo-block-default) - texinfo-environments - nil nil nil nil texinfo-block-default)) + (prog1 + (completing-read (format "Block name [%s]: " + texinfo-block-default) + texinfo-environments + nil nil nil nil texinfo-block-default) + (undo-amalgamate))) \n "@" str ;; Blocks that take parameters: all the def* blocks take parameters, ;; plus a few others.