* edit-command-line problem with emacsclient
@ 2015-09-20 11:46 Peter Vasil
2015-09-20 15:32 ` Bart Schaefer
2015-09-21 21:16 ` Daniel Shahaf
0 siblings, 2 replies; 7+ messages in thread
From: Peter Vasil @ 2015-09-20 11:46 UTC (permalink / raw)
To: zsh-workers
Hi list,
Commit 35ffe36318955d03fca3df0d34a0997970cfc6a3 introduced the change,
that when calling edit-command-line, the curser is put to the right offset.
This is implemented for vim and emacs, however if I set my EDITOR or
VISUAL to emacsclient, the *emacs* condition gets called which does not
work for emacsclient. The arguments specidied for emacs work only for
Emacs but not for emacsclient.
It would be great to change the condition *emacs* that it does not match
emacsclient or add another condition for emacsclient with appropriate
arguments.
Thanks and bests,
Peter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: edit-command-line problem with emacsclient
2015-09-20 11:46 edit-command-line problem with emacsclient Peter Vasil
@ 2015-09-20 15:32 ` Bart Schaefer
[not found] ` <55FF3CE5.9070604@petervasil.net>
2015-09-21 21:16 ` Daniel Shahaf
1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2015-09-20 15:32 UTC (permalink / raw)
To: Peter Vasil, zsh-workers
On Sep 20, 1:46pm, Peter Vasil wrote:
}
} This is implemented for vim and emacs, however if I set my EDITOR or
} VISUAL to emacsclient, the *emacs* condition gets called which does not
} work for emacsclient. The arguments specidied for emacs work only for
} Emacs but not for emacsclient.
So as I read this, for emacsclient the -eval option is mutually exclusive
with opening a file.
It's been a long time since I used emacsclient. Does this work?
diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
index 2c7f34b..bdd7b0b 100644
--- a/Functions/Zle/edit-command-line
+++ b/Functions/Zle/edit-command-line
@@ -17,7 +17,7 @@
local editor=${${VISUAL:-${EDITOR:-vi}}}
case $editor in
(*vim*) ${=editor} -c "normal! ${byteoffset}go" -- $1;;
- (*emacs*) ${=editor} $1 -eval "(goto-char ${byteoffset})";;
+ (*emacs*) ${=editor} -eval "(progn (find-alternate-file ${(qqq)1}) (goto-char ${byteoffset}))";;
(*) ${=editor} $1;;
esac
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: edit-command-line problem with emacsclient
2015-09-20 11:46 edit-command-line problem with emacsclient Peter Vasil
2015-09-20 15:32 ` Bart Schaefer
@ 2015-09-21 21:16 ` Daniel Shahaf
2015-09-21 22:31 ` Bart Schaefer
1 sibling, 1 reply; 7+ messages in thread
From: Daniel Shahaf @ 2015-09-21 21:16 UTC (permalink / raw)
To: Peter Vasil; +Cc: zsh-workers
Peter Vasil wrote on Sun, Sep 20, 2015 at 13:46:26 +0200:
> Commit 35ffe36318955d03fca3df0d34a0997970cfc6a3 introduced the change,
> that when calling edit-command-line, the curser is put to the right offset.
>
I wrote that. Sorry for the bug. I'm a vim user, and I sanity-tested
the emacs case, but I don't actually speak emacs lisp, so I'm not
surprised the patch was complete but not sound. I see now I forgot to
state in the patch mail that the emacs codepath needed extra review :-/
Cheers,
Daniel
(OT: Perhaps I should add "I don't speak emacs lisp" to https://people.apache.org/~danielsh/bilmiyorum/?)
> This is implemented for vim and emacs, however if I set my EDITOR or
> VISUAL to emacsclient, the *emacs* condition gets called which does not
> work for emacsclient. The arguments specidied for emacs work only for
> Emacs but not for emacsclient.
>
> It would be great to change the condition *emacs* that it does not match
> emacsclient or add another condition for emacsclient with appropriate
> arguments.
>
> Thanks and bests,
> Peter
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: edit-command-line problem with emacsclient
2015-09-21 21:16 ` Daniel Shahaf
@ 2015-09-21 22:31 ` Bart Schaefer
2015-09-22 7:10 ` Peter Vasil
0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2015-09-21 22:31 UTC (permalink / raw)
To: zsh-workers
On Sep 21, 9:16pm, Daniel Shahaf wrote:
}
} I wrote that. Sorry for the bug. I'm a vim user, and I sanity-tested
} the emacs case, but I don't actually speak emacs lisp, so I'm not
} surprised the patch was complete but not sound. I see now I forgot to
} state in the patch mail that the emacs codepath needed extra review :-/
S'ok, I think this should do it:
diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
index 2c7f34b..103a1c1 100644
--- a/Functions/Zle/edit-command-line
+++ b/Functions/Zle/edit-command-line
@@ -11,13 +11,16 @@
# Compute the cursor's position in bytes, not characters.
setopt localoptions nomultibyte
- integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
# Open the editor, placing the cursor at the right place if we know how.
local editor=${${VISUAL:-${EDITOR:-vi}}}
case $editor in
- (*vim*) ${=editor} -c "normal! ${byteoffset}go" -- $1;;
- (*emacs*) ${=editor} $1 -eval "(goto-char ${byteoffset})";;
+ (*vim*)
+ integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
+ ${=editor} -c "normal! ${byteoffset}go" -- $1;;
+ (*emacs*)
+ local lines=( ${(f):-"$PREBUFFER$LBUFFER"} )
+ ${=editor} +${#lines}:$((${#lines[-1]} + 1)) $1;;
(*) ${=editor} $1;;
esac
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: edit-command-line problem with emacsclient
2015-09-21 22:31 ` Bart Schaefer
@ 2015-09-22 7:10 ` Peter Vasil
0 siblings, 0 replies; 7+ messages in thread
From: Peter Vasil @ 2015-09-22 7:10 UTC (permalink / raw)
To: Bart Schaefer, zsh-workers
Hi Bart,
Looks really good. I can confirm that your patch works for both emacs
and emacsclient.
Thanks so much!
Cheers,
Peter
On 09/22/2015 12:31 AM, Bart Schaefer wrote:
> On Sep 21, 9:16pm, Daniel Shahaf wrote:
> }
> } I wrote that. Sorry for the bug. I'm a vim user, and I sanity-tested
> } the emacs case, but I don't actually speak emacs lisp, so I'm not
> } surprised the patch was complete but not sound. I see now I forgot to
> } state in the patch mail that the emacs codepath needed extra review :-/
>
> S'ok, I think this should do it:
>
> diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
> index 2c7f34b..103a1c1 100644
> --- a/Functions/Zle/edit-command-line
> +++ b/Functions/Zle/edit-command-line
> @@ -11,13 +11,16 @@
>
> # Compute the cursor's position in bytes, not characters.
> setopt localoptions nomultibyte
> - integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
>
> # Open the editor, placing the cursor at the right place if we know how.
> local editor=${${VISUAL:-${EDITOR:-vi}}}
> case $editor in
> - (*vim*) ${=editor} -c "normal! ${byteoffset}go" -- $1;;
> - (*emacs*) ${=editor} $1 -eval "(goto-char ${byteoffset})";;
> + (*vim*)
> + integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 ))
> + ${=editor} -c "normal! ${byteoffset}go" -- $1;;
> + (*emacs*)
> + local lines=( ${(f):-"$PREBUFFER$LBUFFER"} )
> + ${=editor} +${#lines}:$((${#lines[-1]} + 1)) $1;;
> (*) ${=editor} $1;;
> esac
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-09-22 7:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-20 11:46 edit-command-line problem with emacsclient Peter Vasil
2015-09-20 15:32 ` Bart Schaefer
[not found] ` <55FF3CE5.9070604@petervasil.net>
2015-09-21 4:06 ` Bart Schaefer
[not found] ` <56004B05.9000703@petervasil.net>
[not found] ` <150921120017.ZM426@torch.brasslantern.com>
2015-09-21 19:09 ` Peter Vasil
2015-09-21 21:16 ` Daniel Shahaf
2015-09-21 22:31 ` Bart Schaefer
2015-09-22 7:10 ` Peter Vasil
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).