4.8 Abbreviations

Special abbreviations exist to enable rapid entry of commonly used commands. Emacs abbreviations are expanded by typing text into the buffer and pressing SPC or RET. The special abbreviations used to insert code templates all start with a ‘\’ (the backslash), or, optionally, any other character set in idlwave-abbrev-start-char. IDLWAVE ensures that abbreviations are only expanded where they should be (i.e., not in a string or comment), and permits the point to be moved after an abbreviation expansion: very useful for positioning the mark inside of parentheses, etc.

Special abbreviations are pre-defined for code templates and other useful items. To visit the full list of abbreviations, use M-x idlwave-list-abbrevs.

Template abbreviations:

\prPROCEDURE template
\fuFUNCTION template
\cCASE statement template
\fFOR loop template
\rREPEAT loop template
\wWHILE loop template
\iIF statement template
\elifIF-ELSE statement template

String abbreviations:

\aparg_present()
\bbegin
\cbbyte()
\cccomplex()
\cddouble()
\cffloat()
\cllong()
\cocommon
\csstring()
\cxfix()
\eelse
\ecendcase
\eeendelse
\efendfor
\eiendif else if
\elendif else
\enendif
\erendrep
\esendswitch
\ewendwhile
\ggoto,
\hhelp,
\ikif keyword_set() then
\iapif arg_present() then
\ineif n_elements() eq 0 then
\innif n_elements() ne 0 then
\kkeyword_set()
\nn_elements()
\npn_params()
\oion_ioerror,
\oropenr,
\ouopenu,
\owopenw,
\pprint,
\ptplot,
\pvptr_valid()
\reread,
\rfreadf,
\rtreturn
\rureadu,
\ssize()
\scstrcompress()
\slstrlowcase()
\smstrmid()
\snstrlen()
\spstrpos()
\srstrtrim()
\ststrput()
\sustrupcase()
\tthen
\uuntil
\wcwidget_control,
\wiwidget_info()
\wuwriteu,

You can easily add your own abbreviations or override existing abbrevs with define-abbrev in your mode hook, using the convenience function idlwave-define-abbrev:

(add-hook 'idlwave-mode-hook
          (lambda ()
            (idlwave-define-abbrev "wb" "widget_base()"
                     (idlwave-keyword-abbrev 1))
            (idlwave-define-abbrev "ine" "IF N_Elements() EQ 0 THEN"
                     (idlwave-keyword-abbrev 11))))

Notice how the abbreviation (here wb) and its expansion (widget_base()) are given as arguments, and the single argument to idlwave-keyword-abbrev (here 1) specifies how far back to move the point upon expansion (in this example, to put it between the parentheses).

The abbreviations are expanded in upper or lower case, depending upon the variables idlwave-abbrev-change-case and, for reserved word templates, idlwave-reserved-word-upcase (see Case Changes).

User Option: idlwave-abbrev-start-char ("\")

A single character string used to start abbreviations in abbrev mode. Beware of common characters which might naturally occur in sequence with abbreviation strings.

User Option: idlwave-abbrev-move (t)

Non-nil means the abbrev hook can move point, e.g., to end up between the parentheses of a function call.