[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ring+.el - extensions to GNU `ring.el'
From: |
Drew Adams |
Subject: |
ring+.el - extensions to GNU `ring.el' |
Date: |
Tue, 16 Jan 2001 21:35:20 -0500 |
;;; ring+.el --- Extensions to `ring.el'.
;;
;; Filename: ring+.el
;; Description: Extensions to `ring.el'.
;; Author: Drew Adams
;; Maintainer: Drew Adams
;; Copyright (C) 1996-2001, Drew Adams, all rights reserved.
;; Created: Thu Apr 11 16:46:04 1996
;; Version: $Id: ring+.el,v 1.4 2001/01/09 22:13:30 dadams Exp $
;; Last-Updated: Tue Jan 9 14:13:12 2001
;; By: dadams
;; Update #: 62
;; Keywords: extensions, lisp, local
;; Compatibility: GNU Emacs 20.x
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Extensions to `ring.el'.
;;
;; Main new functions here:
;; `ring-insert-new', `ring-member'.
;;
;;
;; This file should be loaded after loading the standard GNU file
;; `ring.el'. So, in your `~/.emacs' file, do this:
;; (eval-after-load "ring" '(progn (require 'ring+))
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;; RCS $Log: ring+.el,v $
;; RCS Revision 1.4 2001/01/09 22:13:30 dadams
;; RCS Adapted file header for Emacs Lisp Archive.
;; RCS
;; RCS Revision 1.3 2001/01/03 17:44:45 dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.2 2001/01/03 01:07:28 dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.1 2000/09/14 17:23:45 dadams
;; RCS Initial revision
;; RCS
; Revision 1.1 1997/03/20 17:54:48 dadams
; Initial revision
;
; Revision 1.3 1996/07/01 13:22:02 dadams
; (trivial)
;
; Revision 1.2 1996/04/12 12:30:14 dadams
; (trivial)
;
; Revision 1.1 1996/04/12 12:22:54 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 'ring) ;; ring-length, ring-ref, ring-remove, ring-insert
(require 'cl) ;; incf
(provide 'ring+)
;;;;;;;;;;;;;;;;;
;;;###autoload
(defun ring-member (item ring)
"Returns index of ITEM if on RING, else nil. Comparison via `equal'.
The index is 0-based."
(let ((ind 0)
(len (1- (ring-length ring)))
(memberp nil))
(while (and (<= ind len)
(not (setq memberp (equal item (ring-ref ring ind)))))
(incf ind))
(and memberp ind)))
;;;###autoload
(defun ring-insert-new (ring item)
"`ring-remove' ITEM from RING, then `ring-insert' it back onto RING.
This ensures that there is only one ITEM on RING.
Returns the new RING."
(let (ind)
(while (setq ind (ring-member item ring))
(ring-remove ring ind)))
(ring-insert ring item)
ring)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; `ring+.el' ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- ring+.el - extensions to GNU `ring.el',
Drew Adams <=