]> code.delx.au - gnu-emacs-elpa/commitdiff
Backport defvar-local from Emacs 24.2
authorBozhidar Batsov <bozhidar@tradeo.com>
Wed, 4 Jun 2014 13:48:48 +0000 (16:48 +0300)
committerBozhidar Batsov <bozhidar@tradeo.com>
Wed, 4 Jun 2014 13:48:48 +0000 (16:48 +0300)
company-capf.el
company-eclim.el
company-etags.el
company-gtags.el
company-pysmell.el
company-semantic.el
company-template.el
company-xcode.el
company.el

index 3aaeb137a8000550d61b5be4388651cb6a775235..4a3c08395336ac16ac3f576ca823561f56beae1a 100644 (file)
 
 ;;; Code:
 
+(require 'company)
 (require 'cl-lib)
 
-(defvar company--capf-data nil)
-(make-variable-buffer-local 'company--capf-data)
+(defvar-local company--capf-data nil)
 
 (defun company--capf-clear-data (&optional _ignore)
   (setq company--capf-data nil)
index 0eaf38228675de1d41467a7a2e32c986f2197037..1f1beae9604e73c87d499044c04dab1cbb7f8bb4 100644 (file)
@@ -60,11 +60,9 @@ eclim can only complete correctly when the buffer has been saved."
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defvar company-eclim--project-dir 'unknown)
-(make-variable-buffer-local 'company-eclim--project-dir)
+(defvar-local company-eclim--project-dir 'unknown)
 
-(defvar company-eclim--project-name nil)
-(make-variable-buffer-local 'company-eclim--project-name)
+(defvar-local company-eclim--project-name nil)
 
 (declare-function json-read "json")
 (defvar json-array-type)
index 8634103fe9f346df1c15819dd3294f93bec90e36..32c13f7cee34e492224d169892e620ba9fa27bd3 100644 (file)
@@ -47,8 +47,7 @@ buffer automatically."
 (defvar company-etags-modes '(prog-mode c-mode objc-mode c++-mode java-mode
                               jde-mode pascal-mode perl-mode python-mode))
 
-(defvar company-etags-buffer-table 'unknown)
-(make-variable-buffer-local 'company-etags-buffer-table)
+(defvar-local company-etags-buffer-table 'unknown)
 
 (defun company-etags-find-table ()
   (let ((file (locate-dominating-file (or buffer-file-name
index 204a111220a65f7d7419725424321b7517e9b418..d36ac1b3d63eda7ae8ce6e049fd1951f15dc65b5 100644 (file)
@@ -41,8 +41,7 @@
   'company-gtags-gnu-global-program-name
   'company-gtags-executable "earlier")
 
-(defvar company-gtags--tags-available-p 'unknown)
-(make-variable-buffer-local 'company-gtags--tags-available-p)
+(defvar-local company-gtags--tags-available-p 'unknown)
 
 (defvar company-gtags-modes '(c-mode c++-mode jde-mode java-mode php-mode))
 
@@ -64,7 +63,7 @@
                                      "\\([^ ]*\\)" ;; completion
                                      "[ \t]+\\([[:digit:]]+\\)" ;; linum
                                      "[ \t]+\\([^ \t]+\\)" ;; file
-                                     "[ \t]+\\(.*\\)" ;; definition 
+                                     "[ \t]+\\(.*\\)" ;; definition
                                      "$"
                                      ) nil t)
                  collect
index 2f22bf0f53d5d1501d27220b4260f7eb65220952..8a69e76907ad58fa4d3956e7bb0e3ab1ce99346d 100644 (file)
 ;;; Code:
 
 (if t (require 'pysmell))               ;Don't load during compilation.
+(require 'company)
 (require 'cl-lib)
 
-(defvar company-pysmell--available-p 'unknown)
-(make-variable-buffer-local 'company-pysmell--available-p)
+(defvar-local company-pysmell--available-p 'unknown)
 
 (defun company-pysmell--available-p ()
   (if (eq company-pysmell--available-p 'unknown)
index 110d4fd8946adf0bb26994609bc0fca324067700..6c020a30f70ba4eaed2730b0d1c1ea4549ca716e 100644 (file)
@@ -49,9 +49,8 @@
 
 (defvar company-semantic-modes '(c-mode c++-mode jde-mode java-mode))
 
-(defvar company-semantic--current-tags nil
+(defvar-local company-semantic--current-tags nil
   "Tags for the current context.")
-(make-variable-buffer-local 'company-semantic--current-tags)
 
 (defun company-semantic-documentation-for-tag (tag)
   (when (semantic-tag-buffer tag)
index d689183b97099b202174fcf5551bc669c578213b..576b246ecdd8db682932e6aa745394e0212b21a6 100644 (file)
@@ -35,8 +35,7 @@
     (define-key keymap (kbd "TAB") 'company-template-forward-field)
     keymap))
 
-(defvar company-template--buffer-templates nil)
-(make-variable-buffer-local 'company-template--buffer-templates)
+(defvar-local company-template--buffer-templates nil)
 
 ;; interactive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
index 7a985aaedc2e183bb419a1dc41b7391378738e61..91ae60b85e17904402d6ffc7d27d0848b2a40330 100644 (file)
@@ -62,8 +62,7 @@ valid in most contexts."
               (const "Structure") (const "Type") (const "Union")
               (const "Variable") (const "Function")))
 
-(defvar company-xcode-project 'unknown)
-(make-variable-buffer-local 'company-xcode-project)
+(defvar-local company-xcode-project 'unknown)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
index b95a255b41e41db493c0beb1f4708da929b0b279..08b3a9688769f8768cd65218b0ca3fadced31733 100644 (file)
 (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
@@ -639,8 +652,7 @@ asynchronous call into synchronous.")
 
 (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
@@ -714,8 +726,7 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
 
 ;;; 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)))
 
@@ -769,8 +780,7 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
 
 ;;; 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)
@@ -919,51 +929,38 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
 
 ;;; 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)))
@@ -1490,17 +1487,13 @@ Keywords and function definition names are ignored."
 
 ;;; 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))
@@ -1841,8 +1834,7 @@ To show the number next to the candidates in some back-ends, enable
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(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)))
@@ -1917,8 +1909,7 @@ To show the number next to the candidates in some back-ends, enable
 
 ;;; 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)
@@ -1979,11 +1970,9 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 
 ;;; 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)
@@ -2414,8 +2403,7 @@ Returns a negative number if the tooltip should be displayed above point."
 
 ;;; 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)
@@ -2472,8 +2460,7 @@ Returns a negative number if the tooltip should be displayed above point."
 
 ;;; 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)