Skip to content
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

Feature: Spawn external editor to edit message #1521

Closed
6 of 8 tasks
jubalh opened this issue Apr 16, 2021 · 18 comments
Closed
6 of 8 tasks

Feature: Spawn external editor to edit message #1521

jubalh opened this issue Apr 16, 2021 · 18 comments
Assignees
Labels
Milestone

Comments

@jubalh
Copy link
Member

jubalh commented Apr 16, 2021

@StefanKropp had this idea and started it in #1485.

What needs to be done:

Last thing happens when:
Test1:

start profanity
/msg someone
/quit

Test2:

start profanity
/msg someone
write a message using /editor
/quit

In Test2 the terminal will not be cleared properly. There is still part of profanity visible. Maybe something ncurses related.

  • Remove the "EDITOR PREVIEW" from the chatwindow. Or let it stay but replace it later when the actual message have been sent. -> a4deec8
  • Since the inputline is empty it might confuse some people at the start. Let's indicate with something like [Editor] in the statusbar that we are in a special state.
  • Make it configurable which editor to use. Done in 19c5925
  • Save in .local/share/profanity/editor/barejid.md instead of /tmp/profanity-uuid.md. Advantages: not a place where other users have access. By using barejid we can also reopen this later and only delete it once sent. -> 242381c
  • (Maybe) delete the tmp file only once we sent the message. So that one could run /editor several times and amend some text. -> not done
@jubalh jubalh added the feature label Apr 16, 2021
@jubalh jubalh added this to the 0.11.0 milestone Apr 16, 2021
jubalh added a commit that referenced this issue Apr 16, 2021
Add basic functionality to launch external editor

Regards #1521
@jubalh
Copy link
Member Author

jubalh commented Apr 16, 2021

Some ideas where this could lead:

This can later be used to reply to messages too.
Maybe a workflow like his:

  • /reply
  • each line gets a number (Number could be used where currently we have the - ~ etc char)
  • press the number (3)
  • editor gets opened containing ">" + the content of line 3

@kaffeekanne also suggest to use it for correct via /edit correct

@mdosch
Copy link
Contributor

mdosch commented Apr 16, 2021 via email

@jubalh
Copy link
Member Author

jubalh commented Apr 16, 2021

I'd prefer to have a number per message and quote the full message even if it's multiline.

That's what I said?

@mdosch
Copy link
Contributor

mdosch commented Apr 16, 2021

You said 'line' but a message could be several lines.

@jubalh
Copy link
Member Author

jubalh commented Apr 16, 2021

You are right, that was not clear. I meant the same though. Message is not right either. Maybe a better word would be entry. An entry starting with date + nick + message. That entry will have - char where we want the number. And then the message (possibly spread along several lines).

jubalh added a commit that referenced this issue Apr 16, 2021
`/executable set editor /full/path/to/edit`.

Regards #1521
@DebXWoody
Copy link
Contributor

Decide what PREF_COMPOSE_EDITOR should return by default /usr/bin/vim, xdg-open, $EDITOR, $VISUAL? Right now we use fork()/execl() we need a whole path. So just xdg-open or $EDITOR won't work right now.

See: #1546

@DebXWoody
Copy link
Contributor

I just tried to use a graphical editor ( gvim ). At the beginning everything looks fine, but after saving the file, the text will not be added to readline. gvim will run in the background, so we are not able to wait for the session.

I created a file /usr/local/bin/gvimf

#!/bin/bash
gvim -f $1

In profanity I set compose.editor=gvimf.
This was working.

jubalh added a commit that referenced this issue Jun 10, 2021
jubalh added a commit that referenced this issue Jun 10, 2021
@jubalh
Copy link
Member Author

jubalh commented Jul 5, 2021

Good enough for now.

@Hund
Copy link

Hund commented Oct 13, 2021

How do I bind the editor to a key so I can spawn the editor using a keybinding?

@jubalh
Copy link
Member Author

jubalh commented Oct 13, 2021

Most likely by reading the documentation https://profanity-im.github.io/guide/latest/keybindings.html

@Hund
Copy link

Hund commented Oct 13, 2021

Most likely by reading the documentation https://profanity-im.github.io/guide/latest/keybindings.html

I read all the docs and I did extensive research on the web, but came up with nothing.

Instead of wasting energy on being unfriendly, would you please spend the energy on helping me by telling me how to do it instead? It's clearly not documented..

The link you mentioned doesn't even mention the word "editor" once.

@jubalh
Copy link
Member Author

jubalh commented Oct 13, 2021

I'm not unfriendly. I don't know how to do what you are trying to do and said that most likely the link I posted can help you.

From your GitHub I saw that you can code so I assumed you checked the code already.

From what I understand the link I posted uses functions that are defined in _inp_rl_addfuncs() so I assume one would have to add another entry there.

I never created such a shortcut and have absolutely no idea how to do it. Most likely if either you or I spend the time one it one of us can figure it out.

Profanity also has aliases (see /help alias) where you could create a shorter name. But actually for me /e<tab><enter> is quick enough. And most likely the time spent configuring a shortcut will outweigh those few key presses for me since I most of the time write single line messages anyways.

@Hund
Copy link

Hund commented Oct 13, 2021

I'm not unfriendly. I don't know how to do what you are trying to do and said that most likely the link I posted can help you.

My apologies! English is not my native language, and I must have interpreted the tone completely wrong.

From your GitHub I saw that you can code so I assumed you checked the code already.

I wouldn't really call myself a programmer, more like a hobby wannabe 'script kiddie'.

From what I understand the link I posted uses functions that are defined in _inp_rl_addfuncs() so I assume one would have to add another entry there.

I have on idea what that should be though.

I never created such a shortcut and have absolutely no idea how to do it. Most likely if either you or I spend the time one it one of us can figure it out.

Let's hope so!

Profanity also has aliases (see /help alias) where you could create a shorter name. But actually for me /e<tab><enter> is quick enough. And most likely the time spent configuring a shortcut will outweigh those few key presses for me since I most of the time write single line messages anyways.

The issue I have is that I sometimes write a message and then realize it's getting lengthy and would like to format in in fancy ways or just be able to access spellchecking. That's not possible if I have already written any text.

Well. Thanks for being friendly! ;)

@jubalh
Copy link
Member Author

jubalh commented Oct 13, 2021

English is not my native language,

Mine neither. Probably that's part of the problem :D

The issue I have is that I sometimes write a message and then realize it's getting lengthy and would like to format in in fancy ways or just be able to access spellchecking. That's not possible if I have already written any text.

I see. Makes sense. Personally I think it would be best to think about it before :) But I can see the point. Maybe /editor should also allow unlimited arguments and just put them into the editor window if they are there. So that one can just POS1 and prefix /editor to the line. Would that help?

@jubalh
Copy link
Member Author

jubalh commented Oct 13, 2021

Maybe let's wait until #1596.

But if above mentioned idea helps you could maybe try to implement it if you want. I can also guide you, like which files to touch and where to look for inspiration on how to do it. Interested?

@Hund
Copy link

Hund commented Oct 14, 2021

English is not my native language,

Mine neither. Probably that's part of the problem :D

I'm pretty sure it's me, I'm getting old and grumpy. :)

The issue I have is that I sometimes write a message and then realize it's getting lengthy and would like to format in in fancy ways or just be able to access spellchecking. That's not possible if I have already written any text.

I see. Makes sense. Personally I think it would be best to think about it before :) But I can see the point. Maybe /editor should also allow unlimited arguments and just put them into the editor window if they are there. So that one can just POS1 and prefix /editor to the line. Would that help?

Think before doing something? You have high hopes about me for sure. I don't always how lengthy a message might be before it's too late.

Jumping to the beginning of the line and adding the /editor before the message text would be an okay compromise, but I would prefer to be able to use a keybinding, which I'm used to do with my web browser.

@Hund
Copy link

Hund commented Oct 14, 2021

Maybe let's wait until #1596.

But if above mentioned idea helps you could maybe try to implement it if you want. I can also guide you, like which files to touch and where to look for inspiration on how to do it. Interested?

That sounds awfully helpful. I'm not the one to say no to any help. :)

@jubalh
Copy link
Member Author

jubalh commented Oct 14, 2021

Jumping to the beginning of the line and adding the /editor before the message text would be an okay compromise, but I would prefer to be able to use a keybinding, which I'm used to do with my web browser.

Maybe this can be done as a second step.

That sounds awfully helpful. I'm not the one to say no to any help. :)

Great! So you will need to check out src/command/cmd_defs.c and grep for cmd_editor( this is where the defintion is stored. You will need to take a look at the line starting with parse_args where we tell it how many arguments it allows. Look at another command to see what you need to use there. Also at the bottom there is CMD_NOARGS which you will need to change.
Then you will need to check out src/command/cmd_funcs.c and grep for the same function name. You will need to adapt it so that it writes the args passed to it into the file before opening it.

If you have more questions you can also contact my on XMPP or in our MUC.

As I said I would wait for that PR mentioned above to be merged since it will touch that code too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants