comparison lisp/sort.el @ 5418:6eb86cda3856

(sort-float-fields): Commented out.
author Richard M. Stallman <rms@gnu.org>
date Mon, 03 Jan 1994 04:15:18 +0000
parents 2b0671553d8c
children cbd0de32e997
comparison
equal deleted inserted replaced
5417:4d74f3f4ed03 5418:6eb86cda3856
246 "Sort lines in region numerically by the ARGth field of each line. 246 "Sort lines in region numerically by the ARGth field of each line.
247 Fields are separated by whitespace and numbered from 1 up. 247 Fields are separated by whitespace and numbered from 1 up.
248 Specified field must contain a number in each line of the region. 248 Specified field must contain a number in each line of the region.
249 With a negative arg, sorts by the ARGth field counted from the right. 249 With a negative arg, sorts by the ARGth field counted from the right.
250 Called from a program, there are three arguments: 250 Called from a program, there are three arguments:
251 FIELD, BEG and END. BEG and END specify region to sort. 251 FIELD, BEG and END. BEG and END specify region to sort."
252 If you want to sort floating-point numbers, try `sort-float-fields'."
253 (interactive "p\nr") 252 (interactive "p\nr")
254 (sort-fields-1 field beg end 253 (sort-fields-1 field beg end
255 (function (lambda () 254 (function (lambda ()
256 (sort-skip-fields field) 255 (sort-skip-fields field)
257 (string-to-number 256 (string-to-number
262 ;; (skip-chars-forward "[0-9]") 261 ;; (skip-chars-forward "[0-9]")
263 (forward-sexp 1) 262 (forward-sexp 1)
264 (point)))))) 263 (point))))))
265 nil)) 264 nil))
266 265
267 ;;;###autoload 266 ;;;;;###autoload
268 (defun sort-float-fields (field beg end) 267 ;;(defun sort-float-fields (field beg end)
269 "Sort lines in region numerically by the ARGth field of each line. 268 ;; "Sort lines in region numerically by the ARGth field of each line.
270 Fields are separated by whitespace and numbered from 1 up. Specified field 269 ;;Fields are separated by whitespace and numbered from 1 up. Specified field
271 must contain a floating point number in each line of the region. With a 270 ;;must contain a floating point number in each line of the region. With a
272 negative arg, sorts by the ARGth field counted from the right. Called from a 271 ;;negative arg, sorts by the ARGth field counted from the right. Called from a
273 program, there are three arguments: FIELD, BEG and END. BEG and END specify 272 ;;program, there are three arguments: FIELD, BEG and END. BEG and END specify
274 region to sort." 273 ;;region to sort."
275 (interactive "p\nr") 274 ;; (interactive "p\nr")
276 (sort-fields-1 field beg end 275 ;; (sort-fields-1 field beg end
277 (function (lambda () 276 ;; (function (lambda ()
278 (sort-skip-fields field) 277 ;; (sort-skip-fields field)
279 (string-to-number 278 ;; (string-to-number
280 (buffer-substring 279 ;; (buffer-substring
281 (point) 280 ;; (point)
282 (save-excursion 281 ;; (save-excursion
283 (re-search-forward 282 ;; (re-search-forward
284 "[+-]?[0-9]*\.?[0-9]*\\([eE][+-]?[0-9]+\\)?") 283 ;; "[+-]?[0-9]*\.?[0-9]*\\([eE][+-]?[0-9]+\\)?")
285 (point)))))) 284 ;; (point))))))
286 nil)) 285 ;; nil))
287 286
288 ;;;###autoload 287 ;;;###autoload
289 (defun sort-fields (field beg end) 288 (defun sort-fields (field beg end)
290 "Sort lines in region lexicographically by the ARGth field of each line. 289 "Sort lines in region lexicographically by the ARGth field of each line.
291 Fields are separated by whitespace and numbered from 1 up. 290 Fields are separated by whitespace and numbered from 1 up.