Next: , Previous: Code Templates, Up: The IDLWAVE Major Mode

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:

\pr PROCEDURE template
\fu FUNCTION template
\c CASE statement template
\f FOR loop template
\r REPEAT loop template
\w WHILE loop template
\i IF statement template
\elif IF-ELSE statement template

String abbreviations:

\ap arg_present()
\b begin
\cb byte()
\cc complex()
\cd double()
\cf float()
\cl long()
\co common
\cs string()
\cx fix()
\e else
\ec endcase
\ee endelse
\ef endfor
\ei endif else if
\el endif else
\en endif
\er endrep
\es endswitch
\ew endwhile
\g goto,
\h help,
\ik if keyword_set() then
\iap if arg_present() then
\ine if n_elements() eq 0 then
\inn if n_elements() ne 0 then
\k keyword_set()
\n n_elements()
\np n_params()
\oi on_ioerror,
\or openr,
\ou openu,
\ow openw,
\p print,
\pt plot,
\pv ptr_valid()
\re read,
\rf readf,
\rt return
\ru readu,
\s size()
\sc strcompress()
\sl strlowcase()
\sm strmid()
\sn strlen()
\sp strpos()
\sr strtrim()
\st strput()
\su strupcase()
\t then
\u until
\wc widget_control,
\wi widget_info()
\wu writeu,

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.