about summary refs log tree commit diff
path: root/Doc/Zsh/contrib.yo
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2013-01-24 20:28:20 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2013-01-24 20:28:20 +0000
commit6265394d6bc431b9e972aaeccc29582a5694f842 (patch)
treedaca27ab09af3fca5606bde1d0237b275b4eac4f /Doc/Zsh/contrib.yo
parent44757a653cb547ae7b556e8c92629d296d3c1f12 (diff)
downloadzsh-6265394d6bc431b9e972aaeccc29582a5694f842.tar.gz
zsh-6265394d6bc431b9e972aaeccc29582a5694f842.tar.xz
zsh-6265394d6bc431b9e972aaeccc29582a5694f842.zip
users/17608: use function to modify currrent command line argument
Diffstat (limited to 'Doc/Zsh/contrib.yo')
-rw-r--r--Doc/Zsh/contrib.yo25
1 files changed, 22 insertions, 3 deletions
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 8dbc095fd..00f70a2bf 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -2477,15 +2477,22 @@ See the function tt(modify-current-argument), described below, for
 an example of how to call this function.
 )
 tindex(modify-current-argument)
-item(tt(modify-current-argument) var(expr-using-)tt($ARG))(
+item(tt(modify-current-argument) [ var(expr-using-)tt($ARG) | var(func) ])(
 This function provides a simple method of allowing user-defined widgets
 to modify the command line argument under the cursor (or immediately to the
-left of the cursor if the cursor is between arguments).  The argument
-should be an expression which when evaluated operates on the shell
+left of the cursor if the cursor is between arguments).
+
+The argument can be an expression which when evaluated operates on the shell
 parameter tt(ARG), which will have been set to the command line argument
 under the cursor.  The expression should be suitably quoted to prevent
 it being evaluated too early.
 
+Alternatively, if the argument does not contain the string tt(ARG), it
+is assumed to be a shell function, to which the current command line
+argument is passed as the only argument.  The function should set the
+variable tt(REPLY) to the new value for the command line argument.
+If the function returns non-zero status, so does the calling function.
+
 For example, a user-defined widget containing the following code
 converts the characters in the argument under the cursor into all upper
 case:
@@ -2497,6 +2504,18 @@ or one of the styles of quotes), and replaces it with single quoting
 throughout:
 
 example(modify-current-argument '${(qq)${(Q)ARG}}')
+
+The following performs directory expansion on the command line
+argument and replaces it by the absolute path:
+
+example(expand-dir() {
+  REPLY=${~1}
+  REPLY=${REPLY:a}
+}
+modify-current-argument expand-dir)
+
+In practice the function tt(expand-dir) would probably not be defined
+within the widget where tt(modify-current-argument) is called.
 )
 enditem()