Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@janpeterd
Copy link
Contributor

@janpeterd janpeterd commented Sep 2, 2023

Related issues:

A new command cmd-delete-word-back is added.
A new configuration option unixwords is added.
Docs about this command added.

This is my first pull request and I am inexperienced in go. So any feedback or suggestions are welcome.

@joelim-work
Copy link
Collaborator

@janpeterd Thanks for your contribution. I am not sure if you have seen this yet, but there is a set of guidelines for first-time contributors.

Regarding your changes, I think it is better to not add the unixwords option at all, and just providing a separate cmd-delete-word-back command should suffice. The relationship between cmd-delete-word-back and and cmd-delete-word should be similar to the relationship between cmd-word-back and cmd-word.

BTW I think the line editing in lf is based on bash, and what you are really trying to do is to implement backward-kill-word (press alt+backspace) in https://www.gnu.org/software/bash/manual/html_node/Commands-For-Killing.html

One other thing I noticed is that you have saved the deleted text in the yank buffer for cmd-delete-word-back, but interestingly cmd-delete-word doesn't do this. I'm not sure which one is correct but I think the behavior should be consistent between these two commands.

@joelim-work joelim-work mentioned this pull request Sep 3, 2023
@gokcehan
Copy link
Owner

gokcehan commented Sep 3, 2023

@janpeterd Thank you very much for working on this.

@joelim-work I don't remember anything about the missing yank for cmd-delete-word. It is probably a mistake so we should probably fix it. I will try to go over all command-line commands to make sure they have compatible behavior with readline/bash defaults.

@janpeterd I agree with @joelim-work in that unixwords option is not necessary. Support for alt+backspace in lf was added recently. So maybe we can use it for this new cmd-delete-word-back command as this shortcut is mentioned in both bash and readline documentations.

Not quite related to this discussion, but I'm thinking of moving the Contributions wiki page to the repository. I think it is more common to find it in the repository. It is also mostly intended for developers so it should be separate from the content intended for users (i.e. wiki).

@janpeterd
Copy link
Contributor Author

I removed the configuration option and mapped the command by default to <a-backspace> and <a-backspace2>. Also bash doesn't save the removed text to the yank-buffer for this command, so I have removed that code. Thanks for bringing that up @joelim-work.

@janpeterd janpeterd changed the title Add cmd-delete-word-back command for zsh/vim-like word deletion Add cmd-delete-word-back command Sep 3, 2023
Copy link
Collaborator

@joelim-work joelim-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, just a couple of very minor comments.

doc.go Outdated
cmd-word (default '<a-f>')
cmd-word-back (default '<a-b>')
cmd-delete-word (default '<a-d>')
cmd-delete-word-back (default '<a-backspace> and <a-backspace2>')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you made a small typo:

Suggested change
cmd-delete-word-back (default '<a-backspace> and <a-backspace2>')
cmd-delete-word-back (default '<a-backspace>' and '<a-backspace2>')

opts.go Outdated
Comment on lines 357 to 358
gOpts.cmdkeys["<a-backspace>"] = &callExpr{"cmd-delete-word-back", nil, 1}
gOpts.cmdkeys["<a-backspace2>"] = &callExpr{"cmd-delete-word-back", nil, 1}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor, but I would suggest to move this to just under cmd-delete-word to group them together.

@joelim-work
Copy link
Collaborator

@gokcehan I don't have any issues with moving the contribution guidelines to CONTRIBUTING.md, it sounds good to me.

@janpeterd
Copy link
Contributor Author

@joelim-work typo corrected and block of code moved.

@gokcehan
Copy link
Owner

gokcehan commented Sep 3, 2023

Looks good to me as well. Thank you @janpeterd for the patch and @joelim-work for the review.

By the way, both alt+d and alt+backspace save the deleted text in the yank buffer on my bash. I can see these commands are listed under "Killing and Yanking" in man readline, so I think this is the expected behavior. Therefore, I'm thinking of adding yanking to both of these commands in lf as well. Let me know if there is an issue with this.

@gokcehan gokcehan merged commit 791dfff into gokcehan:master Sep 3, 2023
gokcehan added a commit that referenced this pull request Sep 3, 2023
gokcehan added a commit that referenced this pull request Sep 3, 2023
@joelim-work joelim-work mentioned this pull request Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants