# Writing the patch description from an editor

**URL:** <https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55>\
**Category:** Development\
**Created:** [July 17, 2017, 2:23pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55 "2017-07-17T14:23:34Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [July 17, 2017, 2:23pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/1 "2017-07-17T14:23:34Z")

</div>

Hi everybody.

One of the latest “key feature” `pijul` still lacks _from my point of view_ is the hability to write the patch description (that is the patch name and as much as text as you want then to give some context) within a text editor. I remember @pmeunier saying once on IRC the feature was not implemented yet because it was difficult to implement it in a portable way. That is very true indeed, but I think it could be a very cool acheivement (along with the @laumann `pijul status` enhancement discussed [here](https://discourse.pijul.org/t/request-for-comments-listing-files-with-conflicts-in-pijul-status/49/6)) for `pijul-0.8.0`.

What do you think?

---

<div class="post-metadata">

**Author:** ![gabomgp](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/gabomgp/32/57_2.png) [@gabomgp](https://discourse.pijul.org/u/gabomgp)\
**Post date:** [July 21, 2017, 2:28am UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/2 "2017-07-21T02:28:12Z")

</div>

What library do you think to use?

---

<div class="post-metadata">

**Author:** ![laumann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/laumann/32/8_2.png) [@laumann](https://discourse.pijul.org/u/laumann)\
**Post date:** [July 25, 2017, 9:40pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/3 "2017-07-25T21:40:33Z")

</div>

Could we start with a hack and see how it works?

What if `pijul record` looks for a specific file in `.pijul`, like `.pijul/PATCH_DESC` and uses its contents as the patch description and subsequently deletes the file?

That way adding description could be done interactively, as maybe

```bash
$ pijul record
# Add changes...
What is the name of this patch? The best patch ever!

Add a patch description? [yn] y
# Open editor if .pijul/PATCH_DESC doesn't exist (if possible); or
# ask to use .pijul/PATCH_DESC as the patch description

```

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [July 25, 2017, 9:59pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/4 "2017-07-25T21:59:38Z")

</div>

I like that feature, but remember that not everyone can use a text editor. I’m pretty sure atom/sublime/eclipse users don’t want to fire up their favourite editor just to write one line. This should be configurable, both globally and per repository.

As an emacs user who cannot use emacs-daemon, starting an emacs (that moreover, in the case of git and darcs, is _not_ my usual emacs-x11) to write just a single line is also painful for me.

---

<div class="post-metadata">

**Author:** ![laumann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/laumann/32/8_2.png) [@laumann](https://discourse.pijul.org/u/laumann)\
**Post date:** [July 26, 2017, 12:31am UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/5 "2017-07-26T00:31:41Z")

</div>

Hmm, how about as a command-line argument as well: `pijul record --description <file>`

Eclipse integration with Git is actually quite good, the implementation handles adding files to the index and writing the commit message in a dedicated editor window before hitting “Commit”. Like so:

 ![](https://canada1.discourse-cdn.com/flex031/uploads/pijul/original/1X/13bd8f2a64f55c05aad4ae3ded1198f1414ca63d.png)

([source](http://www.vogella.com/tutorials/EclipseGit/article.html))

Pijul integration in Eclipse could just provide two buffers: The patch name (as a single line) and the description (as a larger textarea).

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [August 23, 2017, 12:39pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/6 "2017-08-23T12:39:48Z")

</div>

This looks like a good idea. One first quick and dirty hack could be to check is `PATCH_DESC` exists and use it when it does. _Then_ we could move forward and ask to spawn an editor.

I will try to work with that this week and see how it goes.

---

<div class="post-metadata">

**Author:** ![laumann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/laumann/32/8_2.png) [@laumann](https://discourse.pijul.org/u/laumann)\
**Post date:** [August 23, 2017, 7:48pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/7 "2017-08-23T19:48:52Z")

</div>

> [@lthms](#):
>
> One first quick and dirty hack could be to check is PATCH\_DESC exists and use it when it does.

That sounds simple, though I think the user should be prompted on whether or not to use the file (if found).

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [September 21, 2017, 8:28pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/8 "2017-09-21T20:28:16Z")

</div>

I wrote a patch that deals with using an external editor to write a patch name/description. You can find it [on the Nest](https://nest.pijul.com/lthms/pijul/patches/AVUre8HrqhBltQu9s8VLj9i0VIv7LOb4daVSfgsp1ARUttFgFjoYRqwyVT3mP1AYncpBnrwMU33M9n83w6_KdEs) and your feedback is really welcome!

As the description said:

> With this patch, pijul now supports writing a patch name and  
> description from an editor. To do so, the user needs to configure his  
> or her repository. If the `editor` variable is not set, then the  
> behaviour does not change. However, if it is, then pijul spawns the  
> editor. The user can then write the patch name and description. If he  
> or she leaves the file empty, then pijul aborts. If the file contains  
> some text after the headline, this text is used as the patch  
> description.

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [May 1, 2020, 6:56pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/9 "2020-05-01T18:56:53Z")

</div>

@lthms was it implemented? I cannot see the patch on The nest and the documentation doesn’t mention it at all

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [May 1, 2020, 9:18pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/10 "2020-05-01T21:18:21Z")

</div>

It was implemented indeed. You can use the `--editor` command-line argument to choose which editor you want to use. Or you can configure it in the local (to your repo) or global (to your user) meta file (using the `editor` field.

It should work. (:

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [May 10, 2020, 10:38am UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/11 "2020-05-10T10:38:14Z")

</div>

Sorry to bother again with this. Could you give some more details? I’m using 0.12, when I run `pijul record --editor nvim` it says:

> error: Found argument ‘–editor’ which wasn’t expected, or isn’t valid in this context  
> Did you mean --no-editor?

Also I added `editor = nvim` to my `~/.local/share/pijul/config/config.toml` and it doesn’t work (it asks for the patch name interactively). What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [May 10, 2020, 3:59pm UTC](https://discourse.pijul.org/t/writing-the-patch-description-from-an-editor/55/12 "2020-05-10T15:59:35Z")

</div>

I don’t remember if `pijul` looks at this file for config. Mine is located at `${HOME}/.pijulconfig/config.toml`. I recall there were some discussions to use xdg config directory standard, but I am not sure it was ever applied.
