unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* undo bug?
@ 2008-04-01 11:06 Katsumi Yamaoka
  2008-04-01 11:43 ` martin rudalics
  0 siblings, 1 reply; 11+ messages in thread
From: Katsumi Yamaoka @ 2008-04-01 11:06 UTC (permalink / raw)
  To: emacs-devel

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.




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-04-03 14:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-01 11:06 undo bug? Katsumi Yamaoka
2008-04-01 11:43 ` martin rudalics
2008-04-01 11:55   ` Katsumi Yamaoka
2008-04-01 15:07   ` Stefan Monnier
2008-04-01 18:52     ` martin rudalics
2008-04-01 19:25       ` Stefan Monnier
2008-04-01 20:53         ` martin rudalics
2008-04-02 13:59           ` Stefan Monnier
2008-04-02 17:01             ` martin rudalics
2008-04-03 13:55               ` Stefan Monnier
2008-04-03 14:43                 ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).