[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 85bd83e 23/23: Merge commit 'e077caf1957f1846fae29aa84a021
From: |
Dmitry Gutov |
Subject: |
[elpa] master 85bd83e 23/23: Merge commit 'e077caf1957f1846fae29aa84a021234c43be96f' |
Date: |
Fri, 11 Nov 2016 22:21:42 +0000 (UTC) |
branch: master
commit 85bd83ee11b9880858dff39ab523b83ca38059e1
Merge: ec15f45 e077caf
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Merge commit 'e077caf1957f1846fae29aa84a021234c43be96f'
---
packages/company/NEWS.md | 13 ++++
packages/company/company-dabbrev-code.el | 2 +-
packages/company/company-files.el | 42 +++++++++--
packages/company/company-gtags.el | 3 +-
packages/company/company-keywords.el | 10 +++
packages/company/company-tests.el | 5 +-
packages/company/company.el | 117 ++++++++++++++++++++----------
packages/company/test/files-tests.el | 48 ++++++++++++
packages/company/test/frontends-tests.el | 12 +--
9 files changed, 195 insertions(+), 57 deletions(-)
diff --git a/packages/company/NEWS.md b/packages/company/NEWS.md
index 758f0be..32d05b3 100644
--- a/packages/company/NEWS.md
+++ b/packages/company/NEWS.md
@@ -1,5 +1,18 @@
# History of user-visible changes
+## 2016-11-12 (0.9.1)
+
+* `company-indent-or-complete-common` skips trying to indent if
+ `indent-line-function` is `indent-relative` or `indent-relative-maybe`.
+* Better visualization of search matches. New face
`company-tooltip-search-selection`.
+* New variable `company-files-exclusions`.
+* `company-next-page` and `company-previous-page` adhere to
+ `company-selection-wrap-around` docstring more closely and only wrap around
+ when the selection is at the start of the end of the list.
+* `company-pseudo-tooltip-unless-just-one-frontend-with-delay` handles custom
+ frontends derived from `company-preview-frontend` better.
+* `company-idle-delay` is automatically adjusted to a non-zero value.
+
## 2016-06-23 (0.9.0)
* Group of backends can now contain keyword `:separate`, which makes candidates
diff --git a/packages/company/company-dabbrev-code.el
b/packages/company/company-dabbrev-code.el
index 9331087..37f287c 100644
--- a/packages/company/company-dabbrev-code.el
+++ b/packages/company/company-dabbrev-code.el
@@ -96,7 +96,7 @@ comments or strings."
(`t (list major-mode))
(`code company-dabbrev-code-modes)
(`all `all))
- t)))
+ (not company-dabbrev-code-everywhere))))
(ignore-case company-dabbrev-code-ignore-case)
(duplicates t)))
diff --git a/packages/company/company-files.el
b/packages/company/company-files.el
index c19d3d6..4410281 100644
--- a/packages/company/company-files.el
+++ b/packages/company/company-files.el
@@ -1,4 +1,4 @@
-;;; company-files.el --- company-mode completion backend for file paths
+;;; company-files.el --- company-mode completion backend for file names
;; Copyright (C) 2009-2011, 2014-2015 Free Software Foundation, Inc.
@@ -28,14 +28,40 @@
(require 'company)
(require 'cl-lib)
+(defgroup company-files nil
+ "Completion backend for file names."
+ :group 'company)
+
+(defcustom company-files-exclusions nil
+ "File name extensions and directory names to ignore.
+The values should use the same format as `completion-ignored-extensions'."
+ :type '(const string)
+ :package-version '(company . "0.9.1"))
+
(defun company-files--directory-files (dir prefix)
- (ignore-errors
- ;; Don't use directory-files. It produces directories without trailing /.
- (let ((comp (sort (file-name-all-completions prefix dir)
- (lambda (s1 s2) (string-lessp (downcase s1) (downcase
s2))))))
- (if (equal prefix "")
- (delete "../" (delete "./" comp))
- comp))))
+ ;; Don't use directory-files. It produces directories without trailing /.
+ (condition-case err
+ (let ((comp (sort (file-name-all-completions prefix dir)
+ (lambda (s1 s2) (string-lessp (downcase s1) (downcase
s2))))))
+ (when company-files-exclusions
+ (setq comp (company-files--exclusions-filtered comp)))
+ (if (equal prefix "")
+ (delete "../" (delete "./" comp))
+ comp))
+ (file-error nil)))
+
+(defun company-files--exclusions-filtered (completions)
+ (let* ((dir-exclusions (cl-delete-if-not #'company-files--trailing-slash-p
+ company-files-exclusions))
+ (file-exclusions (cl-set-difference company-files-exclusions
+ dir-exclusions)))
+ (cl-loop for c in completions
+ unless (if (company-files--trailing-slash-p c)
+ (member c dir-exclusions)
+ (cl-find-if (lambda (exclusion)
+ (string-suffix-p exclusion c))
+ file-exclusions))
+ collect c)))
(defvar company-files--regexps
(let* ((root (if (eq system-type 'windows-nt)
diff --git a/packages/company/company-gtags.el
b/packages/company/company-gtags.el
index 5050783..82b8032 100644
--- a/packages/company/company-gtags.el
+++ b/packages/company/company-gtags.el
@@ -66,7 +66,8 @@ completion."
(with-temp-buffer
(let (tags)
(when (= 0 (call-process company-gtags-executable nil
- (list (current-buffer) nil) nil "-xGq" (concat
"^" prefix)))
+ ;; "-T" goes through all the tag files listed
in GTAGSLIBPATH
+ (list (current-buffer) nil) nil "-xGqT" (concat
"^" prefix)))
(goto-char (point-min))
(cl-loop while
(re-search-forward (concat
diff --git a/packages/company/company-keywords.el
b/packages/company/company-keywords.el
index e59eaa2..fac37f5 100644
--- a/packages/company/company-keywords.el
+++ b/packages/company/company-keywords.el
@@ -210,6 +210,14 @@
"do" "else" "elsif" "end" "ensure" "false" "for" "if" "in" "module"
"next" "nil" "not" "or" "redo" "rescue" "retry" "return" "self" "super"
"then" "true" "undef" "unless" "until" "when" "while" "yield")
+ ;; From https://doc.rust-lang.org/grammar.html#keywords
+ ;; but excluding unused reserved words:
https://www.reddit.com/r/rust/comments/34fq0k/is_there_a_good_list_of_rusts_keywords/cqucvnj
+ (rust-mode
+ "Self"
+ "as" "box" "break" "const" "continue" "crate" "else" "enum" "extern"
+ "false" "fn" "for" "if" "impl" "in" "let" "loop" "macro" "match" "mod"
+ "move" "mut" "pub" "ref" "return" "self" "static" "struct" "super"
+ "trait" "true" "type" "unsafe" "use" "where" "while")
(scala-mode
"abstract" "case" "catch" "class" "def" "do" "else" "extends" "false"
"final" "finally" "for" "forSome" "if" "implicit" "import" "lazy" "match"
@@ -225,8 +233,10 @@
)
;; aliases
(js2-mode . javascript-mode)
+ (js2-jsx-mode . javascript-mode)
(espresso-mode . javascript-mode)
(js-mode . javascript-mode)
+ (js-jsx-mode . javascript-mode)
(cperl-mode . perl-mode)
(jde-mode . java-mode)
(ess-julia-mode . julia-mode))
diff --git a/packages/company/company-tests.el
b/packages/company/company-tests.el
index f0d669d..5f7a852 100644
--- a/packages/company/company-tests.el
+++ b/packages/company/company-tests.el
@@ -1,6 +1,6 @@
;;; company-tests.el --- company-mode test helpers -*- lexical-binding: t -*-
-;; Copyright (C) 2011, 2013-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2013-2016 Free Software Foundation, Inc.
;; Author: Dmitry Gutov
@@ -21,6 +21,9 @@
(require 'company)
+(defvar company-dir (file-name-directory (or load-file-name
+ buffer-file-name)))
+
(defun company--column (&optional pos)
(car (company--col-row pos)))
diff --git a/packages/company/company.el b/packages/company/company.el
index a2908af..360142b 100644
--- a/packages/company/company.el
+++ b/packages/company/company.el
@@ -5,7 +5,7 @@
;; Author: Nikolaj Schumacher
;; Maintainer: Dmitry Gutov <address@hidden>
;; URL: http://company-mode.github.io/
-;; Version: 0.9.0
+;; Version: 0.9.1
;; Keywords: abbrev, convenience, matching
;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
@@ -83,7 +83,17 @@ buffer-local wherever it is set."
(declare (debug defvar) (doc-string 3))
`(progn
(defvar ,var ,val ,docstring)
- (make-variable-buffer-local ',var)))))
+ (make-variable-buffer-local ',var))))
+
+ (unless (fboundp 'string-suffix-p)
+ (defun string-suffix-p (suffix string &optional ignore-case)
+ "Return non-nil if SUFFIX is a suffix of STRING.
+If IGNORE-CASE is non-nil, the comparison is done without paying
+attention to case differences."
+ (let ((start-pos (- (length string) (length suffix))))
+ (and (>= start-pos 0)
+ (eq t (compare-strings suffix nil nil
+ string start-pos nil ignore-case)))))))
(defgroup company nil
"Extensible inline text completion mechanism"
@@ -108,9 +118,13 @@ buffer-local wherever it is set."
"Face used for the selection in the tooltip.")
(defface company-tooltip-search
- '((default :inherit company-tooltip-selection))
+ '((default :inherit highlight))
"Face used for the search string in the tooltip.")
+(defface company-tooltip-search-selection
+ '((default :inherit highlight))
+ "Face used for the search string inside the selection in the tooltip.")
+
(defface company-tooltip-mouse
'((default :inherit highlight))
"Face used for the tooltip item under the mouse.")
@@ -683,6 +697,12 @@ asynchronous call into synchronous.")
(unless (keywordp b)
(company-init-backend b))))))
+(defun company--maybe-init-backend (backend)
+ (or (not (symbolp backend))
+ (eq t (get backend 'company-init))
+ (unless (get backend 'company-init)
+ (company-init-backend backend))))
+
(defcustom company-lighter-base "company"
"Base string to use for the `company-mode' lighter."
:type 'string
@@ -735,9 +755,6 @@ keymap during active completions (`company-active-map'):
nil company-lighter company-mode-map
(if company-mode
(progn
- (when (eq company-idle-delay t)
- (setq company-idle-delay 0)
- (warn "Setting `company-idle-delay' to t is deprecated. Set it to 0
instead."))
(add-hook 'pre-command-hook 'company-pre-command nil t)
(add-hook 'post-command-hook 'company-post-command nil t)
(mapc 'company-init-backend company-backends))
@@ -913,13 +930,16 @@ matches IDLE-BEGIN-AFTER-RE, return it wrapped in a cons."
(if (functionp company-backend)
(apply company-backend args)
(apply #'company--multi-backend-adapter company-backend args))
+ (user-error (user-error
+ "Company: backend %s user-error: %s"
+ company-backend (error-message-string err)))
(error (error "Company: backend %s error \"%s\" with args %s"
company-backend (error-message-string err) args))))
(defun company--multi-backend-adapter (backends command &rest args)
(let ((backends (cl-loop for b in backends
- when (not (and (symbolp b)
- (eq 'failed (get b 'company-init))))
+ when (or (keywordp b)
+ (company--maybe-init-backend b))
collect b))
(separate (memq :separate backends)))
@@ -1521,10 +1541,7 @@ prefix match (same case) will be prioritized."
(setq prefix
(if (or (symbolp backend)
(functionp backend))
- (when (or (not (symbolp backend))
- (eq t (get backend 'company-init))
- (unless (get backend 'company-init)
- (company-init-backend backend)))
+ (when (company--maybe-init-backend backend)
(funcall backend 'prefix))
(company--multi-backend-adapter backend 'prefix)))
(when prefix
@@ -1638,11 +1655,13 @@ prefix match (same case) will be prioritized."
(company--perform)))
(if company-candidates
(company-call-frontends 'post-command)
- (and (numberp company-idle-delay)
+ (and (or (numberp company-idle-delay)
+ ;; Deprecated.
+ (eq company-idle-delay t))
(not defining-kbd-macro)
(company--should-begin)
(setq company-timer
- (run-with-timer company-idle-delay nil
+ (run-with-timer (company--idle-delay) nil
'company-idle-begin
(current-buffer) (selected-window)
(buffer-chars-modified-tick)
(point))))))
@@ -1651,6 +1670,11 @@ prefix match (same case) will be prioritized."
(company-cancel))))
(company-install-map))
+(defun company--idle-delay ()
+ (if (memql company-idle-delay '(t 0 0.0))
+ 0.01
+ company-idle-delay))
+
(defvar company--begin-inhibit-commands '(company-abort
company-complete-mouse
company-complete
@@ -1977,15 +2001,23 @@ With ARG, move by that many elements."
"Select the candidate one page further."
(interactive)
(when (company-manual-begin)
- (company-set-selection (+ company-selection
- company-tooltip-limit))))
+ (if (and company-selection-wrap-around
+ (= company-selection (1- company-candidates-length)))
+ (company-set-selection 0)
+ (let (company-selection-wrap-around)
+ (company-set-selection (+ company-selection
+ company-tooltip-limit))))))
(defun company-previous-page ()
"Select the candidate one page earlier."
(interactive)
(when (company-manual-begin)
- (company-set-selection (- company-selection
- company-tooltip-limit))))
+ (if (and company-selection-wrap-around
+ (zerop company-selection))
+ (company-set-selection (1- company-candidates-length))
+ (let (company-selection-wrap-around)
+ (company-set-selection (- company-selection
+ company-tooltip-limit))))))
(defvar company-pseudo-tooltip-overlay)
@@ -2075,6 +2107,9 @@ With ARG, move by that many elements."
(cond
((use-region-p)
(indent-region (region-beginning) (region-end)))
+ ((memq indent-line-function
+ '(indent-relative indent-relative-maybe))
+ (company-complete-common))
((let ((old-point (point))
(old-tick (buffer-chars-modified-tick))
(tab-always-indent t))
@@ -2450,22 +2485,24 @@ If SHOW-VERSION is non-nil, show the version in the
echo area."
'company-tooltip-common-selection
'company-tooltip-common)
line)
- (when selected
- (if (let ((re (funcall company-search-regexp-function
+ (when (let ((re (funcall company-search-regexp-function
company-search-string)))
(and (not (string= re ""))
(string-match re value (length company-prefix))))
- (pcase-dolist (`(,mbeg . ,mend) (company--search-chunks))
- (let ((beg (+ margin mbeg))
- (end (+ margin mend))
- (width (- width (length right))))
- (when (< beg width)
- (font-lock-prepend-text-property beg (min end width)
- 'face 'company-tooltip-search
- line))))
- (font-lock-append-text-property 0 width 'face
- 'company-tooltip-selection
- line)))
+ (pcase-dolist (`(,mbeg . ,mend) (company--search-chunks))
+ (let ((beg (+ margin mbeg))
+ (end (+ margin mend))
+ (width (- width (length right))))
+ (when (< beg width)
+ (font-lock-prepend-text-property beg (min end width) 'face
+ (if selected
+
'company-tooltip-search-selection
+ 'company-tooltip-search)
+ line)))))
+ (when selected
+ (font-lock-append-text-property 0 width 'face
+ 'company-tooltip-selection
+ line))
(font-lock-append-text-property 0 width 'face
'company-tooltip
line)
@@ -2865,20 +2902,20 @@ Returns a negative number if the tooltip should be
displayed above point."
(defun company-pseudo-tooltip-unless-just-one-frontend-with-delay (command)
"`compandy-pseudo-tooltip-frontend', but shown after a delay.
Delay is determined by `company-tooltip-idle-delay'."
+ (defvar company-preview-overlay)
+ (when (and (memq command '(pre-command hide))
+ company-tooltip-timer)
+ (cancel-timer company-tooltip-timer)
+ (setq company-tooltip-timer nil))
(cl-case command
- (pre-command
- (company-pseudo-tooltip-unless-just-one-frontend command)
- (when company-tooltip-timer
- (cancel-timer company-tooltip-timer)
- (setq company-tooltip-timer nil)))
(post-command
(if (or company-tooltip-timer
(overlayp company-pseudo-tooltip-overlay))
- (if (not (memq 'company-preview-frontend company-frontends))
+ (if (not (overlayp company-preview-overlay))
(company-pseudo-tooltip-unless-just-one-frontend command)
- (company-preview-frontend 'pre-command)
- (company-pseudo-tooltip-unless-just-one-frontend command)
- (company-preview-frontend 'post-command))
+ (let (company-tooltip-timer)
+ (company-call-frontends 'pre-command))
+ (company-call-frontends 'post-command))
(setq company-tooltip-timer
(run-with-timer company-tooltip-idle-delay nil
'company-pseudo-tooltip-unless-just-one-frontend-with-delay
diff --git a/packages/company/test/files-tests.el
b/packages/company/test/files-tests.el
new file mode 100644
index 0000000..254baa2
--- /dev/null
+++ b/packages/company/test/files-tests.el
@@ -0,0 +1,48 @@
+;;; filtes-tests.el --- company-mode tests -*- lexical-binding: t -*-
+
+;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+;; Author: Dmitry Gutov
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+(require 'company-tests)
+(require 'company-files)
+
+(ert-deftest company-files-candidates-normal ()
+ (let (company-files--completion-cache)
+ (should (member (expand-file-name "test/" company-dir)
+ (company-files 'candidates
+ company-dir)))))
+
+(ert-deftest company-files-candidates-normal-root ()
+ (let (company-files--completion-cache)
+ (should (member "/lost+found/"
+ (company-files 'candidates "/")))))
+
+(ert-deftest company-files-candidates-excluding-dir ()
+ (let ((company-files-exclusions '("test/"))
+ company-files--completion-cache)
+ (should-not (member (expand-file-name "test/" company-dir)
+ (company-files 'candidates
+ company-dir)))))
+
+(ert-deftest company-files-candidates-excluding-files ()
+ (let ((company-files-exclusions '(".el"))
+ company-files--completion-cache)
+ (should-not (member (expand-file-name "company.el" company-dir)
+ (company-files 'candidates
+ company-dir)))))
diff --git a/packages/company/test/frontends-tests.el
b/packages/company/test/frontends-tests.el
index 7b8ee61..9592bed 100644
--- a/packages/company/test/frontends-tests.el
+++ b/packages/company/test/frontends-tests.el
@@ -256,18 +256,18 @@
(should (ert-equal-including-properties
(company-fill-propertize "barfoo" nil 6 t nil nil)
#("barfoo"
- 0 3 (face (company-tooltip) mouse-face (company-tooltip-mouse))
- 3 6 (face (company-tooltip-search company-tooltip) mouse-face
(company-tooltip-mouse)))))
+ 0 3 (face (company-tooltip-selection company-tooltip)
mouse-face (company-tooltip-mouse))
+ 3 6 (face (company-tooltip-search-selection
company-tooltip-selection company-tooltip) mouse-face
(company-tooltip-mouse)))))
(should (ert-equal-including-properties
(company-fill-propertize "barfoo" nil 5 t "" " ")
#("barfo "
- 0 3 (face (company-tooltip) mouse-face (company-tooltip-mouse))
- 3 5 (face (company-tooltip-search company-tooltip) mouse-face
(company-tooltip-mouse))
- 5 6 (face (company-tooltip) mouse-face
(company-tooltip-mouse)))))
+ 0 3 (face (company-tooltip-selection company-tooltip)
mouse-face (company-tooltip-mouse))
+ 3 5 (face (company-tooltip-search-selection
company-tooltip-selection company-tooltip) mouse-face (company-tooltip-mouse))
+ 5 6 (face (company-tooltip-selection company-tooltip)
mouse-face (company-tooltip-mouse)))))
(should (ert-equal-including-properties
(company-fill-propertize "barfoo" nil 3 t " " " ")
#(" bar "
- 0 5 (face (company-tooltip) mouse-face
(company-tooltip-mouse)))))))
+ 0 5 (face (company-tooltip-selection company-tooltip)
mouse-face (company-tooltip-mouse)))))))
(ert-deftest company-fill-propertize-overrides-face-property ()
(let ((company-backend #'ignore)
- [elpa] master f78f9c1 21/23: Initialize grouped backends on the fly as well, (continued)
- [elpa] master f78f9c1 21/23: Initialize grouped backends on the fly as well, Dmitry Gutov, 2016/11/11
- [elpa] master e6689ea 12/23: company-files--directory-files: Swallow file-error, Dmitry Gutov, 2016/11/11
- [elpa] master 9476aef 09/23: company-files--directory-files: Don't ignore errors, Dmitry Gutov, 2016/11/11
- [elpa] master c353c71 14/23: global goes through all the tag files listed in GTAGSLIBPATH, Dmitry Gutov, 2016/11/11
- [elpa] master f2327bc 19/23: Merge pull request #575 from Wilfred/patch-1, Dmitry Gutov, 2016/11/11
- [elpa] master e077caf 22/23: Release 0.9.1, Dmitry Gutov, 2016/11/11
- [elpa] master ba87881 16/23: Merge pull request #572 from Wilfred/rust_keywords, Dmitry Gutov, 2016/11/11
- [elpa] master 6025006 08/23: Add company-files-exclusions, Dmitry Gutov, 2016/11/11
- [elpa] master d8ca520 13/23: Improve search visualization, Dmitry Gutov, 2016/11/11
- [elpa] master 1028f38 20/23: company-indent-or-complete-common: Blacklist some indentation functions, Dmitry Gutov, 2016/11/11
- [elpa] master 85bd83e 23/23: Merge commit 'e077caf1957f1846fae29aa84a021234c43be96f',
Dmitry Gutov <=
- [elpa] master 917936c 17/23: Fix keyword ordering, Dmitry Gutov, 2016/11/11