]> code.delx.au - gnu-emacs-elpa/commitdiff
Added interactive form for back-ends.
authorNikolaj Schumacher <git@nschum.de>
Fri, 10 Apr 2009 08:28:03 +0000 (10:28 +0200)
committerNikolaj Schumacher <git@nschum.de>
Mon, 13 Apr 2009 08:24:19 +0000 (10:24 +0200)
company-css.el
company-dabbrev.el
company-elisp.el
company-etags.el
company-files.el
company-gtags.el
company-ispell.el
company-nxml.el
company-oddmuse.el
company-semantic.el
company.el

index 6d811b757b8e46041b2442977e96c8639b943386..23c2802bbf92702cabebdc0ec1a9eb9446c54eec 100644 (file)
@@ -271,9 +271,12 @@ Returns \"\" if no property found, but feasible at this position."
   "\\_<\\([[:alpha:]-]+\\):\\(?:[^};]*[[:space:]]+\\)?\\([^};]*\\_>\\|\\)\\="
   "A regular expression matching CSS tags")
 
+;;;###autoload
 (defun company-css (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for `css-mode'."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-css))
     ('prefix (and (eq major-mode 'css-mode)
                   (or (company-grab company-css-tag-regexp 1)
                       (company-grab company-css-pseudo-regexp 1)
index 2a7c1b475c9f80cb79e3708d356a0188a8e85e60..64e55a2ef6648c43034ee3d73bbf9fac363b5f24 100644 (file)
         (dabbrev--goto-start-of-abbrev)
         (buffer-substring-no-properties (point) end)))))
 
+;;;###autoload
 (defun company-dabbrev (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for `dabbrev-completion'."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-dabbrev))
     ('prefix (company-grab-dabbrev-prefix))
     ('candidates (let ((dabbrev-check-other-buffers))
                    (dabbrev--reset-global-variables)
index 112fd1113b2acb78ff44e29f08cd5de5b59b7773..5336d8339ebf154150cf533e89483c34d915c73d 100644 (file)
@@ -104,9 +104,12 @@ Functions are offered for completion only after ' and \(."
          (string-match ".*$" doc)
          (match-string 0 doc))))
 
+;;;###autoload
 (defun company-elisp (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for `emacs-lisp-mode'."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-elisp))
     ('prefix (and (eq (derived-mode-p 'emacs-lisp-mode) 'emacs-lisp-mode)
                   (company-grab-lisp-symbol)))
     ('candidates (company-elisp-candidates arg))
index 5f2280f77872074fb7c015de1fd7a5bc630304c8..b0104238ad38cb3e915aed3d4ef28846ec4fbbd5 100644 (file)
@@ -56,9 +56,12 @@ buffer automatically."
           (setq company-etags-buffer-table (company-etags-find-table))
         company-etags-buffer-table)))
 
+;;;###autoload
 (defun company-etags (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for etags."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-etags))
     ('prefix (and (memq major-mode company-etags-modes)
                   (not (company-in-string-or-comment))
                   (require 'etags nil t)
index 4ae2d07a496f1edb936d1272e25be84f8702c7a2..b81625a0d24092d5fddc326cc6634462b48798f0 100644 (file)
       (setq company-files-completion-cache (cons dir (nreverse candidates))))
     (cdr company-files-completion-cache)))
 
+;;;###autoload
 (defun company-files (command &optional arg &rest ignored)
   "a `company-mode' completion back-end existing file names."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-files))
     ('prefix (company-files-grab-existing-name))
     ('candidates (company-files-complete arg))
     ('location (cons (dired-noselect
index d3b429a3a40914325fd015e8953068a576d3321f..d27d103f06ef11809d91f4dce23aa1539dc0f632 100644 (file)
           (cons (expand-file-name (match-string 2))
                 (string-to-number (match-string 1)))))))
 
+;;;###autoload
 (defun company-gtags (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for GNU Global."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-gtags))
     ('prefix (and (memq major-mode company-gtags-modes)
                   (not (company-in-string-or-comment))
                   (company-gtags-available)
index 0bf68c26fe9548bade0825f2528abb69fae6595c..3096148c5b46f87676f7a745c2342c994fa4ef86 100644 (file)
@@ -41,9 +41,12 @@ If nil, use `ispell-complete-word-dict'."
        (setq company-ispell-available nil))))
   company-ispell-available)
 
+;;;###autoload
 (defun company-ispell (command &optional arg &rest ignored)
   "A `company-mode' completion back-end using ispell."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-ispell))
     ('prefix (when (company-ispell-available)
                (company-grab "\\<\\w+\\>")))
     ('candidates (lookup-words arg (or company-ispell-dictionary
index d9d30574ff29fc9366fe2ff625fe5b5668cc99aa..2855be69e2c4b344362478d5dcb7e351f70e1f2a 100644 (file)
                           (all-completions arg
                            (rng-match-possible-value-strings))))))))
 
+;;;###autoload
 (defun company-nxml (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for `nxml-mode'."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-nxml))
     ('prefix (or (company-nxml-tag 'prefix)
                  (company-nxml-attribute 'prefix)
                  (company-nxml-attribute-value 'prefix)))
index 67ab0d38e415dfd398cf6a1680789b53bb3ec849..6012a1bd923cfed401394f8fe3b7ff9aa41620f8 100644 (file)
     ('oddmuse-mode (with-no-warnings
                      (oddmuse-make-completion-table oddmuse-wiki)))))
 
+;;;###autoload
 (defun company-oddmuse (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for `oddmuse-mode'."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-oddmuse))
     ('prefix (let ((case-fold-search nil))
                (and (memq major-mode '(oddmuse-mode yaoddmuse-mode))
                     (looking-back company-oddmuse-link-regexp (point-at-bol))
index 9a9e038417631f7c5192f8bdb144360cde01df36..8ddcc199f1407923352d2d837dbe15a76a18e248 100644 (file)
           (context (semantic-analyze-current-context)))
       (all-completions prefix (semantic-ia-get-completions context (point))))))
 
+;;;###autoload
 (defun company-semantic (command &optional arg &rest ignored)
   "A `company-mode' completion back-end using CEDET Semantic."
+  (interactive (list 'interactive))
   (case command
+    ('interactive (company-begin-backend 'company-semantic))
     ('prefix (and (memq major-mode '(c-mode c++-mode jde-mode java-mode))
                   (not (company-in-string-or-comment))
                   (or (company-grab company-semantic-context-regexp 2) "")))
index 2ebaa66e8c1bc4e834891e0d71e0f817e5f781d2..d73503bfa237f488578fa7980b2ef4ef0c5ec60c 100644 (file)
@@ -65,6 +65,7 @@
 ;;
 ;;; Change Log:
 ;;
+;;    Back-ends are now interactive.  You can start them with M-x backend-name.
 ;;    Added `company-begin-with' for starting company from elisp-code.
 ;;    Added hooks.
 ;;    Added `company-require-match' and `company-auto-complete' options.
 (add-to-list 'debug-ignored-errors "^No \\(document\\|loc\\)ation available$")
 (add-to-list 'debug-ignored-errors "^Company not ")
 (add-to-list 'debug-ignored-errors "^No candidate number ")
+(add-to-list 'debug-ignored-errors "^Cannot complete at point$")
 
 (defgroup company nil
   "Extensible inline text completion mechanism"
@@ -267,7 +269,8 @@ user that choice with `company-require-match'.  Return value 'never overrides
 that option the other way around.
 
 The back-end should return nil for all commands it does not support or
-does not know about."
+does not know about.  It should also be callable interactively and use
+`company-begin-backend' to start itself in that case."
   :group 'company
   :type '(repeat (function :tag "function" nil)))
 
@@ -407,7 +410,8 @@ Completions can be searched with `company-search-candidates' or
 inactive, as well.
 
 The completion data is retrieved using `company-backends' and displayed using
-`company-frontends'.
+`company-frontends'.  If you want to start a specific back-end, call it
+interactively or use `company-begin-backend'.
 
 regular keymap (`company-mode-map'):
 
@@ -1159,6 +1163,11 @@ when the selection has been changed, the selected candidate is completed."
 
 (defun company-begin-backend (backend &optional callback)
   "Start a completion at point using BACKEND."
+  (interactive (let ((val (completing-read "Company back-end: "
+                                           obarray
+                                           'functionp nil "company-")))
+                 (when val
+                   (list (intern val)))))
   (when callback
     (setq company-callback
           `(lambda (completion)
@@ -1167,7 +1176,9 @@ when the selection has been changed, the selected candidate is completed."
     (add-hook 'company-completion-cancelled-hook 'company-remove-callback nil t)
     (add-hook 'company-completion-finished-hook company-callback nil t))
   (setq company-backend backend)
-  (company-manual-begin))
+  ;; Return non-nil if active.
+  (or (company-manual-begin)
+      (error "Cannot complete at point")))
 
 (defun company-begin-with (candidates
                            &optional prefix-length require-match callback)