From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Robert Weiner Newsgroups: gmane.emacs.bugs,gmane.emacs.devel Subject: bug#23794: Emacs bug #23794; sort-line behavior regressed from prior Emacs versions Date: Sun, 19 Jun 2016 12:51:08 -0400 Message-ID: References: <83shwa9zmr.fsf@gnu.org> <83lh229ywc.fsf@gnu.org> <83inx69xcx.fsf@gnu.org> <0984ce22-cbcf-42a6-906e-a03b65f3c71c@default> <8360t5aolu.fsf@gnu.org> <83vb158awq.fsf@gnu.org> <83oa6x87ky.fsf@gnu.org> Reply-To: rswgnu@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113ce25abdb8590535a46662 X-Trace: ger.gmane.org 1466355155 16044 80.91.229.3 (19 Jun 2016 16:52:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Jun 2016 16:52:35 +0000 (UTC) Cc: 23794@debbugs.gnu.org, Richard Stallman , emacs-devel To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 19 18:52:25 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 1bEfxI-0005sH-TP for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Jun 2016 18:52:17 +0200 Original-Received: from localhost ([::1]:39421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEfxI-00077f-9P for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Jun 2016 12:52:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEfx9-00074R-5L for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 12:52:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEfx4-0006jH-57 for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 12:52:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEfx4-0006jD-1S for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 12:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bEfx3-0004ZD-Ua for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 12:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Weiner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Jun 2016 16:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23794 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23794-submit@debbugs.gnu.org id=B23794.146635511117537 (code B ref 23794); Sun, 19 Jun 2016 16:52:01 +0000 Original-Received: (at 23794) by debbugs.gnu.org; 19 Jun 2016 16:51:51 +0000 Original-Received: from localhost ([127.0.0.1]:46603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEfws-0004Ym-T0 for submit@debbugs.gnu.org; Sun, 19 Jun 2016 12:51:51 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEfwr-0004YY-V0 for 23794@debbugs.gnu.org; Sun, 19 Jun 2016 12:51:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEfwi-0006gf-T3 for 23794@debbugs.gnu.org; Sun, 19 Jun 2016 12:51:44 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:55402) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEfwi-0006gR-Ow for 23794@debbugs.gnu.org; Sun, 19 Jun 2016 12:51:40 -0400 Original-Received: from mail-oi0-f54.google.com ([209.85.218.54]:32777) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bEfwh-0001Y6-1l for 23794@debbugs.gnu.org; Sun, 19 Jun 2016 12:51:39 -0400 Original-Received: by mail-oi0-f54.google.com with SMTP id u201so180854169oie.0 for <23794@debbugs.gnu.org>; Sun, 19 Jun 2016 09:51:38 -0700 (PDT) X-Gm-Message-State: ALyK8tLQT8jAcJrRYRujv6zpeG+kAZaF63stNP2wIL1og5kMLtdrCkukhPTHgUGlZ2KW7XOLABVob68qp5ia3w== X-Received: by 10.202.178.84 with SMTP id b81mr5562803oif.155.1466355098169; Sun, 19 Jun 2016 09:51:38 -0700 (PDT) Original-Received: by 10.202.236.73 with HTTP; Sun, 19 Jun 2016 09:51:08 -0700 (PDT) In-Reply-To: <83oa6x87ky.fsf@gnu.org> X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:119782 gmane.emacs.devel:204531 Archived-At: --001a113ce25abdb8590535a46662 Content-Type: text/plain; charset=UTF-8 On Sun, Jun 19, 2016 at 12:30 PM, Eli Zaretskii wrote: > Didn't think that far, but is it really clean for sort-lines to have > special code for some major mode? I thought a better way is to > override the default behavior by having sort-lines call functions > through funcall or somesuch, and then outline modes could set the > appropriate variable to the function of their liking? > The problem with that approach is that each mode has to be aware of this and add a setting, really not much different than each mode having its own sort function or way of calling a sort function. It is much more useful to centralize the behavior within the sorting library, even if it adds some conditional complexity to the code. Here is the suggested patch to do it this way. -- Bob *** sort-orig.el.gz 2016-06-19 12:42:12.000000000 -0400 --- sort.el.gz 2016-06-19 12:42:12.000000000 -0400 *************** *** 39,44 **** --- 39,50 ---- :type 'boolean) ;;;###autoload(put 'sort-fold-case 'safe-local-variable 'booleanp) + (defcustom sort-invisible-lines nil + "Non-nil if the buffer `sort-line' function should treat invisible lines like visible ones." + :group 'sort + :type 'boolean) + ;;;###autoload(put 'sort-invisible-lines 'safe-local-variable 'booleanp) + ;;;###autoload (defun sort-subr (reverse nextrecfun endrecfun &optional startkeyfun endkeyfun predicate) *************** *** 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) --- 216,228 ---- (goto-char (point-min)) (let ;; To make `end-of-line' and etc. to ignore fields. ((inhibit-field-text-motion t)) ! (if (and (not sort-invisible-lines) ! (or (derived-mode-p 'outline-mode) ! (and (boundp 'outline-minor-mode) outline-minor-mode))) ! ;; In in an outline mode with sort-invisible-lines nil, sort ! ;; only visible lines. ! (sort-subr reverse 'forward-visible-line 'end-of-visible-line) ! (sort-subr reverse 'forward-line 'end-of-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 --001a113ce25abdb8590535a46662 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On S= un, Jun 19, 2016 at 12:30 PM, Eli Zaretskii <eliz@gnu.org> wrot= e:
Didn't think that far, but is it really cle= an for sort-lines to have
special code for some major mode?=C2=A0 I thought a better way is to
override the default behavior by having sort-lines call functions
through funcall or somesuch, and then outline modes could set the
appropriate variable to the function of their liking?

The problem with that approach is that each mode has to be= aware of this and add a setting, really not much different than each mode = having its own sort function or way of calling a sort function.=C2=A0 It is= much more useful to centralize the behavior within the sorting library, ev= en if it adds some conditional complexity to the code.=C2=A0 Here is the su= ggested patch to do it this way. =C2=A0-- Bob

*** sort-orig.el.gz 2016-06-19= 12:42:12.000000000 -0400
--- sort.el.gz 2016-06-19 12:42:12.000000000 -0400
********= *******
*** 39,44 ****
--- 39,50 ----
=C2=A0 = =C2=A0 :type 'boolean)
=C2=A0 ;;;###autoload(put 'sort-fo= ld-case 'safe-local-variable 'booleanp)
=C2=A0=C2=A0
+ (defcustom sort-invisible-lines nil
+ =C2=A0 "Non-ni= l if the buffer `sort-line' function should treat invisible lines like = visible ones."
+ =C2=A0 :group 'sort
+ =C2=A0 = :type 'boolean)
+ ;;;###autoload(put 'sort-invisible-line= s 'safe-local-variable 'booleanp)
+=C2=A0
=C2= =A0 ;;;###autoload
=C2=A0 (defun sort-subr (reverse nextrecfun en= drecfun
=C2=A0 = =C2=A0&optional startkeyfun endkeyfun predicate)
************= ***
*** 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 `en= d-of-line' and etc. to ignore fields.
=C2=A0 =C2=A0((inhibit-field-text-motion t))
! (sort-subr reverse 'f= orward-line 'end-of-line)))))
=C2=A0=C2=A0
=C2=A0 ;= ;;###autoload
=C2=A0 (defun sort-paragraphs (reverse beg end)
--- 216,228 ----
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (goto-char (p= oint-min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ;; To make `end-of-li= ne' and etc. to ignore fields.
=C2=A0 =C2=A0((inhibit-field-text-motion t))
! (if (and (not sort-invisible-lin= es)
! (or (derived= -mode-p 'outline-mode)
! =C2=A0 =C2=A0 (and (boundp 'outline-minor-mode) outline-mino= r-mode)))
! =C2=A0 = =C2=A0;; In in an outline mode with sort-invisible-lines nil, sort
! =C2=A0 =C2=A0;; only visi= ble lines.
! =C2=A0= =C2=A0(sort-subr reverse 'forward-visible-line 'end-of-visible-lin= e)
! =C2=A0(sort-su= br reverse 'forward-line 'end-of-line))))))
=C2=A0=C2=A0<= /div>
=C2=A0 ;;;###autoload
=C2=A0 (defun sort-paragraphs (re= verse 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=C2=A0
! (defun forward-visible-line (arg)
! =C2=A0 "Move forward by ARG= =C2=A0lines, ignoring cur= rently invisible newlines only.
=C2=A0 If ARG is negative, move backward -ARG=C2= =A0lines.
=C2=A0 If ARG is zer= o, move to the beginning of the current line."
=C2=A0 =C2=A0 (condition-cas= e nil
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (> arg 0)
=C2=A0 =C2=A0(progn
--- 4909,4919 ----<= /span>
=C2= =A0 (kill-region (point)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(progn (forward-visible-li= ne arg) (point))))))
=C2=A0=C2=A0
! (defun forward-visible-line (&optional arg)
! =C2= =A0 "Move forward by optional ARG=C2=A0lines=C2=A0(default =3D 1), ignoring currently invisib= le newlines only.
=C2=A0 If ARG is negative, move backward -ARG=C2=A0l= ines
.
=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


--001a113ce25abdb8590535a46662--