Discussion:
[9fans] git and (p9p) acme
(too old to reply)
Mathieu Lonjaret
2012-04-19 11:51:40 UTC
Permalink
Hello,

Is anyone using git with p9p acme set as the editor?
Most things here work fine (as long as the pager is set to cat or
something like that), but I've been having problems with 'git commit
--amend'. If I use B as the $EDITOR, git considers the log file edited
as soon as it is opened in acme (and does not wait for a Put), and if
I use E instead (which I thought was meant for that), git does not
"notice" when I Put the file, so it just hangs there.
Am I missing something? is there a simple solution to that?

Cheers,
Mathieu
dexen deVries
2012-04-19 12:10:51 UTC
Permalink
hi list,
Post by Mathieu Lonjaret
Is anyone using git with p9p acme set as the editor?
i have the following in ~dexen/.profile
export VISUAL=E
if [ "$DISPLAY" ]; then
nohup plumber </dev/null >/dev/null 2>/dev/null &
fi


plus a few custom rules in ~dexen/lib/plumbing to deal with PHP's `FILE on
line LINE' convention in error messages etc.
Post by Mathieu Lonjaret
Most things here work fine (as long as the pager is set to cat or
something like that), but I've been having problems with 'git commit
--amend'. If I use B as the $EDITOR, git considers the log file edited
as soon as it is opened in acme (and does not wait for a Put), and if
I use E instead (which I thought was meant for that), git does not
"notice" when I Put the file, so it just hangs there.
Am I missing something? is there a simple solution to that?
i use `git gui' for commits, but had similar problem with `git rebase -i'. git
did not notice change in file when i merely re-ordered commits, cause the total
length stays the same, and mtime somehow doesn't get listed by `ls -l'.

git notices change of file when the editor exit()s. E has a simple loop around
`ls -l $1' to detect file change; exit()s when it notices change in ls' output.
if you have strange output of `ls', E may not notice change.

a possible workaround is to change length of the file -- add something in the
comment (hashed-out) section of commit message. in case of `git rebase -i',
change `edit' to `e'.

or re-implement E, really.

caveat:
using VISUAL=E with git, be wary of saving the file several times; the first Put
will cause git to go ahead and subsequent changes to file will most likely be
ignored.


cheers,
--
dexen deVries


Weightless and alone
you speed through the eerie nothingness of space
you circle 'round the Moon
and journey back
to face the punishing torment of re-entry

-- LUNA-C, ``Supaset8 (full release)'', #24m52s
Aram Hăvărneanu
2012-04-19 12:16:10 UTC
Permalink
Post by dexen deVries
using VISUAL=E with git, be wary of saving the file several times; the first Put
will cause git to go ahead and subsequent changes to file will most likely be
ignored.
Great caveat, it bit me once.
--
Aram Hăvărneanu
Aram Hăvărneanu
2012-04-19 12:12:04 UTC
Permalink
Post by Mathieu Lonjaret
Is anyone using git with p9p acme set as the editor?
Most things here work fine (as long as the pager is set to cat or
something like that), but I've been having problems with 'git commit
--amend'. If I use B as the $EDITOR, git considers the log file edited
as soon as it is opened in acme (and does not wait for a Put), and if
I use E instead (which I thought was meant for that), git does not
"notice" when I Put the file, so it just hangs there.
Am I missing something? is there a simple solution to that?
I do. Rather than remembering what I did, I'll link to my environment:

http://code.google.com/p/aram-dotfiles/source/browse/

Check the big Plan 9 branch in profile:

http://code.google.com/p/aram-dotfiles/source/browse/profile
--
Aram Hăvărneanu
Mathieu Lonjaret
2012-04-20 17:07:57 UTC
Permalink
Thanks Dexen and Aram for the explanation.
Post by Mathieu Lonjaret
Is anyone using git with p9p acme set as the editor?
<snip>
Post by Mathieu Lonjaret
I use E instead (which I thought was meant for that), git does not
"notice" when I Put the file, so it just hangs there.
 I never tried using EDITOR=E, instead wrote my own little script. I'm
a little compulsive when it comes to hitting Put, so my script
actually waits until you delete the acme window. Also you can hit
"Cancel" to have the script exit non-zero. Anyway this is what I use
http://sqweek.net/plan9/acmeedit
Nice, it almost works out of the box.
I got a 9p error message when using it:
9p: write error: ill-formed control message
but it actually does the job anyway.
Thanks!

I'll investigate later on to see which part fails exactly.
Russ Cox
2012-04-25 20:21:01 UTC
Permalink
I guess it depends on what you expect to break.
I like using the E script because (once you learn not
to click Put, which doesn't take too long) after I click
Put the window is still there with my work in it in case
the tool I just sent it to chooses to blow up and
discard my efforts.

Russ
Lyndon Nerenberg
2012-04-25 20:30:15 UTC
Permalink
Post by Russ Cox
I like using the E script because (once you learn not
to click Put, which doesn't take too long) after I click
Put the window is still there with my work in it in case
the tool I just sent it to chooses to blow up and
discard my efforts.
If 'sam file' did the obvious thing this would be much less of a problem.
Russ Cox
2012-04-25 20:36:31 UTC
Permalink
Post by Lyndon Nerenberg
If 'sam file' did the obvious thing this would be much less of a problem.
What is not obvious about what 'sam file' does?
John Floren
2012-04-25 20:51:43 UTC
Permalink
Post by Russ Cox
What is not obvious about what 'sam file' does?
Plugging 'sam file' into a script does not launch the editor with the specified file in a window for the user to edit, and then save out.
Works for me... this is what I do when writing commit messages in hg.
Sure, you have to go into the right-button menu and open the file
window, but it's 2 mouse clicks and I find sam a lot more convenient
than acme for this kind of quick edit.

What behavior are you seeing?

john
Russ Cox
2012-04-25 20:58:38 UTC
Permalink
A lack of expectation.  I.e. I expect 'sam foo' to, well, edit 'foo'.  'acme foo' does that, as does 'ed foo.'  From a UI perspective, the 'sam foo' behaviour is as non-intuitive as it gets.
If 'sam foo' (i.e. with a single filename argument) loaded the file into the edit window, it would mimic the behaviour of almost every other editor out there.
Are you complaining that 'sam foo' pops up a sam window and
you have to click to place the new window for foo instead of having
the window automatically placed?

Otherwise, I don't know what you're talking about.
sam foo starts a copy of sam editing foo.

Russ
Lyndon Nerenberg
2012-04-25 21:01:38 UTC
Permalink
Post by Russ Cox
Otherwise, I don't know what you're talking about.
Yes you do.
Lyndon Nerenberg
2012-04-25 20:57:20 UTC
Permalink
Post by John Floren
What behavior are you seeing?
A lack of expectation. I.e. I expect 'sam foo' to, well, edit 'foo'. 'acme foo' does that, as does 'ed foo.' From a UI perspective, the 'sam foo' behaviour is as non-intuitive as it gets.

If 'sam foo' (i.e. with a single filename argument) loaded the file into the edit window, it would mimic the behaviour of almost every other editor out there.

--lyndon
Lyndon Nerenberg
2012-04-25 20:46:37 UTC
Permalink
Post by Russ Cox
What is not obvious about what 'sam file' does?
Plugging 'sam file' into a script does not launch the editor with the specified file in a window for the user to edit, and then save out.

People are clamouring for a (visual) 'ed foo' replacement. Acme can't do that. Sam can, but it needs some unintuitive arguments. If 'E foo' wrapped sam up in the proper glue to make it fake out 'vi foo' as far as the atomic editing from the command line needs that started this thread, that would be wonderful.

That aside, I think rio+acme provides enough glue to make it possible to have an 'E' script that launches an acme window and blocks until the window is closed. If I have time over the weekend I'll fiddle about and see what comes out.
Russ Cox
2012-04-25 20:56:52 UTC
Permalink
Plugging 'sam file' into a script does not launch the editor with the specified file in a window for the user to edit, and then save
out.

Sure it does. And so does 'acme file', if you are on Plan 9 or
if you are on plan9port and don't already have acme running.

The point of the E script is to let you edit in the editor you're
already using instead of opening a new one.

Russ
Lyndon Nerenberg
2012-04-25 21:04:37 UTC
Permalink
Are you sure you are running 'sam foo' and not 'sam foo &'?
Sam 'blocks' until you quit out of it, just like acme or vi or ed.
It doesn't load the file for the user to edit. Given a single file on the command line, the obvious behaviour should be to load the file the user asked to edit.
Christian Neukirchen
2012-04-27 16:15:28 UTC
Permalink
Post by Lyndon Nerenberg
Are you sure you are running 'sam foo' and not 'sam foo &'?
Sam 'blocks' until you quit out of it, just like acme or vi or ed.
It doesn't load the file for the user to edit.
It does, but it doesnt show the buffer by default. Just right-click and
select it.
--
Christian Neukirchen <***@gmail.com> http://chneukirchen.org
Russ Cox
2012-04-25 21:02:59 UTC
Permalink
But none of those commands will block until the file is saved, and that's the issue.
Are you sure you are running 'sam foo' and not 'sam foo &'?
Sam 'blocks' until you quit out of it, just like acme or vi or ed.

Russ
Lyndon Nerenberg
2012-04-25 21:05:23 UTC
Permalink
Are you sure you are running 'sam foo' and not 'sam foo &'?
Sam 'blocks' until you quit out of it, just like acme or vi or ed.
And you're right -- blocking behaviour isn't the problem with sam.
Russ Cox
2012-04-25 21:06:35 UTC
Permalink
Post by Lyndon Nerenberg
It doesn't load the file for the user to edit.
You must be running a different sam than I am.
I would make a video and post it on YouTube
but I am too lazy.

Russ
Lyndon Nerenberg
2012-04-25 20:59:04 UTC
Permalink
Post by Russ Cox
The point of the E script is to let you edit in the editor you're
already using instead of opening a new one.
But none of those commands will block until the file is saved, and that's the issue.
Mathieu Lonjaret
2012-04-25 21:35:59 UTC
Permalink
So, are you saying E just works out of the box for you as the $EDITOR
for git/hg?
Or did you have to tweak a few things like what Aram and Dexen describe?

I wouldn't mind using E as it is, with Put being the trigger to the
tool (git in that case), but it does not seem to be working here.
Post by Russ Cox
I guess it depends on what you expect to break.
I like using the E script because (once you learn not
to click Put, which doesn't take too long) after I click
Put the window is still there with my work in it in case
the tool I just sent it to chooses to blow up and
discard my efforts.
Russ
Aram Hăvărneanu
2012-04-25 21:44:13 UTC
Permalink
Post by Mathieu Lonjaret
So, are you saying E just works out of the box for you as the $EDITOR
for git/hg?
Or did you have to tweak a few things like what Aram and Dexen describe?
I guess all you need to run up awd in your cd alias. I think I stole
my cd function from Russ.
--
Aram Hăvărneanu
Aram Hăvărneanu
2012-04-25 21:49:29 UTC
Permalink
Post by Aram Hăvărneanu
I guess all you need to run up awd in your cd alias. I think I stole
my cd function from Russ.
Actually, the way one does this is documented in label(1). Beware that
this requires X, hence the $DISPLAY check in my profile.
--
Aram Hăvărneanu
Mathieu Lonjaret
2012-04-25 22:35:55 UTC
Permalink
Indeed, it seems like awd was all that was needed.
Thanks!
Post by Aram Hăvărneanu
Post by Aram Hăvărneanu
I guess all you need to run up awd in your cd alias. I think I stole
my cd function from Russ.
Actually, the way one does this is documented in label(1). Beware that
this requires X, hence the $DISPLAY check in my profile.
--
Aram Hăvărneanu
Russ Cox
2012-04-26 03:32:48 UTC
Permalink
On Wed, Apr 25, 2012 at 5:35 PM, Mathieu Lonjaret
Post by Mathieu Lonjaret
So, are you saying E just works out of the box for you as the $EDITOR
for git/hg?
Yes. Note that E waits for the file to change by running
ls -l on the file in a loop. If for some reason doing the Put
does not change the ls -l output (date+size, primarily) then
E will not exit. If you are having trouble I would suggest
putting some echo statements in the script or just doing
'set -e' at the top so that it echoes each statement as it
executes (including the all-important comparison).

I cannot imagine why using awd would change the behavior
of the E script.

Russ
Rob Pike
2012-04-26 08:05:44 UTC
Permalink
set -x

-rob
Mathieu Lonjaret
2012-04-26 22:20:49 UTC
Permalink
I've just retried on the machine where I had the problem and it now
just works. No need even for awd indeed.
I'll try and reproduce the behavior, but I just don't see what I may
have done different the previous times...

thanks,
Mathieu
Post by Russ Cox
On Wed, Apr 25, 2012 at 5:35 PM, Mathieu Lonjaret
Post by Mathieu Lonjaret
So, are you saying E just works out of the box for you as the $EDITOR
for git/hg?
Yes.  Note that E waits for the file to change by running
ls -l on the file in a loop.  If for some reason doing the Put
does not change the ls -l output (date+size, primarily) then
E will not exit.  If you are having trouble I would suggest
putting some echo statements in the script or just doing
'set -e' at the top so that it echoes each statement as it
executes (including the all-important comparison).
I cannot imagine why using awd would change the behavior
of the E script.
Russ
Mathieu Lonjaret
2012-06-14 12:51:54 UTC
Permalink
It happened again. and I've just realized it's simply what you had
warned about: since it was an --amend and I didn't change anything in
the message there was no change to the ls -l output, hence E did
nothing when I Put.

On Fri, Apr 27, 2012 at 12:20 AM, Mathieu Lonjaret
Post by Mathieu Lonjaret
I've just retried on the machine where I had the problem and it now
just works. No need even for awd indeed.
I'll try and reproduce the behavior, but I just don't see what I may
have done different the previous times...
thanks,
Mathieu
Post by Russ Cox
On Wed, Apr 25, 2012 at 5:35 PM, Mathieu Lonjaret
Post by Mathieu Lonjaret
So, are you saying E just works out of the box for you as the $EDITOR
for git/hg?
Yes.  Note that E waits for the file to change by running
ls -l on the file in a loop.  If for some reason doing the Put
does not change the ls -l output (date+size, primarily) then
E will not exit.  If you are having trouble I would suggest
putting some echo statements in the script or just doing
'set -e' at the top so that it echoes each statement as it
executes (including the all-important comparison).
I cannot imagine why using awd would change the behavior
of the E script.
Russ
dexen deVries
2012-04-26 08:43:24 UTC
Permalink
Post by Mathieu Lonjaret
So, are you saying E just works out of the box for you as the $EDITOR
for git/hg?
Or did you have to tweak a few things like what Aram and Dexen describe?
worked out-of-box; I only add plumbing for PHP stuff -- and start plumber in
~/.profile

use $VISUAL rather than $EDITOR to ensure it is used only under X Windows
--
dexen deVries



Weightless and alone
you speed through the eerie nothingness of space
you circle 'round the Moon
and journey back
to face the punishing torment of re-entry

-- LUNA-C, ``Supaset8 (full release)'', #24m52s
Continue reading on narkive:
Loading...