[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX] A package to write LaTeX files with help of package aucTeX and

From: Paul . Lennon
Subject: [AUCTeX] A package to write LaTeX files with help of package aucTeX and auto-complete
Date: Thu, 30 Jun 2011 22:32:51 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110428 Fedora/3.1.10-1.fc15 Thunderbird/3.1.10 ThunderBrowse/3.3.5


        This is a package writen with the help of aucTeX and
auto-complete packages.

        It is very useful for me.

        Happy TeXing,



;;; auto-complete-latex  --- auto-complete for LaTeX auctex

;; Copyright (C) 2010 Guy Yeterian gyecmonet <@> free <dot> fr

;; Author: Guy Yeterian
;; Maintainer: the author
;; Created: 07 Aug 2010
;; Version: 1.0
;; version  1.8 Jun 2011
;; Keywords: auctex auto-complete

;; 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 1, 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
;; GNU General Public License for more details.

;; A copy of the GNU General Public License can be obtained from this
;; program's author (send electronic mail to
;; address@hidden) or from the Free Software Foundation,
;; Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

;; LCD Archive Entry:
;; ac-latex|rockymyroot|address@hidden
;; |auto-complete for LaTeX auctex
;; |$Date$|$Revision$|~/packages/ac-latex.el

;;; Installation
;; This is a very useful package to write LaTeX documents with aucTeX and auto-complete
;;  To use this package you must install aucTeX and auto-complete packages.
;;  Just add to the .emacs file:
;;     (autoload 'ac-latex-setup "auto-complete-latex" "ac and aucTeX" t)
;;     (add-hook 'LaTeX-mode-hook (lambda() (ac-latex-setup)))
;; when you type 'enu' you must see all (even yours) laTeX-environments and TeX-macros that
;;  begins with this words.

;;; Commentary:
;;  Free softwards are great and make me happy.
;;  Many thanks to Richard Stallman for free softward concept and for emacs
;;  Many thanks for the aucTeX group mainteneers
;;  Many thanks for auto-complete author Tomohiro Matsuyama.

;;; Change log:
;; $Log$

;;; Code:
(provide 'auto-complete-latex)

(require 'tex)
(require 'latex)

  (require 'auto-complete)
  (require 'popup-pos-tip))

(defface ac-latex-candidate-face
  '((t (:background "LemonChiffon1" :foreground "black")))
  "Face for LaTeX candidate."
  :group 'LaTeX)

(defface ac-latex-selection-face
  '((t (:background "PaleGreen1" :foreground "black")))
  "Face for the LaTeX selected candidate."
  :group 'LaTeX)

;; add LaTeX-mode to ac-modes
(setq ac-modes (append '(LaTeX-mode latex-mode) ac-modes))

(defvar candidate nil
  "Just for the Elisp compiler not complain")

;;; TeX-macros source and action

(defun ac-source-latex-macros ()
   (let ((comlist (if TeX-symbol-list
                     (mapcar (lambda (x)
                       (if (listp x)
                           (car x)
                       (mapcar 'car TeX-symbol-list)))))
    (all-completions ac-prefix comlist))) ;; ac-latex-source-commandes

;;; action on macros
(defun action-auctex-macro ()
  (re-search-backward candidate)
  (delete-region (match-beginning 0) (match-end 0))
  (TeX-insert-macro candidate)
  ) ;; action-auctex-commande

(ac-define-source  LaTeX-macros
  '((init . TeX-symbol-list)
    (candidates . ac-source-latex-macros)
    (document . TeXdoc)
    ;(depends . '(LaTeX-mode  auto-complete-mode))
    (action . action-auctex-macro)
    (requires . 2)
    (candidate-face . ac-latex-candidate-face)
    (selection-face . ac-latex-selection-face)
    (symbol . "m")));; LaTeX-macros

;; end TeX macros

;;;  LaTeX-environmants source and action

(defun ac-source-latex-environments ()
    (let ((envlist (mapcar 'car LaTeX-environment-list))

    (all-completions ac-prefix envlist))
  ) ;; ac-latex-source-environments

;; action pour les environments
(defun action-auctex-environment ()
  (re-search-backward candidate)
  (delete-region (match-beginning 0) (match-end 0))
  (LaTeX-environment-menu candidate)
  ) ;; action-auctex-environment

(ac-define-source LaTeX-environments
  '((init . LaTeX-environment-list)
    (candidates . ac-source-latex-environments)
    (document .  TeXdoc)
    (action .  action-auctex-environment)
    (requires . 2)
    (selection-face . ac-latex-selection-face)
    (candidate-face . ac-latex-candidate-face)
    (symbol . "e")))

;;; end LaTeX environments source and action

;; some help if you work with TeXlive
;; you can change it if too long. F1 give help immediateley
;; this work with TeXlive
(setq ac-quick-help-delay 5.2)

;; work with TeXlive
(defun TeXdoc (item)
  (TeX-doc item))
 ;; end of TeXdoc

;; setup  you call ac-latex-setup with LaTeX-mode-hook
(defun ac-latex-setup ()
  (setq ac-sources (append
                      '(ac-source-LaTeX-macros ac-source-LaTeX-environments)

(provide 'auto-complete-latex)
;;;  end of auto-complete-package

reply via email to

[Prev in Thread] Current Thread [Next in Thread]