;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(require 'abbrev)
(defun company-abbrev-insert (match)
(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))
;; 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)))
;;; 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)
(require 'company)
(require 'company-template)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defgroup company-clang nil
"Completion back-end for Clang."
"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)))
(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)
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
;;; Code:
-(eval-when-compile (require 'cl))
(require 'company)
+(require 'cl-lib)
(defgroup company-cmake nil
"Completion back-end for CMake."
"`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
;;; 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
(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)
(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."
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))
;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defgroup company-dabbrev nil
"dabbrev-like completion back-end."
(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))))))
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
(require 'company)
(require 'company-template)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defgroup company-eclim nil
"Completion back-end for Eclim."
(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))
(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")
(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)))
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
(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])
;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(require 'help-mode)
(require 'find-func)
(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))
(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<))
(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)))
;;; Code:
-(eval-when-compile (require 'cl))
(require 'company)
+(require 'cl-lib)
(require 'etags)
(defgroup company-etags nil
(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))
;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defun company-files-directory-files (dir prefix)
(ignore-errors
(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)
(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))
;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defgroup company-gtags nil
"Completion back-end for GNU Global."
(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)
;;; Code:
(require 'company)
+(require 'cl-lib)
(require 'ispell)
-(eval-when-compile (require 'cl))
(defgroup company-ispell nil
"Completion back-end using Ispell."
(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)))
;;; 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))
;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defvar rng-open-elements)
(defvar rng-validate-mode)
,@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)))
(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
(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)
;;; 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))
"\\(\\<[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
(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))
;;; 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)
"`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
;;; Code:
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defun company-ropemacs--grab-symbol ()
(let ((symbol (company-grab-symbol)))
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)
;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defvar semantic-idle-summary-function)
(declare-function semantic-documentation-for-tag "semantic/doc" )
(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)
;;; Code:
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defface company-template-field
'((((background dark)) (:background "yellow" :foreground "black"))
(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))
(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))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
"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))
(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)
;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(require 'tempo)
(defsubst company-tempo-lookup (match)
(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)) ""))
;;; Code:
-(eval-when-compile (require 'cl))
(require 'ert)
(require 'company)
(require 'company-keywords)
(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)
;;; Code:
(require 'company)
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(defgroup company-xcode nil
"Completion back-end for Xcode projects."
(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)
;;; Code:
+(require 'cl-lib)
(require 'yasnippet)
(defun company-yasnippet--candidates (prefix)
(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.
;; 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.
;;; Code:
-(eval-when-compile (require 'cl))
+(require 'cl-lib)
(require 'newcomment)
;; FIXME: Use `user-error'.
(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))
(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)
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)))
(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)
(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.
(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)
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)
(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
Keywords and function definition names are ignored."
(let* (occurs
(noccurs
- (delete-if
+ (cl-delete-if
(lambda (candidate)
(when (or
(save-excursion
(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")))
(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))
(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)
(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))
(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)
(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))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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
(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)
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))
(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
(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)
(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))
(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)))