(add-to-list 'debug-ignored-errors "^Cannot complete at point$")
(add-to-list 'debug-ignored-errors "^No other back-end$")
+;;; Compatibility
+(eval-and-compile
+ ;; `defvar-local' for Emacs 24.2 and below
+ (unless (fboundp 'defvar-local)
+ (defmacro defvar-local (var val &optional docstring)
+ "Define VAR as a buffer-local variable with default value VAL.
+Like `defvar' but additionally marks the variable as being automatically
+buffer-local wherever it is set."
+ (declare (debug defvar) (doc-string 3))
+ `(progn
+ (defvar ,var ,val ,docstring)
+ (make-variable-buffer-local ',var)))))
+
(defgroup company nil
"Extensible inline text completion mechanism"
:group 'abbrev
(defcustom company-tooltip-minimum-width 0
"The minimum width of the tooltip's inner area.
This doesn't include the margins and the scroll bar."
- :type 'integer)
+ :type 'integer
+ :package-version '(company . "0.8.0"))
(defcustom company-tooltip-margin 1
"Width of margin columns to show around the toolip."
(defcustom company-tooltip-align-annotations nil
"When non-nil, align annotations to the right tooltip border."
- :type 'boolean)
+ :type 'boolean
+ :package-version '(company . "0.7.1"))
(defcustom company-tooltip-flip-when-above nil
"Whether to flip the tooltip when it's above the current line."
"If enabled, cancel a manually started completion when the prefix gets
shorter than both `company-minimum-prefix-length' and the length of the
prefix it was started from."
- :type 'boolean)
+ :type 'boolean
+ :package-version '(company . "0.8.0"))
(defcustom company-require-match 'company-explicit-action-p
"If enabled, disallow non-matching input.
(define-key keymap [tab] 'company-complete-common)
(define-key keymap (kbd "TAB") 'company-complete-common)
(define-key keymap (kbd "<f1>") 'company-show-doc-buffer)
+ (define-key keymap (kbd "C-h") 'company-show-doc-buffer)
(define-key keymap "\C-w" 'company-show-location)
(define-key keymap "\C-s" 'company-search-candidates)
(define-key keymap "\C-\M-s" 'company-filter-candidates)
(defvar company-default-lighter " company")
-(defvar company-lighter company-default-lighter)
-(make-variable-buffer-local 'company-lighter)
+(defvar-local company-lighter company-default-lighter)
;;;###autoload
(define-minor-mode company-mode
;;; keymaps ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-my-keymap nil)
-(make-variable-buffer-local 'company-my-keymap)
+(defvar-local company-my-keymap nil)
(defvar company-emulation-alist '((t . nil)))
;;; backends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-backend nil)
-(make-variable-buffer-local 'company-backend)
+(defvar-local company-backend nil)
(defun company-grab (regexp &optional expression limit)
(when (looking-back regexp limit)
;;; completion mechanism ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-prefix nil)
-(make-variable-buffer-local 'company-prefix)
+(defvar-local company-prefix nil)
-(defvar company-candidates nil)
-(make-variable-buffer-local 'company-candidates)
+(defvar-local company-candidates nil)
-(defvar company-candidates-length nil)
-(make-variable-buffer-local 'company-candidates-length)
+(defvar-local company-candidates-length nil)
-(defvar company-candidates-cache nil)
-(make-variable-buffer-local 'company-candidates-cache)
+(defvar-local company-candidates-cache nil)
-(defvar company-candidates-predicate nil)
-(make-variable-buffer-local 'company-candidates-predicate)
+(defvar-local company-candidates-predicate nil)
-(defvar company-common nil)
-(make-variable-buffer-local 'company-common)
+(defvar-local company-common nil)
-(defvar company-selection 0)
-(make-variable-buffer-local 'company-selection)
+(defvar-local company-selection 0)
-(defvar company-selection-changed nil)
-(make-variable-buffer-local 'company-selection-changed)
+(defvar-local company-selection-changed nil)
-(defvar company--manual-action nil
+(defvar-local company--manual-action nil
"Non-nil, if manual completion took place.")
-(make-variable-buffer-local 'company--manual-action)
-(defvar company--manual-prefix nil)
-(make-variable-buffer-local 'company--manual-prefix)
+(defvar-local company--manual-prefix nil)
(defvar company--auto-completion nil
"Non-nil when current candidate is being inserted automatically.
Controlled by `company-auto-complete'.")
-(defvar company--point-max nil)
-(make-variable-buffer-local 'company--point-max)
+(defvar-local company--point-max nil)
-(defvar company-point nil)
-(make-variable-buffer-local 'company-point)
+(defvar-local company-point nil)
(defvar company-timer nil)
-(defvar company-added-newline nil)
-(make-variable-buffer-local 'company-added-newline)
+(defvar-local company-added-newline nil)
(defsubst company-strip-prefix (str)
(substring str (length company-prefix)))
;;; search ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-search-string nil)
-(make-variable-buffer-local 'company-search-string)
+(defvar-local company-search-string nil)
-(defvar company-search-lighter " Search: \"\"")
-(make-variable-buffer-local 'company-search-lighter)
+(defvar-local company-search-lighter " Search: \"\"")
-(defvar company-search-old-map nil)
-(make-variable-buffer-local 'company-search-old-map)
+(defvar-local company-search-old-map nil)
-(defvar company-search-old-selection 0)
-(make-variable-buffer-local 'company-search-old-selection)
+(defvar-local company-search-old-selection 0)
(defun company-search (text lines)
(let ((quoted (regexp-quote text))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-last-metadata nil)
-(make-variable-buffer-local 'company-last-metadata)
+(defvar-local company-last-metadata nil)
(defun company-fetch-metadata ()
(let ((selected (nth company-selection company-candidates)))
;;; package functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-callback nil)
-(make-variable-buffer-local 'company-callback)
+(defvar-local company-callback nil)
(defun company-remove-callback (&optional ignored)
(remove-hook 'company-completion-finished-hook company-callback t)
;;; pseudo-tooltip ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-pseudo-tooltip-overlay nil)
-(make-variable-buffer-local 'company-pseudo-tooltip-overlay)
+(defvar-local company-pseudo-tooltip-overlay nil)
-(defvar company-tooltip-offset 0)
-(make-variable-buffer-local 'company-tooltip-offset)
+(defvar-local company-tooltip-offset 0)
(defun company-tooltip--lines-update-offset (selection num-lines limit)
(cl-decf limit 2)
(company-pseudo-tooltip-show (1+ row) col company-selection)))
(defun company-pseudo-tooltip-edit (selection)
- (let ((height (overlay-get company-pseudo-tooltip-overlay 'company-height)))
+ (let* ((height (overlay-get company-pseudo-tooltip-overlay 'company-height))
+ (lines (company--create-lines selection (abs height))))
+ (overlay-put company-pseudo-tooltip-overlay 'company-width
+ (string-width (car lines)))
(overlay-put company-pseudo-tooltip-overlay 'company-after
(apply 'company--replacement-string
- (company--create-lines selection (abs height))
+ lines
(overlay-get company-pseudo-tooltip-overlay
'company-replacement-args)))))
;;; overlay ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-preview-overlay nil)
-(make-variable-buffer-local 'company-preview-overlay)
+(defvar-local company-preview-overlay nil)
(defun company-preview-show-at-point (pos)
(company-preview-hide)
;;; echo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar company-echo-last-msg nil)
-(make-variable-buffer-local 'company-echo-last-msg)
+(defvar-local company-echo-last-msg nil)
(defvar company-echo-timer nil)