]> rtime.felk.cvut.cz Git - sojka/company-mode.git/blob - company-oddmuse.el
Bumped version to 0.3.1.
[sojka/company-mode.git] / company-oddmuse.el
1 ;;; company-oddmuse.el --- a company-mode completion back-end for oddmuse-mode
2 ;;
3 ;; Copyright (C) 2009 Nikolaj Schumacher
4 ;;
5 ;; This file is part of company 0.3.1.
6 ;;
7 ;; This program is free software; you can redistribute it and/or
8 ;; modify it under the terms of the GNU General Public License
9 ;; as published by the Free Software Foundation; either version 2
10 ;; of the License, or (at your option) any later version.
11 ;;
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 (require 'company)
21 (eval-when 'compile (require 'yaooddmuse nil t))
22 (eval-when 'compile (require 'oddmuse nil t))
23 (eval-when-compile (require 'cl))
24
25 (defvar company-oddmuse-link-regexp
26   "\\(\\<[A-Z][[:alnum:]]*\\>\\)\\|\\[\\[\\([[:alnum:]]+\\>\\|\\)")
27
28 (defun company-oddmuse-get-page-table ()
29   (case major-mode
30     ('yaoddmuse-mode (with-no-warnings
31                        (yaoddmuse-get-pagename-table yaoddmuse-wikiname)))
32     ('oddmuse-mode (with-no-warnings
33                      (oddmuse-make-completion-table oddmuse-wiki)))))
34
35 ;;;###autoload
36 (defun company-oddmuse (command &optional arg &rest ignored)
37   "A `company-mode' completion back-end for `oddmuse-mode'."
38   (interactive (list 'interactive))
39   (case command
40     ('interactive (company-begin-backend 'company-oddmuse))
41     ('prefix (let ((case-fold-search nil))
42                (and (memq major-mode '(oddmuse-mode yaoddmuse-mode))
43                     (looking-back company-oddmuse-link-regexp (point-at-bol))
44                     (or (match-string 1)
45                         (match-string 2)))))
46     ('candidates (all-completions arg (company-oddmuse-get-page-table)))))
47
48 (provide 'company-oddmuse)
49 ;;; company-oddmuse.el ends here