5.6 Custom Expression Examination

The variety of possible variable and expression examination commands is endless (just look, for instance, at the keyword list to widget_info()). Rather than attempt to include them all, IDLWAVE provides two easy methods to customize your own commands, with a special mouse examine command, and two macros for generating your own examine key and mouse bindings.

The most powerful and flexible mouse examine command of all is available on C-S-mouse-2. Just as for all the other mouse examine commands, it permits click or drag expression selection, but instead of sending hard-coded commands to the shell, it pops-up a customizable selection list of examine functions to choose among, configured with the idlwave-shell-examine-alist variable6. This variable is a list of key-value pairs (an alist in Emacs parlance), where the key gives a name to be shown for the examine command, and the value is the command strings itself, in which the text ___ (three underscores) will be replaced by the selected expression before being sent to the shell. An example might be key Structure Help with value help,___,/STRUCTURE. In that case, you’d be prompted with Structure Help, which might send something like help,var,/STRUCTURE to the shell for output. idlwave-shell-examine-alist comes configured by default with a large list of examine commands, but you can easily customize it to add your own.

In addition to configuring the functions available to the pop-up mouse command, you can easily create your own customized bindings to inspect expressions using the two convenience macros idlwave-shell-examine and idlwave-shell-mouse-examine. These create keyboard or mouse-based custom inspections of variables, sharing all the same properties of the built-in examine commands. Both functions take a single string argument sharing the syntax of the idlwave-shell-examine-alist values, e.g.:

(add-hook 'idlwave-shell-mode-hook
          (lambda ()
            (idlwave-shell-define-key-both [s-down-mouse-2]
                                  "print, size(___,/DIMENSIONS)"))
            (idlwave-shell-define-key-both [f9] (idlwave-shell-examine
                                       "print, size(___,/DIMENSIONS)"))
            (idlwave-shell-define-key-both [f10] (idlwave-shell-examine
            (idlwave-shell-define-key-both [f11] (idlwave-shell-examine

Now pressing f9, or middle-mouse dragging with the SUPER key depressed, will print the dimensions of the nearby or highlighted expression. Pressing f10 will give the type string, and f11 will show the contents of a nearby structure. As you can see, the possibilities are only marginally finite.

User Option: idlwave-shell-examine-alist

An alist of examine commands in which the keys name the command and are displayed in the selection pop-up, and the values are custom IDL examine command strings to send, after all instances of ___ (three underscores) are replaced by the indicated expression.



In Electric Debug Mode (see Electric Debug Mode), the key x provides a single-character shortcut interface to the same examine functions for the expression at point or marked by the region.