diff lisp/prim/sort.el @ 72:b9518feda344 r20-0b31

Import from CVS: tag r20-0b31
author cvs
date Mon, 13 Aug 2007 09:03:46 +0200
parents 131b0175ea99
children c0c698873ce1
line wrap: on
line diff
--- a/lisp/prim/sort.el	Mon Aug 13 09:03:07 2007 +0200
+++ b/lisp/prim/sort.el	Mon Aug 13 09:03:46 2007 +0200
@@ -19,11 +19,11 @@
 ;; General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with XEmacs; see the file COPYING.  If not, write to the 
-;; Free Software Foundation, 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with XEmacs; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;; 02111-1307, USA.
 
-;;; Synched up with: FSF 19.30.
+;;; Synched up with: FSF 19.34.
 
 ;;; Commentary:
 
@@ -75,42 +75,43 @@
     (save-excursion
       (if messages (message "Finding sort keys..."))
       (let* ((sort-lists (sort-build-lists nextrecfun endrecfun
-                                           startkeyfun endkeyfun))
-             (old (reverse sort-lists))
+					   startkeyfun endkeyfun))
+	     (old (reverse sort-lists))
 	     (case-fold-search sort-fold-case))
-        (if (null sort-lists)
-            ()
-          (or reverse (setq sort-lists (nreverse sort-lists)))
-          (if messages (message "Sorting records..."))
-          (setq sort-lists
-                (if (fboundp 'sortcar)
-                    (sortcar sort-lists
-                             (cond ((numberp (car (car sort-lists)))
+	(if (null sort-lists)
+	    ()
+	  (or reverse (setq sort-lists (nreverse sort-lists)))
+	  (if messages (message "Sorting records..."))
+	  (setq sort-lists
+		(if (fboundp 'sortcar)
+		    (sortcar sort-lists
+			     (cond ((numberp (car (car sort-lists)))
 				    ;; This handles both ints and floats.
-                                    '<)
-                                   ((consp (car (car sort-lists)))
+				    '<)
+				   ((consp (car (car sort-lists)))
 				    (function
 				     (lambda (a b)
 				       (> 0 (compare-buffer-substrings 
 					     nil (car a) (cdr a)
 					     nil (car b) (cdr b))))))
-                                   (t
-                                    'string<)))
-                    (sort sort-lists
-                          (cond ((numberp (car (car sort-lists)))
+				   (t
+				    'string<)))
+		  (sort sort-lists
+			(cond ((numberp (car (car sort-lists)))
 			       'car-less-than-car)
-                                ((consp (car (car sort-lists)))
-                                 (function (lambda (a b)
-                                   (> 0 (compare-buffer-substrings 
-                                          nil (car (car a)) (cdr (car a))
-                                          nil (car (car b)) (cdr (car b)))))))
-                                (t
-                                 (function
-                                  (lambda (a b)
-                                   (string< (car a) (car b)))))))))
-            (if reverse (setq sort-lists (nreverse sort-lists)))
-            (if messages (message "Reordering buffer..."))
-            (sort-reorder-buffer sort-lists old)))
+			      ((consp (car (car sort-lists)))
+			       (function
+				(lambda (a b)
+				  (> 0 (compare-buffer-substrings
+					nil (car (car a)) (cdr (car a))
+					nil (car (car b)) (cdr (car b)))))))
+			      (t
+			       (function
+				(lambda (a b)
+				  (string< (car a) (car b)))))))))
+	  (if reverse (setq sort-lists (nreverse sort-lists)))
+	  (if messages (message "Reordering buffer..."))
+	  (sort-reorder-buffer sort-lists old)))
       (if messages (message "Reordering buffer... Done"))))
   nil)
 
@@ -139,7 +140,7 @@
 		      (let ((start (point)))
 			(funcall (or endkeyfun
 				     (prog1 endrecfun (setq done t))))
-                        (cons start (point))))))
+			(cons start (point))))))
       ;; Move to end of this record (start of next one, or end of buffer).
       (cond ((prog1 done (setq done nil)))
 	    (endrecfun (funcall endrecfun))
@@ -212,9 +213,10 @@
       (narrow-to-region beg end)
       (goto-char (point-min))
       (sort-subr reverse
-		 (function (lambda ()
-                   (while (and (not (eobp)) (looking-at paragraph-separate))
-                     (forward-line 1))))
+		 (function
+		  (lambda ()
+		    (while (and (not (eobp)) (looking-at paragraph-separate))
+		      (forward-line 1))))
 		 'forward-paragraph))))
 
 ;;;###autoload
@@ -267,6 +269,7 @@
 				  (point))))))
 		 nil))
 
+;; This function is commented out of 19.34.
 ;;;###autoload
 (defun sort-float-fields (field beg end)
   "Sort lines in region numerically by the ARGth field of each line.
@@ -348,7 +351,6 @@
     ;; Position at the front of the field
     ;; even if moving backwards.
     (skip-chars-backward "^ \t\n")))
-
 
 (defvar sort-regexp-fields-regexp)
 (defvar sort-regexp-record-end)
@@ -456,12 +458,12 @@
       (setq col-start (min col-beg1 col-end1))
       (setq col-end (max col-beg1 col-end1))
       (if (search-backward "\t" beg1 t)
-	  (error
-	   "sort-columns does not work with tabs.  Use M-x untabify."))
+	  (error "sort-columns does not work with tabs.  Use M-x untabify."))
       (if (not (eq system-type 'vax-vms))
 	  ;; Use the sort utility if we can; it is 4 times as fast.
 	  (call-process-region beg1 end1 "sort" t t nil
 			       (if reverse "-rt\n" "-t\n")
+			       ;; XEmacs (use int-to-string conversion)
 			       (concat "+0." (int-to-string col-start))
 			       (concat "-0." (int-to-string col-end)))
 	;; On VMS, use Emacs's own facilities.