[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2ded593875: Make sort-numeric-fields resilient towards blank line
From: |
Lars Ingebrigtsen |
Subject: |
master 2ded593875: Make sort-numeric-fields resilient towards blank lines |
Date: |
Thu, 3 Feb 2022 14:34:46 -0500 (EST) |
branch: master
commit 2ded5938753a2fac94e5aebce2e97fc5b4d91076
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make sort-numeric-fields resilient towards blank lines
* lisp/sort.el (sort-numeric-fields): Don't signal an error on
blank lines (bug#31800).
---
lisp/sort.el | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/lisp/sort.el b/lisp/sort.el
index eb8e2787d1..90eee01caf 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -286,25 +286,30 @@ FIELD, BEG and END. BEG and END specify region to sort."
(interactive "p\nr")
(let ;; To make `end-of-line' and etc. to ignore fields.
((inhibit-field-text-motion t))
- (sort-fields-1 field beg end
- (lambda ()
- (sort-skip-fields field)
- (let* ((case-fold-search t)
- (base
- (if (looking-at "\\(0x\\)[0-9a-f]\\|\\(0\\)[0-7]")
- (cond ((match-beginning 1)
- (goto-char (match-end 1))
- 16)
- ((match-beginning 2)
- (goto-char (match-end 2))
- 8)
- (t nil)))))
- (string-to-number (buffer-substring (point)
- (save-excursion
- (forward-sexp 1)
- (point)))
- (or base sort-numeric-base))))
- nil)))
+ (sort-fields-1
+ field beg end
+ (lambda ()
+ ;; Don't try to parse blank lines (they'll be
+ ;; sorted at the start).
+ (if (looking-at "[\t ]*$")
+ 0
+ (sort-skip-fields field)
+ (let* ((case-fold-search t)
+ (base
+ (if (looking-at "\\(0x\\)[0-9a-f]\\|\\(0\\)[0-7]")
+ (cond ((match-beginning 1)
+ (goto-char (match-end 1))
+ 16)
+ ((match-beginning 2)
+ (goto-char (match-end 2))
+ 8)
+ (t nil)))))
+ (string-to-number (buffer-substring (point)
+ (save-excursion
+ (forward-sexp 1)
+ (point)))
+ (or base sort-numeric-base)))))
+ nil)))
;;;;;###autoload
;;(defun sort-float-fields (field beg end)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 2ded593875: Make sort-numeric-fields resilient towards blank lines,
Lars Ingebrigtsen <=