Rocco Rutte:
[apps/madmutt.git] / doc / manual.sgml.head
index 5dcbb64..179aa7d 100644 (file)
@@ -1240,7 +1240,10 @@ For a complete list, see the <ref id="commands" name="command reference">.
 
 <!--}}}--> 
 
-<sect>Variable Expansion <!--{{{--> 
+<sect>Expansion within variables <!--{{{--> 
+
+  <p>Besides just assign static content to variables, there's plenty of
+  ways of adding external and more or less dynamic content.
 
   <sect1>Commands' Output 
 
@@ -1301,28 +1304,33 @@ set imap_home_namespace = $folder
 
     <p>Mutt-ng flexibly allows users to define their own variables. To
     avoid conflicts with the standard set and to prevent misleading
-    error messages, there's a reserved namespace for them. All
+    error messages, there's a reserved namespace for them: all
     user-defined variables must be prefixed with <tt/user_/ and can be
     used just like any ordinary configuration or environment
     variable.
 
-    <p>For example, to view the manual, users can either define three
+    <p>For example, to view the manual, users can either define two
     macros like the following
 
 <tscreen><verb>
 macro generic &lt;F1&gt; "!less -r /path/to/manual" "Show manual"
 macro pager &lt;F1&gt; "!less -r /path/to/manual" "Show manual"
-macro index &lt;F1&gt; "!less -r /path/to/manual" "Show manual"
 </verb></tscreen>
 
     <p>for <tt/generic/, <tt/pager/ and <tt/index/. The alternative is to
     define a custom variable like so:
 
 <tscreen><verb>
-set user_manualcmd = '!less -r /path/to_manual"
+set user_manualcmd = "!less -r /path/to_manual"
 macro generic &lt;F1&gt; "$user_manualcmd&lt;enter&gt;" "Show manual"
 macro pager &lt;F1&gt; "$user_manualcmd&lt;enter&gt;" "Show manual"
 macro index &lt;F1&gt; "$user_manualcmd&lt;enter&gt;" "Show manual"
+</verb></tscreen>
+
+    <p>to re-use the command sequence as in:
+
+<tscreen><verb>
+macro index &lt;F2&gt; "$user_manualcmd | grep '\^[ ]\\+~. '" "Show Patterns"
 </verb></tscreen>
 
     <p>Using this feature, arbitrary sequences can be defined once and
@@ -1330,6 +1338,113 @@ macro index &lt;F1&gt; "$user_manualcmd&lt;enter&gt;" "Show manual"
     include to save a variable's value at the beginning of macro
     sequence and restore it at end.
 
+    <p>When the variable is first defined, the first value it gets
+    assigned is also the initial value to which it can be reset using
+    the <tt/reset/ command.
+
+    <p>The complete removal is done via the <tt/unset/ keyword.
+
+    <p>After the following sequence:
+
+<tscreen><verb>
+set user_foo = 42
+set user_foo = 666
+</verb></tscreen>
+
+    <p>the variable <tt>$user_foo</tt> has a current value of 666 and an
+    initial of 42. The query
+
+<tscreen><verb>
+set ?user_foo
+</verb></tscreen>
+
+    <p>will show 666. After doing the reset via
+
+<tscreen><verb>
+reset user_foo
+</verb></tscreen>
+
+    <p>a following query will give 42 as the result. After unsetting it
+    via
+
+<tscreen><verb>
+unset user_foo
+</verb></tscreen>
+
+    <p>any query or operation (except the noted expansion within other
+    statements) will lead to an error message.
+
+  <sect1>Pre-Defined Variables 
+
+    <p>In order to allow users to share one setup over a number of
+    different machines without having to change its contents, there's a
+    number of pre-defined variables. These are prefixed with
+    <tt/muttng_/ and are read-only, i.e. they cannot be set, unset or
+    reset. The reference chapter lists all available variables.
+
+    <p><em> Please consult the local copy of your manual for their
+    values as they may differ from different manual sources.</em> Where
+    the manual is installed in can be queried (already using such a
+    variable) by running:
+
+<tscreen><verb>
+muttng -Q muttng_docdir
+</verb></tscreen>
+
+    <p>To extend the example for viewing the manual via self-defined
+    variables, it can be made more readable and more portable by
+    changing the real path in:
+
+<tscreen><verb>
+set user_manualcmd = '!less -r /path/to_manual'
+</verb></tscreen>
+
+    <p>to:
+
+<tscreen><verb>
+set user_manualcmd = "!less -r $muttng_docdir/manual.txt"
+</verb></tscreen>
+
+    <p>which works everywhere if a manual is installed.
+
+    <p>Please note that by the type of quoting, muttng determines when
+    to expand these values: when it finds double quotes, the value will
+    be expanded during reading the setup files but when it finds single
+    quotes, it'll expand it at runtime as needed.
+
+    <p>For example, the statement
+
+<tscreen><verb>
+folder-hook . "set user_current_folder = $muttng_folder_name"
+</verb></tscreen>
+
+    <p>will be already be translated to the following when reading the
+    startup files:
+
+<tscreen><verb>
+folder-hook . "set user_current_folder = some_folder"
+</verb></tscreen>
+
+    <p>with <tt/some_folder/ being the name of the first folder muttng
+    opens. On the contrary,
+
+<tscreen><verb>
+folder-hook . 'set user_current_folder = $muttng_folder_name'
+</verb></tscreen>
+
+    <p>will be executed at runtime because of the single quotes so that
+    <tt/user_current_folder/ will always have the value of the currently
+    opened folder.
+
+    <p>A more practical example is:
+
+<tscreen><verb>
+folder-hook . 'source ~/.mutt/score-$muttng_folder_name'
+</verb></tscreen>
+
+    <p>which can be used to source files containing score commands
+    depending on the folder the user enters.
+
   <sect1>Type Conversions 
 
     <p>A note about variable's types during conversion: internally
@@ -1342,7 +1457,7 @@ macro index &lt;F1&gt; "$user_manualcmd&lt;enter&gt;" "Show manual"
 <tscreen><verb>
 set read_inc = 100
 set folder = $read_inc
-set $read_inc = $folder
+set read_inc = $folder
 set user_magic_number = 42
 set folder = $user_magic_number
 </verb></tscreen>
@@ -2273,8 +2388,8 @@ message will ever get marked as read or deleted.
 and the <tt>&tilde;n</tt> pattern:
 
 <verb>
-color   black   yellow  "~n 10-"
-color   red     yellow  "~n 100-"</verb>
+color index  black   yellow  "~n 10-"
+color index  red     yellow  "~n 100-"</verb>
 
 <p>The rules above mark all messages with a score between 10 and 99
 with black and yellow, and messages with a score greater or equal
@@ -4676,6 +4791,7 @@ of the file ``&tilde;/run2.dat''.
 ~L EXPR         message is either originated or received by EXPR
 ~l              message is addressed to a known mailing list
 ~m [MIN]-[MAX]  message in the range MIN to MAX *)
+~M              multipart messages
 ~n [MIN]-[MAX]  messages with a score in the range MIN to MAX *)
 ~N              new messages
 ~O              old messages