]> code.delx.au - gnu-emacs-elpa/blobdiff - company-oddmuse.el
Added company-elisp-functions-only-in-context option.
[gnu-emacs-elpa] / company-oddmuse.el
index d9602dd99e17d81d425cdca485cd5f3228d52bbd..901318e3b838bd9a55aca049baa52f2cbd96514d 100644 (file)
@@ -2,7 +2,7 @@
 ;;
 ;; Copyright (C) 2009 Nikolaj Schumacher
 ;;
-;; This file is part of company.
+;; This file is part of company 0.2.
 ;;
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License
 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 (require 'company)
-(require 'oddmuse)
+(eval-when 'compile (require 'yaooddmuse nil t))
+(eval-when 'compile (require 'oddmuse nil t))
 (eval-when-compile (require 'cl))
 
 (defvar company-oddmuse-link-regexp
   "\\(\\<[A-Z][[:alnum:]]*\\>\\)\\|\\[\\[\\([[:alnum:]]+\\>\\|\\)")
 
+(defun company-oddmuse-get-page-table ()
+  (case major-mode
+    ('yaoddmuse-mode (with-no-warnings
+                       (yaoddmuse-get-pagename-table yaoddmuse-wikiname)))
+    ('oddmuse-mode (with-no-warnings
+                     (oddmuse-make-completion-table oddmuse-wiki)))))
+
 (defun company-oddmuse (command &optional arg &rest ignored)
+  "A `company-mode' completion back-end for `oddmuse-mode'."
   (case command
     ('prefix (let ((case-fold-search nil))
-               (and (eq major-mode 'oddmuse-mode)
+               (and (memq major-mode '(oddmuse-mode yaoddmuse-mode))
                     (looking-back company-oddmuse-link-regexp (point-at-bol))
                     (or (match-string 1)
                         (match-string 2)))))
-    ('candidates (all-completions arg
-                                  (oddmuse-make-completion-table oddmuse-wiki)))
-    ))
+    ('candidates (all-completions arg (company-oddmuse-get-page-table)))))
 
 (provide 'company-oddmuse)
 ;;; company-oddmuse.el ends here