/usr/share/doc/gnat-gps/html/Defining-text-aliases.html is in gnat-gps-doc 5.0-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | <html lang="en">
<head>
<title>Defining text aliases - Using the GNAT Programming Studio</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using the GNAT Programming Studio">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files" title="Customizing through XML and Python files">
<link rel="prev" href="Adding-support-for-new-languages.html#Adding-support-for-new-languages" title="Adding support for new languages">
<link rel="next" href="Defining-project-attributes.html#Defining-project-attributes" title="Defining project attributes">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 2002-2010 AdaCore.
This document is free; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This document is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see `http://www.gnu.org/licenses/'.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
pre.smallexample {background-color:rgb(240,240,240);
font-family: courier new,courier,fixed;
font-size: 14px;
margin: 0px 40px 0px 40px;
border-width: 1px 2px 2px 1px;
border-top-style: dotted;
border-left-style: dotted;
border-right-style: solid;
border-bottom-style: solid;
border-color: black;}
code {color:black;
font-family: courier new,courier,fixed;
font-size: 14px;}
body {font-family: arial,helvetica,sans-serif;
font-size: 16px;
max-width: 800px;
text-align: justify}
samp {font-family: courier new,courier,fixed;
font-size: 14px}
--></style>
</head>
<body>
<div class="node">
<a name="Defining-text-aliases"></a>
<p>
Next: <a rel="next" accesskey="n" href="Defining-project-attributes.html#Defining-project-attributes">Defining project attributes</a>,
Previous: <a rel="previous" accesskey="p" href="Adding-support-for-new-languages.html#Adding-support-for-new-languages">Adding support for new languages</a>,
Up: <a rel="up" accesskey="u" href="Customizing-through-XML-and-Python-files.html#Customizing-through-XML-and-Python-files">Customizing through XML and Python files</a>
<hr>
</div>
<h4 class="subsection">16.5.13 Defining text aliases</h4>
<p><a name="index-aliases-825"></a><a name="index-g_t_003calias_003e-826"></a><!-- -->
<p class="noindent">GPS provides a mechanism known as <b>aliases</b>. These are defined
through the menu <code>Edit->Aliases</code>.
<p>Each alias has a name, which is generally a short string of characters.
When you type them in any textual entry in GPS (generally a source editor, but
also entry fields for instance in the file selector), and then press the special
activation key (by default <control-o>, controlled by a
preference), this name is removed from the source editor, and replaced
by the text you have associated with it.
<p>Alias names may be composed of any character except newlines, but must start
with a letter. GPS will jump to the start of each word before the current
cursor position, and if the characters between this word start and the
cursor position is an alias name (the comparison is case insensitive), this
alias is expanded.
<p><a name="index-screen-shot-827"></a><img src="aliases.jpg" alt="aliases.jpg">
<p>The alias editor is divided into three main parts: on the left side, the list of
currently defined aliases is shown. Clicking on any of them will
display the replacement text for this alias. If you click again the
selected alias, GPS displays a text entry which you can use to rename
an existing alias. Alias names must start with a letter. A check
button at the bottom selects whether the read-only aliases
(i.e. system-wide aliases) should be displayed.
<p>The second part is the expansion text for the alias, at the bottom
right corner. This replacement text can used multiple lines, and
contain some special text that act as a special replacement. These
special texts are highlighted in a different color. You can insert
these special entities either by typing them, or by right-clicking in
the editor, and select the entity in the contextual menu.
<p>The following special entities are currently defined:
<dl>
<dt><code>%_</code><dd>This is the position where the cursor should be put once the
replacement text has been inserted in the editor.
<br><dt><code>%(name)</code><dd>This is the name of a parameter. <i>name</i> can be any string you want,
excluding closing parenthesis. See below for more information on
parameters.
<br><dt><code>%D</code><dd>This is the current date, in ISO format. The year is displayed first,
then the month and the day
<br><dt><code>%H</code><dd>This is the current time (hour, minutes and seconds)
<br><dt><code>%l</code><dd>If the expansion of the alias is done in a source editor, this is the
line on which the cursor is when pressing <control-o>.
<br><dt><code>%c</code><dd>This is similar to <i>%l</i>, except it returns the current column.
<br><dt><code>%f</code><dd>If the expansion is done in a source editor, this is the name of the
current file (its base name only, this doesn't include the directory)
<br><dt><code>%d</code><dd>If the expansion is done in a source editor, this is the directory in
which the current file is
<br><dt><code>%p</code><dd>If the expansion is done in a source editor, this is the base name of
the project file to which the file belongs.
<br><dt><code>%P</code><dd>If the expansion is done in a source editor, this is the full path
name to the project file (directory and base name).
<br><dt><code>%O</code><dd>Used for recursive aliases expansion. This special character will expand
the text seen before it in the current alias, after replacement of the
parameters and possibly other recursive expansions. This is similar to pressing
<control-o> (or any key you have defined for alias expansion) in the
expanded form of the alias.
<br><dt><code>%%</code><dd>Inserts a percent sign as part of the expanded text
<p>You cannot expand an alias recursively when already expanding that alias. For
instance, if the alias expansion for <i>procedure</i> contains <i>procedure%O</i>,
the inner procedure will not be expanded.
</dl>
<p>The indentation as set in the expansion of the alias is preserved when
the alias is expanded. All the lines will be indented the same amount
to the right as the alias name. You can override this default behavior
by selecting the check button <code>Indent source editor after expansion</code>.
In this case, GPS will replace the name of the alias by its expansion,
and then automatically recompute the position of each line with its
internal indentation engine, as if the text had been inserted manually.
<p>The third part of the aliases editor, at the top right corner, lists
the parameters for the currently selected alias. Any time you insert a
<i>%(name)</i> string in the expansion text, GPS automatically detects
there is a new parameter reference (or an old reference has changed
name or was removed); the list of parameters is automatically updated
to show the current list.
<p>Each parameters has three attributes:
<dl>
<dt><b>name</b><dd>This is the name you use in the expansion text of the alias in the
<i>%(name)</i> special entity.
<br><dt><b>Environment</b><dd>This specifies whether the default value of the parameter comes from
the list of environment variables set before GPS was started.
<br><dt><b>default value</b><dd>Instead of getting the default value from the environment variable,
you can also specify a fixed text.
Clicking on the initial value of the currently selected variable opens
a text entry which you can use to edit this default value.
</dl>
<p>When an alias that contains parameters is expanded, GPS will first
display a dialog to ask for the value of the parameters. You can
interactively enter this value, which replaces all the <i>%(name)</i>
entities in the expansion text.
<h4 class="subsection">16.5.14 Aliases files</h4>
<p class="noindent">The customization files described earlier can also contain aliases
definition. This can be used for instance to create project or system wide
aliases. All the customization files will be parsed to look for aliases
definition.
<p>All these customization files are considered as read-only by GPS,
and therefore cannot be edited through the graphical interface. It is
possible to override some of the aliases in your own custom files.
<p>There is one specific files, which must contain only aliases definition. This
is the file <samp><span class="file">$HOME/.gps/aliases</span></samp>. Whenever you edit aliases graphically,
or create new ones, they are stored in this file, which is the only one that
GPS will ever modify automatically.
<p>The system files are loaded first, and aliases defined there can be
overridden by the user-defined file.
<p>These files are standard XML customization files.
The specific XML tag to use is <i><alias></i>, one per new alias.
The following example contains a standalone customization file, but you might
wish to merge the <i><alias></i> tag in any other customization file.
<p>The following tags are available:
<dl>
<dt><code>alias</code><dd>This indicates the start of a new alias. It has one mandatory
attribute, <code>name</code>, which the text to type in the source editor
before pressing <control-o>.
It has one optional attribute, <code>indent</code>, which, if set to <i>true</i>,
indicate that GPS should recompute the indentation of the newly inserted
paragraph after the expansion.
<br><dt><code>param</code><dd>These are children of the <code>alias</code> node. There is one per
parameter of the alias. They have one mandatory attribute,
<code>name</code>, which is the name to type between <i>%(name)</i> in the
alias expansion text.
<p>They have one optional attribute, <code>environment</code>, which indicates
the default value must be read from the environment variables if it is
set to true.
<p>These tags contain text, which is the default value for the parameter.
<br><dt><code>text</code><dd>This is a child of the <code>alias</code> node, whose value is the
replacement text for the alias.
</dl>
<p>Here is an example of an alias file:
<pre class="smallexample"> <?xml version="1.0"?>
<Aliases>
<alias name="proc" >
<param name="p" >Proc1</param>
<param environment="true" name="env" />
<text>procedure %(p) is
%(env)%_
end %(p);</text>
</alias>
</Aliases>
</pre>
<!-- -->
</body></html>
|