GNU bug report logs - #31800
suggestion of improvement for sort-numeric-fields function.

Previous Next

Package: emacs;

Reported by: SK Kim <tttuuu888 <at> gmail.com>

Date: Tue, 12 Jun 2018 16:10:01 UTC

Severity: wishlist

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Kangas <stefan <at> marxist.se>
To: SK Kim <tttuuu888 <at> gmail.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 31800 <at> debbugs.gnu.org
Subject: bug#31800: suggestion of improvement for sort-numeric-fields function.
Date: Mon, 20 Jan 2020 20:55:04 +0100
SK Kim <tttuuu888 <at> gmail.com> writes:

> I made this patch from github emacs-mirror repository.
> I hope this will be of help.
>
> Thanks.
>
> 2019년 7월 13일 (토) 오후 12:42, Lars Ingebrigtsen <larsi <at> gnus.org>님이 작성:
>
>  SK Kim <tttuuu888 <at> gmail.com> writes:
>
>  > This is not likely a bug but sort-numeric-fields function does not
>  > allow region with blank lines, while sort-lines does.
>  >
>  > This was because sort-skip-fields occurs error with blank line. And
>  > when I added condition for sort-skip-fields like below,
>  > sort-numeric-fields was working with blank lines too.
>  >
>  >                      (when (not (string-match-p "^\\s-*$" (thing-at-point 'line)))
>  >                        (sort-skip-fields field))
>  >
>  > So, I just hope sort-numeric-fields would work for region with blank
>  > lines too.

The patch below looks good to me.  Does anyone else have an opinion
here, or should I go ahead and commit it to master?

Best regards,
Stefan Kangas

> From d08c5d368337ee49bb72d9915c409edcbc73b4e0 Mon Sep 17 00:00:00 2001
> From: SeungKi Kim <tttuuu888 <at> gmail.com>
> Date: Sat, 13 Jul 2019 17:12:46 +0900
> Subject: [PATCH] Improve `sort-numeric-fields'
>
> * lisp/sort.el (sort-numeric-fields) : Allow including empty lines.
> ---
>  lisp/sort.el | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/sort.el b/lisp/sort.el
> index 6ea1c44060..3e9413e4af 100644
> --- a/lisp/sort.el
> +++ b/lisp/sort.el
> @@ -281,7 +281,8 @@ FIELD, BEG and END.  BEG and END specify region to sort."
>        ((inhibit-field-text-motion t))
>      (sort-fields-1 field beg end
>  		   (lambda ()
> -		     (sort-skip-fields field)
> +                     (unless (string-match-p "^\\s-*$" (thing-at-point 'line))
> +                       (sort-skip-fields field))
>  		     (let* ((case-fold-search t)
>  			    (base
>  			     (if (looking-at "\\(0x\\)[0-9a-f]\\|\\(0\\)[0-7]")




This bug report was last modified 3 years and 164 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.