From 1e9a1229b170a4b3b0e0ab4fc228b2281b42ec25 Mon Sep 17 00:00:00 2001 From: Alan J Third Date: Fri, 15 Jan 2016 10:26:10 +0200 Subject: [PATCH] Fix picture-mode wrt double-width characters * lisp/textmodes/picture.el (picture-insert): Check the width of the character being replaced, not just that of the replacement. (Bug#1808) [This reapplies commit b70dba4e18514411ed38b5bbb846558158842ace, which was inadvertently lost by merge commit 7823745acbe9b87eea2db4ef434e379fc903ec35.] Copyright-paperwork-exempt: yes --- lisp/textmodes/picture.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el index 4aee2734158..b77f8e9717c 100644 --- a/lisp/textmodes/picture.el +++ b/lisp/textmodes/picture.el @@ -272,7 +272,11 @@ Use \"\\[command-apropos] picture-movement\" to see commands which control motio (or (eolp) (let ((pos (point))) (move-to-column col t) - (delete-region pos (point))))) + (let ((old-width (string-width (buffer-substring pos (point))))) + (delete-region pos (point)) + (when (> old-width width) + (insert-char ? (- old-width width)) + (goto-char pos)))))) (insert ch) (forward-char -1) (picture-move)))) -- 2.39.2