File: expand.el.html

This package defines abbrevs which expand into structured constructs for certain languages. The construct is indented for you, and contains slots for you to fill in other text.

These abbrevs expand only at the end of a line and when not in a comment or a string.

  Look at the Sample: section for emacs-lisp, perl and c expand lists.
For example for c-mode, you could declare your abbrev table with :

(defconst c-expand-list
  '(("if" "if () {\\n \\n} else {\\n \\n}" (5 10 21))
    ("ifn" "if () {}" (5 8))
    ("uns" "unsigned ")
    ("for" "for(; ; ) {\\n\\n}" (5 7 9 13))
    ("switch" "switch () {\\n\\n}" (9 13))
    ("case" "case :\\n\\nbreak;\\n" (6 8 16))
    ("do" "do {\\n\\n} while ();" (6 16))
    ("while" "while () {\\n\\n}" (8 12))
    ("default" "default:\\n\\nbreak;" 10)
    ("main" "int\\nmain(int argc, char * argv[])\\n{\\n\\n}\\n" 37))
  "Expansions for C mode")

  and enter Abbrev mode with the following hook :

(add-hook 'c-mode-hook
(lambda ()
(expand-add-abbrevs c-mode-abbrev-table c-expand-list)
(abbrev-mode 1)))

  you can also init some post-process hooks :

(add-hook 'expand-expand-hook 'indent-according-to-mode)
(add-hook 'expand-jump-hook 'indent-according-to-mode)

Remarks:

  Many thanks to Heddy Boubaker <boubaker@cenatls.cena.dgac.fr>,
                 Jerome Santini <santini@chambord.univ-orleans.fr>,
                 Jari Aalto <jaalto@tre.tele.nokia.fi>.

Defined variables (10)

expand-c-sample-expand-listExpansions for C mode. See ‘expand-add-abbrevs’.
expand-expand-hookHooks run when an abbrev made by ‘expand-add-abbrevs’ is expanded.
expand-indexIndex of the last marker used in ‘expand-pos’.
expand-jump-hookHooks run by ‘expand-jump-to-previous-slot’ and ‘expand-jump-to-next-slot’.
expand-listTemporary variable used by the Expand package.
expand-load-hookHooks run when ‘expand.el’ is loaded.
expand-pointEnd of the expanded region.
expand-posIf non-nil, store a vector with position markers defined by the last expansion.
expand-sample-lisp-mode-expand-listExpansions for Lisp mode. See ‘expand-add-abbrevs’.
expand-sample-perl-mode-expand-listExpansions for Perl mode. See ‘expand-add-abbrevs’.

Defined functions (11)

expand-abbrev-from-expand(WORD)
expand-abbrev-hook()
expand-add-abbrev(TABLE ABBREV EXPANSION ARG &rest REST)
expand-add-abbrevs(TABLE ABBREVS)
expand-c-for-skeleton(&optional STR ARG)
expand-clear-markers()
expand-in-literal()
expand-jump-to-next-slot()
expand-jump-to-previous-slot()
expand-list-to-markers(L)
expand-previous-word()

Defined faces (0)