Action Button Link Types
The simplest way to create a new implicit link type (from which any number of buttons can be recognized within text) is to create an action button link type.
A call to the defal macro of the form:
(defal TYPE LINK-EXPR &optional DOC)
will create a Hyperbole action button link TYPE (an unquoted symbol) whose buttons always take the form of: <TYPE link-text> where link-text is substituted into LINK-EXPR as grouping 1 (wherever %s or \\1 is found) to form the link referent that is displayed for each button. Hyperbole automatically creates a doc string for the type but you can override this by providing an optional DOC string.
When the Action Key is pressed in a buffer between the start and end delimiters and the text in-between matches to TEXT-REGEXP, then the button is activated and does one of four things with LINK-EXPR:
- executes it as a brace-delimited key series;
- displays it in a web browser as a URL;
- displays it as a path (possibly with trailing colon-separated line and column numbers);
- invokes a function or action type of one argument, the button text sans the function name, to display it.
For example, if you use Python and have a ‘PYTHONPATH’ environment variable, then pressing {C-x C-e} eval-last-sexp after this expression:
(defal pylib "${PYTHONPATH}/%s")
defines a new action button link type called ’pylib’ whose buttons take the form of:
<pylib PYTHON-LIBRARY-FILENAME>
and display the associated Python libraries (typically Python source files). Optional colon separated line and column numbers may be given as well.
Therefore an Action Key press on:
<pylib string.py:5:7>
would display the source for string.py (wherever it is installed on your system) from the Python standard library with point on the fifth line at the seventh character.
See Implicit Button Link Types, for more flexible regular expression-based link type creation. See Programmatic Implicit Button Types, for the most general implicit button type creation.