Upgrade company package to 0.8.5
This commit is contained in:
		
							
								
								
									
										2
									
								
								elpa/company-0.8.2/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								elpa/company-0.8.2/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +0,0 @@
 | 
			
		||||
*.elc
 | 
			
		||||
ert.el
 | 
			
		||||
@@ -19,8 +19,5 @@ install:
 | 
			
		||||
        sudo apt-get install -qq emacs-snapshot;
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
before_script:
 | 
			
		||||
  make downloads
 | 
			
		||||
 | 
			
		||||
script:
 | 
			
		||||
  make test-batch EMACS=${EMACS}
 | 
			
		||||
@@ -1,3 +1,15 @@
 | 
			
		||||
2014-09-14  Dmitry Gutov  <dgutov@yandex.ru>
 | 
			
		||||
 | 
			
		||||
	Merge commit 'fa4ba155a3e22ddc4b8bc33fcbf8cc69ef8f0043' from company
 | 
			
		||||
 | 
			
		||||
2014-09-13  Dmitry Gutov  <dgutov@yandex.ru>
 | 
			
		||||
 | 
			
		||||
	Merge commit '2ef6263c65a109b4d36503e6484fdbf4cb307d0f' from company
 | 
			
		||||
 | 
			
		||||
2014-08-27  Dmitry Gutov  <dgutov@yandex.ru>
 | 
			
		||||
 | 
			
		||||
	Merge commit 'f4ffe2b47cf6854ff3bc3ca1717efe1258c01547' from company
 | 
			
		||||
 | 
			
		||||
2014-07-26  Dmitry Gutov  <dgutov@yandex.ru>
 | 
			
		||||
 | 
			
		||||
	Merge commit 'b1d019a4c815ac8bdc240d69eaa74eb4e34640e8' from
 | 
			
		||||
@@ -1,6 +1,4 @@
 | 
			
		||||
EMACS=emacs
 | 
			
		||||
CURL=curl --silent
 | 
			
		||||
ERT_URL=http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/emacs-lisp/ert.el?h=emacs-24.3
 | 
			
		||||
 | 
			
		||||
.PHONY: ert test test-batch
 | 
			
		||||
 | 
			
		||||
@@ -29,9 +27,5 @@ test-batch:
 | 
			
		||||
	${EMACS} -Q --batch -L . -l company-tests.el -l company-elisp-tests.el \
 | 
			
		||||
	--eval "(ert-run-tests-batch-and-exit '(not (tag interactive)))"
 | 
			
		||||
 | 
			
		||||
downloads:
 | 
			
		||||
	${EMACS} -Q --batch -l ert || \
 | 
			
		||||
	${CURL} ${ERT_URL} > ert.el
 | 
			
		||||
 | 
			
		||||
compile:
 | 
			
		||||
	${EMACS} -Q --batch -L . -f batch-byte-compile company.el company-*.el
 | 
			
		||||
@@ -1,5 +1,19 @@
 | 
			
		||||
# History of user-visible changes
 | 
			
		||||
 | 
			
		||||
## 2014-08-13 (0.8.4)
 | 
			
		||||
 | 
			
		||||
* `company-ropemacs` is only used when `ropemacs-mode` is on.
 | 
			
		||||
* `company-gtags` is enabled in all `prog-mode` derivatives by default.
 | 
			
		||||
* `company-end-of-buffer-workaround` is not used anymore.
 | 
			
		||||
* `company-begin-commands` includes several `cc-mode` commands.
 | 
			
		||||
 | 
			
		||||
## 2014-08-27 (0.8.3)
 | 
			
		||||
 | 
			
		||||
* On Emacs 24.4 or newer, tooltip positioning takes line-spacing into account.
 | 
			
		||||
* New face `company-tooltip-search`, used for the search string in the tooltip.
 | 
			
		||||
* The default value of `company-dabbrev-minimum-length` is set to 4, independent
 | 
			
		||||
  of the `company-minimum-prefix-length` value.
 | 
			
		||||
 | 
			
		||||
## 2014-07-26 (0.8.2)
 | 
			
		||||
 | 
			
		||||
* New user option `company-occurrence-weight-function`, allowing to tweak the
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (global-company-mode company-mode) "company" "company.el"
 | 
			
		||||
;;;;;;  (21475 23817 56009 901000))
 | 
			
		||||
;;;;;;  (21553 22041 719690 945000))
 | 
			
		||||
;;; Generated autoloads from company.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-mode "company" "\
 | 
			
		||||
@@ -58,7 +58,7 @@ See `company-mode' for more information on Company mode.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-abbrev) "company-abbrev" "company-abbrev.el"
 | 
			
		||||
;;;;;;  (21475 23816 615018 715000))
 | 
			
		||||
;;;;;;  (21553 22041 262700 327000))
 | 
			
		||||
;;; Generated autoloads from company-abbrev.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-abbrev "company-abbrev" "\
 | 
			
		||||
@@ -69,7 +69,7 @@ See `company-mode' for more information on Company mode.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-bbdb) "company-bbdb" "company-bbdb.el"
 | 
			
		||||
;;;;;;  (21475 23817 97009 82000))
 | 
			
		||||
;;;;;;  (21553 22041 760690 102000))
 | 
			
		||||
;;; Generated autoloads from company-bbdb.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-bbdb "company-bbdb" "\
 | 
			
		||||
@@ -79,8 +79,8 @@ See `company-mode' for more information on Company mode.
 | 
			
		||||
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-css) "company-css" "company-css.el" (21475
 | 
			
		||||
;;;;;;  23816 641018 195000))
 | 
			
		||||
;;;### (autoloads (company-css) "company-css" "company-css.el" (21553
 | 
			
		||||
;;;;;;  22041 295699 650000))
 | 
			
		||||
;;; Generated autoloads from company-css.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-css "company-css" "\
 | 
			
		||||
@@ -91,7 +91,7 @@ See `company-mode' for more information on Company mode.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-dabbrev) "company-dabbrev" "company-dabbrev.el"
 | 
			
		||||
;;;;;;  (21475 23816 683017 356000))
 | 
			
		||||
;;;;;;  (21553 22041 336698 811000))
 | 
			
		||||
;;; Generated autoloads from company-dabbrev.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-dabbrev "company-dabbrev" "\
 | 
			
		||||
@@ -102,7 +102,7 @@ dabbrev-like `company-mode' completion back-end.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-dabbrev-code) "company-dabbrev-code" "company-dabbrev-code.el"
 | 
			
		||||
;;;;;;  (21475 23817 330004 425000))
 | 
			
		||||
;;;;;;  (21553 22041 992685 338000))
 | 
			
		||||
;;; Generated autoloads from company-dabbrev-code.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-dabbrev-code "company-dabbrev-code" "\
 | 
			
		||||
@@ -115,7 +115,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-elisp) "company-elisp" "company-elisp.el"
 | 
			
		||||
;;;;;;  (21475 23816 807014 878000))
 | 
			
		||||
;;;;;;  (21553 22041 461696 242000))
 | 
			
		||||
;;; Generated autoloads from company-elisp.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-elisp "company-elisp" "\
 | 
			
		||||
@@ -126,7 +126,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-etags) "company-etags" "company-etags.el"
 | 
			
		||||
;;;;;;  (21475 23816 392023 172000))
 | 
			
		||||
;;;;;;  (21553 22041 55704 578000))
 | 
			
		||||
;;; Generated autoloads from company-etags.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-etags "company-etags" "\
 | 
			
		||||
@@ -137,7 +137,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-files) "company-files" "company-files.el"
 | 
			
		||||
;;;;;;  (21475 23816 847014 78000))
 | 
			
		||||
;;;;;;  (21553 22041 511695 221000))
 | 
			
		||||
;;; Generated autoloads from company-files.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-files "company-files" "\
 | 
			
		||||
@@ -148,7 +148,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-gtags) "company-gtags" "company-gtags.el"
 | 
			
		||||
;;;;;;  (21475 23817 379003 447000))
 | 
			
		||||
;;;;;;  (21553 22042 50684 150000))
 | 
			
		||||
;;; Generated autoloads from company-gtags.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-gtags "company-gtags" "\
 | 
			
		||||
@@ -159,7 +159,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-ispell) "company-ispell" "company-ispell.el"
 | 
			
		||||
;;;;;;  (21475 23816 351023 991000))
 | 
			
		||||
;;;;;;  (21553 22041 3705 646000))
 | 
			
		||||
;;; Generated autoloads from company-ispell.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-ispell "company-ispell" "\
 | 
			
		||||
@@ -170,7 +170,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-keywords) "company-keywords" "company-keywords.el"
 | 
			
		||||
;;;;;;  (21475 23816 426022 492000))
 | 
			
		||||
;;;;;;  (21553 22041 88703 901000))
 | 
			
		||||
;;; Generated autoloads from company-keywords.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-keywords "company-keywords" "\
 | 
			
		||||
@@ -181,7 +181,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-nxml) "company-nxml" "company-nxml.el"
 | 
			
		||||
;;;;;;  (21475 23816 467021 673000))
 | 
			
		||||
;;;;;;  (21553 22041 130703 38000))
 | 
			
		||||
;;; Generated autoloads from company-nxml.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-nxml "company-nxml" "\
 | 
			
		||||
@@ -192,7 +192,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-oddmuse) "company-oddmuse" "company-oddmuse.el"
 | 
			
		||||
;;;;;;  (21475 23816 881013 399000))
 | 
			
		||||
;;;;;;  (21553 22041 544694 537000))
 | 
			
		||||
;;; Generated autoloads from company-oddmuse.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-oddmuse "company-oddmuse" "\
 | 
			
		||||
@@ -203,7 +203,7 @@ comments or strings.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-pysmell) "company-pysmell" "company-pysmell.el"
 | 
			
		||||
;;;;;;  (21475 23816 990011 221000))
 | 
			
		||||
;;;;;;  (21553 22041 652692 320000))
 | 
			
		||||
;;; Generated autoloads from company-pysmell.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-pysmell "company-pysmell" "\
 | 
			
		||||
@@ -215,7 +215,7 @@ This requires pysmell.el and pymacs.el.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-semantic) "company-semantic" "company-semantic.el"
 | 
			
		||||
;;;;;;  (21475 23817 594999 129000))
 | 
			
		||||
;;;;;;  (21553 22042 308678 850000))
 | 
			
		||||
;;; Generated autoloads from company-semantic.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-semantic "company-semantic" "\
 | 
			
		||||
@@ -226,7 +226,7 @@ This requires pysmell.el and pymacs.el.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-tempo) "company-tempo" "company-tempo.el"
 | 
			
		||||
;;;;;;  (21475 23817 172007 583000))
 | 
			
		||||
;;;;;;  (21553 22041 835688 555000))
 | 
			
		||||
;;; Generated autoloads from company-tempo.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-tempo "company-tempo" "\
 | 
			
		||||
@@ -237,7 +237,7 @@ This requires pysmell.el and pymacs.el.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-xcode) "company-xcode" "company-xcode.el"
 | 
			
		||||
;;;;;;  (21475 23817 247006 84000))
 | 
			
		||||
;;;;;;  (21553 22041 901687 207000))
 | 
			
		||||
;;; Generated autoloads from company-xcode.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-xcode "company-xcode" "\
 | 
			
		||||
@@ -248,7 +248,7 @@ This requires pysmell.el and pymacs.el.
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
;;;### (autoloads (company-yasnippet) "company-yasnippet" "company-yasnippet.el"
 | 
			
		||||
;;;;;;  (21475 23817 487001 288000))
 | 
			
		||||
;;;;;;  (21553 22042 158681 930000))
 | 
			
		||||
;;; Generated autoloads from company-yasnippet.el
 | 
			
		||||
 | 
			
		||||
(autoload 'company-yasnippet "company-yasnippet" "\
 | 
			
		||||
@@ -281,7 +281,7 @@ shadow back-ends that come after it.  Recommended usages:
 | 
			
		||||
;;;### (autoloads nil nil ("company-capf.el" "company-clang.el" "company-cmake.el"
 | 
			
		||||
;;;;;;  "company-eclim.el" "company-elisp-tests.el" "company-pkg.el"
 | 
			
		||||
;;;;;;  "company-ropemacs.el" "company-template.el" "company-tests.el")
 | 
			
		||||
;;;;;;  (21475 23817 679245 801000))
 | 
			
		||||
;;;;;;  (21553 22042 393632 690000))
 | 
			
		||||
 | 
			
		||||
;;;***
 | 
			
		||||
 | 
			
		||||
@@ -28,7 +28,20 @@
 | 
			
		||||
(require 'company)
 | 
			
		||||
(require 'cl-lib)
 | 
			
		||||
 | 
			
		||||
(defvar company--capf-cache nil)
 | 
			
		||||
 | 
			
		||||
(defun company--capf-data ()
 | 
			
		||||
  (let ((cache company--capf-cache))
 | 
			
		||||
    (if (and (equal (current-buffer) (car cache))
 | 
			
		||||
             (equal (point) (car (setq cache (cdr cache))))
 | 
			
		||||
             (equal (buffer-chars-modified-tick) (car (setq cache (cdr cache)))))
 | 
			
		||||
        (cadr cache)
 | 
			
		||||
      (let ((data (company--capf-data-real)))
 | 
			
		||||
        (setq company--capf-cache
 | 
			
		||||
              (list (current-buffer) (point) (buffer-chars-modified-tick) data))
 | 
			
		||||
        data))))
 | 
			
		||||
 | 
			
		||||
(defun company--capf-data-real ()
 | 
			
		||||
  (cl-letf* (((default-value 'completion-at-point-functions)
 | 
			
		||||
              ;; Ignore tags-completion-at-point-function because it subverts
 | 
			
		||||
              ;; company-etags in the default value of company-backends, where
 | 
			
		||||
@@ -66,7 +66,7 @@ See also `company-dabbrev-code-time-limit'."
 | 
			
		||||
  :type 'boolean)
 | 
			
		||||
 | 
			
		||||
(defcustom company-dabbrev-code-ignore-case nil
 | 
			
		||||
  "Non-nil to ignore case in completion candidates."
 | 
			
		||||
  "Non-nil to ignore case when collecting completion candidates."
 | 
			
		||||
  :type 'boolean)
 | 
			
		||||
 | 
			
		||||
(defsubst company-dabbrev-code--make-regexp (prefix)
 | 
			
		||||
@@ -51,7 +51,9 @@ See also `company-dabbrev-time-limit'."
 | 
			
		||||
  :type 'regexp)
 | 
			
		||||
 | 
			
		||||
(defcustom company-dabbrev-ignore-case 'keep-prefix
 | 
			
		||||
  "The value of `ignore-case' returned by `company-dabbrev'.")
 | 
			
		||||
  "Non-nil to ignore case when collecting completion candidates.
 | 
			
		||||
When it's `keep-prefix', the text before point will remain unchanged after
 | 
			
		||||
candidate is inserted, even some of its characters have different case.")
 | 
			
		||||
 | 
			
		||||
(defcustom company-dabbrev-downcase 'case-replace
 | 
			
		||||
  "Whether to downcase the returned candidates.
 | 
			
		||||
@@ -63,9 +65,11 @@ Any other value means downcase.
 | 
			
		||||
If you set this value to nil, you may also want to set
 | 
			
		||||
`company-dabbrev-ignore-case' to any value other than `keep-prefix'.")
 | 
			
		||||
 | 
			
		||||
(defcustom company-dabbrev-minimum-length (1+ company-minimum-prefix-length)
 | 
			
		||||
  "The minimum length for the string to be included."
 | 
			
		||||
  :type 'integer)
 | 
			
		||||
(defcustom company-dabbrev-minimum-length 4
 | 
			
		||||
  "The minimum length for the completion candidate to be included.
 | 
			
		||||
This variable affects both `company-dabbrev' and `company-dabbrev-code'."
 | 
			
		||||
  :type 'integer
 | 
			
		||||
  :package-version '(company . "0.8.3"))
 | 
			
		||||
 | 
			
		||||
(defmacro company-dabrev--time-limit-while (test start limit &rest body)
 | 
			
		||||
  (declare (indent 3) (debug t))
 | 
			
		||||
@@ -95,7 +99,7 @@ If you set this value to nil, you may also want to set
 | 
			
		||||
          start limit
 | 
			
		||||
        (setq match (match-string-no-properties 0))
 | 
			
		||||
        (if (and ignore-comments (company-in-string-or-comment))
 | 
			
		||||
            (re-search-backward "\\s<\\|\\s!\\|\\s\"\\|\\s|" nil t)
 | 
			
		||||
            (goto-char (nth 8 (syntax-ppss)))
 | 
			
		||||
          (when (>= (length match) company-dabbrev-minimum-length)
 | 
			
		||||
            (push match symbols))))
 | 
			
		||||
      (goto-char (or pos (point-min)))
 | 
			
		||||
@@ -135,14 +139,15 @@ If you set this value to nil, you may also want to set
 | 
			
		||||
    (interactive (company-begin-backend 'company-dabbrev))
 | 
			
		||||
    (prefix (company-grab-word))
 | 
			
		||||
    (candidates
 | 
			
		||||
     (let ((words (company-dabbrev--search (company-dabbrev--make-regexp arg)
 | 
			
		||||
                                           company-dabbrev-time-limit
 | 
			
		||||
                                           (pcase company-dabbrev-other-buffers
 | 
			
		||||
                                             (`t (list major-mode))
 | 
			
		||||
                                             (`all `all))))
 | 
			
		||||
           (downcase-p (if (eq company-dabbrev-downcase 'case-replace)
 | 
			
		||||
                           case-replace
 | 
			
		||||
                         company-dabbrev-downcase)))
 | 
			
		||||
     (let* ((case-fold-search company-dabbrev-ignore-case)
 | 
			
		||||
            (words (company-dabbrev--search (company-dabbrev--make-regexp arg)
 | 
			
		||||
                                            company-dabbrev-time-limit
 | 
			
		||||
                                            (pcase company-dabbrev-other-buffers
 | 
			
		||||
                                              (`t (list major-mode))
 | 
			
		||||
                                              (`all `all))))
 | 
			
		||||
            (downcase-p (if (eq company-dabbrev-downcase 'case-replace)
 | 
			
		||||
                            case-replace
 | 
			
		||||
                          company-dabbrev-downcase)))
 | 
			
		||||
       (if downcase-p
 | 
			
		||||
           (mapcar 'downcase words)
 | 
			
		||||
         words)))
 | 
			
		||||
@@ -48,7 +48,12 @@
 | 
			
		||||
 | 
			
		||||
(defvar-local company-gtags--tags-available-p 'unknown)
 | 
			
		||||
 | 
			
		||||
(defvar company-gtags-modes '(c-mode c++-mode jde-mode java-mode php-mode))
 | 
			
		||||
(defcustom company-gtags-modes '(prog-mode jde-mode)
 | 
			
		||||
  "Modes that use `company-gtags'.
 | 
			
		||||
In all these modes (and their derivatives) `company-gtags' will perform
 | 
			
		||||
completion."
 | 
			
		||||
  :type '(repeat (symbol :tag "Major mode"))
 | 
			
		||||
  :package-version '(company . "0.8.4"))
 | 
			
		||||
 | 
			
		||||
(defun company-gtags--tags-available-p ()
 | 
			
		||||
  (if (eq company-gtags--tags-available-p 'unknown)
 | 
			
		||||
@@ -90,7 +95,7 @@
 | 
			
		||||
  (cl-case command
 | 
			
		||||
    (interactive (company-begin-backend 'company-gtags))
 | 
			
		||||
    (prefix (and company-gtags-executable
 | 
			
		||||
                 (memq major-mode company-gtags-modes)
 | 
			
		||||
                 (apply #'derived-mode-p company-gtags-modes)
 | 
			
		||||
                 (not (company-in-string-or-comment))
 | 
			
		||||
                 (company-gtags--tags-available-p)
 | 
			
		||||
                 (or (company-grab-symbol) 'stop)))
 | 
			
		||||
@@ -1,2 +1,2 @@
 | 
			
		||||
;; Generated package description from company.el
 | 
			
		||||
(define-package "company" "0.8.2" "Modular text completion framework" '((emacs "24.1") (cl-lib "0.5")) :url "http://company-mode.github.io/" :keywords '("abbrev" "convenience" "matching"))
 | 
			
		||||
(define-package "company" "0.8.5" "Modular text completion framework" '((emacs "24.1") (cl-lib "0.5")) :url "http://company-mode.github.io/" :keywords '("abbrev" "convenience" "matching"))
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
;;; company-ropemacs.el --- company-mode completion back-end for ropemacs
 | 
			
		||||
 | 
			
		||||
;; Copyright (C) 2009-2011, 2013  Free Software Foundation, Inc.
 | 
			
		||||
;; Copyright (C) 2009-2011, 2013-2014  Free Software Foundation, Inc.
 | 
			
		||||
 | 
			
		||||
;; Author: Nikolaj Schumacher
 | 
			
		||||
 | 
			
		||||
@@ -56,15 +56,11 @@
 | 
			
		||||
  "`company-mode' completion back-end for ropemacs.
 | 
			
		||||
 | 
			
		||||
Depends on third-party code: Pymacs (both Python and Emacs packages),
 | 
			
		||||
rope, ropemacs and ropemode."
 | 
			
		||||
rope, ropemacs and ropemode.  Requires `ropemacs-mode' to be on."
 | 
			
		||||
  (interactive (list 'interactive))
 | 
			
		||||
  (cl-case command
 | 
			
		||||
    (init (when (and (derived-mode-p 'python-mode)
 | 
			
		||||
                     (not (fboundp 'rope-completions)))
 | 
			
		||||
            (require 'pymacs)
 | 
			
		||||
            (pymacs-load "ropemacs" "rope-")))
 | 
			
		||||
    (interactive (company-begin-backend 'company-ropemacs))
 | 
			
		||||
    (prefix (and (derived-mode-p 'python-mode)
 | 
			
		||||
    (prefix (and (bound-and-true-p ropemacs-mode)
 | 
			
		||||
                 (not (company-in-string-or-comment))
 | 
			
		||||
                 (company-ropemacs--grab-symbol)))
 | 
			
		||||
    (candidates (mapcar (lambda (element) (concat arg element))
 | 
			
		||||
@@ -30,6 +30,9 @@
 | 
			
		||||
(require 'company-keywords)
 | 
			
		||||
(require 'company-clang)
 | 
			
		||||
 | 
			
		||||
(defun company--column (&optional pos)
 | 
			
		||||
  (car (company--col-row pos)))
 | 
			
		||||
 | 
			
		||||
;;; Core
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-sorted-keywords ()
 | 
			
		||||
@@ -395,7 +398,7 @@
 | 
			
		||||
        (let (this-command)
 | 
			
		||||
          (company-call 'complete))
 | 
			
		||||
        (company-call 'open-line 1)
 | 
			
		||||
        (should (eq 2 (overlay-start company-pseudo-tooltip-overlay)))))))
 | 
			
		||||
        (should (eq 1 (overlay-start company-pseudo-tooltip-overlay)))))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-pseudo-tooltip-show ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
@@ -415,8 +418,8 @@
 | 
			
		||||
        ;; FIXME: Make it 2?
 | 
			
		||||
        (should (eq (overlay-get ov 'company-height) company-tooltip-limit))
 | 
			
		||||
        (should (eq (overlay-get ov 'company-column) col))
 | 
			
		||||
        (should (string= (overlay-get ov 'company-after)
 | 
			
		||||
                         "  123 \nc 45  c\nddd\n")))))))
 | 
			
		||||
        (should (string= (overlay-get ov 'company-display)
 | 
			
		||||
                         "\n  123 \nc 45  c\nddd\n")))))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-pseudo-tooltip-edit-updates-width ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
@@ -445,8 +448,10 @@
 | 
			
		||||
      (let ((company-candidates-length 1)
 | 
			
		||||
            (company-candidates '("123")))
 | 
			
		||||
        (company-preview-show-at-point (point))
 | 
			
		||||
        (let ((ov company-preview-overlay))
 | 
			
		||||
          (should (string= (overlay-get ov 'display) "123\n")))))))
 | 
			
		||||
        (let* ((ov company-preview-overlay)
 | 
			
		||||
               (str (overlay-get ov 'after-string)))
 | 
			
		||||
          (should (string= str "123"))
 | 
			
		||||
          (should (eq (get-text-property 0 'cursor str) t)))))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-pseudo-tooltip-show-with-annotations ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
@@ -465,8 +470,8 @@
 | 
			
		||||
        (let ((ov company-pseudo-tooltip-overlay))
 | 
			
		||||
          ;; With margins.
 | 
			
		||||
          (should (eq (overlay-get ov 'company-width) 8))
 | 
			
		||||
          (should (string= (overlay-get ov 'company-after)
 | 
			
		||||
                           " 123(4) \n 45     \n")))))))
 | 
			
		||||
          (should (string= (overlay-get ov 'company-display)
 | 
			
		||||
                           "\n 123(4) \n 45     \n")))))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-pseudo-tooltip-show-with-annotations-right-aligned ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
@@ -486,8 +491,8 @@
 | 
			
		||||
        (let ((ov company-pseudo-tooltip-overlay))
 | 
			
		||||
          ;; With margins.
 | 
			
		||||
          (should (eq (overlay-get ov 'company-width) 13))
 | 
			
		||||
          (should (string= (overlay-get ov 'company-after)
 | 
			
		||||
                           " 123     (4) \n 45          \n 67 (891011) \n")))))))
 | 
			
		||||
          (should (string= (overlay-get ov 'company-display)
 | 
			
		||||
                           "\n 123     (4) \n 45          \n 67 (891011) \n")))))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-create-lines-shows-numbers ()
 | 
			
		||||
  (let ((company-show-numbers t)
 | 
			
		||||
@@ -522,24 +527,84 @@
 | 
			
		||||
                           (format " %s " (make-string (- ww 2) ?4)))
 | 
			
		||||
                     (company--create-lines 0 999))))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-create-lines-truncates-common-part ()
 | 
			
		||||
  (let* ((ww (company--window-width))
 | 
			
		||||
         (company-candidates-length 2)
 | 
			
		||||
         (company-tooltip-margin 1)
 | 
			
		||||
         (company-backend #'ignore))
 | 
			
		||||
    (let* ((company-common (make-string (- ww 3) ?1))
 | 
			
		||||
           (company-candidates `(,(concat company-common "2")
 | 
			
		||||
                                 ,(concat company-common "3"))))
 | 
			
		||||
      (should (equal (list (format " %s2 " (make-string (- ww 3) ?1))
 | 
			
		||||
                           (format " %s3 " (make-string (- ww 3) ?1)))
 | 
			
		||||
                     (company--create-lines 0 999))))
 | 
			
		||||
    (let* ((company-common (make-string (- ww 2) ?1))
 | 
			
		||||
           (company-candidates `(,(concat company-common "2")
 | 
			
		||||
                                 ,(concat company-common "3"))))
 | 
			
		||||
      (should (equal (list (format " %s " company-common)
 | 
			
		||||
                           (format " %s " company-common))
 | 
			
		||||
                     (company--create-lines 0 999))))
 | 
			
		||||
    (let* ((company-common (make-string ww ?1))
 | 
			
		||||
           (company-candidates `(,(concat company-common "2")
 | 
			
		||||
                                 ,(concat company-common "3")))
 | 
			
		||||
           (res (company--create-lines 0 999)))
 | 
			
		||||
      (should (equal (list (format " %s " (make-string (- ww 2) ?1))
 | 
			
		||||
                           (format " %s " (make-string (- ww 2) ?1)))
 | 
			
		||||
                     res))
 | 
			
		||||
      (should (eq 'company-tooltip-common-selection
 | 
			
		||||
                    (get-text-property (- ww 2) 'face
 | 
			
		||||
                                       (car res))))
 | 
			
		||||
      (should (eq 'company-tooltip-selection
 | 
			
		||||
                  (get-text-property (1- ww) 'face
 | 
			
		||||
                                     (car res))))
 | 
			
		||||
 | 
			
		||||
)))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-column-with-composition ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
  (with-temp-buffer
 | 
			
		||||
    (insert "lambda ()")
 | 
			
		||||
    (compose-region 1 (1+ (length "lambda")) "\\")
 | 
			
		||||
    (should (= (company--column) 4))))
 | 
			
		||||
    (save-window-excursion
 | 
			
		||||
      (set-window-buffer nil (current-buffer))
 | 
			
		||||
      (insert "lambda ()")
 | 
			
		||||
      (compose-region 1 (1+ (length "lambda")) "\\")
 | 
			
		||||
      (should (= (company--column) 4)))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-column-with-line-prefix ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
  (with-temp-buffer
 | 
			
		||||
    (insert "foo")
 | 
			
		||||
    (put-text-property (point-min) (point) 'line-prefix "  ")
 | 
			
		||||
    (should (= (company--column) 5))))
 | 
			
		||||
    (save-window-excursion
 | 
			
		||||
      (set-window-buffer nil (current-buffer))
 | 
			
		||||
      (insert "foo")
 | 
			
		||||
      (put-text-property (point-min) (point) 'line-prefix "  ")
 | 
			
		||||
      (should (= (company--column) 5)))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-column-wth-line-prefix-on-empty-line ()
 | 
			
		||||
(ert-deftest company-column-with-line-prefix-on-empty-line ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
  (with-temp-buffer
 | 
			
		||||
    (insert "\n")
 | 
			
		||||
    (forward-char -1)
 | 
			
		||||
    (put-text-property (point-min) (point-max) 'line-prefix "  ")
 | 
			
		||||
    (should (= (company--column) 2))))
 | 
			
		||||
    (save-window-excursion
 | 
			
		||||
      (set-window-buffer nil (current-buffer))
 | 
			
		||||
      (insert "\n")
 | 
			
		||||
      (forward-char -1)
 | 
			
		||||
      (put-text-property (point-min) (point-max) 'line-prefix "  ")
 | 
			
		||||
      (should (= (company--column) 2)))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-column-with-tabs ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
  (with-temp-buffer
 | 
			
		||||
    (save-window-excursion
 | 
			
		||||
      (set-window-buffer nil (current-buffer))
 | 
			
		||||
      (insert "|\t|\t|\t(")
 | 
			
		||||
      (let ((tab-width 8))
 | 
			
		||||
        (should (= (company--column) 25))))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-row-with-header-line-format ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
  (with-temp-buffer
 | 
			
		||||
    (save-window-excursion
 | 
			
		||||
      (set-window-buffer nil (current-buffer))
 | 
			
		||||
      (should (= (company--row) 0))
 | 
			
		||||
      (setq header-line-format "aaaaaaa")
 | 
			
		||||
      (should (= (company--row) 0)))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-plainify ()
 | 
			
		||||
  (let ((tab-width 8))
 | 
			
		||||
@@ -552,6 +617,22 @@
 | 
			
		||||
           (company-plainify (propertize "foobar" 'line-prefix "-*-"))
 | 
			
		||||
           "-*-foobar")))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-buffer-lines-with-lines-folded ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
  (with-temp-buffer
 | 
			
		||||
    (insert (propertize "aaa\nbbb\nccc\nddd\n" 'display "aaa+\n"))
 | 
			
		||||
    (insert "eee\nfff\nggg")
 | 
			
		||||
    (should (equal (company-buffer-lines (point-min) (point-max))
 | 
			
		||||
                   '("aaa" "eee" "fff" "ggg")))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-buffer-lines-with-multiline-display ()
 | 
			
		||||
  :tags '(interactive)
 | 
			
		||||
  (with-temp-buffer
 | 
			
		||||
    (insert (propertize "a" 'display "bbb\nccc\ndddd\n"))
 | 
			
		||||
    (insert "eee\nfff\nggg")
 | 
			
		||||
    (should (equal (company-buffer-lines (point-min) (point-max))
 | 
			
		||||
                   '("" "" "" "eee" "fff" "ggg")))))
 | 
			
		||||
 | 
			
		||||
(ert-deftest company-modify-line ()
 | 
			
		||||
  (let ((str "-*-foobar"))
 | 
			
		||||
    (should (equal-including-properties
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
;; Author: Nikolaj Schumacher
 | 
			
		||||
;; Maintainer: Dmitry Gutov <dgutov@yandex.ru>
 | 
			
		||||
;; URL: http://company-mode.github.io/
 | 
			
		||||
;; Version: 0.8.2
 | 
			
		||||
;; Version: 0.8.5
 | 
			
		||||
;; Keywords: abbrev, convenience, matching
 | 
			
		||||
;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
 | 
			
		||||
 | 
			
		||||
@@ -58,11 +58,6 @@
 | 
			
		||||
;; enrich gtags with dabbrev-code results (to emulate local variables).
 | 
			
		||||
;; To do this, add a list with both back-ends as an element in company-backends.
 | 
			
		||||
;;
 | 
			
		||||
;; Known Issues:
 | 
			
		||||
;; When point is at the very end of the buffer, the pseudo-tooltip appears very
 | 
			
		||||
;; wrong, unless company is allowed to temporarily insert a fake newline.
 | 
			
		||||
;; This behavior is enabled by `company-end-of-buffer-workaround'.
 | 
			
		||||
;;
 | 
			
		||||
;;; Change Log:
 | 
			
		||||
;;
 | 
			
		||||
;; See NEWS.md in the repository.
 | 
			
		||||
@@ -117,6 +112,10 @@ buffer-local wherever it is set."
 | 
			
		||||
    (t (:background "green")))
 | 
			
		||||
  "Face used for the selection in the tooltip.")
 | 
			
		||||
 | 
			
		||||
(defface company-tooltip-search
 | 
			
		||||
  '((default :inherit company-tooltip-selection))
 | 
			
		||||
  "Face used for the search string in the tooltip.")
 | 
			
		||||
 | 
			
		||||
(defface company-tooltip-mouse
 | 
			
		||||
  '((default :inherit highlight))
 | 
			
		||||
  "Face used for the tooltip item under the mouse.")
 | 
			
		||||
@@ -550,7 +549,12 @@ happens.  The value of nil means no idle completion."
 | 
			
		||||
                 (const :tag "immediate (0)" 0)
 | 
			
		||||
                 (number :tag "seconds")))
 | 
			
		||||
 | 
			
		||||
(defcustom company-begin-commands '(self-insert-command org-self-insert-command)
 | 
			
		||||
(defcustom company-begin-commands '(self-insert-command
 | 
			
		||||
                                    org-self-insert-command
 | 
			
		||||
                                    c-scope-operator
 | 
			
		||||
                                    c-electric-colon
 | 
			
		||||
                                    c-electric-lt-gt
 | 
			
		||||
                                    c-electric-slash)
 | 
			
		||||
  "A list of commands after which idle completion is allowed.
 | 
			
		||||
If this is t, it can show completions after any command except a few from a
 | 
			
		||||
pre-defined list.  See `company-idle-delay'.
 | 
			
		||||
@@ -559,7 +563,8 @@ Alternatively, any command with a non-nil `company-begin' property is
 | 
			
		||||
treated as if it was on this list."
 | 
			
		||||
  :type '(choice (const :tag "Any command" t)
 | 
			
		||||
                 (const :tag "Self insert command" '(self-insert-command))
 | 
			
		||||
                 (repeat :tag "Commands" function)))
 | 
			
		||||
                 (repeat :tag "Commands" function))
 | 
			
		||||
  :package-version '(company . "0.8.4"))
 | 
			
		||||
 | 
			
		||||
(defcustom company-continue-commands '(not save-buffer save-some-buffers
 | 
			
		||||
                                           save-buffers-kill-terminal
 | 
			
		||||
@@ -586,10 +591,6 @@ commands in the `company-' namespace, abort completion."
 | 
			
		||||
  :type '(choice (const :tag "off" nil)
 | 
			
		||||
                 (const :tag "on" t)))
 | 
			
		||||
 | 
			
		||||
(defvar company-end-of-buffer-workaround t
 | 
			
		||||
  "Work around a visualization bug when completing at the end of the buffer.
 | 
			
		||||
The work-around consists of adding a newline.")
 | 
			
		||||
 | 
			
		||||
(defvar company-async-wait 0.03
 | 
			
		||||
  "Pause between checks to see if the value's been set when turning an
 | 
			
		||||
asynchronous call into synchronous.")
 | 
			
		||||
@@ -626,12 +627,8 @@ asynchronous call into synchronous.")
 | 
			
		||||
    (define-key keymap "\C-s" 'company-search-candidates)
 | 
			
		||||
    (define-key keymap "\C-\M-s" 'company-filter-candidates)
 | 
			
		||||
    (dotimes (i 10)
 | 
			
		||||
      (define-key keymap (vector (+ (aref (kbd "M-0") 0) i))
 | 
			
		||||
        `(lambda ()
 | 
			
		||||
           (interactive)
 | 
			
		||||
           (company-complete-number ,(if (zerop i) 10 i)))))
 | 
			
		||||
 | 
			
		||||
    keymap)
 | 
			
		||||
      (define-key keymap (kbd (format "M-%d" i)) 'company-complete-number))
 | 
			
		||||
     keymap)
 | 
			
		||||
  "Keymap that is enabled during an active completion.")
 | 
			
		||||
 | 
			
		||||
(defvar company--disabled-backends nil)
 | 
			
		||||
@@ -764,7 +761,7 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
 | 
			
		||||
;; Hack:
 | 
			
		||||
;; Emacs calculates the active keymaps before reading the event.  That means we
 | 
			
		||||
;; cannot change the keymap from a timer.  So we send a bogus command.
 | 
			
		||||
;; XXX: Seems not to be needed anymore in Emacs 24.4
 | 
			
		||||
;; XXX: Even in Emacs 24.4, seems to be needed in the terminal.
 | 
			
		||||
(defun company-ignore ()
 | 
			
		||||
  (interactive)
 | 
			
		||||
  (setq this-command last-command))
 | 
			
		||||
@@ -774,22 +771,21 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
 | 
			
		||||
(defun company-input-noop ()
 | 
			
		||||
  (push 31415926 unread-command-events))
 | 
			
		||||
 | 
			
		||||
(defun company--column (&optional pos)
 | 
			
		||||
  (save-excursion
 | 
			
		||||
    (when pos (goto-char pos))
 | 
			
		||||
    (save-restriction
 | 
			
		||||
      (+ (save-excursion
 | 
			
		||||
           (vertical-motion 0)
 | 
			
		||||
           (narrow-to-region (point) (point-max))
 | 
			
		||||
           (let ((prefix (get-text-property (point) 'line-prefix)))
 | 
			
		||||
             (if prefix (length prefix) 0)))
 | 
			
		||||
         (current-column)))))
 | 
			
		||||
(defun company--posn-col-row (posn)
 | 
			
		||||
  (let ((col (car (posn-col-row posn)))
 | 
			
		||||
        ;; `posn-col-row' doesn't work well with lines of different height.
 | 
			
		||||
        ;; `posn-actual-col-row' doesn't handle multiple-width characters.
 | 
			
		||||
        (row (cdr (posn-actual-col-row posn))))
 | 
			
		||||
    (when (and header-line-format (version< emacs-version "24.3.93.3"))
 | 
			
		||||
      ;; http://debbugs.gnu.org/18384
 | 
			
		||||
      (cl-decf row))
 | 
			
		||||
    (cons (+ col (window-hscroll)) row)))
 | 
			
		||||
 | 
			
		||||
(defun company--col-row (&optional pos)
 | 
			
		||||
  (company--posn-col-row (posn-at-point pos)))
 | 
			
		||||
 | 
			
		||||
(defun company--row (&optional pos)
 | 
			
		||||
  (save-excursion
 | 
			
		||||
    (when pos (goto-char pos))
 | 
			
		||||
    (count-screen-lines (window-start)
 | 
			
		||||
                        (progn (vertical-motion 0) (point)))))
 | 
			
		||||
  (cdr (company--col-row pos)))
 | 
			
		||||
 | 
			
		||||
;;; backends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | 
			
		||||
 | 
			
		||||
@@ -973,8 +969,6 @@ Controlled by `company-auto-complete'.")
 | 
			
		||||
 | 
			
		||||
(defvar company-timer nil)
 | 
			
		||||
 | 
			
		||||
(defvar-local company-added-newline nil)
 | 
			
		||||
 | 
			
		||||
(defsubst company-strip-prefix (str)
 | 
			
		||||
  (substring str (length company-prefix)))
 | 
			
		||||
 | 
			
		||||
@@ -984,7 +978,7 @@ Controlled by `company-auto-complete'.")
 | 
			
		||||
  (if (eq (company-call-backend 'ignore-case) 'keep-prefix)
 | 
			
		||||
      (insert (company-strip-prefix candidate))
 | 
			
		||||
    (delete-region (- (point) (length company-prefix)) (point))
 | 
			
		||||
    (insert candidate)))
 | 
			
		||||
    (insert-before-markers candidate)))
 | 
			
		||||
 | 
			
		||||
(defmacro company-with-candidate-inserted (candidate &rest body)
 | 
			
		||||
  "Evaluate BODY with CANDIDATE temporarily inserted.
 | 
			
		||||
@@ -997,7 +991,8 @@ can retrieve meta-data for them."
 | 
			
		||||
     (company--insert-candidate ,candidate)
 | 
			
		||||
     (unwind-protect
 | 
			
		||||
         (progn ,@body)
 | 
			
		||||
       (delete-region company-point (point)))))
 | 
			
		||||
       (delete-region company-point (point))
 | 
			
		||||
       (set-buffer-modified-p modified-p))))
 | 
			
		||||
 | 
			
		||||
(defun company-explicit-action-p ()
 | 
			
		||||
  "Return whether explicit completion action was taken by the user."
 | 
			
		||||
@@ -1283,8 +1278,7 @@ from the rest of the back-ends in the group, if any, will be left at the end."
 | 
			
		||||
       (eq tick (buffer-chars-modified-tick))
 | 
			
		||||
       (eq pos (point))
 | 
			
		||||
       (when (company-auto-begin)
 | 
			
		||||
         (when (version< emacs-version "24.3.50")
 | 
			
		||||
           (company-input-noop))
 | 
			
		||||
         (company-input-noop)
 | 
			
		||||
         (company-post-command))))
 | 
			
		||||
 | 
			
		||||
(defun company-auto-begin ()
 | 
			
		||||
@@ -1460,11 +1454,6 @@ from the rest of the back-ends in the group, if any, will be left at the end."
 | 
			
		||||
  (or (and company-candidates (company--continue))
 | 
			
		||||
      (and (company--should-complete) (company--begin-new)))
 | 
			
		||||
  (when company-candidates
 | 
			
		||||
    (let ((modified (buffer-modified-p)))
 | 
			
		||||
      (when (and company-end-of-buffer-workaround (eobp))
 | 
			
		||||
        (save-excursion (insert "\n"))
 | 
			
		||||
        (setq company-added-newline
 | 
			
		||||
              (or modified (buffer-chars-modified-tick)))))
 | 
			
		||||
    (setq company-point (point)
 | 
			
		||||
          company--point-max (point-max))
 | 
			
		||||
    (company-ensure-emulation-alist)
 | 
			
		||||
@@ -1472,14 +1461,6 @@ from the rest of the back-ends in the group, if any, will be left at the end."
 | 
			
		||||
    (company-call-frontends 'update)))
 | 
			
		||||
 | 
			
		||||
(defun company-cancel (&optional result)
 | 
			
		||||
  (and company-added-newline
 | 
			
		||||
       (> (point-max) (point-min))
 | 
			
		||||
       (let ((tick (buffer-chars-modified-tick)))
 | 
			
		||||
         (delete-region (1- (point-max)) (point-max))
 | 
			
		||||
         (equal tick company-added-newline))
 | 
			
		||||
       ;; Only set unmodified when tick remained the same since insert,
 | 
			
		||||
       ;; and the buffer wasn't modified before.
 | 
			
		||||
       (set-buffer-modified-p nil))
 | 
			
		||||
  (unwind-protect
 | 
			
		||||
      (when company-prefix
 | 
			
		||||
        (if (stringp result)
 | 
			
		||||
@@ -1488,8 +1469,7 @@ from the rest of the back-ends in the group, if any, will be left at the end."
 | 
			
		||||
              (run-hook-with-args 'company-completion-finished-hook result)
 | 
			
		||||
              (company-call-backend 'post-completion result))
 | 
			
		||||
          (run-hook-with-args 'company-completion-cancelled-hook result)))
 | 
			
		||||
    (setq company-added-newline nil
 | 
			
		||||
          company-backend nil
 | 
			
		||||
    (setq company-backend nil
 | 
			
		||||
          company-prefix nil
 | 
			
		||||
          company-candidates nil
 | 
			
		||||
          company-candidates-length nil
 | 
			
		||||
@@ -1809,14 +1789,7 @@ and invoke the normal binding."
 | 
			
		||||
                (>= evt-row (+ row height)))))))
 | 
			
		||||
 | 
			
		||||
(defun company--event-col-row (event)
 | 
			
		||||
  (let* ((col-row (posn-actual-col-row (event-start event)))
 | 
			
		||||
         (col (car col-row))
 | 
			
		||||
         (row (cdr col-row)))
 | 
			
		||||
    (cl-incf col (window-hscroll))
 | 
			
		||||
    (and header-line-format
 | 
			
		||||
         (version< "24" emacs-version)
 | 
			
		||||
         (cl-decf row))
 | 
			
		||||
    (cons col row)))
 | 
			
		||||
  (company--posn-col-row (event-start event)))
 | 
			
		||||
 | 
			
		||||
(defun company-select-mouse (event)
 | 
			
		||||
  "Select the candidate picked by the mouse."
 | 
			
		||||
@@ -1883,7 +1856,11 @@ inserted."
 | 
			
		||||
(defun company-complete-number (n)
 | 
			
		||||
  "Insert the Nth candidate.
 | 
			
		||||
To show the number next to the candidates in some back-ends, enable
 | 
			
		||||
`company-show-numbers'."
 | 
			
		||||
`company-show-numbers'.  When called interactively, uses the last typed
 | 
			
		||||
character, stripping the modifiers.  That character must be a digit."
 | 
			
		||||
  (interactive
 | 
			
		||||
   (list (let ((n (- (event-basic-type last-command-event) ?0)))
 | 
			
		||||
           (if (zerop n) 10 n))))
 | 
			
		||||
  (when (company-manual-begin)
 | 
			
		||||
    (and (or (< n 1) (> n company-candidates-length))
 | 
			
		||||
         (error "No candidate number %d" n))
 | 
			
		||||
@@ -2110,8 +2087,8 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 | 
			
		||||
 | 
			
		||||
(defun company-fill-propertize (value annotation width selected left right)
 | 
			
		||||
  (let* ((margin (length left))
 | 
			
		||||
         (common (+ (or (company-call-backend 'match value)
 | 
			
		||||
                        (length company-common)) margin))
 | 
			
		||||
         (common (or (company-call-backend 'match value)
 | 
			
		||||
                     (length company-common)))
 | 
			
		||||
         (ann-ralign company-tooltip-align-annotations)
 | 
			
		||||
         (ann-truncate (< width
 | 
			
		||||
                          (+ (length value) (length annotation)
 | 
			
		||||
@@ -2135,6 +2112,7 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 | 
			
		||||
                                                  (- width (length annotation)))
 | 
			
		||||
                          annotation))
 | 
			
		||||
                       right)))
 | 
			
		||||
    (setq common (+ (min common width) margin))
 | 
			
		||||
    (setq width (+ width margin (length right)))
 | 
			
		||||
 | 
			
		||||
    (add-text-properties 0 width '(face company-tooltip
 | 
			
		||||
@@ -2155,7 +2133,7 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 | 
			
		||||
                             (length company-prefix)))
 | 
			
		||||
          (let ((beg (+ margin (match-beginning 0)))
 | 
			
		||||
                (end (+ margin (match-end 0))))
 | 
			
		||||
            (add-text-properties beg end '(face company-tooltip-selection)
 | 
			
		||||
            (add-text-properties beg end '(face company-tooltip-search)
 | 
			
		||||
                                 line)
 | 
			
		||||
            (when (< beg common)
 | 
			
		||||
              (add-text-properties beg common
 | 
			
		||||
@@ -2174,8 +2152,8 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 | 
			
		||||
 | 
			
		||||
(defun company-buffer-lines (beg end)
 | 
			
		||||
  (goto-char beg)
 | 
			
		||||
  (let (lines)
 | 
			
		||||
    (while (and (= 1 (vertical-motion 1))
 | 
			
		||||
  (let (lines lines-moved)
 | 
			
		||||
    (while (and (> (setq lines-moved (vertical-motion 1)) 0)
 | 
			
		||||
                (<= (point) end))
 | 
			
		||||
      (let ((bound (min end (1- (point)))))
 | 
			
		||||
        ;; A visual line can contain several physical lines (e.g. with outline's
 | 
			
		||||
@@ -2186,6 +2164,10 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 | 
			
		||||
                                  (re-search-forward "$" bound 'move)
 | 
			
		||||
                                  (point)))
 | 
			
		||||
              lines))
 | 
			
		||||
      ;; One physical line can be displayed as several visual ones as well:
 | 
			
		||||
      ;; add empty strings to the list, to even the count.
 | 
			
		||||
      (dotimes (_ (1- lines-moved))
 | 
			
		||||
        (push "" lines))
 | 
			
		||||
      (setq beg (point)))
 | 
			
		||||
    (unless (eq beg end)
 | 
			
		||||
      (push (buffer-substring beg end) lines))
 | 
			
		||||
@@ -2232,10 +2214,12 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 | 
			
		||||
                    (company--offset-line (pop lines) offset))
 | 
			
		||||
            new))
 | 
			
		||||
 | 
			
		||||
    (let ((str (concat (when nl "\n")
 | 
			
		||||
    (let ((str (concat (when nl " ")
 | 
			
		||||
                       "\n"
 | 
			
		||||
                       (mapconcat 'identity (nreverse new) "\n")
 | 
			
		||||
                       "\n")))
 | 
			
		||||
      (font-lock-append-text-property 0 (length str) 'face 'default str)
 | 
			
		||||
      (when nl (put-text-property 0 1 'cursor t str))
 | 
			
		||||
      str)))
 | 
			
		||||
 | 
			
		||||
(defun company--offset-line (line offset)
 | 
			
		||||
@@ -2358,12 +2342,13 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 | 
			
		||||
 | 
			
		||||
;; show
 | 
			
		||||
 | 
			
		||||
(defsubst company--window-inner-height ()
 | 
			
		||||
  (let ((edges (window-inside-edges)))
 | 
			
		||||
    (- (nth 3 edges) (nth 1 edges))))
 | 
			
		||||
(defsubst company--window-height ()
 | 
			
		||||
  (if (fboundp 'window-screen-lines)
 | 
			
		||||
      (floor (window-screen-lines))
 | 
			
		||||
    (window-body-height)))
 | 
			
		||||
 | 
			
		||||
(defsubst company--window-width ()
 | 
			
		||||
  (let ((ww (window-width)))
 | 
			
		||||
  (let ((ww (window-body-width)))
 | 
			
		||||
    ;; Account for the line continuation column.
 | 
			
		||||
    (when (zerop (cadr (window-fringes)))
 | 
			
		||||
      (cl-decf ww))
 | 
			
		||||
@@ -2381,7 +2366,7 @@ If SHOW-VERSION is non-nil, show the version in the echo area."
 | 
			
		||||
  "Calculate the appropriate tooltip height.
 | 
			
		||||
Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
  (let* ((lines (company--row))
 | 
			
		||||
         (below (- (company--window-inner-height) 1 lines)))
 | 
			
		||||
         (below (- (company--window-height) 1 lines)))
 | 
			
		||||
    (if (and (< below (min company-tooltip-minimum company-candidates-length))
 | 
			
		||||
             (> lines below))
 | 
			
		||||
        (- (max 3 (min company-tooltip-limit lines)))
 | 
			
		||||
@@ -2403,7 +2388,7 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
             (end (save-excursion
 | 
			
		||||
                    (move-to-window-line (+ row (abs height)))
 | 
			
		||||
                    (point)))
 | 
			
		||||
             (ov (make-overlay beg end))
 | 
			
		||||
             (ov (make-overlay (if nl beg (1- beg)) end nil t))
 | 
			
		||||
             (args (list (mapcar 'company-plainify
 | 
			
		||||
                                 (company-buffer-lines beg end))
 | 
			
		||||
                         column nl above)))
 | 
			
		||||
@@ -2412,7 +2397,7 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
        (overlay-put ov 'company-replacement-args args)
 | 
			
		||||
 | 
			
		||||
        (let ((lines (company--create-lines selection (abs height))))
 | 
			
		||||
          (overlay-put ov 'company-after
 | 
			
		||||
          (overlay-put ov 'company-display
 | 
			
		||||
                       (apply 'company--replacement-string lines args))
 | 
			
		||||
          (overlay-put ov 'company-width (string-width (car lines))))
 | 
			
		||||
 | 
			
		||||
@@ -2420,17 +2405,17 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
        (overlay-put ov 'company-height height)))))
 | 
			
		||||
 | 
			
		||||
(defun company-pseudo-tooltip-show-at-point (pos column-offset)
 | 
			
		||||
  (let ((row (company--row pos))
 | 
			
		||||
        (col (- (company--column pos) column-offset)))
 | 
			
		||||
  (let* ((col-row (company--col-row pos))
 | 
			
		||||
         (col (- (car col-row) column-offset)))
 | 
			
		||||
    (when (< col 0) (setq col 0))
 | 
			
		||||
    (company-pseudo-tooltip-show (1+ row) col company-selection)))
 | 
			
		||||
    (company-pseudo-tooltip-show (1+ (cdr col-row)) col company-selection)))
 | 
			
		||||
 | 
			
		||||
(defun company-pseudo-tooltip-edit (selection)
 | 
			
		||||
  (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
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'company-display
 | 
			
		||||
                 (apply 'company--replacement-string
 | 
			
		||||
                        lines
 | 
			
		||||
                        (overlay-get company-pseudo-tooltip-overlay
 | 
			
		||||
@@ -2444,26 +2429,32 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
(defun company-pseudo-tooltip-hide-temporarily ()
 | 
			
		||||
  (when (overlayp company-pseudo-tooltip-overlay)
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'invisible nil)
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'line-prefix nil)
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'after-string nil)))
 | 
			
		||||
 | 
			
		||||
(defun company-pseudo-tooltip-unhide ()
 | 
			
		||||
  (when company-pseudo-tooltip-overlay
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'invisible t)
 | 
			
		||||
    ;; Beat outline's folding overlays, at least.
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'priority 1)
 | 
			
		||||
    ;; No (extra) prefix for the first line.
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'line-prefix "")
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'after-string
 | 
			
		||||
                 (overlay-get company-pseudo-tooltip-overlay 'company-after))
 | 
			
		||||
    (overlay-put company-pseudo-tooltip-overlay 'window (selected-window))))
 | 
			
		||||
    (let* ((ov company-pseudo-tooltip-overlay)
 | 
			
		||||
           (disp (overlay-get ov 'company-display)))
 | 
			
		||||
      ;; Beat outline's folding overlays, at least.
 | 
			
		||||
      (overlay-put ov 'priority 1)
 | 
			
		||||
      ;; `display' could be better (http://debbugs.gnu.org/18285), but it
 | 
			
		||||
      ;; doesn't work when the overlay is empty, which is what happens at eob.
 | 
			
		||||
      ;; It also seems to interact badly with `cursor'.
 | 
			
		||||
      ;; We deal with priorities by having the overlay start before the newline.
 | 
			
		||||
      (overlay-put ov 'after-string disp)
 | 
			
		||||
      (overlay-put ov 'invisible t)
 | 
			
		||||
      (overlay-put ov 'window (selected-window)))))
 | 
			
		||||
 | 
			
		||||
(defun company-pseudo-tooltip-guard ()
 | 
			
		||||
  (list
 | 
			
		||||
  (cons
 | 
			
		||||
   (save-excursion (beginning-of-visual-line))
 | 
			
		||||
   (let ((ov company-pseudo-tooltip-overlay))
 | 
			
		||||
   (let ((ov company-pseudo-tooltip-overlay)
 | 
			
		||||
         (overhang (save-excursion (end-of-visual-line)
 | 
			
		||||
                                   (- (line-end-position) (point)))))
 | 
			
		||||
     (when (>= (overlay-get ov 'company-height) 0)
 | 
			
		||||
       (buffer-substring-no-properties (point) (overlay-start ov))))))
 | 
			
		||||
       (cons
 | 
			
		||||
        (buffer-substring-no-properties (point) (overlay-start ov))
 | 
			
		||||
        (when (>= overhang 0) overhang))))))
 | 
			
		||||
 | 
			
		||||
(defun company-pseudo-tooltip-frontend (command)
 | 
			
		||||
  "`company-mode' front-end similar to a tooltip but based on overlays."
 | 
			
		||||
@@ -2502,7 +2493,7 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
(defun company-preview-show-at-point (pos)
 | 
			
		||||
  (company-preview-hide)
 | 
			
		||||
 | 
			
		||||
  (setq company-preview-overlay (make-overlay pos (1+ pos)))
 | 
			
		||||
  (setq company-preview-overlay (make-overlay pos pos))
 | 
			
		||||
 | 
			
		||||
  (let ((completion (nth company-selection company-candidates)))
 | 
			
		||||
    (setq completion (propertize completion 'face 'company-preview))
 | 
			
		||||
@@ -2523,10 +2514,9 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
         (not (equal completion ""))
 | 
			
		||||
         (add-text-properties 0 1 '(cursor t) completion))
 | 
			
		||||
 | 
			
		||||
    (overlay-put company-preview-overlay 'display
 | 
			
		||||
                 (concat completion (unless (eq pos (point-max))
 | 
			
		||||
                                      (buffer-substring pos (1+ pos)))))
 | 
			
		||||
    (overlay-put company-preview-overlay 'window (selected-window))))
 | 
			
		||||
    (let ((ov company-preview-overlay))
 | 
			
		||||
      (overlay-put ov 'after-string completion)
 | 
			
		||||
      (overlay-put ov 'window (selected-window)))))
 | 
			
		||||
 | 
			
		||||
(defun company-preview-hide ()
 | 
			
		||||
  (when company-preview-overlay
 | 
			
		||||
@@ -2549,8 +2539,8 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
(defun company--show-inline-p ()
 | 
			
		||||
  (and (not (cdr company-candidates))
 | 
			
		||||
       company-common
 | 
			
		||||
       (string-prefix-p company-prefix company-common
 | 
			
		||||
                        (company-call-backend 'ignore-case))))
 | 
			
		||||
       (or (eq (company-call-backend 'ignore-case) 'keep-prefix)
 | 
			
		||||
           (string-prefix-p company-prefix company-common))))
 | 
			
		||||
 | 
			
		||||
;;; echo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | 
			
		||||
 | 
			
		||||
@@ -2579,7 +2569,7 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
 | 
			
		||||
(defun company-echo-format ()
 | 
			
		||||
 | 
			
		||||
  (let ((limit (window-width (minibuffer-window)))
 | 
			
		||||
  (let ((limit (window-body-width (minibuffer-window)))
 | 
			
		||||
        (len -1)
 | 
			
		||||
        ;; Roll to selection.
 | 
			
		||||
        (candidates (nthcdr company-selection company-candidates))
 | 
			
		||||
@@ -2609,7 +2599,7 @@ Returns a negative number if the tooltip should be displayed above point."
 | 
			
		||||
 | 
			
		||||
(defun company-echo-strip-common-format ()
 | 
			
		||||
 | 
			
		||||
  (let ((limit (window-width (minibuffer-window)))
 | 
			
		||||
  (let ((limit (window-body-width (minibuffer-window)))
 | 
			
		||||
        (len (+ (length company-prefix) 2))
 | 
			
		||||
        ;; Roll to selection.
 | 
			
		||||
        (candidates (nthcdr company-selection company-candidates))
 | 
			
		||||
		Reference in New Issue
	
	Block a user