107 lines
5.0 KiB
HTML
107 lines
5.0 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>Conditional Init Constructs - Debugging with GDB</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="Debugging with GDB">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="Readline-Init-File.html#Readline-Init-File" title="Readline Init File">
|
|
<link rel="prev" href="Readline-Init-File-Syntax.html#Readline-Init-File-Syntax" title="Readline Init File Syntax">
|
|
<link rel="next" href="Sample-Init-File.html#Sample-Init-File" title="Sample Init File">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
Copyright (C) 1988-2019 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with the
|
|
Invariant Sections being ``Free Software'' and ``Free Software Needs
|
|
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
|
|
and with the Back-Cover Texts as in (a) below.
|
|
|
|
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
|
|
this GNU Manual. Buying copies from GNU Press supports the FSF in
|
|
developing GNU and promoting software freedom.''
|
|
-->
|
|
<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; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="Conditional-Init-Constructs"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="Sample-Init-File.html#Sample-Init-File">Sample Init File</a>,
|
|
Previous: <a rel="previous" accesskey="p" href="Readline-Init-File-Syntax.html#Readline-Init-File-Syntax">Readline Init File Syntax</a>,
|
|
Up: <a rel="up" accesskey="u" href="Readline-Init-File.html#Readline-Init-File">Readline Init File</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h4 class="subsection">32.3.2 Conditional Init Constructs</h4>
|
|
|
|
<p>Readline implements a facility similar in spirit to the conditional
|
|
compilation features of the C preprocessor which allows key
|
|
bindings and variable settings to be performed as the result
|
|
of tests. There are four parser directives used.
|
|
|
|
<dl>
|
|
<dt><code>$if</code><dd>The <code>$if</code> construct allows bindings to be made based on the
|
|
editing mode, the terminal being used, or the application using
|
|
Readline. The text of the test extends to the end of the line;
|
|
no characters are required to isolate it.
|
|
|
|
<dl>
|
|
<dt><code>mode</code><dd>The <code>mode=</code> form of the <code>$if</code> directive is used to test
|
|
whether Readline is in <code>emacs</code> or <code>vi</code> mode.
|
|
This may be used in conjunction
|
|
with the ‘<samp><span class="samp">set keymap</span></samp>’ command, for instance, to set bindings in
|
|
the <code>emacs-standard</code> and <code>emacs-ctlx</code> keymaps only if
|
|
Readline is starting out in <code>emacs</code> mode.
|
|
|
|
<br><dt><code>term</code><dd>The <code>term=</code> form may be used to include terminal-specific
|
|
key bindings, perhaps to bind the key sequences output by the
|
|
terminal's function keys. The word on the right side of the
|
|
‘<samp><span class="samp">=</span></samp>’ is tested against both the full name of the terminal and
|
|
the portion of the terminal name before the first ‘<samp><span class="samp">-</span></samp>’. This
|
|
allows <code>sun</code> to match both <code>sun</code> and <code>sun-cmd</code>,
|
|
for instance.
|
|
|
|
<br><dt><code>application</code><dd>The <var>application</var> construct is used to include
|
|
application-specific settings. Each program using the Readline
|
|
library sets the <var>application name</var>, and you can test for
|
|
a particular value.
|
|
This could be used to bind key sequences to functions useful for
|
|
a specific program. For instance, the following command adds a
|
|
key sequence that quotes the current or previous word in Bash:
|
|
<pre class="example"> $if Bash
|
|
# Quote the current or previous word
|
|
"\C-xq": "\eb\"\ef\""
|
|
$endif
|
|
</pre>
|
|
</dl>
|
|
|
|
<br><dt><code>$endif</code><dd>This command, as seen in the previous example, terminates an
|
|
<code>$if</code> command.
|
|
|
|
<br><dt><code>$else</code><dd>Commands in this branch of the <code>$if</code> directive are executed if
|
|
the test fails.
|
|
|
|
<br><dt><code>$include</code><dd>This directive takes a single filename as an argument and reads commands
|
|
and bindings from that file.
|
|
For example, the following directive reads from <samp><span class="file">/etc/inputrc</span></samp>:
|
|
<pre class="example"> $include /etc/inputrc
|
|
</pre>
|
|
</dl>
|
|
|
|
</body></html>
|
|
|