emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

undo bug?


From: Katsumi Yamaoka
Subject: undo bug?
Date: Tue, 01 Apr 2008 20:06:46 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Hi,

I use egg[1] for writing Japanese text in Emacs buffers and have
a problem that the point jumps to an improper position when
performing `undo' after writing Japanese text.  This happens with
Emacs 22.1 and newer.  The following functions emulate what egg
does when writing Japanese text in order to reproduce the problem.

The scene it expresses is that I enter the ascii character `a'
within the fence (i.e. |...|) and convert it into the Japanese
character `A'.  Could you try evaluating those Lisp forms, and
performing `M-x x1', `M-x x2', and `M-x undo'?  You will see that
the point does not stay at the position where there was the
Japanese character `A'.

--8<---------------cut here---------------start------------->8---
(defun x1 ()
  (interactive)
  (funcall (if (and (get-buffer "*testing*")
                    (prog1 (string-equal (buffer-name) "*testing*")
                      (kill-buffer "*testing*")))
               #'switch-to-buffer #'pop-to-buffer)
           (generate-new-buffer "*testing*"))
  (text-mode)
  (use-local-map (copy-keymap (current-local-map)))
  (local-set-key "\C-m" 'x3)
  (insert "12345678")
  (goto-char 3))

(defun x2 ()
  (interactive)
  (insert "|a|")
  (sit-for 1)
  (setq unread-command-events '(?\C-m)))

(defun x3 ()
  (interactive)
  (delete-backward-char 3)
  (setq buffer-undo-list nil)
  (insert "A")
  (message "%s" buffer-undo-list))
--8<---------------cut here---------------end--------------->8---

Before performing `undo', `buffer-undo-list' has the value
`(nil (3 . 4) 6)', which means that `undo' will delete the thing
existing in the area (3 . 4) and move the point to 6.  Where does
`6' come from?  I'm not sure of it but it might be due to the way
to run the interactive command `x3'.  I.e., it is done by setting
`unread-command-events' to the key which is bound to the `x3'
command.  It doesn't happen in Emacs 21 and 20 anyway.

Now I use the following workaround just after inserting Japanese
text in order to remove `6' from `buffer-undo-list'.  But nothing
can be better than not using such one.  Could anyone look into it?

(if (car buffer-undo-list)
    (if (numberp (cadr buffer-undo-list))
        (setcdr buffer-undo-list (nthcdr 2 buffer-undo-list)))
  (if (numberp (nth 2 buffer-undo-list))
      (setcdr (cdr buffer-undo-list) (nthcdr 3 buffer-undo-list))))

Thanks in advance.

Regards,

[1] Egg v3 was first developed in 1988 for Nemacs, which was the
    enhanced version of Emacs 18 so as to be able to handle
    Japanese text.  It still survives as Emcws, sj3-egg, wnn7egg,
    and the egg-its XEmacs package.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]