bugWeeChat - Bugs: bug #31932, hook_modifier(weechat_print) does...


bug #31932: hook_modifier(weechat_print) does not discard each message if you return empty string

Submitter:  Nils G <nils_2>
Submitted:  Sun 19 Dec 2010 09:26:15 PM UTC
Category:  script API plugins Severity:  3 - Normal
Item Group:  display Status:  Confirmed
Privacy:  Public Assigned to:  flashcode
Originator Name:  Open/Closed:  Open
Release:  * 0.3.3 IRC nick:  nils_2
* Mandatory Fields

Add a New Comment Rich Markup

Tue 28 Dec 2010 06:43:23 PM UTC, comment #5: 

I would prefer to use a constant string as return value.

Nils G <nils_2>
Group Member
Tue 28 Dec 2010 01:32:40 PM UTC, comment #4: 

By the way, same problem could happen with some other modifiers. So a constant string value to discard a modifier string could be added in API, something like WEECHAT_HOOK_MODIFIER_DISCARD.

Sebastien Helleu <flashcode>
Group administrator
Tue 28 Dec 2010 01:30:26 PM UTC, comment #3: 

I understand problem now. It happens with /help because this command prints some empty lines. When your modifier returns same string as given string, it will be considered as "non modified" (even if it's empty string). That explains why empty lines can't be removed.

Only way to fix that would be a string with special value to remove it from display, but which value? It should be something not used in strings (for example string with one char, like "\x01" ?) Do you have better suggestions?

Sebastien Helleu <flashcode>
Group administrator
Mon 27 Dec 2010 04:42:34 PM UTC, comment #2: 

I already tested with another instance of weechat.  Here is the output (latest git).
After installing the script "test" i did a /help and got two empty lines. I also changed some weechat options, always with same result.

17:22:32     | Installierte "perl" Skripten:
17:22:32     |   (keine)
17:22:35     |
17:22:35     | Installierte "python" Skripten:
17:22:35     |   (keine)
17:22:41     |
17:22:41     | Installierte "lua" Skripten:
17:22:41     |   (keine)
17:22:48     |
17:22:48     | Installierte "tcl" Skripten:
17:22:48     |   (keine)
17:23:05     |
17:23:05     | Installierte "ruby" Skripten:
17:23:05     |   (keine)
17:23:11     | python: Lade das Skript "/home/nils/weechat-git/.weechat_blank/python/test.py"
17:23:11     | python: registriertes Skript "test", Version 0.0.1 (test me)
17:23:17     |
17:23:17     |

Nils G <nils_2>
Group Member
Mon 27 Dec 2010 10:33:43 AM UTC, comment #1: 

It's working for me, with both scripts (python and perl).

Can you try to run weechat in another directory (with --dir) and load only one of these scripts?
(maybe you have another script modifying string that interacts with this one)

Sebastien Helleu <flashcode>
Group administrator
Sun 19 Dec 2010 09:26:15 PM UTC, original submission:  

How to reproduce:

- load one of the scripts
- type for example: /help
- output:
22:11:54     | perl: registered script "test", Version 0.01 (do nothing...)
22:11:57     |
22:11:57     |

SCRIPT_NAME    = "test"
SCRIPT_DESC    = "test me"

import weechat

def my_modifier_cb(data, modifier, modifier_data, string):
  return ""


weechat.hook_modifier("weechat_print", "my_modifier_cb", "")

my $SCRIPT  = "test";
my $AUTHOR  = "blafasel";
my $Version = "0.01";
my $LICENCE = "GPL3";
my $DESCRIPTION   = "do nothing...";

use strict;

weechat::register( $SCRIPT, $AUTHOR, $Version, $LICENCE, $DESCRIPTION, "", "" );

sub my_modifier_cb {
my (undef, $signal, undef, $data) = @_;
return "";
weechat::hook_modifier("weechat_print", "my_modifier_cb", "");

Nils G <nils_2>
Group Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by flashcode (Posted a comment)
  • -email is unavailable- added by nils_2 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-01-06 flashcode StatusWorks For Me Confirmed
        Release3.3-dev 0.3.3
    2010-12-27 flashcode Item GroupNone display
        StatusNone Works For Me
        Assigned toNone flashcode

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code