aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimen Heggestøyl2016-09-09 18:46:55 +0200
committerSimen Heggestøyl2016-09-09 18:46:55 +0200
commit367f8568bc9e759ebdfb423648891efa0346456b (patch)
tree53af7a92fcac725150fe6fce916b27c9e0153473
parent8634efa38179f44c2cb5c52c25ced3f02fa5ec1a (diff)
downloademacs-367f8568bc9e759ebdfb423648891efa0346456b.tar.gz
emacs-367f8568bc9e759ebdfb423648891efa0346456b.zip
* lisp/emacs-lisp/ring.el: Use lexical-binding
* lisp/emacs-lisp/ring.el (ring-elements): Don't use the RESULT argument of `dotimes' when the iteration variable isn't referred by it. (ring-member): Don't pass nil as the RESULT argument of `dotimes' since it's the default.
-rw-r--r--lisp/emacs-lisp/ring.el9
-rw-r--r--test/lisp/emacs-lisp/ring-tests.el2
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.
168Comparison is done via `equal'. The index is 0-based." 169Comparison 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