Index: doc/user-guide/misc.xml
===================================================================
--- doc/user-guide/misc.xml (revision 5e98ff07af5a8d89b7c813f55dfd0972fca11297)
+++ doc/user-guide/misc.xml (revision 6f0ea5781ea4bd50324ee81758a9fd72ef780fcd)
@@ -204,10 +204,29 @@
-One modifier is currently available: %-@variable will remove all characters from the first @ in the string.
-
-
-
-In all cases, invalid characters (like spaces) will be stripped. Depending
-on your locale settings, characters with accents will be converted to ASCII.
+Invalid characters (like spaces) will always be stripped. Depending on your
+locale settings, characters with accents will be converted to ASCII.
+
+
+
+See set nick_format2 for some more information.
+
+
+
+
+
+Nickname formatting - modifiers
+
+
+Two modifiers ares currently available: You can include only the first few
+characters of a variable by putting a number right after the %. For example,
+[%3group]%-@nick will include only the first three
+characters of the group name in the nick.
+
+
+
+Also, you can truncate variables from a certain character using
+the -modifier. For example, you may want to leave out
+everything after the @. %-@handle will expand to
+everything in the handle up to the first @.
Index: nick.c
===================================================================
--- nick.c (revision 5e98ff07af5a8d89b7c813f55dfd0972fca11297)
+++ nick.c (revision 6f0ea5781ea4bd50324ee81758a9fd72ef780fcd)
@@ -117,4 +117,5 @@
{
char *part, chop = '\0', *asc = NULL;
+ int len = MAX_NICK_LENGTH;
if( *fmt != '%' )
@@ -135,4 +136,11 @@
return NULL;
fmt += 2;
+ }
+ else if( isdigit( *fmt ) )
+ {
+ len = 0;
+ /* Grab a number. */
+ while( isdigit( *fmt ) )
+ len = len * 10 + ( *(fmt++) - '0' );
}
else if( g_strncasecmp( fmt, "nick", 4 ) == 0 )
@@ -188,5 +196,5 @@
g_string_append_c( ret, '_' );
- while( part && *part && *part != chop )
+ while( part && *part && *part != chop && len > 0 )
{
if( strchr( nick_lc_chars, *part ) ||
@@ -195,4 +203,5 @@
part ++;
+ len --;
}
g_free( asc );