]> code.delx.au - gnu-emacs-elpa/commitdiff
Support 'stop return value for 'prefix command.
authorNikolaj Schumacher <git@nschum.de>
Wed, 15 Apr 2009 07:59:51 +0000 (09:59 +0200)
committerNikolaj Schumacher <git@nschum.de>
Wed, 15 Apr 2009 11:38:39 +0000 (13:38 +0200)
company-elisp.el
company-etags.el
company-gtags.el
company-semantic.el
company-xcode.el
company.el

index 5c7a11ecba22e9c22ca6dd31efa4b871cd082643..a501efef86f890cece45dfd6f90b9abb36b82166 100644 (file)
@@ -109,7 +109,7 @@ Functions are offered for completion only after ' and \(."
   (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)))
index a2fa1310b1bea76de86d9e8ccae30c58fab397e6..fcf7856d850144a76fb4de47d4204eb647502d4b 100644 (file)
@@ -63,7 +63,7 @@ buffer automatically."
                   (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)
index b4dedeb2ee7699a6e23a1f66300f62a7c1c9a83d..083bc777a23e13136669d3a335031bc9867b007b 100644 (file)
@@ -60,7 +60,7 @@
     ('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))))
index 93b5441f632d440b8a34fb0208c8899ab8b09b65..90d3d3ff7e3f6b6f53ec16b86785a70a742c76da 100644 (file)
@@ -74,7 +74,7 @@
     ('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
index 8e068ade17edc048a54a78cdc78f8ee368d47cdf..725f3f81fc215749072acba3d23217f94889e339 100644 (file)
@@ -101,7 +101,7 @@ valid in most contexts."
     ('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))))))
 
index 598bf56c8499920dce986d662b4eab93a2f5935a..c4bd200e641c963e452cdfbc19df1939ab5cb5cf 100644 (file)
@@ -69,6 +69,7 @@
 ;;
 ;;; Change Log:
 ;;
+;;    Added 'stop prefix to prevent dabbrev from completing inside of symbols.
 ;;    Fixed issues with tabbar-mode and line-spacing.
 ;;    Performance enhancements.
 ;;
@@ -249,7 +250,8 @@ of the following:
 
 '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.
@@ -526,13 +528,15 @@ keymap during active completions (`company-active-map'):
   (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)))
@@ -775,12 +779,13 @@ keymap during active completions (`company-active-map'):
                          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))