(case command
('interactive (company-begin-backend 'company-elisp))
('prefix (and (eq (derived-mode-p 'emacs-lisp-mode) 'emacs-lisp-mode)
- (company-grab-lisp-symbol)))
+ (or (company-grab-lisp-symbol) 'stop)))
('candidates (company-elisp-candidates arg))
('meta (company-elisp-doc arg))
('doc-buffer (let ((symbol (intern arg)))
(not (company-in-string-or-comment))
(require 'etags nil t)
(company-etags-buffer-table)
- (company-grab-symbol)))
+ (or (company-grab-symbol) 'stop)))
('candidates (let ((tags-table-list (company-etags-buffer-table))
(completion-ignore-case nil))
(and (fboundp 'tags-completion-table)
('prefix (and company-gtags-executable
(memq major-mode company-gtags-modes)
(not (company-in-string-or-comment))
- (company-grab-symbol)))
+ (or (company-grab-symbol) 'stop)))
('candidates (company-gtags-fetch-tags arg))
('sorted t)
('location (company-gtags-location arg))))
('prefix (and (memq major-mode '(c-mode c++-mode jde-mode java-mode))
(semantic-active-p)
(not (company-in-string-or-comment))
- (company-grab-symbol)))
+ (or (company-grab-symbol) 'stop)))
('candidates (or (company-semantic-completions arg)
(company-semantic-completions-raw arg)))
('meta (funcall company-semantic-metadata-function
('prefix (and company-xcode-xcodeindex-executable
(not (company-in-string-or-comment))
(company-xcode-tags)
- (company-grab-symbol)))
+ (or (company-grab-symbol) 'stop)))
('candidates (let ((completion-ignore-case nil))
(all-completions arg (company-xcode-tags))))))
;;
;;; Change Log:
;;
+;; Added 'stop prefix to prevent dabbrev from completing inside of symbols.
;; Fixed issues with tabbar-mode and line-spacing.
;; Performance enhancements.
;;
'prefix: The back-end should return the text to be completed. It must be
text immediately before `point'. Returning nil passes control to the next
-back-end.
+back-end. The function should return 'stop if it should complete but cannot
+(e.g. if it is in the middle of a string).
'candidates: The second argument is the prefix to be completed. The
return value should be a list of candidates that start with the prefix.
(if (looking-at "\\_>")
(buffer-substring (point) (save-excursion (skip-syntax-backward "w_")
(point)))
- ""))
+ (unless (and (char-after) (memq (char-syntax (char-after)) '(?w ?_)))
+ "")))
(defun company-grab-word ()
(if (looking-at "\\>")
(buffer-substring (point) (save-excursion (skip-syntax-backward "w")
(point)))
- ""))
+ (unless (and (char-after) (eq (char-syntax (char-after)) ?w))
+ "")))
(defun company-in-string-or-comment ()
(let ((ppss (syntax-ppss)))
company-backends))
(when (and (functionp backend)
(setq prefix (funcall backend 'prefix)))
- (setq company-backend backend)
- (when (>= (length prefix) company-minimum-prefix-length)
+ (when (and (stringp prefix)
+ (>= (length prefix) company-minimum-prefix-length))
+ (setq company-backend backend
+ company-prefix prefix)
(let ((c (company-calculate-candidates prefix)))
;; t means complete/unique. We don't start, so no hooks.
(when (consp c)
- (setq company-prefix prefix)
(company-update-candidates c)
(run-hook-with-args 'company-completion-started-hook
(company-explicit-action-p))