unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Weiner <rsw@gnu.org>
To: 23794@debbugs.gnu.org
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	[thread overview]
Message-ID: <CA+OMD9gF+7j37bCm-GtNXwzimWzYa1yVu2UbBhd2uTwBzvp13g@mail.gmail.com> (raw)

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

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

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

             reply	other threads:[~2016-06-18 15:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87mvmji9jv.fsf@163.com>
2016-06-18 15:47 ` Robert Weiner [this message]
2016-06-18 17:26   ` bug#23794: Emacs 25.0.94: Patch to make sort-lines respect visible lines (fairly urgent) Eli Zaretskii
2016-06-18 17:42     ` Robert Weiner
2016-06-18 17:49       ` Eli Zaretskii
2016-06-18 18:19         ` Eli Zaretskii
     [not found]   ` <CA+OMD9i=3i5Z3xsnmjUvi8Jfs68x++kkZentoRM8yu9o2srE=Q@mail.gmail.com>
     [not found]     ` <E1bEgMo-0005Ld-M3@fencepost.gnu.org>
     [not found]       ` <CA+OMD9i8eQFeKV840uP+ecbrtKYjHcKz4e5HsnQaXbSivRdnAQ@mail.gmail.com>
     [not found]         ` <E1bF8FJ-00035J-Vn@fencepost.gnu.org>
     [not found]           ` <CA+OMD9gMn6cOOa4=Mj+oWs9zg41+PEFtRN6ryeDoZUTq3iY1QA@mail.gmail.com>
     [not found]             ` <E1bFbjx-0002sy-LM@fencepost.gnu.org>
2017-08-28  4:00               ` bug#23794: Fwd: Fwd: bug#23789: " Robert Weiner
2017-12-24  2:21                 ` bug#23794: " Robert Weiner
2019-06-25 13:08   ` bug#23794: " Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+OMD9gF+7j37bCm-GtNXwzimWzYa1yVu2UbBhd2uTwBzvp13g@mail.gmail.com \
    --to=rsw@gnu.org \
    --cc=23794@debbugs.gnu.org \
    --cc=rswgnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).