summaryrefslogtreecommitdiff
path: root/doc/en
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-01-22 13:48:42 +0100
committerSebastien Helleu <flashcode@flashtux.org>2012-01-22 13:48:42 +0100
commit5f6df8021b73c1da27161d238cd35180cce29727 (patch)
treedcb79e7db0ee27e94c8b433c68a5e2b2781a7c9f /doc/en
parent51491469e5c6311ccd9dd10830f62fd436af754f (diff)
downloadweechat-5f6df8021b73c1da27161d238cd35180cce29727.zip
core: add support of flags in regular expressions and highlight options, add irc options to customize/disable default nick highlight (task #11128)
New functions in C plugin API: - string_regex_flags - string_regcomp New irc options: - irc.look.highlight_server - irc.look.highlight_channel - irc.look.highlight_pv Regex flags are supported in following options/commands: - option weechat.look.highlight - option weechat.look.highlight_regex - options irc.look.highlight_{server|channel|pv} - option relay.network.allowed_ips - core command /filter - irc command /list - irc command /ignore - rmodifier command /rmodifier
Diffstat (limited to 'doc/en')
-rw-r--r--doc/en/autogen/user/irc_commands.txt4
-rw-r--r--doc/en/autogen/user/irc_options.txt15
-rw-r--r--doc/en/autogen/user/relay_options.txt2
-rw-r--r--doc/en/autogen/user/rmodifier_commands.txt2
-rw-r--r--doc/en/autogen/user/weechat_commands.txt1
-rw-r--r--doc/en/autogen/user/weechat_options.txt4
-rw-r--r--doc/en/weechat_plugin_api.en.txt165
7 files changed, 154 insertions, 39 deletions
diff --git a/doc/en/autogen/user/irc_commands.txt b/doc/en/autogen/user/irc_commands.txt
index 42316c583..3d13c4263 100644
--- a/doc/en/autogen/user/irc_commands.txt
+++ b/doc/en/autogen/user/irc_commands.txt
@@ -172,6 +172,8 @@ reason: reason for quit
server: internal server name where ignore is working
channel: channel name where ignore is working
+Note: the regular expression can start with "(?-i)" to become case sensitive.
+
Examples:
ignore nick "toto" everywhere:
/ignore add toto
@@ -272,7 +274,7 @@ server_mask: list of servers must match this mask
channel: channel to list
server: server name
- regex: regular expression used to filter results
+ regex: regular expression used to filter results (case insensitive, can start by "(?-i)" to become case sensitive)
Examples:
list all channels on server (can be very slow on large networks):
diff --git a/doc/en/autogen/user/irc_options.txt b/doc/en/autogen/user/irc_options.txt
index d2cfb689b..c8b91b08e 100644
--- a/doc/en/autogen/user/irc_options.txt
+++ b/doc/en/autogen/user/irc_options.txt
@@ -158,6 +158,21 @@
** type: boolean
** values: on, off (default value: `on`)
+* [[option_irc.look.highlight_channel]] *irc.look.highlight_channel*
+** description: `comma separated list of words to highlight in channel buffers (case insensitive, use "(?-i)" at beginning of words to make them case sensitive; special variables $nick, $channel and $server are replaced by their value), these words are added to buffer local variable "highlight_words" only when buffer is created (it does not affect current buffers), an empty string disables default highlight on nick, examples: "$nick", "(?-i)$nick"`
+** type: string
+** values: any string (default value: `"$nick"`)
+
+* [[option_irc.look.highlight_pv]] *irc.look.highlight_pv*
+** description: `comma separated list of words to highlight in private buffers (case insensitive, use "(?-i)" at beginning of words to make them case sensitive; special variables $nick, $channel and $server are replaced by their value), these words are added to buffer local variable "highlight_words" only when buffer is created (it does not affect current buffers), an empty string disables default highlight on nick, examples: "$nick", "(?-i)$nick"`
+** type: string
+** values: any string (default value: `"$nick"`)
+
+* [[option_irc.look.highlight_server]] *irc.look.highlight_server*
+** description: `comma separated list of words to highlight in server buffers (case insensitive, use "(?-i)" at beginning of words to make them case sensitive; special variables $nick, $channel and $server are replaced by their value), these words are added to buffer local variable "highlight_words" only when buffer is created (it does not affect current buffers), an empty string disables default highlight on nick, examples: "$nick", "(?-i)$nick"`
+** type: string
+** values: any string (default value: `"$nick"`)
+
* [[option_irc.look.highlight_tags]] *irc.look.highlight_tags*
** description: `comma separated list of tags for messages that may produce highlight (usually any message from another user, not server messages,..)`
** type: string
diff --git a/doc/en/autogen/user/relay_options.txt b/doc/en/autogen/user/relay_options.txt
index e11887a88..a3cf672c9 100644
--- a/doc/en/autogen/user/relay_options.txt
+++ b/doc/en/autogen/user/relay_options.txt
@@ -49,7 +49,7 @@
** values: 0 .. 65535 (default value: `256`)
* [[option_relay.network.allowed_ips]] *relay.network.allowed_ips*
-** description: `regular expression with IPs allowed to use relay, example: "^(123.45.67.89|192.160.*)$"`
+** description: `regular expression with IPs allowed to use relay (case insensitive, use "(?-i)" at beginning to make it case sensitive), example: "^(123.45.67.89|192.160.*)$"`
** type: string
** values: any string (default value: `""`)
diff --git a/doc/en/autogen/user/rmodifier_commands.txt b/doc/en/autogen/user/rmodifier_commands.txt
index e9cf8cd65..18906369e 100644
--- a/doc/en/autogen/user/rmodifier_commands.txt
+++ b/doc/en/autogen/user/rmodifier_commands.txt
@@ -12,7 +12,7 @@ listdefault: list default rmodifiers
name: name of rmodifier
modifiers: comma separated list of modifiers
groups: action on groups found: comma separated list of groups (from 1 to 9) with optional "*" after number to hide group
- regex: regular expression
+ regex: regular expression (case insensitive, can start by "(?-i)" to become case sensitive)
del: delete a rmodifier
-all: delete all rmodifiers
default: restore default rmodifiers
diff --git a/doc/en/autogen/user/weechat_commands.txt b/doc/en/autogen/user/weechat_commands.txt
index 1c223fb79..f04f5bdc0 100644
--- a/doc/en/autogen/user/weechat_commands.txt
+++ b/doc/en/autogen/user/weechat_commands.txt
@@ -219,6 +219,7 @@ disable: disable filters
- use '\t' to separate prefix from message, special chars like '|' must be escaped: '\|'
- if regex starts with '!', then matching result is reversed (use '\!' to start with '!')
- two regular expressions are created: one for prefix and one for message
+ - regex are case insensitive, they can start by "(?-i)" to become case sensitive
The default key alt+'=' toggles filtering on/off.
diff --git a/doc/en/autogen/user/weechat_options.txt b/doc/en/autogen/user/weechat_options.txt
index f35a1fa24..128f5a2ac 100644
--- a/doc/en/autogen/user/weechat_options.txt
+++ b/doc/en/autogen/user/weechat_options.txt
@@ -449,12 +449,12 @@
** values: on, off (default value: `off`)
* [[option_weechat.look.highlight]] *weechat.look.highlight*
-** description: `comma separated list of words to highlight (case insensitive comparison, words may begin or end with "*" for partial match)`
+** description: `comma separated list of words to highlight; case insensitive comparison (use "(?-i)" at beginning of words to make them case sensitive), words may begin or end with "*" for partial match; example: "test,(?-i)*toto*,flash*"`
** type: string
** values: any string (default value: `""`)
* [[option_weechat.look.highlight_regex]] *weechat.look.highlight_regex*
-** description: `regular expression used to check if a message has highlight or not, at least one match in string must be surrounded by word chars (alphanumeric, "-", "_" or "|"), regular expression is case sensitive, example: "FlashCode|flashy"`
+** description: `regular expression used to check if a message has highlight or not, at least one match in string must be surrounded by word chars (alphanumeric, "-", "_" or "|"), regular expression is case insensitive (use "(?-i)" at beginning to make it case sensitive), examples: "flashcode|flashy", "(?-i)FlashCode|flashy"`
** type: string
** values: any string (default value: `""`)
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index a61157f24..cfb4fc994 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -983,33 +983,35 @@ free (str);
[NOTE]
This function is not available in scripting API.
-weechat_string_has_highlight
+weechat_string_mask_to_regex
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Check if a string has one or more highlights, using list of highlight words.
+Return a regex, built with a mask, where only special char is "`*`". All other
+special chars for regex are escaped.
Prototype:
[source,C]
----------------------------------------
-int weechat_string_has_highlight (const char *string,
- const char highlight_words);
+char *weechat_string_mask_to_regex (const char *mask);
----------------------------------------
Arguments:
-* 'string': string
-* 'highlight_words': list of highlight words, separated by comma
+* 'mask': mask
Return value:
-* 1 if string has one or more highlights, otherwise 0
+* regular expression, as string (must be freed by calling "free" after use)
C example:
[source,C]
----------------------------------------
-int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
+char *str_regex = weechat_string_mask_to_regex ("test*mask");
+/* result: "test.*mask" */
+/* ... */
+free (str_regex);
----------------------------------------
Script (Python):
@@ -1017,32 +1019,126 @@ Script (Python):
[source,python]
----------------------------------------
# prototype
-highlight = weechat.string_has_highlight(string, highlight_words)
+regex = weechat.string_mask_to_regex(mask)
# example
-highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
+regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
----------------------------------------
-weechat_string_has_highlight_regex
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+weechat_string_regex_flags
+^^^^^^^^^^^^^^^^^^^^^^^^^^
-_New in version 0.3.4._
+_New in version 0.3.7._
-Check if a string has one or more highlights, using a regular expression.
-For at least one match of regular expression on string, it must be surrounded
-by word chars (alphanumeric character, "-", "_" or "|").
+Get pointer on string after flags and return mask with flags to compile regular
+expression.
Prototype:
[source,C]
----------------------------------------
-int weechat_string_has_highlight_regex (const char *string, const char *regex);
+const char *weechat_string_regex_flags (const char *regex, int default_flags, int *flags)
----------------------------------------
Arguments:
-* 'string': string
* 'regex': regular expression
+* 'default_flags': combination of following values (see `man regcomp`):
+** REG_EXTENDED
+** REG_ICASE
+** REG_NEWLINE
+** REG_NOSUB
+* 'flags': pointer value is set with flags used in regular expression (default
+ flags + flags set in regular expression)
+
+Flags must be at beginning of regular expression. Format is:
+"(?eins-eins)string".
+
+Allowed flags are:
+
+* 'e': POSIX extended regular expression ('REG_EXTENDED')
+* 'i': case insensitive ('REG_ICASE')
+* 'n': match-any-character operators don't match a newline ('REG_NEWLINE')
+* 's': support for substring addressing of matches is not required ('REG_NOSUB')
+
+Return value:
+
+* pointer in 'regex', after flags
+
+C example:
+
+[source,C]
+----------------------------------------
+const char *regex = "(?i)test";
+int flags;
+const char *ptr_regex = weechat_string_regex_flags (regex, REG_EXTENDED, &flags);
+/* ptr_regex == "test", flags == REG_EXTENDED | REG_ICASE */
+----------------------------------------
+
+[NOTE]
+This function is not available in scripting API.
+
+weechat_string_regcomp
+^^^^^^^^^^^^^^^^^^^^^^
+
+_New in version 0.3.7._
+
+Compile a regular expression using optional flags at beginning of string (for
+format of flags, see <<_weechat_string_regex_flags,weechat_string_regex_flags>>).
+
+Prototype:
+
+[source,C]
+----------------------------------------
+int weechat_string_regcomp (regex_t *preg, const char *regex, int default_flags)
+----------------------------------------
+
+Arguments:
+
+* 'preg': pointer to 'regex_t' structure
+* 'regex': regular expression
+* 'default_flags': combination of following values (see `man regcomp`):
+** REG_EXTENDED
+** REG_ICASE
+** REG_NEWLINE
+** REG_NOSUB
+
+Return value:
+
+* same return code as function `regcomp` (0 if ok, other value for error,
+ see `man regcomp`)
+
+C example:
+
+[source,C]
+----------------------------------------
+regex_t my_regex;
+if (weechat_string_regcomp (&my_regex, "(?i)test", REG_EXTENDED) != 0)
+{
+ /* error */
+}
+----------------------------------------
+
+[NOTE]
+This function is not available in scripting API.
+
+weechat_string_has_highlight
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Check if a string has one or more highlights, using list of highlight words.
+
+Prototype:
+
+[source,C]
+----------------------------------------
+int weechat_string_has_highlight (const char *string,
+ const char highlight_words);
+----------------------------------------
+
+Arguments:
+
+* 'string': string
+* 'highlight_words': list of highlight words, separated by comma
Return value:
@@ -1052,7 +1148,7 @@ C example:
[source,C]
----------------------------------------
-int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
+int hl = weechat_string_has_highlight ("my test string", "test,word2"); /* == 1 */
----------------------------------------
Script (Python):
@@ -1060,41 +1156,42 @@ Script (Python):
[source,python]
----------------------------------------
# prototype
-highlight = weechat.string_has_highlight_regex(string, regex)
+highlight = weechat.string_has_highlight(string, highlight_words)
# example
-highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
+highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
----------------------------------------
-weechat_string_mask_to_regex
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+weechat_string_has_highlight_regex
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Return a regex, built with a mask, where only special char is "`*`". All other
-special chars for regex are escaped.
+_New in version 0.3.4._
+
+Check if a string has one or more highlights, using a regular expression.
+For at least one match of regular expression on string, it must be surrounded
+by word chars (alphanumeric character, "-", "_" or "|").
Prototype:
[source,C]
----------------------------------------
-char *weechat_string_mask_to_regex (const char *mask);
+int weechat_string_has_highlight_regex (const char *string, const char *regex);
----------------------------------------
Arguments:
-* 'mask': mask
+* 'string': string
+* 'regex': regular expression
Return value:
-* regular expression, as string (must be freed by calling "free" after use)
+* 1 if string has one or more highlights, otherwise 0
C example:
[source,C]
----------------------------------------
-char *str_regex = weechat_string_mask_to_regex ("test*mask");
-/* result: "test.*mask" */
-/* ... */
-free (str_regex);
+int hl = weechat_string_has_highlight_regex ("my test string", "test|word2"); /* == 1 */
----------------------------------------
Script (Python):
@@ -1102,10 +1199,10 @@ Script (Python):
[source,python]
----------------------------------------
# prototype
-regex = weechat.string_mask_to_regex(mask)
+highlight = weechat.string_has_highlight_regex(string, regex)
# example
-regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
+highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
----------------------------------------
weechat_string_split