comparison lisp/sort.el @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents 375f2633d815
children f9a65d7ebd29
comparison
equal deleted inserted replaced
89908:ee1402f7b568 89909:68c22ea6027c
478 (setq end1 (point)) 478 (setq end1 (point))
479 (setq col-start (min col-beg1 col-end1)) 479 (setq col-start (min col-beg1 col-end1))
480 (setq col-end (max col-beg1 col-end1)) 480 (setq col-end (max col-beg1 col-end1))
481 (if (search-backward "\t" beg1 t) 481 (if (search-backward "\t" beg1 t)
482 (error "sort-columns does not work with tabs -- use M-x untabify")) 482 (error "sort-columns does not work with tabs -- use M-x untabify"))
483 (if (not (or (eq system-type 'vax-vms) 483 (if (not (or (memq system-type '(vax-vms windows-nt))
484 (text-properties-at beg1) 484 (let ((pos beg1) plist fontified)
485 (< (next-property-change beg1 nil end1) end1))) 485 (catch 'found
486 (while (< pos end1)
487 (setq plist (text-properties-at pos))
488 (setq fontified (plist-get plist 'fontified))
489 (while (consp plist)
490 (unless (or (eq (car plist) 'fontified)
491 (and (eq (car plist) 'face)
492 fontified))
493 (throw 'found t))
494 (setq plist (cddr plist)))
495 (setq pos (next-property-change pos nil end1)))))))
486 ;; Use the sort utility if we can; it is 4 times as fast. 496 ;; Use the sort utility if we can; it is 4 times as fast.
487 ;; Do not use it if there are any properties in the region, 497 ;; Do not use it if there are any non-font-lock properties
488 ;; since the sort utility would lose the properties. 498 ;; in the region, since the sort utility would lose the
499 ;; properties.
489 (let ((sort-args (list (if reverse "-rt\n" "-t\n") 500 (let ((sort-args (list (if reverse "-rt\n" "-t\n")
490 (concat "+0." (int-to-string col-start)) 501 (concat "+0." (int-to-string col-start))
491 (concat "-0." (int-to-string col-end))))) 502 (concat "-0." (int-to-string col-end)))))
492 (when sort-fold-case 503 (when sort-fold-case
493 (push "-f" sort-args)) 504 (push "-f" sort-args))
494 (apply #'call-process-region beg1 end1 "sort" t t nil sort-args)) 505 (apply #'call-process-region beg1 end1 "sort" t t nil sort-args))
495 ;; On VMS, use Emacs's own facilities. 506 ;; On VMS and ms-windows, use Emacs's own facilities.
496 (save-excursion 507 (save-excursion
497 (save-restriction 508 (save-restriction
498 (narrow-to-region beg1 end1) 509 (narrow-to-region beg1 end1)
499 (goto-char beg1) 510 (goto-char beg1)
500 (sort-subr reverse 'forward-line 'end-of-line 511 (sort-subr reverse 'forward-line 'end-of-line
533 (setq ll (cdr ll))) 544 (setq ll (cdr ll)))
534 (insert (car ll))))) 545 (insert (car ll)))))
535 546
536 (provide 'sort) 547 (provide 'sort)
537 548
549 ;;; arch-tag: fbac12be-2a7b-4c8a-9665-264d61f70bd9
538 ;;; sort.el ends here 550 ;;; sort.el ends here