]> code.delx.au - gnu-emacs-elpa/commitdiff
Use cl-lib
authorBozhidar Batsov <bozhidar@tradeo.com>
Wed, 9 Apr 2014 15:25:01 +0000 (18:25 +0300)
committerBozhidar Batsov <bozhidar@tradeo.com>
Wed, 9 Apr 2014 15:39:04 +0000 (18:39 +0300)
27 files changed:
company-abbrev.el
company-bbdb.el
company-capf.el
company-clang.el
company-cmake.el
company-css.el
company-dabbrev-code.el
company-dabbrev.el
company-eclim.el
company-elisp-tests.el
company-elisp.el
company-etags.el
company-files.el
company-gtags.el
company-ispell.el
company-keywords.el
company-nxml.el
company-oddmuse.el
company-pysmell.el
company-ropemacs.el
company-semantic.el
company-template.el
company-tempo.el
company-tests.el
company-xcode.el
company-yasnippet.el
company.el

index 0c4e327bc46baef1983269ae4267a33d616fbdac..a454aaa90d277c2d3950b7a5177969152fa2090f 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 (require 'abbrev)
 
 (defun company-abbrev-insert (match)
@@ -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))
index 8e4705f73910437c958d04e50d5a659c42def25b..acdd30ac14922aeb683bb1e14984cd3202736c06 100644 (file)
@@ -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")
 (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)))
 
index 17be772126736ab282b2524fd509c8cc190a9c7f..04f8413edffbccfea75430785579585e57d4abfa 100644 (file)
@@ -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)
 (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)
index 4c7b0c7426f2acc4b4d27e7eadc47ee2c8ce60b0..14b6753e6450aedf072223945f8dc7cb69cb714e 100644 (file)
@@ -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."
@@ -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)))
@@ -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)
@@ -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
index 34359dc7ab011a1e0a9b298cfcd66e8fa29c9136..a466f60b7a75b5abdad3ec06a4fd3e367ca9a46f 100644 (file)
@@ -25,8 +25,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
 (require 'company)
+(require 'cl-lib)
 
 (defgroup company-cmake nil
   "Completion back-end for CMake."
@@ -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
index 11e195adabdf2c03584be1d63826a8a8a1224d98..c4154c2ec4efa85847d4d289c0e354cc22c0b8d5 100644 (file)
@@ -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
@@ -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)
index 6f827cd50d7e71bb8ee250f7651829774203f809..1039e4a66d192e511bc5e989f3067b564d4a0c6f 100644 (file)
@@ -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."
@@ -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))
index c0cd0e0ab6818ee0150a4a4b9d75492a38fb34cf..ee3f65804ac55a3646f24fb25fd8bb1f37435f64 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defgroup company-dabbrev nil
   "dabbrev-like completion back-end."
@@ -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))))))
@@ -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
index 65fb215542f4b1246f6c5a09e766cfb4786fb66e..24f05f517ffcdb4d72ec5f3e4040d6ed489c1ebf 100644 (file)
@@ -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."
@@ -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))
@@ -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")
@@ -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)))
 
@@ -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
index 432d8ca8b6b8354da5591a891431927668d832f0..9b7cba33379bda942d69cf1bfc8ac158548881c2 100644 (file)
                      (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])
index 0ea4c69403f67739b9071e971b5a235541b70695..5efd8d051e2104e803bfdb4bbd5ad161011b3c32 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 (require 'help-mode)
 (require 'find-func)
 
@@ -131,14 +131,14 @@ 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))
 
@@ -146,9 +146,9 @@ first in the candidates list."
   (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<))
@@ -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)))
index 6f4912ff4917d16955fd21701fc59466323a9e41..8634103fe9f346df1c15819dd3294f93bec90e36 100644 (file)
@@ -25,8 +25,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
 (require 'company)
+(require 'cl-lib)
 (require 'etags)
 
 (defgroup company-etags nil
@@ -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))
index b897e3d3751404b358652bfa00f6b3ed247a0816..a450526a0f50d89871c6b44b5e28fd8fc9619654 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defun company-files-directory-files (dir prefix)
   (ignore-errors
@@ -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)
@@ -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))
index 645100757e97c131b79f58b3f12ed43587e8d2d8..0ae98d7d62e0d66a33327c27a816398b980056de 100644 (file)
@@ -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."
@@ -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)
index 3e599f03e51fee11468c71f2c5b9724134617ba5..1561beef1a1b62e633c79ae4451c5a53d8fa1be8 100644 (file)
@@ -26,8 +26,8 @@
 ;;; Code:
 
 (require 'company)
+(require 'cl-lib)
 (require 'ispell)
-(eval-when-compile (require 'cl))
 
 (defgroup company-ispell nil
   "Completion back-end using Ispell."
@@ -56,7 +56,7 @@ If nil, use `ispell-complete-word-dict'."
 (defun company-ispell (command &optional arg &rest ignored)
   "`company-mode' completion back-end using Ispell."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-ispell))
     (prefix (when (company-ispell-available)
               (company-grab-word)))
index 461fdf6b04ec4b506073c945a7e7c952224bd737..c700af769bee7b235ae94f2dfa160092d6e5cdb7 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defun company-keywords-upper-lower (&rest lst)
   ;; Upcase order is different for _.
 (defun company-keywords (command &optional arg &rest ignored)
   "`company-mode' back-end for programming language keywords."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-keywords))
     (prefix (and (assq major-mode company-keywords-alist)
                  (not (company-in-string-or-comment))
index 62e6e31543af65d2a6df2fdff4b2b6987821c677..70e1c096bf31b561d403a5ade0d22187c5e10b3f 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defvar rng-open-elements)
 (defvar rng-validate-mode)
@@ -76,7 +76,7 @@
        ,@body)))
 
 (defun company-nxml-tag (command &optional arg &rest ignored)
-  (case command
+  (cl-case command
     (prefix (and (derived-mode-p 'nxml-mode)
                  rng-validate-mode
                  (company-grab company-nxml-in-tag-name-regexp 1)))
@@ -86,7 +86,7 @@
     (sorted t)))
 
 (defun company-nxml-attribute (command &optional arg &rest ignored)
-  (case command
+  (cl-case command
     (prefix (and (derived-mode-p 'nxml-mode)
                  rng-validate-mode
                  (memq (char-after) '(?\  ?\t ?\n)) ;; outside word
@@ -99,7 +99,7 @@
     (sorted t)))
 
 (defun company-nxml-attribute-value (command &optional arg &rest ignored)
-  (case command
+  (cl-case command
     (prefix (and (derived-mode-p 'nxml-mode)
                  rng-validate-mode
                  (and (memq (char-after) '(?' ?\" ?\  ?\t ?\n)) ;; outside word
 (defun company-nxml (command &optional arg &rest ignored)
   "`company-mode' completion back-end for `nxml-mode'."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-nxml))
     (prefix (or (company-nxml-tag 'prefix)
                 (company-nxml-attribute 'prefix)
index 358d5ea9258333584c8b82488904d635ac2d4dc7..aa30f2a296794456d2c717b934f5710d138d5f00 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 (eval-when-compile (require 'yaooddmuse nil t))
 (eval-when-compile (require 'oddmuse nil t))
 
@@ -34,7 +34,7 @@
   "\\(\\<[A-Z][[:alnum:]]*\\>\\)\\|\\[\\[\\([[:alnum:]]+\\>\\|\\)")
 
 (defun company-oddmuse-get-page-table ()
-  (case major-mode
+  (cl-case major-mode
     (yaoddmuse-mode (with-no-warnings
                       (yaoddmuse-get-pagename-table yaoddmuse-wikiname)))
     (oddmuse-mode (with-no-warnings
@@ -44,7 +44,7 @@
 (defun company-oddmuse (command &optional arg &rest ignored)
   "`company-mode' completion back-end for `oddmuse-mode'."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-oddmuse))
     (prefix (let ((case-fold-search nil))
               (and (memq major-mode '(oddmuse-mode yaoddmuse-mode))
index fdb1b78e025e580f1d6cb6d15f0bc3d5295c4178..d9cf86b0fb9b5bb0b829c6d633342fea0e83b4a3 100644 (file)
@@ -27,8 +27,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
 (require 'pysmell)
+(require 'cl-lib)
 
 (defvar company-pysmell--available-p 'unknown)
 (make-variable-buffer-local 'company-pysmell--available-p)
@@ -56,7 +56,7 @@
   "`company-mode' completion back-end for pysmell.
 This requires pysmell.el and pymacs.el."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-pysmell))
     (prefix (and (derived-mode-p 'python-mode)
                  buffer-file-name
index 0ba26e68b2a8f8ee6b0ca3801c3c7fc564bc59db..677c4536bc59aff209b3d44b7e867fcf521e123b 100644 (file)
@@ -25,7 +25,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defun company-ropemacs--grab-symbol ()
   (let ((symbol (company-grab-symbol)))
@@ -58,7 +58,7 @@
 Depends on third-party code: Pymacs (both Python and Emacs packages),
 rope, ropemacs and ropemode."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (init (when (and (derived-mode-p 'python-mode)
                      (not (fboundp 'rope-completions)))
             (require 'pymacs)
index 372a6f6c9e60ba93f007043568a3489b4d87a433..110d4fd8946adf0bb26994609bc0fca324067700 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defvar semantic-idle-summary-function)
 (declare-function semantic-documentation-for-tag "semantic/doc" )
@@ -121,7 +121,7 @@ Symbols are chained by \".\" or \"->\"."
 (defun company-semantic (command &optional arg &rest ignored)
   "`company-mode' completion back-end using CEDET Semantic."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-semantic))
     (prefix (and (featurep 'semantic)
                  (semantic-active-p)
index ab180166ca00ef7d66c02088b483adf34e4d88fb..d689183b97099b202174fcf5551bc669c578213b 100644 (file)
@@ -21,7 +21,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defface company-template-field
   '((((background dark)) (:background "yellow" :foreground "black"))
@@ -59,8 +59,8 @@
   (let* ((start (point))
          (templates (company-template-templates-at (point)))
          (minimum (apply 'max (mapcar 'overlay-end templates)))
-         (fields (loop for templ in templates
-                       append (overlay-get templ 'company-template-fields))))
+         (fields (cl-loop for templ in templates
+                          append (overlay-get templ 'company-template-fields))))
     (dolist (pos (mapcar 'overlay-start fields))
       (and pos
            (> pos (point))
@@ -71,9 +71,9 @@
     (company-template-remove-field (company-template-field-at start))))
 
 (defun company-template-field-at (&optional point)
-  (loop for ovl in (overlays-at (or point (point)))
-        when (overlay-get ovl 'company-template-parent)
-        return ovl))
+  (cl-loop for ovl in (overlays-at (or point (point)))
+           when (overlay-get ovl 'company-template-parent)
+           return ovl))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -98,7 +98,7 @@
   "Add new field to template TEMPL at POS, inserting TEXT.
 When DISPLAY is non-nil, set the respective property on the overlay.
 Leave point at the end of the field."
-  (assert templ)
+  (cl-assert templ)
   (goto-char pos)
   (insert text)
   (when (> (point) (overlay-end templ))
@@ -164,7 +164,7 @@ Leave point at the end of the field."
               (save-excursion
                 (company-template-add-field templ (match-beginning 1)
                                             (format "arg%d" cnt) sig))
-              (incf cnt)))
+              (cl-incf cnt)))
           (company-template-move-to-first templ))))))
 
 (provide 'company-template)
index feea6982a47badd018b3699074308b5b7bb8eb28..ac91988623d3d1a8ea4b926e8474d81212933b96 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 (require 'tempo)
 
 (defsubst company-tempo-lookup (match)
@@ -50,7 +50,7 @@
 (defun company-tempo (command &optional arg &rest ignored)
   "`company-mode' completion back-end for tempo."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-tempo
                                         'company-tempo-insert))
     (prefix (or (car (tempo-find-match-string tempo-match-finder)) ""))
index 9e678af343074a7f1a9b37ab9c4689942d4ea594..abd970423e110c6ca898e554d22edd7f1fa942fe 100644 (file)
@@ -25,7 +25,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
 (require 'ert)
 (require 'company)
 (require 'company-keywords)
@@ -62,7 +61,7 @@
     (let (company-frontends
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abc" "abd")))))))
       (company-manual-begin)
 (ert-deftest company-multi-backend-with-lambdas ()
   (let ((company-backend
          (list (lambda (command &optional arg &rest ignore)
-                 (case command
+                 (cl-case command
                    (prefix "z")
                    (candidates '("a" "b"))))
                (lambda (command &optional arg &rest ignore)
-                 (case command
+                 (cl-case command
                    (prefix "z")
                    (candidates '("c" "d")))))))
     (should (equal (company-call-backend 'candidates "z") '("a" "b" "c" "d")))))
 (ert-deftest company-multi-backend-remembers-candidate-backend ()
   (let ((company-backend
          (list (lambda (command &optional arg)
-                 (case command
+                 (cl-case command
                    (ignore-case nil)
                    (annotation "1")
                    (candidates '("a" "c"))
                    (post-completion "13")))
                (lambda (command &optional arg)
-                 (case command
+                 (cl-case command
                    (ignore-case t)
                    (annotation "2")
                    (candidates '("b" "d"))
                    (post-completion "42")))
                (lambda (command &optional arg)
-                 (case command
+                 (cl-case command
                    (annotation "3")
                    (candidates '("e"))
                    (post-completion "74"))))))
 
 (ert-deftest company-multi-backend-handles-keyword-with ()
   (let ((primo (lambda (command &optional arg)
-                 (case command
+                 (cl-case command
                    (prefix "a")
                    (candidates '("abb" "abc" "abd")))))
         (secundo (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix "a")
                      (candidates '("acc" "acd"))))))
     (let ((company-backend (list 'ignore 'ignore :with secundo)))
     (let (company-frontends
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix "a")
                      (candidates '("a" "ab" "ac")))))))
       (let (this-command)
           (company-require-match 'company-explicit-action-p)
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abc" "abd")))))))
       (let (this-command)
           (company-require-match 'company-explicit-action-p)
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abc" "abd")))))))
       (company-idle-begin (current-buffer) (selected-window)
           company-begin-commands
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abc" "abd")))))))
       (let ((company-continue-commands nil))
           company-begin-commands
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abc" "abd")))))))
       (let ((company-continue-commands '(not backward-delete-char)))
           (company-auto-complete-chars '(? ))
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abcd" "abef")))))))
       (let (this-command)
           (company-auto-complete-chars '(? ))
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abcd" "abef")))))))
       (company-idle-begin (current-buffer) (selected-window)
           company-end-of-buffer-workaround
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abcd" "abef"))
                      (ignore-case t))))))
     (let (company-frontends
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("abcd" "abef"))
                      (ignore-case 'keep-prefix))))))
           company-end-of-buffer-workaround
           (company-backends
            (list (lambda (command &optional arg)
-                   (case command
+                   (cl-case command
                      (prefix (buffer-substring (point-min) (point)))
                      (candidates '("tea-cup" "teal-color")))))))
       (let (this-command)
             (company-begin-commands '(self-insert-command))
             (company-backends
              (list (lambda (c &optional arg)
-                     (case c (prefix "") (candidates '("a" "b" "c")))))))
+                     (cl-case c (prefix "") (candidates '("a" "b" "c")))))))
         (let (this-command)
           (company-call 'complete))
         (company-call 'open-line 1)
index ac8d133454e8626ae49ac3cecaf560df2a583fb1..7a985aaedc2e183bb419a1dc41b7391378738e61 100644 (file)
@@ -26,7 +26,7 @@
 ;;; Code:
 
 (require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 
 (defgroup company-xcode nil
   "Completion back-end for Xcode projects."
@@ -109,7 +109,7 @@ valid in most contexts."
 (defun company-xcode (command &optional arg &rest ignored)
   "`company-mode' completion back-end for Xcode projects."
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-xcode))
     (prefix (and company-xcode-xcodeindex-executable
                  (company-xcode-tags)
index ae370c78feca440e0eb64cc024604e3fd88fb111..4730b211b7989e09d2639155a511b1154d79ccf6 100644 (file)
@@ -25,6 +25,7 @@
 
 ;;; Code:
 
+(require 'cl-lib)
 (require 'yasnippet)
 
 (defun company-yasnippet--candidates (prefix)
@@ -74,7 +75,7 @@ shadow back-ends that come after it.  Recommended usages:
   (global-set-key (kbd \"C-c y\") 'company-yasnippet)
 "
   (interactive (list 'interactive))
-  (case command
+  (cl-case command
     (interactive (company-begin-backend 'company-yasnippet))
     (prefix
      ;; Should probably use `yas--current-key', but that's bound to be slower.
index 6204c0145c6b0ed48f79fdb8928f3b4d1c6c6ea4..7b185e398620d1ef1fbf14121f0787cd73b791a5 100644 (file)
@@ -7,7 +7,7 @@
 ;; URL: http://company-mode.github.io/
 ;; Version: 0.8.0-cvs
 ;; Keywords: abbrev, convenience, matching
-;; Package-Requires: ((emacs "24.1"))
+;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
 
 ;; This file is part of GNU Emacs.
 
@@ -69,7 +69,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
 (require 'newcomment)
 
 ;; FIXME: Use `user-error'.
@@ -295,7 +295,7 @@ This doesn't include the margins and the scroll bar."
               (unless (if (consp backend)
                           (company-safe-backends-p backend)
                         (assq backend company-safe-backends))
-                (return t))))))
+                (cl-return t))))))
 
 (defvar company--include-capf (version< "24.3.50" emacs-version))
 
@@ -624,7 +624,7 @@ asynchronous call into synchronous.")
        (unless (memq backend company--disabled-backends)
          (message "Company back-end '%s' could not be initialized:\n%s"
                   backend (error-message-string err)))
-       (pushnew backend company--disabled-backends)
+       (cl-pushnew backend company--disabled-backends)
        nil)))
    ;; No initialization for lambdas.
    ((functionp backend) t)
@@ -833,10 +833,10 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
                   company-backend (error-message-string err) args))))
 
 (defun company--multi-backend-adapter (backends command &rest args)
-  (let ((backends (loop for b in backends
-                        when (not (and (symbolp b)
-                                       (eq 'failed (get b 'company-init))))
-                        collect b)))
+  (let ((backends (cl-loop for b in backends
+                           when (not (and (symbolp b)
+                                          (eq 'failed (get b 'company-init))))
+                           collect b)))
     (setq backends
           (if (eq command 'prefix)
               (butlast backends (length (member :with backends)))
@@ -851,7 +851,7 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
          (dolist (backend backends)
            (when (setq value (company--force-sync
                               backend (cons command args) backend))
-             (return value)))))
+             (cl-return value)))))
       (_
        (let ((arg (car args)))
          (when (> (length arg) 0)
@@ -860,16 +860,16 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
              (apply backend command args))))))))
 
 (defun company--multi-backend-adapter-candidates (backends prefix)
-  (let ((pairs (loop for backend in (cdr backends)
-                     when (equal (funcall backend 'prefix)
-                                 prefix)
-                     collect (cons (funcall backend 'candidates prefix)
-                                   (let ((b backend))
-                                     (lambda (candidates)
-                                       (mapcar
-                                        (lambda (str)
-                                          (propertize str 'company-backend b))
-                                        candidates)))))))
+  (let ((pairs (cl-loop for backend in (cdr backends)
+                        when (equal (funcall backend 'prefix)
+                                    prefix)
+                        collect (cons (funcall backend 'candidates prefix)
+                                      (let ((b backend))
+                                        (lambda (candidates)
+                                          (mapcar
+                                           (lambda (str)
+                                             (propertize str 'company-backend b))
+                                           candidates)))))))
     (when (equal (funcall (car backends) 'prefix) prefix)
       ;; Small perf optimization: don't tag the candidates received
       ;; from the first backend in the group.
@@ -879,12 +879,12 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
     (company--merge-async pairs (lambda (values) (apply #'append values)))))
 
 (defun company--merge-async (pairs merger)
-  (let ((async (loop for pair in pairs
-                     thereis
-                     (eq :async (car-safe (car pair))))))
+  (let ((async (cl-loop for pair in pairs
+                        thereis
+                        (eq :async (car-safe (car pair))))))
     (if (not async)
-        (funcall merger (loop for (val . mapper) in pairs
-                              collect (funcall mapper val)))
+        (funcall merger (cl-loop for (val . mapper) in pairs
+                                 collect (funcall mapper val)))
       (cons
        :async
        (lambda (callback)
@@ -1048,7 +1048,7 @@ can retrieve meta-data for them."
               company-candidates candidates)
         (when selected
           (while (and candidates (string< (pop candidates) selected))
-            (incf company-selection))
+            (cl-incf company-selection))
           (unless candidates
             ;; Make sure selection isn't out of bounds.
             (setq company-selection (min (1- company-candidates-length)
@@ -1085,7 +1085,7 @@ can retrieve meta-data for them."
               (when (setq prev (cdr (assoc (substring prefix 0 (- len i))
                                            company-candidates-cache)))
                 (setq candidates (all-completions prefix prev))
-                (return t)))))
+                (cl-return t)))))
         ;; no cache match, call back-end
         (setq candidates
               (company--process-candidates
@@ -1173,7 +1173,7 @@ point. The rest of the list is appended unchanged.
 Keywords and function definition names are ignored."
   (let* (occurs
          (noccurs
-          (delete-if
+          (cl-delete-if
            (lambda (candidate)
              (when (or
                     (save-excursion
@@ -1250,7 +1250,7 @@ Keywords and function definition names are ignored."
         (company-cancel)
         (dolist (backend next)
           (when (ignore-errors (company-begin-backend backend))
-            (return t))))
+            (cl-return t))))
     (company-manual-begin))
   (unless company-candidates
     (error "No other back-end")))
@@ -1371,7 +1371,7 @@ Keywords and function definition names are ignored."
             (run-hook-with-args 'company-completion-started-hook
                                 (company-explicit-action-p))
             (company-call-frontends 'show)))
-        (return c)))))
+        (cl-return c)))))
 
 (defun company-begin ()
   (or (and company-candidates (company--continue))
@@ -1498,8 +1498,8 @@ Keywords and function definition names are ignored."
         (i 0))
     (dolist (line lines)
       (when (string-match quoted line (length company-prefix))
-        (return i))
-      (incf i))))
+        (cl-return i))
+      (cl-incf i))))
 
 (defun company-search-printing-char ()
   (interactive)
@@ -1594,10 +1594,10 @@ Keywords and function definition names are ignored."
     (define-key keymap [t] 'company-search-other-char)
     (while (< i ?\s)
       (define-key keymap (make-string 1 i) 'company-search-other-char)
-      (incf i))
+      (cl-incf i))
     (while (< i 256)
       (define-key keymap (vector i) 'company-search-printing-char)
-      (incf i))
+      (cl-incf i))
     (let ((meta-map (make-sparse-keymap)))
       (define-key keymap (char-to-string meta-prefix-char) meta-map)
       (define-key keymap [escape] meta-map))
@@ -1720,10 +1720,10 @@ and invoke the normal binding."
   (let* ((col-row (posn-actual-col-row (event-start event)))
          (col (car col-row))
          (row (cdr col-row)))
-    (incf col (window-hscroll))
+    (cl-incf col (window-hscroll))
     (and header-line-format
          (version< "24" emacs-version)
-         (decf row))
+         (cl-decf row))
     (cons col row)))
 
 (defun company-select-mouse (event)
@@ -1795,7 +1795,7 @@ To show the number next to the candidates in some back-ends, enable
   (when (company-manual-begin)
     (and (< n 1) (> n company-candidates-length)
          (error "No candidate number %d" n))
-    (decf n)
+    (cl-decf n)
     (company-finish (nth n company-candidates))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1976,26 +1976,26 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 (make-variable-buffer-local 'company-tooltip-offset)
 
 (defun company-tooltip--lines-update-offset (selection num-lines limit)
-  (decf limit 2)
+  (cl-decf limit 2)
   (setq company-tooltip-offset
         (max (min selection company-tooltip-offset)
              (- selection -1 limit)))
 
   (when (<= company-tooltip-offset 1)
-    (incf limit)
+    (cl-incf limit)
     (setq company-tooltip-offset 0))
 
   (when (>= company-tooltip-offset (- num-lines limit 1))
-    (incf limit)
+    (cl-incf limit)
     (when (= selection (1- num-lines))
-      (decf company-tooltip-offset)
+      (cl-decf company-tooltip-offset)
       (when (<= company-tooltip-offset 1)
         (setq company-tooltip-offset 0)
-        (incf limit))))
+        (cl-incf limit))))
 
   limit)
 
-(defun company-tooltip--simple-update-offset (selection num-lines limit)
+(defun company-tooltip--simple-update-offset (selection _num-lines limit)
   (setq company-tooltip-offset
         (if (< selection company-tooltip-offset)
             selection
@@ -2114,13 +2114,13 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
     (length lst)))
 
 (defun company--replacement-string (lines old column nl &optional align-top)
-  (decf column company-tooltip-margin)
+  (cl-decf column company-tooltip-margin)
 
   (let ((width (length (car lines)))
         (remaining-cols (- (+ (company--window-width) (window-hscroll))
                            column)))
     (when (> width remaining-cols)
-      (decf column (- width remaining-cols))))
+      (cl-decf column (- width remaining-cols))))
 
   (let ((offset (and (< column 0) (- column)))
         new)
@@ -2184,14 +2184,14 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
             remainder (when (> remainder 0)
                         (setq remainder (format "...(%d)" remainder))))))
 
-    (decf selection company-tooltip-offset)
+    (cl-decf selection company-tooltip-offset)
     (setq width (max (length previous) (length remainder))
           lines (nthcdr company-tooltip-offset company-candidates)
           len (min limit len)
           lines-copy lines)
 
-    (decf window-width (* 2 company-tooltip-margin))
-    (when scrollbar-bounds (decf window-width))
+    (cl-decf window-width (* 2 company-tooltip-margin))
+    (when scrollbar-bounds (cl-decf window-width))
 
     (dotimes (_ len)
       (let* ((value (pop lines-copy))
@@ -2228,8 +2228,8 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
                (right (company-space-string company-tooltip-margin))
                (width width))
           (when (< numbered 10)
-            (decf width 2)
-            (incf numbered)
+            (cl-decf width 2)
+            (cl-incf numbered)
             (setq right (concat (format " %d" (mod numbered 10)) right)))
           (push (concat
                  (company-fill-propertize str annotation
@@ -2366,7 +2366,7 @@ Returns a negative number if the tooltip should be displayed above point."
 
 (defun company-pseudo-tooltip-frontend (command)
   "`company-mode' front-end similar to a tooltip but based on overlays."
-  (case command
+  (cl-case command
     (pre-command (company-pseudo-tooltip-hide-temporarily))
     (post-command
      (let ((old-height (if (overlayp company-pseudo-tooltip-overlay)
@@ -2497,8 +2497,8 @@ Returns a negative number if the tooltip should be displayed above point."
           (progn
             (setq comp (propertize (format "%d: %s" i comp)
                                    'face 'company-echo))
-            (incf len 3)
-            (incf i)
+            (cl-incf len 3)
+            (cl-incf i)
             (add-text-properties 3 (+ 3 (length company-common))
                                  '(face company-echo-common) comp))
         (setq comp (propertize comp 'face 'company-echo))
@@ -2525,8 +2525,8 @@ Returns a negative number if the tooltip should be displayed above point."
       (when (< i 10)
         ;; Add number.
         (setq comp (format "%s (%d)" comp i))
-        (incf len 4)
-        (incf i))
+        (cl-incf len 4)
+        (cl-incf i))
       (if (>= len limit)
           (setq candidates nil)
         (push (propertize comp 'face 'company-echo) msg)))