mirror of
https://github.com/beyondx/Notes.git
synced 2026-02-07 04:13:59 +08:00
96 lines
3.1 KiB
Plaintext
96 lines
3.1 KiB
Plaintext
Content-Type: text/x-zim-wiki
|
|
Wiki-Format: zim 0.4
|
|
Creation-Date: 2012-01-10T15:37:35+08:00
|
|
|
|
====== ac-math ======
|
|
Created Tuesday 10 January 2012
|
|
|
|
Repo: svn checkout http://ac-math.googlecode.com/svn/trunk/ ac-math-read-only
|
|
Homepage: http://code.google.com/p/ac-math/
|
|
|
|
This is an add-on which defines three ac-sources for the__ auto-complete__ package:
|
|
|
|
* ac-source-latex-commands - input latex commands
|
|
* ac-source-math-latex - input math latex tags (active only in math environments)
|
|
* ac-source-math-unicode - input of unicode symbols (active everywhere except math environments)
|
|
|
|
To start the math completion by typing the prefix "\" key. To select the completion type RET.
|
|
|
|
Depending on the context the unicode symbol or latex \tag will be inserted.
|
|
|
|
===== Activation =====
|
|
|
|
You must have auto-complete package installed.
|
|
|
|
Download ac-math.el and put it into your load-path directory.
|
|
|
|
This is an example of how to activate the 'ac-math' in latex-mode:
|
|
|
|
(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)
|
|
|
|
If you are using 'flyspell' you would also like to activate the workaround:
|
|
|
|
(ac-flyspell-workaround)
|
|
|
|
===== Unicode Input =====
|
|
|
|
To use unicode in full force with LaTeX you will need XeTeX bundle.
|
|
|
|
By default unicode input (ac-source-math-unicode) is not activated in latex math environments. To activate it do
|
|
|
|
(setq ac-math-unicode-in-math-p t)
|
|
|
|
You can always call UNDO to insert LaTeX command instead of Unicode character. For instance \alp RET inserts the character, next undo reinserts \alpha. Thus, you might consider removing ac-source-math-latex altogether from the list of ac-sources to increase the completion speed:
|
|
|
|
(defun ac-latex-mode-setup ()
|
|
(setq ac-sources
|
|
(append '(ac-source-math-unicode ac-source-latex-commands)
|
|
ac-sources))
|
|
)
|
|
|
|
Unicode input is not restricted to LaTeX modes and is particularly useful in org-mode with it's powerful exporting facilities, or web development tools where unicode is crucial.
|
|
|
|
Suppose you want it for mode XXX:
|
|
|
|
(require 'ac-math)
|
|
|
|
(add-to-list 'ac-modes 'XXX-mode)
|
|
|
|
(defun ac-XXX-mode-setup ()
|
|
(add-to-list 'ac-sources 'ac-source-math-unicode)
|
|
)
|
|
|
|
(add-hook 'XXX-mode-hook 'ac-XXX-mode-setup)
|
|
|
|
===== Other Sources =====
|
|
|
|
Here is how to make the TaTeX completion work everywhere (default is only in math mode):
|
|
|
|
(defvar ac-source-math-latex-everywere
|
|
'((candidates . ac-math-symbols-latex)
|
|
(prefix . "\\\\\\(.*\\)")
|
|
(action . ac-math-action-latex)
|
|
(symbol . "l")
|
|
))
|
|
|
|
Here is how to make unicode completion work with prefix "%" (prefix is deleted automatically on completion):
|
|
|
|
(defvar ac-source-math-unicode-on-%
|
|
'((candidates . ac-math-symbols-unicode)
|
|
(prefix . "%\\(.*\\)")
|
|
(action . ac-math-action-unicode)
|
|
(symbol . "u")
|
|
))
|
|
|
|
Please let me know if you want anything different from above.
|