GermainZ / weechat-vimode

A WeeChat script that adds vi-like modes, commands and keybindings.
GNU General Public License v3.0
266 stars 28 forks source link

feature request - nice quoting functionality. #58

Open rnmhdn opened 6 years ago

rnmhdn commented 6 years ago

I think these commands can be so nice and handy.

:<num>m (quote line <num> message)
:<num>q (quote msg + nick)
:<num1>,<num2>m (copy msgs from lines num1 to num2 to input_text)
:<num1>,<num2>q (...)
GermainZ commented 6 years ago

Unfortunately, this doesn't seem to be possible yet.

Notes (mostly to myself, but also to anyone who might want to investigate):

  1. q/Q/m in cursor mode do some special things (see /key list cursor).
  2. We can't do the same thing as it depends on the focus hashtable, and hook_focus() is only called on user input, once the cursor mode is active.
  3. Accessing the buffer's lines directly (using hdata methods) doesn't give us info about the line number, so things break for wrapped lines.

A hacky way would be to do it via the xdotool program (or similar), but that would only allow :<num>m and :<num>q, without support for ranges.

I can revisit this if weechat/weechat#1245 is resolved, but this is an admittedly niche issue and the WeeChat contributors might have other priorities. :)

rnmhdn commented 6 years ago

I don't know much about weechat API but I was thinking maybe something like this would work: when user does :4,5m we do the following silently: :4 m save the value in text_input to a local array variable, say lines[0] :5 m save the value in text_input to lines[1] text_input='\n'.join(lines)

another way would be to just loop over the range and do :num and then paste and send. but the first solution would be much better because this one neither has the warning nor the yy functionality.

GermainZ commented 6 years ago

I can't send the "m" keystroke (or whatever key, short of using xdotool) nor do its action directly in the script programmatically (this may be possible in the future, see the issue I linked above).

rnmhdn commented 6 years ago

oh... my bad... sorry:D

GermainZ commented 6 years ago

This should be possible in a future WeeChat release / vimode update (I have a working implementation, but it requires a patch that isn't in WeeChat yet; the final implementation may also change), hopefully in a few months.

If someone wants to try it anyway, you have to build WeeChat from source and apply the above patch, then apply this patch to vimode.py.

I'm keeping the issue open for tracking purposes and as a reminder.