From unknown Sat Jun 21 12:14:35 2025 X-Loop: owner@emacsbugs.donarmstrong.com Subject: bug#5131: Subject: 23.1; interaction of transpose-regions with markers and multibyte chars Reply-To: schochet@post.tau.ac.il, 5131@debbugs.gnu.org Resent-From: schochet@post.tau.ac.il Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Sun, 06 Dec 2009 02:30:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-Emacs-PR-Message: report 5131 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12600662324812 (code B ref -1); Sun, 06 Dec 2009 02:30:06 +0000 Received: (at submit) by emacsbugs.donarmstrong.com; 6 Dec 2009 02:23:52 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: * X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=1.1 required=4.0 tests=FOURLA,FVGT_m_MULTI_ODD, MIME_QP_LONG_LINE autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB62NniR004809 for ; Sat, 5 Dec 2009 18:23:51 -0800 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NH6mr-0000hv-Ae for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 21:23:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NH6mk-0000d3-Uu for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 21:23:47 -0500 Received: from [199.232.76.173] (port=49066 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NH6mk-0000d0-SB for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 21:23:42 -0500 Received: from mxcampus2.tau.ac.il ([132.66.7.202]:46168) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NH6mk-0004VB-2A for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 21:23:42 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApECAI6kGkuEQhFRU2dsb2JhbACEKJYYgSIBFg0IB6kIj0aBL4ItVwSBZw X-IronPort-AV: E=Sophos;i="4.47,348,1257112800"; d="scan'208";a="87755418" Received: from webmail.tau.ac.il (HELO localhost) ([132.66.17.81]) by mxout2.tau.ac.il with ESMTP; 06 Dec 2009 04:22:06 +0200 Received: from 93-172-58-100.bb.netvision.net.il (93-172-58-100.bb.netvision.net.il [93.172.58.100]) by webmail.tau.ac.il (Horde Framework) with HTTP; Sun, 06 Dec 2009 04:22:06 +0200 Message-ID: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> Date: Sun, 06 Dec 2009 04:22:06 +0200 From: schochet@post.tau.ac.il To: bug-gnu-emacs@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Internet Messaging Program (IMP) H3 (4.2) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. From: schochet@post.tau.ac.il To: bug-gnu-emacs@gnu.org Subject: 23.1; interaction of transpose-regions with markers and =20 multibyte 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 expected: = dcb=C3=B7 input region: =C3=B7ab"=C3=A4=C3=A9 output region has CJK ideograph expec= ted: =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 cases= . This bug does not depend on my .emacs file, since I have reproduced it with 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' =20 '--with-kerberos' '--with-kerberos5' '--with-xim' '--prefix=3D/usr' =20 '--mandir=3D/usr/share/man' '--infodir=3D/usr/share/info' =20 '--datadir=3D/usr/share' '--localstatedir=3D/var' =20 '--sharedstatedir=3D/var/lib' '--libexecdir=3D/usr/lib' '--with-x' =20 '--with-sound' '--with-sync-input' '--with-xpm' '--with-jpeg' =20 '--with-tiff' '--with-gif' '--with-png' '--with-rsvg' '--with-dbus' =20 '--without-gpm' '--with-x-toolkit=3Dgtk' '--x-includes=3D/usr/include' =20 '--x-libraries=3D/usr/lib:/usr/share/X11' '--with-xft' '--with-libotf' =20 '--with-m17n-flt' '--build=3Di586-suse-linux' =20 'build_alias=3Di586-suse-linux' 'CC=3Dgcc' 'CFLAGS=3D-fomit-frame-pointer = =20 -fmessage-length=3D0 -O2 -Wall -D_FORTIFY_SOURCE=3D2 -fstack-protector =20 -funwind-tables -fasynchronous-unwind-tables -g -D_GNU_SOURCE =20 -std=3Dgnu89 -pipe -Wno-pointer-sign -Wno-unused-variable =20 -Wno-unused-label -Wno-unprototyped-calls =20 -DSYSTEM_PURESIZE_EXTRA=3D55000 -DSITELOAD_PURESIZE_EXTRA=3D10000 ' =20 '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 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 From unknown Sat Jun 21 12:14:35 2025 X-Loop: owner@emacsbugs.donarmstrong.com Subject: bug#5131: effect of debugger on bug 5131 Reply-To: schochet@post.tau.ac.il, 5131@debbugs.gnu.org Resent-From: Steve Schochet Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Sun, 06 Dec 2009 05:45:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-Emacs-PR-Message: followup 5131 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by 5131-submit@emacsbugs.donarmstrong.com id=B5131.126007799926712 (code B ref 5131); Sun, 06 Dec 2009 05:45:06 +0000 Received: (at 5131) by emacsbugs.donarmstrong.com; 6 Dec 2009 05:39:59 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=0.0 required=4.0 tests=none autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mail-ew0-f211.google.com (mail-ew0-f211.google.com [209.85.219.211]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB65dvXl026708 for <5131@emacsbugs.donarmstrong.com>; Sat, 5 Dec 2009 21:39:59 -0800 Received: by ewy3 with SMTP id 3so878837ewy.13 for <5131@emacsbugs.donarmstrong.com>; Sat, 05 Dec 2009 21:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=sdTFfG4z5z0q0/1gYL2QcayPcV0H2t0RVUvXRRtzWZs=; b=nqqph3NZPy1lVaTHNeG3rPxLoN5RqPEcfswa5/RUhgyWS+ChZFXjt+LOHmmYPYvBNn Hot9Dq9yM0f5Ybr7fOBrdPde2VwchtFH0YrUeH2azWQVX96LSvAfgQEWUKXQFtbwUIb+ oc+heWtmOAEwJhlOeHv03aqn1G089PX9BwPJ4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=hYm/Jeh4F0nxfDRihSMSVMvb9p2ZOKubJ05j4aYBiVr01zr0bii/zYKzf3hIwI3Mto OAHtQhPiPHGkAeZzQwmbiWi0BDy9+1XsgPiRDppSY2GLK++1M8gSX1ouqaA7XARXOJlX NH0LrnZXoB65ESYTAq5Dolj4Icxa2H2SzRCFU= Received: by 10.213.8.28 with SMTP id f28mr5064465ebf.39.1260077991047; Sat, 05 Dec 2009 21:39:51 -0800 (PST) Received: from ?192.168.1.102? (93-172-58-100.bb.netvision.net.il [93.172.58.100]) by mx.google.com with ESMTPS id 7sm7499783eyg.1.2009.12.05.21.39.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 05 Dec 2009 21:39:50 -0800 (PST) Message-ID: <4B1B4395.4000607@post.tau.ac.il> Date: Sun, 06 Dec 2009 07:39:33 +0200 From: Steve Schochet User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.4pre) Gecko/20090915 SUSE/3.0b4-3.6 Thunderbird/3.0b4 MIME-Version: 1.0 To: 5131@debbugs.gnu.org Content-Type: text/plain; charset=windows-1255 Content-Transfer-Encoding: 7bit I just noticed that if you do: (debug-on-entry 'reverse-all) before calling reverse-all, and step through it in the debugger (using the command "d") then the second case yields the expected behavior instead of the bug that occurs when the debugger is not used. However, the third case still yields a bug. Steve From unknown Sat Jun 21 12:14:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#5131: Subject: 23.1; interaction of transpose-regions with markers and multibyte chars 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: To: schochet@post.tau.ac.il Cc: 5131@debbugs.gnu.org X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org, 5131@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.146872882112731 (code B ref -1); Sun, 17 Jul 2016 04:14:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jul 2016 04:13:41 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 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 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 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 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 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) 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) From: Andrew Hyatt References: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> Date: Sun, 17 Jul 2016 00:13:17 -0400 In-Reply-To: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> (schochet's message of "Sun, 06 Dec 2009 04:22:06 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (darwin) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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 From unknown Sat Jun 21 12:14:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#5131: Subject: 23.1; interaction of transpose-regions with markers and multibyte chars Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Jul 2016 04:47: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: To: Andrew Hyatt Cc: schochet@post.tau.ac.il, 5131@debbugs.gnu.org Received: via spool by 5131-submit@debbugs.gnu.org id=B5131.146873080316069 (code B ref 5131); Sun, 17 Jul 2016 04:47:02 +0000 Received: (at 5131) by debbugs.gnu.org; 17 Jul 2016 04:46:43 +0000 Received: from localhost ([127.0.0.1]:54178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bOdyU-0004B6-QY for submit@debbugs.gnu.org; Sun, 17 Jul 2016 00:46:43 -0400 Received: from mail-it0-f46.google.com ([209.85.214.46]:37240) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bOdyS-0004Au-GZ for 5131@debbugs.gnu.org; Sun, 17 Jul 2016 00:46:41 -0400 Received: by mail-it0-f46.google.com with SMTP id f6so49444991ith.0 for <5131@debbugs.gnu.org>; Sat, 16 Jul 2016 21:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=aVvZGyTnzJAIMgtw1Kti0Mx+dP2xDFZRpI5rsCxntH0=; b=Tp77D15PkgW6crnlDvDqMER3Nk2IRY+HUOstWpuSZnpOQZuPXyj/I6auRHa1aIU6hj DM6oxVRwQRFh4HxvROSaDPmeJlQz8ywFtdjxZeKZ/IIEcZ8lwCO6qwpO08mcskIK1uxH uOh+JK1HaK2YZR1fuOxo7eeBKygan1ZrF+Cm0RXaPFsCa1y1jee0Uq9NjAZXVOqyGCCW 9v3z2DWpzgFF5WahRi16kHvFXV333OiWrkujpItAtT0ft2hx/eF5mA+aYzore+NjoEMZ DbW54sqmT2+agxaPzh/S6fXVvcSBnp37J52HMAr+NHe6I18tJHut09IjVG2XETJAyU3A cRjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=aVvZGyTnzJAIMgtw1Kti0Mx+dP2xDFZRpI5rsCxntH0=; b=KwDO7oSCD1eqF0TPR5Va46ym+a2ZfimsRY1A6KOb47545UQUZCAmo4zbUHQTIKv90j kCm7FPw4R6nFsnWNkC8DOIKV+EvspspECZMJt4h4CIWkWMHv5gu6QLTerEwDpEWS3A7e r6iXFA880LB4Chd9E5NZo7ZORCHe4gJeDVqLnecxW+iTuV8B1jeyTZ9EdpvWJNxDyMAn Sov51HfRhPXxWF6i1ZXMOeU7E+OVwtpfbAzrFIXzOSfQFhbM8oCbEAQplSXliA5C0iUZ GkrJuFb/AHVSEX2cwYxK8iM/+ZDUnxw92R9LZds07jT2hfZAfRgSYx6d/eRYRtr3Z/Zc qZfQ== X-Gm-Message-State: ALyK8tLj8H2fdmZ+Hs78kOrHoGdzSV2UI8pFetYtnm2hI6wbke8DHEfYpD1v9vkCdUTBZQ== X-Received: by 10.36.69.205 with SMTP id c74mr43809702itd.47.1468730794874; Sat, 16 Jul 2016 21:46:34 -0700 (PDT) Received: from zony (206-188-64-44.cpe.distributel.net. [206.188.64.44]) by smtp.googlemail.com with ESMTPSA id g125sm2300832ith.3.2016.07.16.21.46.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Jul 2016 21:46:34 -0700 (PDT) From: npostavs@users.sourceforge.net References: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> Date: Sun, 17 Jul 2016 00:46:34 -0400 In-Reply-To: (Andrew Hyatt's message of "Sun, 17 Jul 2016 00:13:17 -0400") Message-ID: <874m7oeus5.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Andrew Hyatt writes: > 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: > >> ;-*- 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 With the latest emacs-25 branch after evaluating up to case3 here, I get an abort, here is the backtrace: (gdb) bt #0 0x00007ffff1218d59 in raise () from /usr/lib/libpthread.so.0 #1 0x00000000005738c4 in terminate_due_to_signal (sig=3D6, backtrace_limit= =3D2147483647) at emacs.c:381 #2 0x0000000000600d84 in die (msg=3D0x6f4140 "IT_BYTEPOS (*it) =3D=3D CHAR= _TO_BYTE (IT_CHARPOS (*it))", file=3D0x6f1ff0 "xdisp.c",=20 line=3D7442) at alloc.c:7223 #3 0x0000000000452c1c in set_iterator_to_next (it=3D0x7fffffff90f0, reseat= _p=3Dtrue) at xdisp.c:7442 #4 0x00000000004832b4 in display_line (it=3D0x7fffffff90f0) at xdisp.c:209= 97 #5 0x00000000004793af in try_window_id (w=3D0x13fc690) at xdisp.c:18413 #6 0x000000000046fd44 in redisplay_window (window=3D20956821, just_this_on= e_p=3Dtrue) at xdisp.c:16573 #7 0x0000000000467ad2 in redisplay_window_1 (window=3D20956821) at xdisp.c= :14454 #8 0x0000000000621077 in internal_condition_case_1 (bfun=3D0x467a90 , arg=3D20956821, handlers=3D14478067,=20 hfun=3D0x467a0a ) at eval.c:1333 #9 0x0000000000466cbc in redisplay_internal () at xdisp.c:14079 #10 0x00000000004640c2 in redisplay () at xdisp.c:13214 #11 0x000000000057b647 in read_char (commandflag=3D1, map=3D17541507, prev_= event=3D0, used_mouse_menu=3D0x7fffffffe42f, end_time=3D0x0) at keyboard.c:2477 #12 0x000000000058b90f in read_key_sequence (keybuf=3D0x7fffffffe5e0, bufsi= ze=3D30, prompt=3D0, dont_downcase_last=3Dfalse,=20 can_return_switch_frame=3Dtrue, fix_current_buffer=3Dtrue, prevent_redi= splay=3Dfalse) at keyboard.c:9063 #13 0x000000000057854d in command_loop_1 () at keyboard.c:1365 #14 0x0000000000620fdd in internal_condition_case (bfun=3D0x57810b , handlers=3D19056, hfun=3D0x577779 ) at eval.c:1309 #15 0x0000000000577d38 in command_loop_2 (ignore=3D0) at keyboard.c:1107 #16 0x000000000062056f in internal_catch (tag=3D45840, func=3D0x577d0f , arg=3D0) at eval.c:1074 #17 0x0000000000577cda in command_loop () at keyboard.c:1086 #18 0x0000000000577251 in recursive_edit_1 () at keyboard.c:692 #19 0x000000000057745d in Frecursive_edit () at keyboard.c:763 #20 0x00000000005751f5 in main (argc=3D3, argv=3D0x7fffffffea78) at emacs.c= :1606 Lisp Backtrace: "redisplay_internal (C function)" (0x0) In GNU Emacs 25.0.95.21 (x86_64-unknown-linux-gnu, X toolkit) of 2016-07-11 built on zony Repository revision: d1300340cbd44abe79ef71a57ae1488479f76b0d Windowing system distributor 'The X.Org Foundation', version 11.0.11803000 Configured using: 'configure --cache-file=3D../debug-config.cache 'CFLAGS=3D-O0 -g3 -march=3Dnative' --enable-checking MAKEINFO=3Dmakeinfo-4.13a --with-x-toolkit=3Dlucid --without-toolkit-scroll-bars --with-gif=3Dno --with-jpeg=3Dno' From unknown Sat Jun 21 12:14:35 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: schochet@post.tau.ac.il Subject: bug#5131: closed (Re: bug#5131: Subject: 23.1; interaction of transpose-regions with markers and multibyte chars) Message-ID: References: <8360s11umi.fsf@gnu.org> <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> X-Gnu-PR-Message: they-closed 5131 X-Gnu-PR-Package: emacs Reply-To: 5131@debbugs.gnu.org Date: Tue, 19 Jul 2016 16:06:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1468944361-10324-1" This is a multi-part message in MIME format... ------------=_1468944361-10324-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #5131: Subject: 23.1; interaction of transpose-regions with markers and mul= tibyte chars which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 5131@debbugs.gnu.org. --=20 5131: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D5131 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1468944361-10324-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 5131-done) by debbugs.gnu.org; 19 Jul 2016 16:05:36 +0000 Received: from localhost ([127.0.0.1]:57486 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPXWZ-0002ft-QK for submit@debbugs.gnu.org; Tue, 19 Jul 2016 12:05:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41585) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPXWX-0002fg-2n for 5131-done@debbugs.gnu.org; Tue, 19 Jul 2016 12:05:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPXWO-0005Q9-DC for 5131-done@debbugs.gnu.org; Tue, 19 Jul 2016 12:05:27 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPXWO-0005Pk-A8; Tue, 19 Jul 2016 12:05:24 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3508 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bPXWK-0001MP-EN; Tue, 19 Jul 2016 12:05:22 -0400 Date: Tue, 19 Jul 2016 19:05:09 +0300 Message-Id: <8360s11umi.fsf@gnu.org> From: Eli Zaretskii To: npostavs@users.sourceforge.net In-reply-to: <874m7oeus5.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) Subject: Re: bug#5131: Subject: 23.1; interaction of transpose-regions with markers and multibyte chars References: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> <874m7oeus5.fsf@users.sourceforge.net> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 5131-done Cc: ahyatt@gmail.com, schochet@post.tau.ac.il, 5131-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.3 (------) > From: npostavs@users.sourceforge.net > Date: Sun, 17 Jul 2016 00:46:34 -0400 > Cc: schochet@post.tau.ac.il, 5131@debbugs.gnu.org > > Andrew Hyatt writes: > > > 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: > > > >> ;-*- mode: lisp-interaction; coding: utf-8-unix -*- > >> > >> ; case 1: abcd was: abcd > >> ; case 2: ÷bcd was: ÷bcd > >> ; case 3: ÷ab"äé was: ÷ab"äé > >> > >> (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 > > With the latest emacs-25 branch after evaluating up to case3 here, I get > an abort, here is the backtrace: > > (gdb) bt > #0 0x00007ffff1218d59 in raise () from /usr/lib/libpthread.so.0 > #1 0x00000000005738c4 in terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:381 > #2 0x0000000000600d84 in die (msg=0x6f4140 "IT_BYTEPOS (*it) == CHAR_TO_BYTE (IT_CHARPOS (*it))", file=0x6f1ff0 "xdisp.c", > line=7442) at alloc.c:7223 > #3 0x0000000000452c1c in set_iterator_to_next (it=0x7fffffff90f0, reseat_p=true) at xdisp.c:7442 That's because your build is with --enable-checking, while Andrew's probably isn't. This recipe causes some markers to have invalid bytepos values, so any code that calls CHAR_TO_BYTE is likely to crash or cause assertion violations. It feels strange to fix bugs that were introduced 18 years ago; I guess almost no one invokes transpose-regions with last argument non-nil. Fixed on the master branch. I'm closing the bug; feel free to reopen if there are some left-overs. Thanks. ------------=_1468944361-10324-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by emacsbugs.donarmstrong.com; 6 Dec 2009 02:23:52 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: * X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=1.1 required=4.0 tests=FOURLA,FVGT_m_MULTI_ODD, MIME_QP_LONG_LINE autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nB62NniR004809 for ; Sat, 5 Dec 2009 18:23:51 -0800 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NH6mr-0000hv-Ae for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 21:23:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NH6mk-0000d3-Uu for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 21:23:47 -0500 Received: from [199.232.76.173] (port=49066 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NH6mk-0000d0-SB for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 21:23:42 -0500 Received: from mxcampus2.tau.ac.il ([132.66.7.202]:46168) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NH6mk-0004VB-2A for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2009 21:23:42 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApECAI6kGkuEQhFRU2dsb2JhbACEKJYYgSIBFg0IB6kIj0aBL4ItVwSBZw X-IronPort-AV: E=Sophos;i="4.47,348,1257112800"; d="scan'208";a="87755418" Received: from webmail.tau.ac.il (HELO localhost) ([132.66.17.81]) by mxout2.tau.ac.il with ESMTP; 06 Dec 2009 04:22:06 +0200 Received: from 93-172-58-100.bb.netvision.net.il (93-172-58-100.bb.netvision.net.il [93.172.58.100]) by webmail.tau.ac.il (Horde Framework) with HTTP; Sun, 06 Dec 2009 04:22:06 +0200 Message-ID: <20091206042206.10974kro2g12qlhq@webmail.tau.ac.il> Date: Sun, 06 Dec 2009 04:22:06 +0200 From: schochet@post.tau.ac.il To: bug-gnu-emacs@gnu.org Subject: Subject: 23.1; interaction of transpose-regions with markers and multibyte chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Internet Messaging Program (IMP) H3 (4.2) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. From: schochet@post.tau.ac.il To: bug-gnu-emacs@gnu.org Subject: 23.1; interaction of transpose-regions with markers and =20 multibyte 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 expected: = dcb=C3=B7 input region: =C3=B7ab"=C3=A4=C3=A9 output region has CJK ideograph expec= ted: =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 cases= . This bug does not depend on my .emacs file, since I have reproduced it with 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' =20 '--with-kerberos' '--with-kerberos5' '--with-xim' '--prefix=3D/usr' =20 '--mandir=3D/usr/share/man' '--infodir=3D/usr/share/info' =20 '--datadir=3D/usr/share' '--localstatedir=3D/var' =20 '--sharedstatedir=3D/var/lib' '--libexecdir=3D/usr/lib' '--with-x' =20 '--with-sound' '--with-sync-input' '--with-xpm' '--with-jpeg' =20 '--with-tiff' '--with-gif' '--with-png' '--with-rsvg' '--with-dbus' =20 '--without-gpm' '--with-x-toolkit=3Dgtk' '--x-includes=3D/usr/include' =20 '--x-libraries=3D/usr/lib:/usr/share/X11' '--with-xft' '--with-libotf' =20 '--with-m17n-flt' '--build=3Di586-suse-linux' =20 'build_alias=3Di586-suse-linux' 'CC=3Dgcc' 'CFLAGS=3D-fomit-frame-pointer = =20 -fmessage-length=3D0 -O2 -Wall -D_FORTIFY_SOURCE=3D2 -fstack-protector =20 -funwind-tables -fasynchronous-unwind-tables -g -D_GNU_SOURCE =20 -std=3Dgnu89 -pipe -Wno-pointer-sign -Wno-unused-variable =20 -Wno-unused-label -Wno-unprototyped-calls =20 -DSYSTEM_PURESIZE_EXTRA=3D55000 -DSITELOAD_PURESIZE_EXTRA=3D10000 ' =20 '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 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 ------------=_1468944361-10324-1--