From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Robert Weiner Newsgroups: gmane.emacs.bugs Subject: bug#23794: Emacs 25.0.94: Patch to make sort-lines respect visible lines (fairly urgent) Date: Sat, 18 Jun 2016 11:47:08 -0400 Message-ID: Reply-To: rswgnu@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113d48b203ea7605358f6459 X-Trace: ger.gmane.org 1466264908 1812 80.91.229.3 (18 Jun 2016 15:48:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Jun 2016 15:48:28 +0000 (UTC) To: 23794@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 18 17:48: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 1bEITn-0002cx-BY for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Jun 2016 17:48:15 +0200 Original-Received: from localhost ([::1]:35320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEITm-0007Ye-En for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Jun 2016 11:48:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEITf-0007Sj-8b for bug-gnu-emacs@gnu.org; Sat, 18 Jun 2016 11:48:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEITa-0001xB-Uv for bug-gnu-emacs@gnu.org; Sat, 18 Jun 2016 11:48:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:32952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEITa-0001ws-Rs for bug-gnu-emacs@gnu.org; Sat, 18 Jun 2016 11:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bEITa-0005em-Ki for bug-gnu-emacs@gnu.org; Sat, 18 Jun 2016 11:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Weiner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Jun 2016 15:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23794 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.146626487621730 (code B ref -1); Sat, 18 Jun 2016 15:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Jun 2016 15:47:56 +0000 Original-Received: from localhost ([127.0.0.1]:45289 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEITU-0005eQ-35 for submit@debbugs.gnu.org; Sat, 18 Jun 2016 11:47:56 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37537) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEITS-0005e0-02 for submit@debbugs.gnu.org; Sat, 18 Jun 2016 11:47:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEITL-0001nt-K4 for submit@debbugs.gnu.org; Sat, 18 Jun 2016 11:47:48 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:37987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEITL-0001n5-Gx for submit@debbugs.gnu.org; Sat, 18 Jun 2016 11:47:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEITI-0007S1-VX for bug-gnu-emacs@gnu.org; Sat, 18 Jun 2016 11:47:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEITE-0001mo-N1 for bug-gnu-emacs@gnu.org; Sat, 18 Jun 2016 11:47:43 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEITE-0001mR-K2 for bug-gnu-emacs@gnu.org; Sat, 18 Jun 2016 11:47:40 -0400 Original-Received: from mail-oi0-f50.google.com ([209.85.218.50]:35654) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bEITD-00069v-3F for bug-gnu-emacs@gnu.org; Sat, 18 Jun 2016 11:47:39 -0400 Original-Received: by mail-oi0-f50.google.com with SMTP id a64so3588419oii.2 for ; Sat, 18 Jun 2016 08:47:38 -0700 (PDT) X-Gm-Message-State: ALyK8tLmayH2yRCPeh7jh9dvaq7t6VXIuYwemPwo3/vxO8XFwLUycdd3HPwyc69oxVGWpWE+m5lreNSQXIGIaA== X-Received: by 10.202.218.65 with SMTP id r62mr3836293oig.32.1466264858124; Sat, 18 Jun 2016 08:47:38 -0700 (PDT) Original-Received: by 10.202.236.73 with HTTP; Sat, 18 Jun 2016 08:47:08 -0700 (PDT) X-Gmail-Original-Message-ID: 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:119730 Archived-At: --001a113d48b203ea7605358f6459 Content-Type: text/plain; charset=UTF-8 sort-lines calls forward-line rather than forward-visible line, so if you have emacs outline entries that are collapsed/hidden to single lines each and you try to sort them, their bodies and subtrees are sorted separately because forward-visible-line is not used. This patch fixes this problem and also unifies the calling convention of forward-visible-line with that of forward-line (allowing it to take an optional argument) leading to a cleaner calling convention. Please apply it as soon as you can as Hyperbole uses sort-lines to sort its contact manager records and right now this doesn't work. Although, sort-subr could be called directly for this application, sort-lines should work properly with both visible and invisible text and the patch is quite simple. Thanks, Bob -------- In GNU Emacs 25.0.94.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1603)) of 2016-05-17 built on builder10-9.local Windowing system distributor 'Apple', version 10.3.1404 Configured using: 'configure --with-ns '--enable-locallisppath=/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp'' Configured features: NOTIFY ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix ---------------- *** sort-orig.el.gz 2016-06-18 11:31:13.000000000 -0400 --- sort.el.gz 2016-06-18 11:31:13.000000000 -0400 *************** *** 210,216 **** (goto-char (point-min)) (let ;; To make `end-of-line' and etc. to ignore fields. ((inhibit-field-text-motion t)) ! (sort-subr reverse 'forward-line 'end-of-line))))) ;;;###autoload (defun sort-paragraphs (reverse beg end) --- 210,216 ---- (goto-char (point-min)) (let ;; To make `end-of-line' and etc. to ignore fields. ((inhibit-field-text-motion t)) ! (sort-subr reverse 'forward-visible-line 'end-of-visible-line))))) ;;;###autoload (defun sort-paragraphs (reverse beg end) *** simple-orig.el.gz 2016-06-18 11:29:58.000000000 -0400 --- simple.el.gz 2016-06-18 11:29:58.000000000 -0400 *************** *** 4909,4918 **** (kill-region (point) (progn (forward-visible-line arg) (point)))))) ! (defun forward-visible-line (arg) ! "Move forward by ARG lines, ignoring currently invisible newlines only. If ARG is negative, move backward -ARG lines. If ARG is zero, move to the beginning of the current line." (condition-case nil (if (> arg 0) (progn --- 4909,4919 ---- (kill-region (point) (progn (forward-visible-line arg) (point)))))) ! (defun forward-visible-line (&optional arg) ! "Move forward by optional ARG lines (default = 1), ignoring currently invisible newlines only. If ARG is negative, move backward -ARG lines. If ARG is zero, move to the beginning of the current line." + (if (null arg) (setq arg 1)) (condition-case nil (if (> arg 0) (progn --001a113d48b203ea7605358f6459 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
sort-lines calls forward-line rather than forward-visible = line, so if
you have emacs outline entries that are collapsed/hidden to = single lines
each and you try to sort them, their bodies and subtrees ar= e sorted
separately because forward-visible-line is not used.

Thi= s patch fixes this problem and also unifies the calling convention of
fo= rward-visible-line with that of forward-line (allowing it to take an
opt= ional argument) leading to a cleaner calling convention.

Please appl= y it as soon as you can as Hyperbole uses sort-lines to sort
its contact= manager records and right now this doesn't work.=C2=A0 Although,
so= rt-subr could be called directly for this application, sort-lines
should= work properly with both visible and invisible text and the patch
is qui= te simple.

Thanks,

Bob
--------

In GNU Emacs 25.0.9= 4.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F= 1603))
=C2=A0of 2016-05-17 built on builder10-9.local
Windowing syste= m distributor 'Apple', version 10.3.1404
Configured using:
= =C2=A0'configure --with-ns '--enable-locallisppath=3D/Library/Appli= cation
=C2=A0Support/Emacs/${version}/site-lisp:/Library/Application
= =C2=A0Support/Emacs/site-lisp''

Configured features:
NOTI= FY ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS

Important settings:
= =C2=A0 value of $LANG: en_US.UTF-8
=C2=A0 locale-coding-system: utf-8-un= ix

----------------

*** sort-orig.el.gz 2016-06-18 11:31:13.0= 00000000 -0400
--- sort.el.gz 2016-06-18 11:31:13.000000000 -0400
***= ************
*** 210,216 ****
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (goto-char = (point-min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ;; To make `end-of-line= 9; and etc. to ignore fields.
=C2=A0 =C2=A0((inhibit-field-text-motion t= ))
! (sort-subr reverse 'forward-line 'end-of-line)))))
=C2= =A0
=C2=A0 ;;;###autoload
=C2=A0 (defun sort-paragraphs (reverse beg= end)
--- 210,216 ----
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (goto-char (point-= min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ;; To make `end-of-line' and = etc. to ignore fields.
=C2=A0 =C2=A0((inhibit-field-text-motion t))
!= (sort-subr reverse 'forward-visible-line 'end-of-visible-line)))))=
=C2=A0
=C2=A0 ;;;###autoload
=C2=A0 (defun sort-paragraphs (reve= rse beg end)


*** simple-orig.el.gz 2016-06-18 11:29:58.000000000= -0400
--- simple.el.gz 2016-06-18 11:29:58.000000000 -0400
*********= ******
*** 4909,4918 ****
=C2=A0 (kill-region (point)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0(progn (forward-visible-line arg) (point))))))
=C2=A0 <= br>! (defun forward-visible-line (arg)
! =C2=A0 "Move forward by AR= G lines, ignoring currently invisible newlines only.
=C2=A0 If ARG is ne= gative, move backward -ARG lines.
=C2=A0 If ARG is zero, move to the beg= inning of the current line."
=C2=A0 =C2=A0 (condition-case nil
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (> arg 0)
=C2=A0 =C2=A0(progn
--- = 4909,4919 ----
=C2=A0 (kill-region (point)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0(progn (forward-visible-line arg) (point))))))
=C2=A0
! (defun fo= rward-visible-line (&optional arg)
! =C2=A0 "Move forward by op= tional ARG lines (default =3D 1), ignoring currently invisible newlines onl= y.
=C2=A0 If ARG is negative, move backward -ARG lines.
=C2=A0 If ARG= is zero, move to the beginning of the current line."
+ =C2=A0 (if = (null arg) (setq arg 1))
=C2=A0 =C2=A0 (condition-case nil
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 (if (> arg 0)
=C2=A0 =C2=A0(progn
--001a113d48b203ea7605358f6459--