X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/a8ce5598c5067f19f2cba9cac77d5d6390c7f1fe..8cc284ee4eea8f8a1d870f91585f7a1827b40129:/company-etags.el diff --git a/company-etags.el b/company-etags.el index a4c2f1d41..ef53213ba 100644 --- a/company-etags.el +++ b/company-etags.el @@ -1,45 +1,72 @@ -;;; company-etags.el --- a company-mode completion back-end for etags -;; -;; Copyright (C) 2009-2010 Nikolaj Schumacher -;; -;; This file is part of company 0.5. -;; -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License -;; as published by the Free Software Foundation; either version 2 -;; of the License, or (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, +;;; company-etags.el --- company-mode completion backend for etags + +;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. -;; + ;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . +;; along with GNU Emacs. If not, see . + + +;;; Commentary: +;; + +;;; Code: (require 'company) +(require 'cl-lib) (require 'etags) +(defgroup company-etags nil + "Completion backend for etags." + :group 'company) + (defcustom company-etags-use-main-table-list t - "*Always search `tags-table-list' if set. + "Always search `tags-table-list' if set. If this is disabled, `company-etags' will try to find the one table for each buffer automatically." - :group 'company-mode :type '(choice (const :tag "off" nil) (const :tag "on" t))) -(defvar company-etags-modes '(c-mode objc-mode c++-mode java-mode jde-mode - pascal-mode perl-mode python-mode)) +(defcustom company-etags-ignore-case nil + "Non-nil to ignore case in completion candidates." + :type 'boolean + :package-version '(company . "0.7.3")) + +(defcustom company-etags-everywhere nil + "Non-nil to offer completions in comments and strings. +Set it to t or to a list of major modes." + :type '(choice (const :tag "Off" nil) + (const :tag "Any supported mode" t) + (repeat :tag "Some major modes" + (symbol :tag "Major mode"))) + :package-version '(company . "0.9.0")) + +(defvar company-etags-modes '(prog-mode c-mode objc-mode c++-mode java-mode + jde-mode pascal-mode perl-mode python-mode)) -(defvar company-etags-buffer-table 'unknown) -(make-variable-buffer-local 'company-etags-buffer-table) +(defvar-local company-etags-buffer-table 'unknown) (defun company-etags-find-table () - (let ((file (company-locate-dominating-file (or buffer-file-name - default-directory) - "TAGS"))) - (when file - (list (expand-file-name file))))) + (let ((file (expand-file-name + "TAGS" + (locate-dominating-file (or buffer-file-name + default-directory) + "TAGS")))) + (when (and file (file-regular-p file)) + (list file)))) (defun company-etags-buffer-table () (or (and company-etags-use-main-table-list tags-table-list) @@ -49,7 +76,7 @@ buffer automatically." (defun company-etags--candidates (prefix) (let ((tags-table-list (company-etags-buffer-table)) - (completion-ignore-case nil)) + (completion-ignore-case company-etags-ignore-case)) (and (or tags-file-name tags-table-list) (fboundp 'tags-completion-table) (save-excursion @@ -58,12 +85,14 @@ buffer automatically." ;;;###autoload (defun company-etags (command &optional arg &rest ignored) - "A `company-mode' completion back-end for etags." + "`company-mode' completion backend for etags." (interactive (list 'interactive)) - (case command + (cl-case command (interactive (company-begin-backend 'company-etags)) - (prefix (and (memq major-mode company-etags-modes) - (not (company-in-string-or-comment)) + (prefix (and (apply #'derived-mode-p company-etags-modes) + (or (eq t company-etags-everywhere) + (apply #'derived-mode-p company-etags-everywhere) + (not (company-in-string-or-comment))) (company-etags-buffer-table) (or (company-grab-symbol) 'stop))) (candidates (company-etags--candidates arg)) @@ -72,7 +101,7 @@ buffer automatically." (save-excursion (let ((buffer (find-tag-noselect arg))) (cons buffer (with-current-buffer buffer (point)))))))) - (sorted t))) + (ignore-case company-etags-ignore-case))) (provide 'company-etags) ;;; company-etags.el ends here