New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function for editing command line in ext editor #3627

Closed
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
6 participants
@krader1961
Contributor

krader1961 commented Dec 7, 2016

This implements a standard function and bindings for editing the command
line in an external editor. This feature has been requested multiple
times in the past year with various solutions cut and pasted into those
issues. This change combines the best aspects of those solutions.

Fixes #1215

Show outdated Hide outdated doc_src/index.hdr.in
Show outdated Hide outdated doc_src/index.hdr.in
Show outdated Hide outdated share/functions/edit_command_buffer.fish
Show outdated Hide outdated share/functions/edit_command_buffer.fish

krader1961 added some commits Dec 7, 2016

function for editing command line in ext editor
This implements a standard function and bindings for editing the command
line in an external editor. This feature has been requested multiple
times in the past year with various solutions cut and pasted into those
issues. This change combines the best aspects of those solutions.

Fixes #1215
function edit_command_buffer --description 'Edit the command buffer in an external editor'
set -l f (mktemp)
if set -q f[1]
mv $f $f.fish

This comment has been minimized.

@faho

faho Dec 7, 2016

Member

I think you know that this is racy. Though it seems a rather theoretical criticism since this function won't be executed in a tight loop by multiple shells at the same time.

Any fix to this would require either an alternative to mktemp or a mktemp that accepts a suffix, which is unlikely to be available on BSD or macOS.

@faho

faho Dec 7, 2016

Member

I think you know that this is racy. Though it seems a rather theoretical criticism since this function won't be executed in a tight loop by multiple shells at the same time.

Any fix to this would require either an alternative to mktemp or a mktemp that accepts a suffix, which is unlikely to be available on BSD or macOS.

This comment has been minimized.

@faho

faho Dec 7, 2016

Member

In psub, we use mktemp -d and then add a file with a suffix.

@faho

faho Dec 7, 2016

Member

In psub, we use mktemp -d and then add a file with a suffix.

This comment has been minimized.

@krader1961

krader1961 Dec 8, 2016

Contributor

Even if this were executed in a tight loop it is so improbable there would be collision that it can be safely ignored. It's comparable to getting two commits in the fish project with the same leading eight digits of the commit hash.

@krader1961

krader1961 Dec 8, 2016

Contributor

Even if this were executed in a tight loop it is so improbable there would be collision that it can be safely ignored. It's comparable to getting two commits in the fish project with the same leading eight digits of the commit hash.

# Set the command to the output of the edited command and move the cursor to the
# end of the edited command.
commandline -r (cat $f)
commandline -C 999999

This comment has been minimized.

@faho

faho Dec 7, 2016

Member

We should really have a nicer way to set the cursor to the end, and commandline should probably also accept stdin.

@faho

faho Dec 7, 2016

Member

We should really have a nicer way to set the cursor to the end, and commandline should probably also accept stdin.

This comment has been minimized.

@floam

floam Dec 9, 2016

Member

We should really have a nicer way to set the cursor to the end,

-1 perhaps?

@floam

floam Dec 9, 2016

Member

We should really have a nicer way to set the cursor to the end,

-1 perhaps?

This comment has been minimized.

@krader1961

krader1961 Dec 9, 2016

Contributor

@flaom, Perhaps you should open a new issue, and take ownership of it, rather than commenting on a closed PR where your proposal has zero chance of being implemented?

@krader1961

krader1961 Dec 9, 2016

Contributor

@flaom, Perhaps you should open a new issue, and take ownership of it, rather than commenting on a closed PR where your proposal has zero chance of being implemented?

Show outdated Hide outdated share/functions/edit_command_buffer.fish
Show outdated Hide outdated share/functions/edit_command_buffer.fish
Show outdated Hide outdated share/functions/edit_command_buffer.fish
@krader1961

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Dec 9, 2016

Contributor

Closed by merge of commit 59fa04b.

Contributor

krader1961 commented Dec 9, 2016

Closed by merge of commit 59fa04b.

@krader1961 krader1961 closed this Dec 9, 2016

@krader1961 krader1961 added this to the fish 2.5.0 milestone Dec 9, 2016

@krader1961 krader1961 deleted the krader1961:commandline-edit branch Dec 9, 2016

@GaryFurash

This comment has been minimized.

Show comment
Hide comment
@GaryFurash

GaryFurash Nov 21, 2017

was this ever implemented?

GaryFurash commented Nov 21, 2017

was this ever implemented?

@xieyuheng

This comment has been minimized.

Show comment
Hide comment
@xieyuheng

xieyuheng Nov 22, 2017

how to disable this feature ?

xieyuheng commented Nov 22, 2017

how to disable this feature ?

@xieyuheng

This comment has been minimized.

Show comment
Hide comment
@xieyuheng

xieyuheng Nov 22, 2017

how to disable default alt-v alt-e keybinding ?

xieyuheng commented Nov 22, 2017

how to disable default alt-v alt-e keybinding ?

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Nov 23, 2017

Member

@xieyuheng: The same you'd disable any other binding - by either overwriting it with something else, or erasing it.

Add this to a function called fish_user_key_bindings:

bind -e \ee
bind -e \ev

However I'm not sure why you'd want this? Do you have an issue with it? Do you just press these keys accidentally?

Member

faho commented Nov 23, 2017

@xieyuheng: The same you'd disable any other binding - by either overwriting it with something else, or erasing it.

Add this to a function called fish_user_key_bindings:

bind -e \ee
bind -e \ev

However I'm not sure why you'd want this? Do you have an issue with it? Do you just press these keys accidentally?

@xieyuheng

This comment has been minimized.

Show comment
Hide comment
@xieyuheng

xieyuheng Nov 23, 2017

thanks @faho
I do not need this feature,
because I can open an emacsclient window by a keybinding (Alt-shift-x),
and edit commend there.

and I also often accidentally press Alt-v.

xieyuheng commented Nov 23, 2017

thanks @faho
I do not need this feature,
because I can open an emacsclient window by a keybinding (Alt-shift-x),
and edit commend there.

and I also often accidentally press Alt-v.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment