20
849
Fork
You've already forked fuzzel
83

Add delete-line binding #472

Manually merged
markstos merged 1 commit from bbb651/fuzzel:delete-line-binding into master 2025年06月23日 17:58:14 +02:00
Contributor
Copy link

Adds a new delete-line key binding defaulting to Control + Shift + Backspace. It has to be before delete-prev-word because otherwise it takes precedence, this seems less restrictive than disallowing bindings to match if additional modifiers are held (and if that is desirable it's unrelated to this). I saw that delete-line-backward was originally named delete-line, is that an issue?

Adds a new `delete-line` key binding defaulting to <kbd>Control</kbd> + <kbd>Shift</kbd> + <kbd>Backspace</kbd>. It has to be before `delete-prev-word` because otherwise it takes precedence, this seems less restrictive than disallowing bindings to match if additional modifiers are held (and if that is desirable it's unrelated to this). I saw that `delete-line-backward` was originally named `delete-line`, is that an issue?
Add delete-line binding
Some checks reported errors
builds.sr.ht/freebsd-x64 Job failed
ci/woodpecker/pr/woodpecker Pipeline failed
ci/woodpecker/pull_request_closed/woodpecker Pipeline is pending approval
c33da4b01c
Collaborator
Copy link

I use Emacs bindings that already exist for this:

Control-A, Control-K

(Go to beginning of line, kill remainder of line).

If this is to be accepted, I would recommend a clearer name, like "delete-input", as the rows of items to select are also lines.

I use Emacs bindings that already exist for this: Control-A, Control-K (Go to beginning of line, kill remainder of line). If this is to be accepted, I would recommend a clearer name, like "delete-input", as the rows of items to select are also lines.
Owner
Copy link

It has to be before delete-prev-word because otherwise it takes precedence

Moving it before delete-prev-word doesn't actually fix the issue, it just makes the default bindings work (and in a very fragile way, I would add).

The real issue is that is many XKB layouts, shift+backspace is the same as backspace, because the layout considers shift "consumed". This isn't an issue in fuzzel, but in the keyboard layout.

Thus, two better options are:

  • Fix the layout (not something we can do in fuzzel)
  • Use other defaults. Relying on a specific order of the key binding definitions is not an acceptable solution to me.
> It has to be before delete-prev-word because otherwise it takes precedence Moving it before delete-prev-word doesn't actually fix the issue, it just makes the default bindings work (and in a very fragile way, I would add). The real issue is that is many XKB layouts, shift+backspace is the same as backspace, because the layout considers shift "consumed". This isn't an issue in fuzzel, but in the keyboard layout. Thus, two better options are: * Fix the layout (not something we can do in fuzzel) * Use other defaults. Relying on a specific order of the key binding definitions is not an acceptable solution to me.
Author
Contributor
Copy link

I wonder how Emacs maps it, I found this commit which seems relevant, I think they baypass XKB modifier consumption and do it manually somewhere?

A possible option is to special case them, just for the case where the physical key is backspace, the keysym is backspace and shift was consumed (very conservative so it doesn't collide with e.g. remapping it or mapping shift+Backspace to Delete)?

Otherwise, do you have an idea for a default? I'm not used to Emacs bindings so I'll probably change it to Control+a > Backspace, and thought it would make the most sense to match Emacs. Maybe Control+Alt+Backspace or should I leave it unbound?

I wonder how Emacs maps it, I found [this commit](https://github.com/emacs-mirror/emacs/commit/9c268510cf4ce02e46d3884215a4d016914d35f0) which seems relevant, I think they baypass XKB modifier consumption and do it manually somewhere? A possible option is to special case them, just for the case where the physical key is backspace, the keysym is backspace and shift was consumed (very conservative so it doesn't collide with e.g. remapping it or mapping <kbd>shift</kbd>+<kbd>Backspace</kbd> to <kbd>Delete</kbd>)? Otherwise, do you have an idea for a default? I'm not used to Emacs bindings so I'll probably change it to <kbd>Control</kbd>+<kbd>a</kbd> > <kbd>Backspace</kbd>, and thought it would make the most sense to match Emacs. Maybe <kbd>Control</kbd>+<kbd>Alt</kbd>+<kbd>Backspace</kbd> or should I leave it unbound?
Owner
Copy link

I think they baypass XKB modifier consumption and do it manually somewhere?

We do that in fuzzel too. We check both translated (symbol as-is from XKB, consumed modifiers), untranslated (unshifted symbol, explicit modifiers) and raw key codes. In that order.

I'm thinking it might be better to check untranslated/unshifted before translated. That would make shift+backspace match before just backspace. Need to think a bit about this, to make sure there's nothing I'm missing.

> I think they baypass XKB modifier consumption and do it manually somewhere? We do that in fuzzel too. We check both translated (symbol as-is from XKB, consumed modifiers), untranslated (unshifted symbol, explicit modifiers) and raw key codes. In that order. I'm thinking it _might_ be better to check untranslated/unshifted before translated. That would make shift+backspace match before just backspace. Need to think a bit about this, to make sure there's nothing I'm missing.
Collaborator
Copy link

I still wonder if the desire to delete the whole line quickly is better handled with documentation than code.

This is often handled with a combination of existing bindings. In our case, Control-A, Control-K.

Other apps that support "Select All", they may use "Select All, Delete".

Even the OP here suggests they will use "Control A + Backspace" for the binding. And at which point you are already using three keys.... "Control A Control K" is similar effort and already works. If your keyboard layout allows it, you can hold down Control followed by A and K, making it also three keystrokes.

I still wonder if the desire to delete the whole line quickly is better handled with documentation than code. This is often handled with a combination of existing bindings. In our case, Control-A, Control-K. Other apps that support "Select All", they may use "Select All, Delete". Even the OP here suggests they will use "Control A + Backspace" for the binding. And at which point you are already using three keys.... "Control A Control K" is similar effort and already works. If your keyboard layout allows it, you can hold down Control followed by A and K, making it also three keystrokes.
Owner
Copy link

I still wonder if the desire to delete the whole line quickly is better handled with documentation than code.

I haven't made my final decision yet, but I do tend to agree with this.

> I still wonder if the desire to delete the whole line quickly is better handled with documentation than code. I haven't made my final decision yet, but I do tend to agree with this.
Owner
Copy link

#476 should fix the Backspace vs. Shift+Backspace issue. Haven't tested it much yet though, but hopefully it doesn't introduce any other issues...

https://codeberg.org/dnkl/fuzzel/pulls/476 should fix the Backspace vs. Shift+Backspace issue. Haven't tested it much yet though, but hopefully it doesn't introduce any other issues...
Author
Contributor
Copy link

Fwiw I'm still interested in this.

Even the OP here suggests they will use "Control A + Backspace" for the binding. And at which point you are already using three keys.... "Control A Control K" is similar effort and already works. If your keyboard layout allows it, you can hold down Control followed by A and K, making it also three keystrokes.

That doesn't help because I cannot map Backspace to delete-line-forward. Now that I think about it Control + X is much better, it's easy reachable for a (imo) common function and it's mapped to "cut line" (when you don't have text selected) in most editors, it might even be a better default than the emacs one.

Fwiw I'm still interested in this. > Even the OP here suggests they will use "Control A + Backspace" for the binding. And at which point you are already using three keys.... "Control A Control K" is similar effort and already works. If your keyboard layout allows it, you can hold down Control followed by A and K, making it also three keystrokes. That doesn't help because I cannot map <kbd>Backspace</kbd> to `delete-line-forward`. Now that I think about it <kbd>Control</kbd> + <kbd>X</kbd> is much better, it's easy reachable for a (imo) common function and it's mapped to "cut line" (when you don't have text selected) in most editors, it might even be a better default than the emacs one.
Collaborator
Copy link

Given that the docs were updated on how to clear a line via the keyboard and #476, is this PR still of interest?

Given that the docs were updated on how to clear a line via the keyboard and #476, is this PR still of interest?
Author
Contributor
Copy link

Yes, it’s still not possible to do in a single keybind, IIUC #476 made it possible for Control + Shift + Backspace to be a default keybind in a non fragile way, and like I said I think Control + X is also a good option (more intuitive for more users imo with the trade off of not matching emacs).
I can resolve the conflicts and update the binding if needed.

Yes, it’s still not possible to do in a single keybind, IIUC #476 made it possible for <kbd>Control</kbd> + <kbd>Shift</kbd> + <kbd>Backspace</kbd> to be a default keybind in a non fragile way, and like I said I think <kbd>Control</kbd> + <kbd>X</kbd> is also a good option (more intuitive for more users imo with the trade off of not matching emacs). I can resolve the conflicts and update the binding if needed.
markstos left a comment
Copy link

Seems OK with me. Needs approval from @dnkl as well.

Seems OK with me. Needs approval from @dnkl as well.
Owner
Copy link

@bbb651 yes, please rebase on latest master, and clean up the PR

@bbb651 yes, please rebase on latest master, and clean up the PR
markstos manually merged commit 3e7c9a23f3 into master 2025年06月23日 17:58:14 +02:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/fuzzel!472
Reference in a new issue
dnkl/fuzzel
No description provided.
Delete branch "bbb651/fuzzel:delete-line-binding"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?