diff options
| -rw-r--r-- | lisp/emacs-lisp/ring.el | 9 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/ring-tests.el | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/ring.el b/lisp/emacs-lisp/ring.el index b1b66262d45..c6684ec9493 100644 --- a/lisp/emacs-lisp/ring.el +++ b/lisp/emacs-lisp/ring.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; ring.el --- handle rings of items | 1 | ;;; ring.el --- handle rings of items -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1992, 2001-2016 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992, 2001-2016 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -160,14 +160,15 @@ will be performed." | |||
| 160 | (size (ring-size ring)) | 160 | (size (ring-size ring)) |
| 161 | (vect (cddr ring)) | 161 | (vect (cddr ring)) |
| 162 | lst) | 162 | lst) |
| 163 | (dotimes (var (cadr ring) lst) | 163 | (dotimes (var (cadr ring)) |
| 164 | (push (aref vect (mod (+ start var) size)) lst)))) | 164 | (push (aref vect (mod (+ start var) size)) lst)) |
| 165 | lst)) | ||
| 165 | 166 | ||
| 166 | (defun ring-member (ring item) | 167 | (defun ring-member (ring item) |
| 167 | "Return index of ITEM if on RING, else nil. | 168 | "Return index of ITEM if on RING, else nil. |
| 168 | Comparison is done via `equal'. The index is 0-based." | 169 | Comparison is done via `equal'. The index is 0-based." |
| 169 | (catch 'found | 170 | (catch 'found |
| 170 | (dotimes (ind (ring-length ring) nil) | 171 | (dotimes (ind (ring-length ring)) |
| 171 | (when (equal item (ring-ref ring ind)) | 172 | (when (equal item (ring-ref ring ind)) |
| 172 | (throw 'found ind))))) | 173 | (throw 'found ind))))) |
| 173 | 174 | ||
diff --git a/test/lisp/emacs-lisp/ring-tests.el b/test/lisp/emacs-lisp/ring-tests.el index 705bfe5cffe..affde8914bd 100644 --- a/test/lisp/emacs-lisp/ring-tests.el +++ b/test/lisp/emacs-lisp/ring-tests.el | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | ;; Author: Simen Heggestøyl <simenheg@gmail.com> | 5 | ;; Author: Simen Heggestøyl <simenheg@gmail.com> |
| 6 | ;; Keywords: | 6 | ;; Keywords: |
| 7 | 7 | ||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 8 | ;; GNU Emacs is free software: you can redistribute it and/or modify | 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 9 | ;; it under the terms of the GNU General Public License as published by | 11 | ;; it under the terms of the GNU General Public License as published by |
| 10 | ;; the Free Software Foundation, either version 3 of the License, or | 12 | ;; the Free Software Foundation, either version 3 of the License, or |