[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 51f3885 10/29: Merge pull request #618 from kkatsuyuki/pre
From: |
Dmitry Gutov |
Subject: |
[elpa] master 51f3885 10/29: Merge pull request #618 from kkatsuyuki/preview-common |
Date: |
Tue, 28 Mar 2017 20:50:34 -0400 (EDT) |
branch: master
commit 51f38855c5633b19bebfd30f0b5ac3525b86806b
Merge: 6f2ae7f 5e49ddf
Author: Dmitry Gutov <address@hidden>
Commit: GitHub <address@hidden>
Merge pull request #618 from kkatsuyuki/preview-common
Preview the common part of completion candidates
---
company.el | 44 +++++++++++++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/company.el b/company.el
index 7fde671..d219b7d 100644
--- a/company.el
+++ b/company.el
@@ -188,14 +188,19 @@ attention to case differences."
(and (memq
'company-pseudo-tooltip-unless-just-one-frontend-with-delay value)
(memq 'company-pseudo-tooltip-unless-just-one-frontend
value)))
(user-error "Pseudo tooltip frontend cannot be used more than once"))
- (and (memq 'company-preview-if-just-one-frontend value)
- (memq 'company-preview-frontend value)
+ (and (or (and (memq 'company-preview-if-just-one-frontend value)
+ (memq 'company-preview-frontend value))
+ (and (memq 'company-preview-if-just-one-frontend value)
+ (memq 'company-preview-common-frontend value))
+ (and (memq 'company-preview-frontend value)
+ (memq 'company-preview-common-frontend value))
+ )
(user-error "Preview frontend cannot be used twice"))
(and (memq 'company-echo value)
(memq 'company-echo-metadata-frontend value)
(user-error "Echo area cannot be used twice"))
;; Preview must come last.
- (dolist (f '(company-preview-if-just-one-frontend
company-preview-frontend))
+ (dolist (f '(company-preview-if-just-one-frontend company-preview-frontend
company-preview-common-frontend))
(when (cdr (memq f value))
(setq value (append (delq f value) (list f)))))
(set variable value)))
@@ -237,6 +242,8 @@ The visualized data is stored in `company-prefix',
`company-candidates',
(const :tag "preview" company-preview-frontend)
(const :tag "preview, unique only"
company-preview-if-just-one-frontend)
+ (const :tag "preview, common"
+ company-preview-common-frontend)
(function :tag "custom function" nil))))
(defcustom company-tooltip-limit 10
@@ -2909,14 +2916,13 @@ Delay is determined by `company-tooltip-idle-delay'."
(defvar-local company-preview-overlay nil)
-(defun company-preview-show-at-point (pos)
+(defun company-preview-show-at-point (pos completion)
(company-preview-hide)
- (let ((completion (nth company-selection company-candidates)))
- (setq completion (copy-sequence (company--pre-render completion)))
- (font-lock-append-text-property 0 (length completion)
- 'face 'company-preview
- completion)
+ (setq completion (copy-sequence (company--pre-render completion)))
+ (font-lock-append-text-property 0 (length completion)
+ 'face 'company-preview
+ completion)
(font-lock-prepend-text-property 0 (length company-common)
'face 'company-preview-common
completion)
@@ -2953,7 +2959,7 @@ Delay is determined by `company-tooltip-idle-delay'."
(let ((ov company-preview-overlay))
(overlay-put ov (if ptf-workaround 'display 'after-string)
completion)
- (overlay-put ov 'window (selected-window))))))
+ (overlay-put ov 'window (selected-window)))))
(defun company-preview-hide ()
(when company-preview-overlay
@@ -2964,7 +2970,8 @@ Delay is determined by `company-tooltip-idle-delay'."
"`company-mode' frontend showing the selection as if it had been inserted."
(pcase command
(`pre-command (company-preview-hide))
- (`post-command (company-preview-show-at-point (point)))
+ (`post-command (company-preview-show-at-point (point)
+ (nth company-selection
company-candidates)))
(`hide (company-preview-hide))))
(defun company-preview-if-just-one-frontend (command)
@@ -2984,6 +2991,21 @@ Delay is determined by `company-tooltip-idle-delay'."
(when (overlayp company-pseudo-tooltip-overlay)
(not (overlay-get company-pseudo-tooltip-overlay 'invisible))))
+(defun company-preview-common--show-p ()
+ "Returns whether the preview of common can be showed or not"
+ (and company-common
+ (or (eq (company-call-backend 'ignore-case) 'keep-prefix)
+ (string-prefix-p company-prefix company-common))))
+
+(defun company-preview-common-frontend (command)
+ "`company-mode' frontend preview the common part of candidates."
+ (when (or (not (eq command 'post-command))
+ (company-preview-common--show-p))
+ (pcase command
+ (`pre-command (company-preview-hide))
+ (`post-command (company-preview-show-at-point (point) company-common))
+ (`hide (company-preview-hide)))))
+
;;; echo
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar-local company-echo-last-msg nil)
- [elpa] master cf98238 04/29: Preview the common part of completion candidates, (continued)
- [elpa] master cf98238 04/29: Preview the common part of completion candidates, Dmitry Gutov, 2017/03/28
- [elpa] master 40e2200 07/29: Preview func take the exact common part, Dmitry Gutov, 2017/03/28
- [elpa] master a2ec806 12/29: Use tramp-aware `start-file-process' to start completion process, Dmitry Gutov, 2017/03/28
- [elpa] master a4d0421 05/29: Modified for the original frontends to work, Dmitry Gutov, 2017/03/28
- [elpa] master 1c516df 01/29: Increase the minimum Emacs version dependency, Dmitry Gutov, 2017/03/28
- [elpa] master c494fc6 17/29: Fix a failing test, Dmitry Gutov, 2017/03/28
- [elpa] master ec12e27 27/29: Merge branch 'master' of github.com:company-mode/company-mode, Dmitry Gutov, 2017/03/28
- [elpa] master f149940 28/29: Release 0.9.3, Dmitry Gutov, 2017/03/28
- [elpa] master ce42fcf 23/29: Update copyright years, Dmitry Gutov, 2017/03/28
- [elpa] master 7bd93b8 15/29: Merge pull request #629 from juergenhoetzel/tramp-aware-clang, Dmitry Gutov, 2017/03/28
- [elpa] master 51f3885 10/29: Merge pull request #618 from kkatsuyuki/preview-common,
Dmitry Gutov <=
- [elpa] master b74f329 22/29: Track the changes in window width, Dmitry Gutov, 2017/03/28
- [elpa] master 0affd93 21/29: Fix the new test to work in Emacs 24, Dmitry Gutov, 2017/03/28
- [elpa] master f0ff54e 13/29: company-diag: Also show completions if prefix is a cons, Dmitry Gutov, 2017/03/28
- [elpa] master e19e53e 19/29: Remote the overriding-terminal-local-map check, Dmitry Gutov, 2017/03/28
- [elpa] master 90123e7 26/29: Don't use the trailing slash in .elpaignore, Dmitry Gutov, 2017/03/28
- [elpa] master f9c9e85 24/29: Bind message-truncate-lines around call to message in company-echo-show, Dmitry Gutov, 2017/03/28
- [elpa] master edc5d03 29/29: Merge commit 'f1499404163d8148e7a6303a8598f9c0f696d1cb' from company, Dmitry Gutov, 2017/03/28
- [elpa] master 5e49ddf 08/29: Take the exact candidate as an nonoptional arg, Dmitry Gutov, 2017/03/28
- [elpa] master 906deab 14/29: Merge pull request #625 from juergenhoetzel/company-diag-consp, Dmitry Gutov, 2017/03/28
- [elpa] master f932619 25/29: Merge pull request #656 from cpitclaudel/651-truncate-echo, Dmitry Gutov, 2017/03/28