1 ;;; company-oddmuse.el --- company-mode completion backend for oddmuse-mode
3 ;; Copyright (C) 2009-2011, 2013-2016, 2022 Free Software Foundation, Inc.
5 ;; Author: Nikolaj Schumacher
7 ;; This file is part of GNU Emacs.
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.
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.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
30 (eval-when-compile (require 'yaoddmuse nil t))
31 (eval-when-compile (require 'oddmuse nil t))
33 (defvar company-oddmuse-link-regexp
34 "\\(\\<[A-Z][[:alnum:]]*\\>\\)\\|\\[\\[\\([[:alnum:]]+\\>\\|\\)")
36 (defun company-oddmuse-get-page-table ()
38 (yaoddmuse-mode (with-no-warnings
39 (yaoddmuse-get-pagename-table yaoddmuse-wikiname)))
40 (oddmuse-mode (with-no-warnings
41 (oddmuse-make-completion-table oddmuse-wiki)))))
44 (defun company-oddmuse (command &optional arg &rest ignored)
45 "`company-mode' completion backend for `oddmuse-mode'."
46 (interactive (list 'interactive))
48 (interactive (company-begin-backend 'company-oddmuse))
49 (prefix (let ((case-fold-search nil))
50 (and (memq major-mode '(oddmuse-mode yaoddmuse-mode))
51 (looking-back company-oddmuse-link-regexp (line-beginning-position))
54 (candidates (all-completions arg (company-oddmuse-get-page-table)))))
56 (provide 'company-oddmuse)
57 ;;; company-oddmuse.el ends here