[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 21/35: Define and use `company-grab-symbol-cons'
From: |
Dmitry Gutov |
Subject: |
[elpa] 21/35: Define and use `company-grab-symbol-cons' |
Date: |
Sat, 19 Apr 2014 10:12:18 +0000 |
dgutov pushed a commit to branch master
in repository elpa.
commit bc1b047226164ef40834b4e30f7767dcd2e56c39
Author: Dmitry Gutov <address@hidden>
Date: Fri Apr 4 06:17:24 2014 +0300
Define and use `company-grab-symbol-cons'
Closes #88
---
NEWS.md | 1 +
company-clang.el | 14 ++++----------
company.el | 11 +++++++++++
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index fae1a92..d0203d8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
## Next
+* New function `company-grab-symbol-cons`.
* `company-clang` fetches completion candidates asynchronously.
* Added support for asynchronous back-ends (experimental).
* Support for back-end command `crop` dropped (it was never documented).
diff --git a/company-clang.el b/company-clang.el
index 42a5487..4c7b0c7 100644
--- a/company-clang.el
+++ b/company-clang.el
@@ -237,15 +237,9 @@ or automatically through a custom
`company-clang-prefix-guesser'."
(company-clang--build-complete-args (- (point) (length prefix)))))
(defun company-clang--prefix ()
- (let ((symbol (company-grab-symbol)))
- (if symbol
- (if (and company-clang-begin-after-member-access
- (save-excursion
- (forward-char (- (length symbol)))
- (looking-back "\\.\\|->\\|::" (- (point) 2))))
- (cons symbol t)
- symbol)
- 'stop)))
+ (if company-clang-begin-after-member-access
+ (company-grab-symbol-cons "\\.\\|->\\|::" 2)
+ (company-grab-symbol)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -311,7 +305,7 @@ passed via standard input."
buffer-file-name
company-clang-executable
(not (company-in-string-or-comment))
- (company-clang--prefix)))
+ (or (company-clang--prefix) 'stop)))
(candidates (cons :async
(lambda (cb) (company-clang--candidates arg cb))))
(meta (company-clang--meta arg))
diff --git a/company.el b/company.el
index 8f29d4d..24b00cb 100644
--- a/company.el
+++ b/company.el
@@ -784,6 +784,17 @@ means that `company-mode' is always turned on except in
`message-mode' buffers."
(unless (and (char-after) (eq (char-syntax (char-after)) ?w))
"")))
+(defun company-grab-symbol-cons (idle-begin-after-re &optional max-len)
+ (let ((symbol (company-grab-symbol)))
+ (when symbol
+ (save-excursion
+ (forward-char (- (length symbol)))
+ (if (looking-back idle-begin-after-re (if max-len
+ (- (point) max-len)
+ (line-beginning-position)))
+ (cons symbol t)
+ symbol)))))
+
(defun company-in-string-or-comment ()
(let ((ppss (syntax-ppss)))
(or (car (setq ppss (nthcdr 3 ppss)))
- [elpa] 09/35: Add Package-Requires header, (continued)
- [elpa] 09/35: Add Package-Requires header, Dmitry Gutov, 2014/04/19
- [elpa] 13/35: Make company-clang work asynchronously, Dmitry Gutov, 2014/04/19
- [elpa] 12/35: Remove `company-locate-dominating-file', Dmitry Gutov, 2014/04/19
- [elpa] 16/35: Update NEWS, Dmitry Gutov, 2014/04/19
- [elpa] 17/35: company--merge-async: tweak, Dmitry Gutov, 2014/04/19
- [elpa] 19/35: Move company-elisp require, Dmitry Gutov, 2014/04/19
- [elpa] 14/35: Implement async operation for grouped backends, Dmitry Gutov, 2014/04/19
- [elpa] 18/35: company--force-sync: change calling convention, Dmitry Gutov, 2014/04/19
- [elpa] 20/35: Change the summary, Dmitry Gutov, 2014/04/19
- [elpa] 22/35: company--multi-backend-adapter-candidates: bind backend locally, Dmitry Gutov, 2014/04/19
- [elpa] 21/35: Define and use `company-grab-symbol-cons',
Dmitry Gutov <=
- [elpa] 23/35: Introduce `company-tooltip-minimum-width', Dmitry Gutov, 2014/04/19
- [elpa] 25/35: Make version string compatible with Emacs < 24.4, Dmitry Gutov, 2014/04/19
- [elpa] 24/35: Lower company-idle-delay, Dmitry Gutov, 2014/04/19
- [elpa] 06/35: Drop Emacs 23 compatibility, Dmitry Gutov, 2014/04/19
- [elpa] 11/35: Initial support for asynchonous backends (#62), Dmitry Gutov, 2014/04/19
- [elpa] 26/35: Merge pull request #100 from bbatsov/version-fix, Dmitry Gutov, 2014/04/19
- [elpa] 27/35: Try to use the more up-to-date snapshot packages, Dmitry Gutov, 2014/04/19
- [elpa] 29/35: Merge pull request #101 from bbatsov/master, Dmitry Gutov, 2014/04/19
- [elpa] 15/35: Merge branch 'clang-async', Dmitry Gutov, 2014/04/19
- [elpa] 30/35: Fix the test breakage (probably), Dmitry Gutov, 2014/04/19