Keywords: xcoral

Next: Compiling and searching within Up: Using Smac Previous: Using Smac

# Eval expression

First type the Ctrl-x Ctrl-e 'eval expression' command. In the mini-buffer you can enter expressions which are C expressions. Typically the following forms are valid:

In this context, the Tab key can be used to expand the Smac functions, user functions and variables names. If the mini-buffer is empty, a complete list of these is displayed in the message box.

Attention Don't forget the semicolon ';' at the end of the C expression you want to evaluate, otherwise you will get a parser error line 0: syntax error message.

- insert_char (190);

  Inserts the argument at the current position. The function insert_char is one of the built-in functions available in Smac to drive the editor. This example shows how to insert a special character (via its ASCII code).

- set_mode_font ("Latex", "9x15bold");

  This example shows how to change font in Latex mode.

- cmd_shell ( "date `|` awk `'{`print `$4}'` ");

  cmd_shell is a built-in editor function. The argument is executed in a sub-shell and the result is inserted at the current position.

- select_window(new_window());read_file(file_select());

  Opens a new text window, selects it, selects a file from a file-selector and loads it. Obviously it is easier to use the Window menu, but this example shows the Smac facilities to interpret built-in editor functions through an eval expression command.

- key_def ("C-mode", "`^`xe", "goto_end_of_file" );

  In C-mode, binds goto_end_of_file function to Ctrl-x e. The second argument syntax (key_binding), can be:

      	    "c"     --> key.
      	    "^[c"   --> Esc key.
      	    "^[^c"  --> Esc Ctrl key.
      	    "^c"    --> Ctrl-key.
      	    "^xc"   --> Ctrl-x key.
      	    "^x^c"  --> Ctrl-x Ctrl-key.

  where ``c'` is any character except ``^'`. Furthermore ``^^'` appoints the character ``^'` (so `^x^^` is `Ctrl-x ^`), ``^ '` and ``^@'` appoint the character null (code 0).

  It is also possible to bind keysym keys such as Home:

      	    "k"    --> key.
      	    "^[k"  --> Esc key.
      	    "^xk"  --> Ctrl-x key.

  where ``k'` is a keysym name (see §7.3.11 page ).