Repository: kovidgoyal/kitty

Issue:
Seperate select_by_word_characters for left and right of the cursor
I am used to select a filename and a line number via double-click e.g. in grep results or compiler warnings etc.. However those are very often separated by a colon but also followed by a colon. I than use that to open that file at the specific location in my editor (Vim with [vim-fetch](https://github.com/wsdjeg/vim-fetch)).

Example: 
![Screenshot](https://user-images.githubusercontent.com/3797324/155157960-96d65081-fb8e-46a8-8b92-79c799d72d40.png)

@mintty handles left and right characters differently: the colon is included in `select_by_word_characters` on the left of mouse pointer  but not on the right. So that when you double-click on the line number in the first line you'd get `kitty/rc/base.py:238` and if you double-click on the filename you only get `kitty/rc/base.py`

With kitty you would either get `238` (default) or `kitty/rc/base.py:238:def` (with colon in `select_by_word_characters`).


Discussion:
Not related to the colon matching problem:

You can use hints kitten to open the file.
https://sw.kovidgoyal.net/kitty/kittens/hints/

The default shortcut is `ctrl+shift+p > n`.

No need to double-click to select and copy and paste.

Regarding the double click matching:

When I configure a colon in `select_by_word_characters`, then I expect the colon after the double click position to be selected.
You are asking for a new option.
Yes, this would be a new option.

I briefly looked into the kitten. It seems to be more complicated to what I'm used to. Also copy and paste is more flexible than this. Most of the time I don't want to open in a new Vim instance but open a new buffer in a tab or split or even in the current buffer instead... In that case my Vim instance is in the background so I'd need to copy, foreground Vim , type the appropriate command and paste. 

I am new to kitty, but I could probably write a custom hint action to copy this to the clipboard, but I guess I wouldn't use it anyway. 
You dont need to write anything other than a single line in kitty.conf.

map whatever kitten hints --type=linenum --program=@

then you can simply press a couple of keys and copy it to the clipboard. Given that a superior (IMO) way to achieve this use case already exists, I dont see much point in this setting. That said, I will review a PR for it, if you wish to implement it yourself.
Thank you. Could a custom kitten trigger a custom word selection on double-click?
No, kittens dont respond to clicks. 


Resolving patch:
diff --git a/kitty/options/definition.py b/kitty/options/definition.py
--- a/kitty/options/definition.py
+++ b/kitty/options/definition.py
@@ -492,6 +492,18 @@
 '''
     )
 
+opt('select_by_word_characters_forward', '',
+    ctype='!select_by_word_characters_forward',
+    long_text='''
+Characters considered part of a word when extending the selection forward on
+double clicking. In addition to these characters any character that is marked
+as an alphanumeric character in the Unicode database will be matched.
+
+If empty (default) :opt:`select_by_word_characters` will be used for both
+directions.
+'''
+    )
+
 opt('click_interval', '-1.0',
     option_type='float', ctype='time',
     long_text='''
diff --git a/kitty/options/parse.py b/kitty/options/parse.py
--- a/kitty/options/parse.py
+++ b/kitty/options/parse.py
@@ -1163,6 +1163,9 @@ def scrollback_pager_history_size(self, val: str, ans: typing.Dict[str, typing.A
     def select_by_word_characters(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
         ans['select_by_word_characters'] = str(val)
 
+    def select_by_word_characters_forward(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
+        ans['select_by_word_characters_forward'] = str(val)
+
     def selection_background(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
         ans['selection_background'] = to_color_or_none(val)
 
diff --git a/kitty/options/types.py b/kitty/options/types.py
--- a/kitty/options/types.py
+++ b/kitty/options/types.py
@@ -411,6 +411,7 @@
  'scrollback_pager',
  'scrollback_pager_history_size',
  'select_by_word_characters',
+ 'select_by_word_characters_forward',
  'selection_background',
  'selection_foreground',
  'shell',
@@ -561,6 +562,7 @@ class Options:
     scrollback_pager: typing.List[str] = ['less', '--chop-long-lines', '--RAW-CONTROL-CHARS', '+INPUT_LINE_NUMBER']
     scrollback_pager_history_size: int = 0
     select_by_word_characters: str = '@-./_~?&=%+#'
+    select_by_word_characters_forward: str = ''
     selection_background: typing.Optional[kitty.fast_data_types.Color] = Color(255, 250, 205)
     selection_foreground: typing.Optional[kitty.fast_data_types.Color] = Color(0, 0, 0)
     shell: str = '.'


Test patch: