From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrew Hyatt Newsgroups: gmane.emacs.bugs Subject: bug#5131: Subject: 23.1; interaction of transpose-regions with markers and multibyte chars Date: Sun, 17 Jul 2016 00:13:17 -0400 Message-ID: References: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1468728869 20428 80.91.229.3 (17 Jul 2016 04:14:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Jul 2016 04:14:29 +0000 (UTC) Cc: 5131@debbugs.gnu.org To: schochet@post.tau.ac.il Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 17 06:14:17 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bOdT5-00063r-PF for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Jul 2016 06:14:16 +0200 Original-Received: from localhost ([::1]:40064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOdT5-0001TR-2J for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Jul 2016 00:14:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOdSw-0001TD-Rk for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2016 00:14:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bOdSs-0006T9-IU for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2016 00:14:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOdSs-0006T4-FA for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2016 00:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bOdSs-0003Jx-8q for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2016 00:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andrew Hyatt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Jul 2016 04:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5131 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org, 5131@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.146872882112731 (code B ref -1); Sun, 17 Jul 2016 04:14:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Jul 2016 04:13:41 +0000 Original-Received: from localhost ([127.0.0.1]:54169 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bOdSW-0003JH-Lu for submit@debbugs.gnu.org; Sun, 17 Jul 2016 00:13:41 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bOdSU-0003J2-R7 for submit@debbugs.gnu.org; Sun, 17 Jul 2016 00:13:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bOdSO-0006QI-4U for submit@debbugs.gnu.org; Sun, 17 Jul 2016 00:13:33 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:46216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOdSO-0006QA-1I for submit@debbugs.gnu.org; Sun, 17 Jul 2016 00:13:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOdSK-0001OJ-R7 for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2016 00:13:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bOdSH-0006Pg-JI for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2016 00:13:28 -0400 Original-Received: from mail-qk0-x22e.google.com ([2607:f8b0:400d:c09::22e]:33133) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOdSH-0006Pc-DT for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2016 00:13:25 -0400 Original-Received: by mail-qk0-x22e.google.com with SMTP id p74so133124101qka.0 for ; Sat, 16 Jul 2016 21:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=SLLJ+bMMcI6Dhn/OPKKsaq8xOfiwzYDC7b2p4PkNC0c=; b=otRuGOU4u4PnZSzIxAKdYJp70ieRdgPA6p9lDqyt1KRi+gUsG7W3J1MIMFrapC357Y S3FAFeJNSMmHTIdq/MIsMU2BOC5i3+5RYNcsQwL2Kd0IAGoZ3yRXrfcm2bZm39q8+6mi wBsoMjq6I57vLltYEeGtmSaBNFbObd8VGYlz+MKdqty6xpzJyeB0a7ybso/fu3b98DJt fgeiXvBLIGQuccEp49kgs/xVHz/8qf54jVe7OfKMlo7r15AZG3QZUBK9l6fghd17WLQZ xe/6oIBecYWE+2T0Z5cViW8BXT6rDXvYECSv77vMrrxdcAAo1piON3juU1pCyHrbqlJM JOyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=SLLJ+bMMcI6Dhn/OPKKsaq8xOfiwzYDC7b2p4PkNC0c=; b=R0DTXAObOu7GtaP53rPZO3ea84DZvo1kxqyxyGvcuJlEJ0TT3U+jGX6n9NGOM0Y/W/ B25PjcyE4/HNZ4uii5qBz5BHaDJSMBcE3OCxvpYfMnqPi950p+fgT5quy0LfgfEusiNC phAY401JUVAEDiGQTo6z12vDzVa5+1KTzegLagDdTFCfUV1qfgM/pkvDE+QvaXjRJj25 RvgQkrQGCUL6EdjTz0IXR6nT1QmO2lLJZ88HZSvMK25g8QR9kjy9ASh/I3ji7OiWZsrn k5tIaLdJBEAK/WHtYKKb9wVwR8hoRutzFxMS/pbr2qRzYqBueEiWvXcYmrf9FdbPf+VS G0Cw== X-Gm-Message-State: ALyK8tKD3pNd5n/OLLHoTxppC8OtTao2sAJ7F8Hn27DHUTtBE21L4s/8BT3yQN3g+oDnIg== X-Received: by 10.55.167.199 with SMTP id q190mr35759254qke.95.1468728804766; Sat, 16 Jul 2016 21:13:24 -0700 (PDT) Original-Received: from Andrews-MacBook-Pro.local (cpe-74-73-128-199.nyc.res.rr.com. [74.73.128.199]) by smtp.gmail.com with ESMTPSA id n20sm2620342qtn.40.2016.07.16.21.13.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Jul 2016 21:13:22 -0700 (PDT) In-Reply-To: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> (schochet's message of "Sun, 06 Dec 2009 04:22:06 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (darwin) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121156 Archived-At: Sorry for the late reply. I can reproduce the problem of unexpected characters when transposing using markers in Emacs 25. schochet@post.tau.ac.il writes: > From: schochet@post.tau.ac.il > To: bug-gnu-emacs@gnu.org, 5131@debbugs.gnu.org > Subject: 23.1; interaction of transpose-regions with markers and multiby= te > chars > --text follows this line-- > > Repeated use of the function transpose-regions on regions defined by > markers sometimes yields unexpected results when those regions contain > multibyte characters. In some cases the text obtained after running > transpose-regions even includes characters that were not present before. > > The function reverse-all given below is designed to reverse the order > of the characters in a specified region. However, I obtain the following > results: > > input region: abcd output region: dcba as expected > input region: =C3=B7bcd output region: d=C3=B7bc expecte= d: dcb=C3=B7 > input region: =C3=B7ab"=C3=A4=C3=A9 output region has CJK ideograph ex= pected: =C3=A9=C3=A4"ba=C3=B7 > > To reproduce this bug, simply copy to a file the text below, > beginning with the line starting with a semicolon, > visit it in emacs, and evaluate the indicated lisp expressions > by entering \C-j at the end of the indicated lines. > Note that the lisp expressions set markers to specific locations, > so the file should begin precisely where indicated. > The first character after the space after the word "case1:" should be at > position 64 in the file. If for some reason it > is not, the values given to the variable start should be adjusted. > > The file below also contains an alternative function reverse-all2, > which differs from reverse-all only in using variables instead of markers. > The function reverse-all2 yields the expected results in all the above ca= ses. > > This bug does not depend on my .emacs file, since I have reproduced it wi= th > a blank .emacs file. > > Please let me know if you need any more information. > > Steve Schochet > > ;-*- mode: lisp-interaction; coding: utf-8-unix -*- > > ; case 1: abcd was: abcd > ; case 2: =C3=B7bcd was: =C3=B7bcd > ; case 3: =C3=B7ab"=C3=A4=C3=A9 was: =C3=B7ab"=C3=A4=C3=A9 > > (progn (defvar start nil) (defvar len nil)) ;do \C-j here > > ; Using markers to move multi-byte characters may cause problems > > (progn (setq begm (make-marker)) (setq endm (make-marker))) ;do \C-j here > > (defun reverse-all () > (set-marker begm start) > (set-marker endm (+ start (1- len))) > (while (> endm begm) > (progn (transpose-regions begm (1+ begm) endm (1+ endm) t) > (set-marker begm (1+ begm)) > (set-marker endm (1- endm))))) ;do \C-j here > > ;case1 > (progn (setq start 64) (setq len 4) (reverse-all)) ;do \C-j here > > ;case2 > (progn (setq start 94) (setq len 4) (reverse-all)) ;do \C-j here > > ;case3 > (progn (setq start 124) (setq len 6) (reverse-all)) ;do \C-j here > > > ; Using variables instead of markers works > > (progn (defvar begv nil) (defvar endv nil)) > > (defun reverse-all2 () > (setq begv start) > (setq endv (+ start (1- len))) > (while (> endv begv) > (progn (transpose-regions begv (1+ begv) endv (1+ endv) t) > (setq begv (1+ begv)) > (setq endv (1- endv))))) > > ;case1 > (progn (setq start 64) (setq len 4) (reverse-all2)) > > ;case2 > (progn (setq start 94) (setq len 4) (reverse-all2)) > > ;case3 > (progn (setq start 124) (setq len 6) (reverse-all2)) > > ; end of attached file > > > > > In GNU Emacs 23.1.1 (i586-suse-linux-gnu, GTK+ Version 2.18.1) > of 2009-10-24 on build16 > Windowing system distributor `The X.Org Foundation', version 11.0.10605000 > configured using `configure '--with-pop' '--without-hesiod' '--with-ker= beros' > '--with-kerberos5' '--with-xim' '--prefix=3D/usr' '--mandir=3D/usr/share= /man' > '--infodir=3D/usr/share/info' '--datadir=3D/usr/share' '--localstatedir= =3D/var' > '--sharedstatedir=3D/var/lib' '--libexecdir=3D/usr/lib' '--with-x' '--wi= th-sound' > '--with-sync-input' '--with-xpm' '--with-jpeg' '--with-tiff' '--with-gif' > '--with-png' '--with-rsvg' '--with-dbus' '--without-gpm' '--with-x-toolk= it=3Dgtk' > '--x-includes=3D/usr/include' '--x-libraries=3D/usr/lib:/usr/share/X11' > '--with-xft' '--with-libotf' '--with-m17n-flt' '--build=3Di586-suse-linu= x' > 'build_alias=3Di586-suse-linux' 'CC=3Dgcc' 'CFLAGS=3D-fomit-frame-pointer > -fmessage-length=3D0 -O2 -Wall -D_FORTIFY_SOURCE=3D2 -fstack-protector > -funwind-tables -fasynchronous-unwind-tables -g -D_GNU_SOURCE -std=3Dgnu= 89 -pipe > -Wno-pointer-sign -Wno-unused-variable -Wno-unused-label > -Wno-unprototyped-calls -DSYSTEM_PURESIZE_EXTRA=3D55000 > -DSITELOAD_PURESIZE_EXTRA=3D10000 ' 'LDFLAGS=3D-Wl,-O2 -Wl,--hash-size= =3D65521'' > > Important settings: > value of $LC_ALL: nil > 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: @im=3Dlocal > locale-coding-system: utf-8-unix > default-enable-multibyte-characters: t > > Major mode: Lisp Interaction > > Minor modes in effect: > show-paren-mode: t > tooltip-mode: t > tool-bar-mode: t > mouse-wheel-mode: t > menu-bar-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > blink-cursor-mode: t > global-auto-composition-mode: t > auto-composition-mode: t > auto-encryption-mode: t > auto-compression-mode: t > line-number-mode: t > transient-mark-mode: t > > Recent input: > C-x 1 C-j > C-j C-j > C-j C-j > C-j C-x C-s > > > > > > nd-emacs-bug-report> > > Recent messages: > Loading /usr/share/emacs/site-lisp/nxml-mode/rng-auto.el (source)...done > For information about GNU Emacs and the GNU system, type C-h C-a. > Invalid image size (see `max-image-size') [9 times] > Saving file /home/schochet/try/files/reverse-out.el... > Wrote /home/schochet/try/files/reverse-out.el