AutoCompleteSources

This page contains contributed sources for AutoComplete.

Lisp:auto-complete-extension.el contains some sources by AndyStewart.

Lisp:ac-lilypond.el is my (finally working) contribution to LilyPond-mode sources. Redsonya

LaTeX and Unicode Math Input

ac-math provides three sources, one for LaTeX command completion, one for LaTeX math symbols and the another one for Unicode input of math characters. A comprehensive list of math symbols is implemented (more than 2500).

The author of ac-math moved to company-math.

Direct download for the former autocomplete math is ac-math.el (and for company math is company-math).

For Emacs24 and installing ac-math from Melpa (with list-packages), adding these lines in my init.el seems working with AucTeX already installed:

(require 'package)
(package-initialize)

(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)

(require 'ac-math) 
(add-to-list 'ac-modes 'latex-mode)   ; make auto-complete aware of `latex-mode`

 (defun ac-LaTeX-mode-setup () ; add ac-sources to default ac-sources
   (setq ac-sources
         (append '(ac-source-math-unicode ac-source-math-latex ac-source-latex-commands)
                 ac-sources))
   )
(add-hook 'LaTeX-mode-hook 'ac-LaTeX-mode-setup)
(global-auto-complete-mode t)
 
(setq ac-math-unicode-in-math-p t)

Auctex

auto-complete-auctex uses auctex’s parsing to give up-to-date, accurate completions of commands, environments, bib entries, and labels.

Python

Completion for python without rope or anything like that.

Works with python.el, python-mode.el etc.

ChrisPoole

Asynchronous completion for python - async version of Chris Poole’s excellent project. Works best with builtin python.el in Emacs 24.2+. Solves problem with slow autocompletions when using an inferior Python process.

Completion for python using PySmell.

(defvar ac-source-pysmell
  '((candidates
     . (lambda ()
         (require 'pysmell)
         (pysmell-get-all-completions))))
  "Source for PySmell")

(add-hook 'python-mode-hook
          (lambda ()             
            (set (make-local-variable 'ac-sources) (append ac-sources '(ac-source-pysmell)))))

TiagoCamargo

Completion for python using rope.

(ac-ropemacs-initialize)
(add-hook 'python-mode-hook
          (lambda ()
	    (add-to-list 'ac-sources 'ac-source-ropemacs)))

R mode completions

New ESSAuto-complete

And older Lisp:ac-R.el (0.1)

ac-R.el interferes with mode switching between LaTeX and R in noweb mode. This interference can be eliminated by commenting out

    (make-local-variable ac-ignore-case)

in the

    (add-hook 'ess-mode-hook

section near the end. I think this is harmless, but I don’t know lisp well enough to be sure. It works but if someone has a better solution I’d love to hear it.

make-local-variable should accept a quote instead var. otherwise, it would introduce error as “Symbol nil may not be buffer-local” and fail to start ESS process. Please modified

    (make-local-variable ac-ignore-case)

with

     (make-local-variable 'ac-ignore-case)

for both occurs.

      (require 'ac-R)

and then start R manullay which would active the autocomplete thing. and you may find it would be helpful to keeps lines below in your .emacs too.

     (require 'ess-eldoc) 
     (setq ess-eval-visibly-p nil) 

Have a dog day, cheers!

DynamicAbbreviations

Lisp:ac-dabbrev.el (0.0.4)

Semantic Autocompletion

This should get you started:

(defun ac-semantic-construct-candidates (tags)
   "Construct candidates from the list inside of tags."
   (apply 'append
		  (mapcar (lambda (tag)
					(if (listp tag)
						(let ((type (semantic-tag-type tag))
							  (class (semantic-tag-class tag))
							  (name (semantic-tag-name tag)))
						   (if (or (and (stringp type)
										(string= type "class"))
								   (eq class 'function)
								   (eq class 'variable))
							   (list (list name type class))))))
				  tags)))


(defvar ac-source-semantic-analysis nil)
(setq ac-source-semantic
  `((sigil . "b")
    (init . (lambda () (setq ac-source-semantic-analysis
                             (condition-case nil
                                             (ac-semantic-construct-candidates (semantic-fetch-tags))))))
    (candidates . (lambda ()
                    (if ac-source-semantic-analysis
                        (all-completions ac-target (mapcar 'car ac-source-semantic-analysis)))))))

--JonathanArkell

Org Mode

It’s a “snarf and barf” of the org-complete code, but it does the trick. Hopefully I will be able to provide a better version soon.

(defvar ac-org-candidates nil)
(defvar ac-org-pattern nil)
(defun ac-org-construct-candidates ()
  "Pabbrev source for org."
  (let* ((end (point))
	 (beg1 (save-excursion
		(skip-chars-backward (org-re "[:alnum:]_@"))
		(point)))
	 (beg (save-excursion
	       (skip-chars-backward "a-zA-Z0-9_:$")
	       (point)))
	 (confirm (lambda (x) (stringp (car x))))
	 (searchhead (equal (char-before beg) ?*))
	 (struct
	  (when (and (member (char-before beg1) '(?. ?<))
		     (setq a (assoc (buffer-substring beg1 (point))
				    org-structure-template-alist)))
		(org-complete-expand-structure-template (1- beg1) a)
		(throw 'exit t)))
	 (tag (and (equal (char-before beg1) ?:)
		   (equal (char-after (point-at-bol)) ?*)))
	 (prop (and (equal (char-before beg1) ?:)
		    (not (equal (char-after (point-at-bol)) ?*))))
	 (texp (equal (char-before beg) ?\\))
	 (link (equal (char-before beg) ?\[))
	 (opt (equal (buffer-substring (max (point-at-bol) (- beg 2))
				       beg)
		     "#+"))
	 (startup (string-match "^#\\+STARTUP:.*"
				(buffer-substring (point-at-bol) (point))))
	 (completion-ignore-case opt)
	 (type nil)
	 (tbl nil)
	 (table (cond
		 (opt
		  (setq type :opt)
		  (require 'org-exp)
		  (append
		   (mapcar
		    (lambda (x)
		      (string-match "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
		      (cons (match-string 2 x) (match-string 1 x)))
		    (org-split-string (org-get-current-options) "\n"))
		   (mapcar 'list org-additional-option-like-keywords)))
		 (startup
		  (setq type :startup)
		  org-startup-options)
		 (link (append org-link-abbrev-alist-local
			       org-link-abbrev-alist))
		 (texp
		  (setq type :tex)
		  org-html-entities)
		 ((string-match "\\`\\*+[ \t]+\\'"
				(buffer-substring (point-at-bol) beg))
		  (setq type :todo)
		  (mapcar 'list org-todo-keywords-1))
		 (searchhead
		  (setq type :searchhead)
		  (save-excursion
		   (goto-char (point-min))
		   (while (re-search-forward org-todo-line-regexp nil t)
			  (push (list
				 (org-make-org-heading-search-string
				  (match-string 3) t))
				tbl)))
		  tbl)
		 (tag (setq type :tag beg beg1)
		      (or org-tag-alist (org-get-buffer-tags)))
		 (prop (setq type :prop beg beg1)
		       (mapcar 'list (org-buffer-property-keys nil t t)))
		 (t (progn
		     (call-interactively org-completion-fallback-command)
		     (throw 'exit nil))))))
    (setq ac-org-pattern (buffer-substring-no-properties beg end))
    table))

(defvar ac-source-org nil)
(setq ac-source-org
      `((sigil . "o")
	(init . (lambda () (setq ac-org-candidates
				 (condition-case nil
						 (ac-org-construct-candidates)))))
	(candidates . (lambda ()
			(all-completions ac-target ac-org-candidates)))))


--JonathanArkell

Slime

An auto-complete source for Slime, providing lisp symbol completion and pop-up documentation is available.

--StevePurcell

Octave

An auto-complete source for Octave, providing Octave commands completion is available: Lisp:ac-octave.el

OCaml/Tuareg Mode

An auto-complete source for the caml and tuareg modes, gets symbols from caml-help.el in caml mode:

(defun ac-ocaml-candidates (prefix)
  "Candidates for OCaml auto-completion"
  (let ((candidates)
	(module-name 
	  (when (string-match "\\([A-Za-z_][A-Za-z0-9_']*\\)[.]" prefix)
	    (match-string 1 prefix))))
    (if module-name
        (iter (lambda (sym) (push (concat module-name "." sym) candidates))
              (ocaml-module-symbols (assoc module-name (ocaml-module-alist))))
      (iter
       (lambda (mod)
	 (iter (lambda (sym) (push sym candidates))
	       (ocaml-module-symbols mod)))
       (ocaml-visible-modules))
      (iter (lambda (mod) (push (car mod) candidates)) (ocaml-module-alist)))
    candidates))
        
(ac-define-source ocaml
  '((available . (require 'caml-help nil t))
    (candidates . (ac-ocaml-candidates ac-prefix))
    (prefix . "\\(?:[^A-Za-z0-9_.']\\|\\`\\)\\(\\(?:[A-Za-z_][A-Za-z0-9_']*[.]\\)?[A-Za-z0-9_']*\\)")
    (symbol . "s")))

etags

auto-complete-etags.el. Using TagsFile with auto-complete.

targzeta

Writing your own sources

The manual contains a tutorial on how to write your own sources.