Skip to content

Instantly share code, notes, and snippets.

@Philonous
Created June 6, 2014 19:02
Show Gist options
  • Select an option

  • Save Philonous/37cd0b0a09e918b55a01 to your computer and use it in GitHub Desktop.

Select an option

Save Philonous/37cd0b0a09e918b55a01 to your computer and use it in GitHub Desktop.
;;; ac-etags.el --- etags/ctags completion source for auto-complete
;; Copyright (C) 2013 by Syohei YOSHIDA
;; Author: Syohei YOSHIDA <syohex@gmail.com>
;; URL: https://github.com/syohex/emacs-ac-etags
;; Version: 0.06
;; Package-Requires: ((auto-complete "1.4"))
;; 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 3 of the License, or
;; (at your option) any later version.
;; This program 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; `ac-etags.el' is etags/ctags completion source for auto-complete.
;; Sample configuration
;;
;; If you change `requires' auto-complete source attribute
;;
;; (custom-set-variables
;; '(ac-etags-requires 1))
;;
;; (eval-after-load "etags"
;; '(progn
;; (ac-etags-setup)))
;;
;; (defun my/c-mode-common-hook ()
;; (add-to-list 'ac-sources 'ac-source-etags))
;;
;; (add-hook 'c-mode-common-hook 'my/c-mode-common-hook)
;;; Code:
(require 'auto-complete)
(require 'etags)
(defgroup ac-haskell-etags nil
"Auto completion with etags"
:group 'auto-complete)
(defcustom ac-haskell-etags-requires 3
"Minimum input for starting completion"
:type 'integer
:group 'ac-etags)
(defface ac-haskell-etags-candidate-face
'((t (:inherit ac-candidate-face :foreground "navy")))
"Face for etags candidate"
:group 'ac-etags)
(defface ac-haskell-etags-selection-face
'((t (:inherit ac-selection-face :background "navy")))
"Face for the etags selected candidate."
:group 'ac-etags)
(defun ac-haskell-etags-candidates ()
(let* ((prefix ac-prefix)
(tags-file-name (haskell-session-tags-filename (haskell-session)))
(tags-revert-without-query t))
(all-completions prefix (tags-completion-table))))
(ac-define-source haskell-etags
`((candidates . ac-haskell-etags-candidates)
(candidate-face . ac-haskell-etags-candidate-face)
(selection-face . ac-haskell-etags-selection-face)
(requires . ,ac-haskell-etags-requires)
(symbol . "s")))
(provide 'ac-haskell-etags)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment