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