Use cl-lib instead of cl-macs

Fixes #19
This commit is contained in:
Bozhidar Batsov 2015-05-08 23:10:44 +03:00 committed by Oleh Krehel
parent c32b91fa32
commit 6ff26f5377
3 changed files with 27 additions and 21 deletions

5
.dir-locals.el Normal file
View File

@ -0,0 +1,5 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((emacs-lisp-mode
(indent-tabs-mode . nil)))

View File

@ -29,6 +29,7 @@
;;; Code: ;;; Code:
;;* Requires ;;* Requires
(require 'cl-lib)
(require 'avy) (require 'avy)
;;* Customization ;;* Customization
@ -95,16 +96,16 @@ POS is either a position or (BEG . END)."
(defun avy--process (candidates overlay-fn) (defun avy--process (candidates overlay-fn)
"Select one of CANDIDATES using `avy-read'." "Select one of CANDIDATES using `avy-read'."
(unwind-protect (unwind-protect
(cl-case (length candidates) (cl-case (length candidates)
(0 (0
nil) nil)
(1 (1
(car candidates)) (car candidates))
(t (t
(avy--make-backgrounds (list (selected-window))) (avy--make-backgrounds (list (selected-window)))
(avy-read (avy-tree candidates avy-keys) (avy-read (avy-tree candidates avy-keys)
overlay-fn overlay-fn
#'avy--remove-leading-chars))) #'avy--remove-leading-chars)))
(avy--done))) (avy--done)))
(defvar avy--overlays-back nil (defvar avy--overlays-back nil
@ -162,12 +163,12 @@ When PRED is non-nil, it's a filter for matching point positions."
"Create an overlay with STR at PT in WND." "Create an overlay with STR at PT in WND."
(when (<= (1+ pt) (with-selected-window wnd (point-max))) (when (<= (1+ pt) (with-selected-window wnd (point-max)))
(let* ((pt (+ pt avy--overlay-offset)) (let* ((pt (+ pt avy--overlay-offset))
(ol (make-overlay pt (1+ pt) (window-buffer wnd))) (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
(old-str (with-selected-window wnd (old-str (with-selected-window wnd
(buffer-substring pt (1+ pt))))) (buffer-substring pt (1+ pt)))))
(when avy-background (when avy-background
(setq old-str (propertize (setq old-str (propertize
old-str 'face 'avy-background-face))) old-str 'face 'avy-background-face)))
(overlay-put ol 'window wnd) (overlay-put ol 'window wnd)
(overlay-put ol 'display (concat str old-str)) (overlay-put ol 'display (concat str old-str))
(push ol avy--overlays-lead)))) (push ol avy--overlays-lead))))
@ -209,8 +210,8 @@ LEAF is ((BEG . END) . WND)."
old-str 'face 'avy-background-face))) old-str 'face 'avy-background-face)))
(overlay-put ol 'window wnd) (overlay-put ol 'window wnd)
(overlay-put ol 'display (if (string= old-str "\n") (overlay-put ol 'display (if (string= old-str "\n")
(concat str "\n") (concat str "\n")
str)) str))
(push ol avy--overlays-lead)))) (push ol avy--overlays-lead))))
(defun avy--overlay-post (path leaf) (defun avy--overlay-post (path leaf)
@ -274,7 +275,7 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
(avy--generic-jump (avy--generic-jump
(let ((c (read-char "char: "))) (let ((c (read-char "char: ")))
(if (= 13 c) (if (= 13 c)
"\n" "\n"
(regexp-quote (string c)))) (regexp-quote (string c))))
arg arg
avy-goto-char-style)) avy-goto-char-style))
@ -286,8 +287,8 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P") (interactive "P")
(avy--generic-jump (avy--generic-jump
(regexp-quote (string (regexp-quote (string
(read-char "char 1: ") (read-char "char 1: ")
(read-char "char 2: "))) (read-char "char 2: ")))
arg arg
avy-goto-char-style)) avy-goto-char-style))

2
avy.el
View File

@ -42,7 +42,7 @@
;; headache. ;; headache.
;;; Code: ;;; Code:
(require 'cl-macs) (require 'cl-lib)
(defmacro avy-multipop (lst n) (defmacro avy-multipop (lst n)
"Remove LST's first N elements and return them." "Remove LST's first N elements and return them."