]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix picture-mode wrt double-width characters
authorAlan J Third <alan@idiocy.org>
Fri, 15 Jan 2016 08:26:10 +0000 (10:26 +0200)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Mar 2016 00:05:54 +0000 (17:05 -0700)
* 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

index 4aee2734158a9e688d3dd16f644fd4a95e396893..b77f8e9717c975c8556ceb608b7a28cd23de11fc 100644 (file)
@@ -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))))