unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23794: Emacs bug #23794; sort-line behavior regressed from prior Emacs versions
       [not found]                     ` <83oa6x87ky.fsf@gnu.org>
@ 2016-06-19 16:51                       ` Robert Weiner
  2016-06-19 16:55                         ` Eli Zaretskii
                                           ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Robert Weiner @ 2016-06-19 16:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 23794, Richard Stallman, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 3184 bytes --]

On Sun, Jun 19, 2016 at 12:30 PM, Eli Zaretskii <eliz@gnu.org> 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

[-- Attachment #2: Type: text/html, Size: 7053 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#23794: Emacs bug #23794; sort-line behavior regressed from prior Emacs versions
  2016-06-19 16:51                       ` bug#23794: Emacs bug #23794; sort-line behavior regressed from prior Emacs versions Robert Weiner
@ 2016-06-19 16:55                         ` Eli Zaretskii
       [not found]                         ` <83lh2186fh.fsf@gnu.org>
  2016-06-19 20:59                         ` Drew Adams
  2 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2016-06-19 16:55 UTC (permalink / raw)
  To: rswgnu; +Cc: 23794, rms, emacs-devel

> From: Robert Weiner <rsw@gnu.org>
> Date: Sun, 19 Jun 2016 12:51:08 -0400
> Cc: Drew Adams <drew.adams@oracle.com>, Richard Stallman <rms@gnu.org>, 
> 	emacs-devel <emacs-devel@gnu.org>, 23794@debbugs.gnu.org
> 
> On Sun, Jun 19, 2016 at 12:30 PM, Eli Zaretskii <eliz@gnu.org> 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.

Not necessarily: if you set that up in outline-mode, all of its
descendants will inherit the setting for free.

> Here is the suggested patch to do it this way. -- Bob

Thanks, I hope others will comment on this.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#23794: Emacs bug #23794; sort-line behavior regressed from prior Emacs versions
       [not found]                         ` <83lh2186fh.fsf@gnu.org>
@ 2016-06-19 17:03                           ` Robert Weiner
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Weiner @ 2016-06-19 17:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 23794, Richard Stallman, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

On Sun, Jun 19, 2016 at 12:55 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Robert Weiner <rsw@gnu.org>
> >
> > 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.
>
> Not necessarily: if you set that up in outline-mode, all of its
> descendants will inherit the setting for free.
>

Ok.


>
> > Here is the suggested patch to do it this way. -- Bob
>

One other possibility that is fairly clean is to add sort-visible-*
functions to the sort library; then callers would just have to remember to
call the visible or the regular version of the function and there would be
no need for any new defcustoms.


> Thanks, I hope others will comment on this.
>

Yes.

[-- Attachment #2: Type: text/html, Size: 1698 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#23794: Emacs bug #23794; sort-line behavior regressed from prior Emacs versions
  2016-06-19 16:51                       ` bug#23794: Emacs bug #23794; sort-line behavior regressed from prior Emacs versions Robert Weiner
  2016-06-19 16:55                         ` Eli Zaretskii
       [not found]                         ` <83lh2186fh.fsf@gnu.org>
@ 2016-06-19 20:59                         ` Drew Adams
  2 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2016-06-19 20:59 UTC (permalink / raw)
  To: rswgnu, Eli Zaretskii; +Cc: 23794, Richard Stallman, emacs-devel

Please don't send to both the bug list and emacs-devel, in general.

(And please consider using plain text, not HTML, mail.)





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-19 20:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CA+OMD9g7rO1E=1k7BN6T3B6PUqEOF_PxzG4AAiiB_zMcN98oQQ@mail.gmail.com>
     [not found] ` <83shwa9zmr.fsf@gnu.org>
     [not found]   ` <83lh229ywc.fsf@gnu.org>
     [not found]     ` <CA+OMD9h3oQLj6-p2vWEsvg0QA3_QFWMMQAVXPNrHmqxmLtZUkQ@mail.gmail.com>
     [not found]       ` <83inx69xcx.fsf@gnu.org>
     [not found]         ` <CA+OMD9jEwHrM6gsyjzHi5hf2nUGWDPgvFm8Fewh8wmxwTL-RKA@mail.gmail.com>
     [not found]           ` <0984ce22-cbcf-42a6-906e-a03b65f3c71c@default>
     [not found]             ` <8360t5aolu.fsf@gnu.org>
     [not found]               ` <CA+OMD9gYwmYFpa3s_20N4-uLTvKMCkqBdQBOBDUQVbhpngbiaA@mail.gmail.com>
     [not found]                 ` <83vb158awq.fsf@gnu.org>
     [not found]                   ` <CA+OMD9gB=y6Uo3Sh3HCJNEhJ2jx-8Y8pE35KCPR=7FbEX-SGCA@mail.gmail.com>
     [not found]                     ` <83oa6x87ky.fsf@gnu.org>
2016-06-19 16:51                       ` bug#23794: Emacs bug #23794; sort-line behavior regressed from prior Emacs versions Robert Weiner
2016-06-19 16:55                         ` Eli Zaretskii
     [not found]                         ` <83lh2186fh.fsf@gnu.org>
2016-06-19 17:03                           ` Robert Weiner
2016-06-19 20:59                         ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).