This is a packages patch, the Mercurial metadata are from a local repository
and should be ignored.
comparing with /Sources/packages-current-checked-out
searching for changes
changeset: 7:086e30f832e9
tag: tip
user: Aidan Kehoe <kehoea(a)parhasard.net>
date: Sun Apr 20 13:16:55 2008 +0200
summary: Support specifying bases for #'sort-regexp-fields-numerically.
diff -r 13601045291b -r 086e30f832e9 xemacs-packages/xemacs-base/ChangeLog
--- a/xemacs-packages/xemacs-base/ChangeLog Fri Apr 11 20:47:07 2008 +0200
+++ b/xemacs-packages/xemacs-base/ChangeLog Sun Apr 20 13:16:55 2008 +0200
@@ -1,3 +1,14 @@ 2008-02-25 Norbert Koch <viteno@xemacs
+2008-04-20 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * sort.el (sort-regexp-fields-numerically):
+ Support `sort-numeric-base' in #'s-r-f-n, implement the same
+ sniffing of a number's base used in #'sort-numeric-fields, correct
+ and extend the docstring (`sort-fold-case' is not used, the
+ example has been changed to one where numeric sorting is
+ relevant.
+ (sort-numeric-base):
+ Document its use in #'s-r-f-n.
+
2008-02-25 Norbert Koch <viteno(a)xemacs.org>
* Makefile (VERSION): XEmacs package 2.16 released.
diff -r 13601045291b -r 086e30f832e9 xemacs-packages/xemacs-base/sort.el
--- a/xemacs-packages/xemacs-base/sort.el Fri Apr 11 20:47:07 2008 +0200
+++ b/xemacs-packages/xemacs-base/sort.el Sun Apr 20 13:16:55 2008 +0200
@@ -274,7 +274,7 @@ the sort order."
(setq sort-fields-syntax-table table)))
(defcustom sort-numeric-base 10
- "*The default base used by `sort-numeric-fields'."
+ "*Fallback base for `sort-numeric-fields',
`sort-regexp-fields-numerically'."
:group 'sort
:type 'integer)
@@ -500,21 +500,26 @@ RECORD-REGEXP specifies the textual unit
RECORD-REGEXP specifies the textual units which should be sorted.
For example, to sort lines RECORD-REGEXP would be \"^.*$\"
KEY specifies the part of each record (ie each match for RECORD-REGEXP)
- is to be used for sorting.
+ which is to be used for sorting.
If it is \"\\\\digit\" then the digit'th \"\\\\(...\\\\)\"
match field from
RECORD-REGEXP is used.
If it is \"\\\\&\" then the whole record is used.
Otherwise, it is a regular-expression for which to search within the record.
If a match for KEY is not found within a record then that record is ignored.
+If the match for KEY starts with \"0x\", it specifies hexadecimal as the
+conversion base. A match for KEY starting with \"0\" is interpreted as
+octal; otherwise `sort-numeric-base' is consulted for the conversion base to
+use. You can avoid the automatic detection of a field's base by specifying
+RECORD-REGEXP appropriately; \"0*\" before the start of the KEY will prevent
+detection as octal, and including \"[^xX]\" in the group corresponding to
+KEY will prevent detection as hex.
+
With a negative prefix arg sorts in reverse order.
-The variable `sort-fold-case' determines whether alphabetic case affects
-the sort order.
-
-For example: to sort lines in the region by the first word on each line
- starting with the letter \"f\",
- RECORD-REGEXP would be \"^.*$\" and KEY would be
\"\\\\=\\<f\\\\w*\\\\>\""
+For example: to sort lines in the region by the numerical value of the first
+ C hexadecimal constant,
+ RECORD-REGEXP would be \"^.*$\" and KEY would be
\"0[xX][0-9A-Fa-f]+\""
;; using negative prefix arg to mean "reverse" is now inconsistent with
;; other sort-.*fields functions but then again this was before, since it
;; didn't use the magnitude of the arg to specify anything.
@@ -529,9 +534,27 @@ For example: to sort lines in the region
(read-string "Regexp specifying key within record: "
nil 'sort-regexp-history)
beg end)))
- (sort-regexp-fields reverse record-regexp key-regexp beg end
- #'(lambda (a b)
- (< (string-to-number a) (string-to-number b)))))
+ (let ((base-sniff-regexp "\\(0[xX]\\)[0-9a-fA-F]\\|\\(0\\)[0-7]"))
+ (sort-regexp-fields reverse record-regexp key-regexp beg end
+ #'(lambda (a b)
+ ;; If I replace #'< with #'max, the warning
+ ;;
+ ;; ** variable base-sniff-regexp bound but not
+ ;; referenced
+ ;;
+ ;; goes away. Byte compiler bug.
+ (< (string-to-number a
+ (if (string-match base-sniff-regexp a)
+ (cond ((match-beginning 1) 16)
+ ((match-beginning 2) 8)
+ (t sort-numeric-base))
+ sort-numeric-base))
+ (string-to-number b
+ (if (string-match base-sniff-regexp b)
+ (cond ((match-beginning 1) 16)
+ ((match-beginning 2) 8)
+ (t sort-numeric-base))
+ sort-numeric-base)))))))
(defvar sort-columns-subprocess t)
--
¿Dónde estará ahora mi sobrino Yoghurtu Nghé, que tuvo que huir
precipitadamente de la aldea por culpa de la escasez de rinocerontes?
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches