Subject: 24.0.50; kbd-macro breaks atomic-change-group

From: Andreas Politz <[email-masked]>
Date: Mon, 03 May 2010 21:18:27 +0200

I believe this to be a bug.

Executing a kbd-macro inside a atomic-change-group signals an error,
if the group gets cancelled via `cancel-change-group'.

(setq buffer-undo-list (list nil))
(atomic-change-group      
  (execute-kbd-macro "foobar.sFOOBAR"))

I believe the problem is self-inserting-command popping the nil
from buffer-undo-list, which in turn makes cancel-change-group
believe it's understandging of the list became corrupted.

I think it's safe to ignore the car, if it's nil, and proceed on
the cdr.  The next command will push a new nil anyway (as far as
I can tell).

Anyway, that's what this is based upon :

diff -c -B -w /home/politza/src/emacs23/lisp/subr.el /tmp/buffer-content-32254fF
*** /home/politza/src/emacs23/lisp/subr.el	Sat May  1 10:39:53 2010
--- /tmp/buffer-content-32254fF	Mon May  3 21:14:56 2010
***************
*** 2145,2150 ****
--- 2145,2155 ----
    (dolist (elt handle)
      (with-current-buffer (car elt)
        (setq elt (cdr elt))
+       ;; The command loop may have changed the first cons, if it was a
+       ;; boundary (nil), skip it.
+       (when (and (cdr elt)
+                  (null (car elt)))
+         (setq elt (cdr elt)))
        (save-restriction
  	;; Widen buffer temporarily so if the buffer was narrowed within
  	;; the body of `atomic-change-group' all changes can be undone.

Diff finished.  Mon May  3 21:14:56 2010

In GNU Emacs 24.0.50.3 (x86_64-unknown-linux-gnu, GTK+ Version 2.18.9)
 of 2010-05-03 on raven
Windowing system distributor `The X.Org Foundation', version 11.0.10705000
Important settings:
  value of $LC_ALL: C
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Text

Minor modes in effect:
  diff-auto-refine-mode: t
  narrow-stack-mode: t
  server-mode: t
  easy-repeat-mode: t
  shell-dirtrack-mode: t
  recentf-mode: t
  ido-hacks-mode: t
  window-numbering-mode: t
  which-function-mode: t
  show-paren-mode: t
  ido-everywhere: t
  icomplete-mode: t
  global-hi-lock-mode: t
  hi-lock-mode: t
  display-time-mode: t
  savehist-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
c d r C-n TAB C-n TAB C-e C-M-b C-o M-; T h e SPC c 
o m m a n d SPC l o o p SPC m a y SPC h a v e SPC c 
h a n g e d SPC t h e SPC f i r s t SPC c o n s , SPC 
i f SPC i t ' s SPC c a r SPC M-h M-h M-h w a s SPC 
a SPC b o u n d a r y SPC ( C-h C-h SPC ( n i l ) M-q 
. C-p C-e M-b M-b i t SPC M-q C-n C-p M-b M-b M-b M-b 
M-b M-b M-b M-b C-n C-h , SPC s k i p SPC i t . M-q 
M-1 C-j C-j C-p C-p M-q M-x t e x t - <return> C-n 
C-j A n y w a y SPC C-h , SPC t h a t ' s SPC w h a 
t SPC h <backspace> t h i s SPC i s SPC b a s e d SPC 
u p o n SPC : M-2 M-q C-M-x M-1 C-x C-g C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-x C-e q M-2 C-n M-m C-M-SPC 
M-; C-M-x M-1 C-x C-e q q C-/ M-2 C-/ M-x d i f f - 
b u <return> <return> M-1 C-x h M-w C-, C-, C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-j C-y C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-k C-k M-\ C-p C-k C-k C-/ C-/ C-/ C-/ C-x h C-w M-x 
r e p o <return>

Recent messages:
Back to top level.
Mark set
cancel-change-group
Type C-. for help.
Entering debugger... [2 times]
Back to top level.
Undo! [2 times]
Mark set [3 times]
Undo! [4 times]
Mark set [2 times]

Load-path shadows:
/home/politza/.emacs.d/minor-modes/ido hides /home/politza/src/emacs23/lisp/ido

Features:
(shadow emacsbug whitespace diff-mode diff browse-kill-ring apropos
gnus-cite smiley ansi-color gnus-async gnus-bcklg qp sort gnus-ml
disp-table parse-time nnfolder nnmbox utf-7 utf7 netrc starttls nnimap
imap nndraft nnmh bbdb-gnus bbdb-snarf mail-extr bbdb-com warnings nnnil
gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art
mm-uu mml2015 epg-config mm-view smime dig mailcap nntp gnus-cache
gnus-sum nnoo gnus-group gnus-undo nnmail mail-source gnus-start
gnus-spec gnus-win jka-compr find-dired cl-specs edebug newcomment
thingatpt help-mode view debug vc-dispatcher vc-svn reposition etags
multi-isearch vc-git cc-mode cc-fonts cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs find-func minibuffer-regexp pascal
narrow-stack org org-footnote org-src org-list org-faces org-compat
org-entities org-macs noutline outline ispell closure byte-opt bytecomp
byte-compile gnus-int gnus-range message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev gmm-utils mailheader gnus gnus-ems nnheader mail-utils
mm-util mail-prsvr avoid server easy-repeat repeat eldoc linux tex-site
auto-loads ibuf-macs ibuf-ext ibuffer dired-x dired-aux dired
dired-details tramp-imap assoc tramp-gw tramp-fish tramp-smb tramp-cache
tramp-ftp tramp-cmds tramp auth-source gnus-util shell password-cache
format-spec tramp-compat trampver time-date recentf tree-widget wid-edit
easymenu generic ido-hacks hippie-exp my-anything anything edmacro
kmacro kbd-helper derived org-install bbdb-autoloads bbdb timezone
persistent-scratch-buffer window-numbering easy-mmode cl cl-19 uniquify
winner which-func imenu paren ido icomplete grep compile comint
regexp-opt ring hi-lock time cus-start cus-load saveplace savehist
advice help-fns advice-preload tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting font-render-setting gtk x-toolkit x multi-tty emacs)