[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sort+.el - extensions to GNU `sort.el'
From: |
Drew Adams |
Subject: |
sort+.el - extensions to GNU `sort.el' |
Date: |
Tue, 16 Jan 2001 21:35:20 -0500 |
;;; sort+.el --- Extensions to `sort.el'.
;;
;; Filename: sort+.el
;; Description: Extensions to `sort.el'.
;; Author: Drew Adams
;; Maintainer: Drew Adams
;; Copyright (C) 1996-2001, Drew Adams, all rights reserved.
;; Created: Thu Apr 18 10:16:50 1996
;; Version: $Id: sort+.el,v 1.4 2001/01/09 22:22:55 dadams Exp $
;; Last-Updated: Tue Jan 9 14:22:45 2001
;; By: dadams
;; Update #: 62
;; Keywords: unix, tools, local
;; Compatibility: GNU Emacs 20.x
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Extensions to `sort.el'.
;;
;;
;; ***** NOTE: The following function defined in `sort.el' has been
;; REDEFINED HERE:
;;
;; `sort-reorder-buffer' - This version preserves text properties,
;; even in Emacs versions prior to 20.
;;
;;
;; This file should be loaded after loading the standard GNU file
;; `sort.el'. So, in your `~/.emacs' file, do this:
;; (eval-after-load "sort" '(require 'sort+))
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;; RCS $Log: sort+.el,v $
;; RCS Revision 1.4 2001/01/09 22:22:55 dadams
;; RCS Adapted file header for Emacs Lisp Archive.
;; RCS
;; RCS Revision 1.3 2001/01/03 17:46:27 dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.2 2001/01/03 01:16:49 dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.1 2000/09/14 17:24:10 dadams
;; RCS Initial revision
;; RCS
; Revision 1.2 1999/03/17 15:57:31 dadams
; (trivial): setq -> pop.
;
; Revision 1.1 1997/03/21 11:03:48 dadams
; Initial revision
;
; Revision 1.2 1996/07/01 13:26:47 dadams
; (trivial)
;
; Revision 1.1 1996/04/18 09:21:44 dadams
; Initial revision
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(require 'sort)
(require 'cl) ;; cddar, pop
(provide 'sort+)
;;;;;;;;;;;;;;;;;;;
;; REPLACES ORIGINAL in `sort.el':
;; In versions of Emacs prior to 20, the original `sort-reorder-buffer'
;; did not preserve text properties (e.g. face, mouse-face).
;; This version does preserve them. The only difference here is that
;; (insert-buffer-substring (current-buffer)...) has been replaced by
;; (insert-string (buffer-substring...))
(defun sort-reorder-buffer (sort-lists old)
(let ((inhibit-quit t)
(last (point-min))
(min (point-min)) (max (point-max)))
;; Make sure insertions done for reordering do not go after any markers
;; at the end of the sorted region, by inserting a space to separate them.
(goto-char (point-max))
(insert-before-markers " ")
(narrow-to-region min (1- (point-max)))
(while sort-lists
(goto-char (point-max))
(insert-string (buffer-substring last (nth 1 (car old))))
(goto-char (point-max))
(insert-string (buffer-substring (nth 1 (car sort-lists))
(cddar sort-lists)))
(setq last (cddar old))
(pop sort-lists)
(pop old))
(goto-char (point-max))
(insert-string (buffer-substring last max))
(delete-region min max) ; Delete original copy of the text.
(goto-char (point-max)) ; Get rid of the separator, " ".
(narrow-to-region min (1+ (point)))
(delete-region (point) (1+ (point)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; `sort+.el' ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- sort+.el - extensions to GNU `sort.el',
Drew Adams <=