Skip to content

Commit

Permalink
Use cl-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Bozhidar Batsov committed Apr 9, 2014
1 parent 4505ff7 commit 8f2c032
Show file tree
Hide file tree
Showing 27 changed files with 161 additions and 161 deletions.
4 changes: 2 additions & 2 deletions company-abbrev.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;;; Code:

(require 'company)
(eval-when-compile (require 'cl))
(require 'cl-lib)
(require 'abbrev)

(defun company-abbrev-insert (match)
Expand All @@ -37,7 +37,7 @@
(defun company-abbrev (command &optional arg &rest ignored)
"`company-mode' completion back-end for abbrev."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-abbrev
'company-abbrev-insert))
(prefix (company-grab-symbol))
Expand Down
12 changes: 6 additions & 6 deletions company-bbdb.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.

(require 'company)
(eval-when-compile (require 'cl))
(require 'cl-lib)

(declare-function bbdb-record-get-field "bbdb")
(declare-function bbdb-records "bbdb")
Expand All @@ -31,17 +31,17 @@
(defun company-bbdb (command &optional arg &rest ignore)
"`company-mode' completion back-end for `bbdb'."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-bbdb))
(prefix (and (eq major-mode 'message-mode)
(featurep 'bbdb-com)
(looking-back "^\\(To\\|Cc\\|Bcc\\):.*"
(line-beginning-position))
(company-grab-symbol)))
(candidates (mapcan (lambda (record)
(mapcar (lambda (mail) (bbdb-dwim-mail record mail))
(bbdb-record-get-field record 'mail)))
(bbdb-search (bbdb-records) arg nil arg)))
(candidates (cl-mapcan (lambda (record)
(mapcar (lambda (mail) (bbdb-dwim-mail record mail))
(bbdb-record-get-field record 'mail)))
(bbdb-search (bbdb-records) arg nil arg)))
(sorted t)
(no-cache t)))

Expand Down
10 changes: 5 additions & 5 deletions company-capf.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

;;; Code:

(eval-when-compile (require 'cl))
(require 'cl-lib)

(defvar company--capf-data nil)
(make-variable-buffer-local 'company--capf-data)
Expand All @@ -38,10 +38,10 @@
(defun company--capf-data ()
;; Ignore tags-completion-at-point-function because it subverts company-etags
;; in the default value of company-backends, where the latter comes later.
(letf* (((default-value 'completion-at-point-functions) nil)
(data (run-hook-wrapped 'completion-at-point-functions
;; Ignore misbehaving functions.
#'completion--capf-wrapper 'optimist)))
(cl-letf* (((default-value 'completion-at-point-functions) nil)
(data (run-hook-wrapped 'completion-at-point-functions
;; Ignore misbehaving functions.
#'completion--capf-wrapper 'optimist)))
(when (and (consp (cdr data)) (numberp (nth 1 data))) data)))

(defun company-capf (command &optional arg &rest _args)
Expand Down
8 changes: 4 additions & 4 deletions company-clang.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

(require 'company)
(require 'company-template)
(eval-when-compile (require 'cl))
(require 'cl-lib)

(defgroup company-clang nil
"Completion back-end for Clang."
Expand Down Expand Up @@ -115,7 +115,7 @@ or automatically through a custom `company-clang-prefix-guesser'."
"objective-c" "objective-c++")
(substring (symbol-name major-mode) 0 -5)))

(defun company-clang--parse-output (prefix objc)
(defun company-clang--parse-output (prefix _objc)
(goto-char (point-min))
(let ((pattern (format company-clang--completion-pattern
(regexp-quote prefix)))
Expand Down Expand Up @@ -277,7 +277,7 @@ or automatically through a custom `company-clang-prefix-guesser'."
(if (< (point) end)
(insert " ")
(throw 'stop t))
(incf cnt))))
(cl-incf cnt))))
(company-template-move-to-first templ)))

(defun company-clang (command &optional arg &rest ignored)
Expand All @@ -293,7 +293,7 @@ With Clang versions before 2.9, we have to save the buffer before
performing completion. With Clang 2.9 and later, buffer contents are
passed via standard input."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-clang))
(init (when (memq major-mode company-clang-modes)
(unless company-clang-executable
Expand Down
4 changes: 2 additions & 2 deletions company-cmake.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

;;; Code:

(eval-when-compile (require 'cl))
(require 'company)
(require 'cl-lib)

(defgroup company-cmake nil
"Completion back-end for CMake."
Expand Down Expand Up @@ -112,7 +112,7 @@ They affect which types of symbols we get completion candidates for.")
"`company-mode' completion back-end for CMake.
CMake is a cross-platform, open-source make system."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-cmake))
(init (when (memq major-mode company-cmake-modes)
(unless company-cmake-executable
Expand Down
4 changes: 2 additions & 2 deletions company-css.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
;;; Code:

(require 'company)
(eval-when-compile (require 'cl))
(require 'cl-lib)

(defconst company-css-property-alist
;; see http://www.w3.org/TR/CSS21/propidx.html
Expand Down Expand Up @@ -280,7 +280,7 @@ Returns \"\" if no property found, but feasible at this position."
(defun company-css (command &optional arg &rest ignored)
"`company-mode' completion back-end for `css-mode'."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-css))
(prefix (and (derived-mode-p 'css-mode)
(or (company-grab company-css-tag-regexp 1)
Expand Down
4 changes: 2 additions & 2 deletions company-dabbrev-code.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

(require 'company)
(require 'company-dabbrev)
(eval-when-compile (require 'cl))
(require 'cl-lib)

(defgroup company-dabbrev-code nil
"dabbrev-like completion back-end for code."
Expand Down Expand Up @@ -80,7 +80,7 @@ See also `company-dabbrev-code-time-limit'."
The back-end looks for all symbols in the current buffer that aren't in
comments or strings."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-dabbrev-code))
(prefix (and (or (eq t company-dabbrev-code-modes)
(apply 'derived-mode-p company-dabbrev-code-modes))
Expand Down
8 changes: 4 additions & 4 deletions company-dabbrev.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;;; Code:

(require 'company)
(eval-when-compile (require 'cl))
(require 'cl-lib)

(defgroup company-dabbrev nil
"dabbrev-like completion back-end."
Expand Down Expand Up @@ -73,7 +73,7 @@ If you set this value to nil, you may also want to set
(while ,test
,@body
(and ,limit
(eq (incf company-time-limit-while-counter) 25)
(eq (cl-incf company-time-limit-while-counter) 25)
(setq company-time-limit-while-counter 0)
(> (float-time (time-since ,start)) ,limit)
(throw 'done 'company-time-out))))))
Expand Down Expand Up @@ -123,14 +123,14 @@ If you set this value to nil, you may also want to set
limit ignore-comments))))
(and limit
(> (float-time (time-since start)) limit)
(return))))
(cl-return))))
symbols))

;;;###autoload
(defun company-dabbrev (command &optional arg &rest ignored)
"dabbrev-like `company-mode' completion back-end."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-dabbrev))
(prefix (company-grab-word))
(candidates
Expand Down
14 changes: 7 additions & 7 deletions company-eclim.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

(require 'company)
(require 'company-template)
(eval-when-compile (require 'cl))
(require 'cl-lib)

(defgroup company-eclim nil
"Completion back-end for Eclim."
Expand All @@ -45,7 +45,7 @@
(and (file-exists-p (setq file (expand-file-name "plugins" eclipse-root)))
(setq file (car (last (directory-files file t "^org.eclim_"))))
(file-exists-p (setq file (expand-file-name "bin/eclim" file)))
(return file)))))
(cl-return file)))))

(defcustom company-eclim-executable
(or (executable-find "eclim") (company-eclim-executable-find))
Expand Down Expand Up @@ -100,9 +100,9 @@ eclim can only complete correctly when the buffer has been saved."
(let ((dir (company-eclim--project-dir)))
(when dir
(setq company-eclim--project-name
(loop for project in (company-eclim--project-list)
when (equal (cdr (assoc 'path project)) dir)
return (cdr (assoc 'name project))))))))
(cl-loop for project in (company-eclim--project-list)
when (equal (cdr (assoc 'path project)) dir)
return (cdr (assoc 'name project))))))))

(defun company-eclim--candidates (prefix)
(interactive "d")
Expand Down Expand Up @@ -134,7 +134,7 @@ eclim can only complete correctly when the buffer has been saved."
(all-completions prefix completions))))

(defun company-eclim--search-point (prefix)
(if (or (plusp (length prefix)) (eq (char-before) ?.))
(if (or (cl-plusp (length prefix)) (eq (char-before) ?.))
(1- (point))
(point)))

Expand Down Expand Up @@ -163,7 +163,7 @@ Eclim version 1.7.13 or newer (?) is required.
Completions only work correctly when the buffer has been saved.
`company-eclim-auto-save' determines whether to do this automatically."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-eclim))
(prefix (and (derived-mode-p 'java-mode 'jde-mode)
buffer-file-name
Expand Down
16 changes: 8 additions & 8 deletions company-elisp-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@
(company-elisp-candidates "wh"))))))

(ert-deftest company-elisp-candidates-predicate-binding-without-value ()
(loop for (text prefix predicate) in '(("(let (foo|" "foo" boundp)
("(let (foo (bar|" "bar" boundp)
("(let (foo) (bar|" "bar" fboundp))
do
(eval `(company-elisp-with-buffer
,text
(should (eq ',predicate
(company-elisp--candidates-predicate ,prefix)))))))
(cl-loop for (text prefix predicate) in '(("(let (foo|" "foo" boundp)
("(let (foo (bar|" "bar" boundp)
("(let (foo) (bar|" "bar" fboundp))
do
(eval `(company-elisp-with-buffer
,text
(should (eq ',predicate
(company-elisp--candidates-predicate ,prefix)))))))

(ert-deftest company-elisp-finds-vars ()
(let ((obarray [boo bar baz backquote])
Expand Down
14 changes: 7 additions & 7 deletions company-elisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;;; Code:

(require 'company)
(eval-when-compile (require 'cl))
(require 'cl-lib)
(require 'help-mode)
(require 'find-func)

Expand Down Expand Up @@ -131,24 +131,24 @@ first in the candidates list."
(when (looking-at "[ \t\n]*(")
(down-list 1))
(when (looking-at regexp)
(pushnew (match-string-no-properties 1) res)))
(cl-pushnew (match-string-no-properties 1) res)))
(forward-sexp))
(scan-error nil)))
((unless functions-p
(looking-at company-elisp-var-binding-regexp-1))
(down-list 1)
(when (looking-at regexp)
(pushnew (match-string-no-properties 1) res)))))))))
(cl-pushnew (match-string-no-properties 1) res)))))))))
(scan-error nil))
res))

(defun company-elisp-candidates (prefix)
(let* ((predicate (company-elisp--candidates-predicate prefix))
(locals (company-elisp--locals prefix (eq predicate 'fboundp)))
(globals (company-elisp--globals prefix predicate))
(locals (loop for local in locals
when (not (member local globals))
collect local)))
(locals (cl-loop for local in locals
when (not (member local globals))
collect local)))
(if company-elisp-show-locals-first
(append (sort locals 'string<)
(sort globals 'string<))
Expand Down Expand Up @@ -195,7 +195,7 @@ first in the candidates list."
(defun company-elisp (command &optional arg &rest ignored)
"`company-mode' completion back-end for Emacs Lisp."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-elisp))
(prefix (and (derived-mode-p 'emacs-lisp-mode 'inferior-emacs-lisp-mode)
(company-elisp--prefix)))
Expand Down
4 changes: 2 additions & 2 deletions company-etags.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

;;; Code:

(eval-when-compile (require 'cl))
(require 'company)
(require 'cl-lib)
(require 'etags)

(defgroup company-etags nil
Expand Down Expand Up @@ -76,7 +76,7 @@ buffer automatically."
(defun company-etags (command &optional arg &rest ignored)
"`company-mode' completion back-end for etags."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-etags))
(prefix (and (apply 'derived-mode-p company-etags-modes)
(not (company-in-string-or-comment))
Expand Down
6 changes: 3 additions & 3 deletions company-files.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;;; Code:

(require 'company)
(eval-when-compile (require 'cl))
(require 'cl-lib)

(defun company-files-directory-files (dir prefix)
(ignore-errors
Expand All @@ -47,7 +47,7 @@
(let (file dir)
(and (dolist (regexp company-files-regexps)
(when (setq file (company-grab-line regexp 1))
(return file)))
(cl-return file)))
(setq dir (file-name-directory file))
(not (string-match "//" dir))
(file-exists-p dir)
Expand Down Expand Up @@ -78,7 +78,7 @@
(defun company-files (command &optional arg &rest ignored)
"`company-mode' completion back-end existing file names."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-files))
(prefix (company-files-grab-existing-name))
(candidates (company-files-complete arg))
Expand Down
4 changes: 2 additions & 2 deletions company-gtags.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
;;; Code:

(require 'company)
(eval-when-compile (require 'cl))
(require 'cl-lib)

(defgroup company-gtags nil
"Completion back-end for GNU Global."
Expand Down Expand Up @@ -75,7 +75,7 @@
(defun company-gtags (command &optional arg &rest ignored)
"`company-mode' completion back-end for GNU Global."
(interactive (list 'interactive))
(case command
(cl-case command
(interactive (company-begin-backend 'company-gtags))
(prefix (and company-gtags-executable
(memq major-mode company-gtags-modes)
Expand Down
Loading

0 comments on commit 8f2c032

Please sign in to comment.