all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using emacsclient -t as $EDITOR from within Emacs
@ 2013-09-04 20:42 Nikolai Weibull
  2013-09-05  0:26 ` Suvayu Ali
  0 siblings, 1 reply; 13+ messages in thread
From: Nikolai Weibull @ 2013-09-04 20:42 UTC (permalink / raw)
  To: Emacs Users

Hi!

Invoking emacsclient -t from shell-command gives me

emacsclient: could not get terminal name

It seems that ttyname (fileno (stdio)) fails, which doesn’t seem
unreasonable, I suppose, but I was wondering how I should get around
this.  I want to be able to execute commands that invoke $EDITOR,
which I’ve set to a shell script that invokes emacsclient -t, from
within Emacs (for example, from Dired) that’s running as a server and
so far I’m only either failing with errors or locking up my terminal.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-04 20:42 Nikolai Weibull
@ 2013-09-05  0:26 ` Suvayu Ali
  2013-09-05  6:36   ` Nikolai Weibull
  0 siblings, 1 reply; 13+ messages in thread
From: Suvayu Ali @ 2013-09-05  0:26 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, Sep 04, 2013 at 10:42:42PM +0200, Nikolai Weibull wrote:
> Hi!
> 
> Invoking emacsclient -t from shell-command gives me
> 
> emacsclient: could not get terminal name
> 
> It seems that ttyname (fileno (stdio)) fails, which doesn’t seem
> unreasonable, I suppose, but I was wondering how I should get around
> this.  I want to be able to execute commands that invoke $EDITOR,
> which I’ve set to a shell script that invokes emacsclient -t, from
> within Emacs (for example, from Dired) that’s running as a server and
> so far I’m only either failing with errors or locking up my terminal.
> 

eamcsclient -t works only in text terminals.  Does emacsclient -c work
instead?

-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-05  0:26 ` Suvayu Ali
@ 2013-09-05  6:36   ` Nikolai Weibull
  2013-09-05  7:33     ` Suvayu Ali
  0 siblings, 1 reply; 13+ messages in thread
From: Nikolai Weibull @ 2013-09-05  6:36 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: Emacs Users

On Thu, Sep 5, 2013 at 2:26 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> On Wed, Sep 04, 2013 at 10:42:42PM +0200, Nikolai Weibull wrote:
>> Hi!
>>
>> Invoking emacsclient -t from shell-command gives me
>>
>> emacsclient: could not get terminal name
>>
>> It seems that ttyname (fileno (stdio)) fails, which doesn’t seem
>> unreasonable, I suppose, but I was wondering how I should get around
>> this.  I want to be able to execute commands that invoke $EDITOR,
>> which I’ve set to a shell script that invokes emacsclient -t, from
>> within Emacs (for example, from Dired) that’s running as a server and
>> so far I’m only either failing with errors or locking up my terminal.
>>
>
> eamcsclient -t works only in text terminals.  Does emacsclient -c work
> instead?

I’m in a text terminal.  I realize now that I didn’t say so in my
description above.  Sorry about that.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-05  6:36   ` Nikolai Weibull
@ 2013-09-05  7:33     ` Suvayu Ali
  0 siblings, 0 replies; 13+ messages in thread
From: Suvayu Ali @ 2013-09-05  7:33 UTC (permalink / raw)
  To: Nikolai Weibull; +Cc: Emacs Users

On Thu, Sep 05, 2013 at 08:36:24AM +0200, Nikolai Weibull wrote:
> On Thu, Sep 5, 2013 at 2:26 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> > On Wed, Sep 04, 2013 at 10:42:42PM +0200, Nikolai Weibull wrote:
> >> Hi!
> >>
> >> Invoking emacsclient -t from shell-command gives me
> >>
> >> emacsclient: could not get terminal name
> >>
> >> It seems that ttyname (fileno (stdio)) fails, which doesn’t seem
> >> unreasonable, I suppose, but I was wondering how I should get around
> >> this.  I want to be able to execute commands that invoke $EDITOR,
> >> which I’ve set to a shell script that invokes emacsclient -t, from
> >> within Emacs (for example, from Dired) that’s running as a server and
> >> so far I’m only either failing with errors or locking up my terminal.
> >>
> >
> > eamcsclient -t works only in text terminals.  Does emacsclient -c work
> > instead?
> 
> I’m in a text terminal.  I realize now that I didn’t say so in my
> description above.  Sorry about that.

In that case, I don't think it is possible to invoke an emacsclient
frame when it is already occupied.  I'm not sure what you are trying to
achieve though.  Wouldn't just C-x C-f, `find-file', work?

-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
       [not found] <mailman.1318.1378327378.10748.help-gnu-emacs@gnu.org>
@ 2013-09-05 23:36 ` Felix Dietrich
  2013-09-06  6:02   ` Nikolai Weibull
  0 siblings, 1 reply; 13+ messages in thread
From: Felix Dietrich @ 2013-09-05 23:36 UTC (permalink / raw)
  To: help-gnu-emacs

Nikolai Weibull <now@disu.se> writes:
> Invoking emacsclient -t from shell-command gives me
>
> emacsclient: could not get terminal name
>
> It seems that ttyname (fileno (stdio)) fails, which doesn’t seem
> unreasonable, I suppose, but I was wondering how I should get around
> this.  I want to be able to execute commands that invoke $EDITOR,
> which I’ve set to a shell script that invokes emacsclient -t, from
> within Emacs (for example, from Dired) that’s running as a server and
> so far I’m only either failing with errors or locking up my terminal.

If you can leave off the parameter '-t' emacsclient will simply open the
file on the emacs-server.  You can than edit the file in you current
emacs window in you text-shell, or you could if your terminal wouldn't
lock.  Adding an ampersand '&' to the COMMAND string passed to
`shell-command' will run it asynchronously so that you will be able to
continue editing while your command is running in the background, which
it will, because it is you trying to interactively edit a file.

When working with a file opened by emacsclient type 'C-x #' in the
file's buffer to indicate to emacs that you are done editing.  Emacs
will than ask you whether you want to save the changes and notify the
waiting emacsclient that you are done; emacsclient will now exit.
Alternatively use '--no-wait' to make emacsclient exit immediately after
opening the file on the server.

--
Felix Dietrich



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-05 23:36 ` Using emacsclient -t as $EDITOR from within Emacs Felix Dietrich
@ 2013-09-06  6:02   ` Nikolai Weibull
  2013-09-06  7:10     ` Suvayu Ali
  0 siblings, 1 reply; 13+ messages in thread
From: Nikolai Weibull @ 2013-09-06  6:02 UTC (permalink / raw)
  To: Felix Dietrich; +Cc: Emacs Users

On Fri, Sep 6, 2013 at 1:36 AM, Felix Dietrich
<felix.dietrich@sperrhaken.name> wrote:
> Nikolai Weibull <now@disu.se> writes:
>> Invoking emacsclient -t from shell-command gives me
>>
>> emacsclient: could not get terminal name
>>
>> It seems that ttyname (fileno (stdio)) fails, which doesn’t seem
>> unreasonable, I suppose, but I was wondering how I should get around
>> this.  I want to be able to execute commands that invoke $EDITOR,
>> which I’ve set to a shell script that invokes emacsclient -t, from
>> within Emacs (for example, from Dired) that’s running as a server and
>> so far I’m only either failing with errors or locking up my terminal.
>
> If you can leave off the parameter '-t' emacsclient will simply open the
> file on the emacs-server.  You can than edit the file in you current
> emacs window in you text-shell, or you could if your terminal wouldn't
> lock.  Adding an ampersand '&' to the COMMAND string passed to
> `shell-command' will run it asynchronously so that you will be able to
> continue editing while your command is running in the background, which
> it will, because it is you trying to interactively edit a file.

Precisely.  I figured this out yesterday evening.  I had figured that
the -t would allow for a new frame to be created in the daemon and
displayed “over” the current one on the same terminal, but leaving off
-t and running asynchronously seems to be the only way.

Thanks!



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-06  6:02   ` Nikolai Weibull
@ 2013-09-06  7:10     ` Suvayu Ali
  2013-09-06  7:59       ` Yuri Khan
  0 siblings, 1 reply; 13+ messages in thread
From: Suvayu Ali @ 2013-09-06  7:10 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Nikolai,

On Fri, Sep 06, 2013 at 08:02:47AM +0200, Nikolai Weibull wrote:
> 
> Precisely.  I figured this out yesterday evening.  I had figured that
> the -t would allow for a new frame to be created in the daemon and
> displayed “over” the current one on the same terminal, but leaving off
> -t and running asynchronously seems to be the only way.

I'm very curious, what does this offer you over simple C-x C-f.  The way
I see it, emacsclient is useful to have access to single Emacs instance
whenever you want to edit something, so you can connect to the instance
from anywhere.  But if you are already in an emacs frame, how does this
add anything?

-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-06  7:10     ` Suvayu Ali
@ 2013-09-06  7:59       ` Yuri Khan
  2013-09-06  8:57         ` Suvayu Ali
  0 siblings, 1 reply; 13+ messages in thread
From: Yuri Khan @ 2013-09-06  7:59 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: help-gnu-emacs@gnu.org

On Fri, Sep 6, 2013 at 2:10 PM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> Hi Nikolai,

> I'm very curious, what does this offer you over simple C-x C-f.  The way
> I see it, emacsclient is useful to have access to single Emacs instance
> whenever you want to edit something, so you can connect to the instance
> from anywhere.  But if you are already in an emacs frame, how does this
> add anything?

Many external programs, most notably version control systems such as
Subversion and Git, like to call an external editor when they need
some intermediate text that cannot be reasonably expected to be passed
via the command line or via a pre-authored file.

E.g. when you say “git commit”, it asks you for a commit message by
opening an external editor with some temporary file. It then expects
that you will compose your message, save it into the same file, and
exit the editor. After that, it proceeds to store your modifications
in a commit along with the message you wrote.

The external editor used in Git must have two desirable properties:
(1) it must be convenient for you to use, and (2) it must start up
quickly. If (1) leads you to use Emacs, then you’re forced to think
about the issue (2): a conveniently configured Emacs is often slow to
load.

The usual list response to issues of slow startup is “use server and
set emacsclient as your editor”. But if you run Emacs server on a
terminal, then shell in that Emacs, then “git commit” from that shell,
it calls emacsclient which tries to create a frame but cannot
determine the terminal type (because it actually runs in emacs shell
which in fact lacks any terminal capabilities), which leads to
frustration due to interrupted flow (you are either forced to use a
different editor, or to pass a short commit message via the command
line, or to first compose a message, then pass the message file to
“git commit”, then delete that file).

It might be possible using term instead of shell in Emacs, but
probably weird (Emacs running on a terminal emulated by a window in an
Emacs running on a terminal).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-06  7:59       ` Yuri Khan
@ 2013-09-06  8:57         ` Suvayu Ali
  2013-09-06  9:08           ` Nikolai Weibull
  0 siblings, 1 reply; 13+ messages in thread
From: Suvayu Ali @ 2013-09-06  8:57 UTC (permalink / raw)
  To: Yuri Khan; +Cc: help-gnu-emacs@gnu.org

On Fri, Sep 06, 2013 at 02:59:21PM +0700, Yuri Khan wrote:
> On Fri, Sep 6, 2013 at 2:10 PM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> > Hi Nikolai,
> 
> > I'm very curious, what does this offer you over simple C-x C-f.  The way
> > I see it, emacsclient is useful to have access to single Emacs instance
> > whenever you want to edit something, so you can connect to the instance
> > from anywhere.  But if you are already in an emacs frame, how does this
> > add anything?
> 
> Many external programs, most notably version control systems such as
> Subversion and Git, like to call an external editor when they need
> some intermediate text that cannot be reasonably expected to be passed
> via the command line or via a pre-authored file.

Yes I'm aware of that.  That is why I myself use emacsclient most of the
time.  The OP however wants to call emacsclient from an emacs frame as
an asynchronous command.  I fail to see any usecase for that.  If I want
to edit something from an emacs frame, I would just open it.

That said, I think one use case for emacsclient from an emacs frame
would be in eshell or some such shell mode, just call `emacsclient
<file>' and you can edit the file.  However that is still not what the
OP was asking for; hence my question.

Hopefully I was clearer this time around.

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-06  8:57         ` Suvayu Ali
@ 2013-09-06  9:08           ` Nikolai Weibull
  2013-09-06  9:40             ` Suvayu Ali
  0 siblings, 1 reply; 13+ messages in thread
From: Nikolai Weibull @ 2013-09-06  9:08 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: help-gnu-emacs@gnu.org, Yuri Khan

On Fri, Sep 6, 2013 at 10:57 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> On Fri, Sep 06, 2013 at 02:59:21PM +0700, Yuri Khan wrote:
>> On Fri, Sep 6, 2013 at 2:10 PM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:

>> > I'm very curious, what does this offer you over simple C-x C-f.  The way
>> > I see it, emacsclient is useful to have access to single Emacs instance
>> > whenever you want to edit something, so you can connect to the instance
>> > from anywhere.  But if you are already in an emacs frame, how does this
>> > add anything?

>> Many external programs, most notably version control systems such as
>> Subversion and Git, like to call an external editor when they need
>> some intermediate text that cannot be reasonably expected to be passed
>> via the command line or via a pre-authored file.

> Yes I'm aware of that.  That is why I myself use emacsclient most of the
> time.  The OP however wants to call emacsclient from an emacs frame as
> an asynchronous command.  I fail to see any usecase for that.  If I want
> to edit something from an emacs frame, I would just open it.

That wasn’t what I was asking for.  I led with that case, as that’s
what it boiled down to, or so I thought, but I did explain that “I
want to be able to execute commands that invoke $EDITOR, which I’ve
set to a shell script that invokes emacsclient -t, from
within Emacs (for example, from Dired) that’s running as a server”.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-06  9:08           ` Nikolai Weibull
@ 2013-09-06  9:40             ` Suvayu Ali
  2013-09-06  9:46               ` Nikolai Weibull
  0 siblings, 1 reply; 13+ messages in thread
From: Suvayu Ali @ 2013-09-06  9:40 UTC (permalink / raw)
  To: Nikolai Weibull; +Cc: help-gnu-emacs@gnu.org, Yuri Khan

Hi Nikolai,

On Fri, Sep 06, 2013 at 11:08:20AM +0200, Nikolai Weibull wrote:
> On Fri, Sep 6, 2013 at 10:57 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> > On Fri, Sep 06, 2013 at 02:59:21PM +0700, Yuri Khan wrote:
> >> On Fri, Sep 6, 2013 at 2:10 PM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> 
> >> > I'm very curious, what does this offer you over simple C-x C-f.  The way
> >> > I see it, emacsclient is useful to have access to single Emacs instance
> >> > whenever you want to edit something, so you can connect to the instance
> >> > from anywhere.  But if you are already in an emacs frame, how does this
> >> > add anything?
> 
> >> Many external programs, most notably version control systems such as
> >> Subversion and Git, like to call an external editor when they need
> >> some intermediate text that cannot be reasonably expected to be passed
> >> via the command line or via a pre-authored file.
> 
> > Yes I'm aware of that.  That is why I myself use emacsclient most of the
> > time.  The OP however wants to call emacsclient from an emacs frame as
> > an asynchronous command.  I fail to see any usecase for that.  If I want
> > to edit something from an emacs frame, I would just open it.
> 
> That wasn’t what I was asking for.  I led with that case, as that’s
> what it boiled down to, or so I thought, but I did explain that “I
> want to be able to execute commands that invoke $EDITOR, which I’ve
> set to a shell script that invokes emacsclient -t, from
> within Emacs (for example, from Dired) that’s running as a server”.

Almost all the cases I can think of where executing shell commands may
call $EDITOR, I can also think of very nice emacs libraries that provide
very mature integration.  A few examples:
- emails: Gnus, notmuch, vm, message-mode for simple composing, etc,
- using version control: vc-*, magit, etc,
- sudoedit/visudo: tramp

The only one I can think of without a mode like that is when I call
$EDITOR from my pager (less).  But of course running a pager from Emacs
does not make sense.  From the above examples, I can't imagine I would
call any of those from dired.  So I'm still a bit confused about the use
case.  Could you please give an example of the command you are using?

Sorry if I'm being a bit dense, I'm just very curious and would like to
know.

Thanks,

-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-06  9:40             ` Suvayu Ali
@ 2013-09-06  9:46               ` Nikolai Weibull
  2013-09-06 10:05                 ` Suvayu Ali
  0 siblings, 1 reply; 13+ messages in thread
From: Nikolai Weibull @ 2013-09-06  9:46 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: help-gnu-emacs@gnu.org, Yuri Khan

On Fri, Sep 6, 2013 at 11:40 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:

> Could you please give an example of the command you are using?

https://github.com/now/dot-home/blob/master/bin/mfedit.in



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Using emacsclient -t as $EDITOR from within Emacs
  2013-09-06  9:46               ` Nikolai Weibull
@ 2013-09-06 10:05                 ` Suvayu Ali
  0 siblings, 0 replies; 13+ messages in thread
From: Suvayu Ali @ 2013-09-06 10:05 UTC (permalink / raw)
  To: Nikolai Weibull; +Cc: help-gnu-emacs@gnu.org, Yuri Khan

On Fri, Sep 06, 2013 at 11:46:15AM +0200, Nikolai Weibull wrote:
> On Fri, Sep 6, 2013 at 11:40 AM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> 
> > Could you please give an example of the command you are using?
> 
> https://github.com/now/dot-home/blob/master/bin/mfedit.in

Aha!  It is a specialised case I guess, but it makes sense.

Thank you,

-- 
Suvayu

Open source is the future. It sets us free.



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-09-06 10:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1318.1378327378.10748.help-gnu-emacs@gnu.org>
2013-09-05 23:36 ` Using emacsclient -t as $EDITOR from within Emacs Felix Dietrich
2013-09-06  6:02   ` Nikolai Weibull
2013-09-06  7:10     ` Suvayu Ali
2013-09-06  7:59       ` Yuri Khan
2013-09-06  8:57         ` Suvayu Ali
2013-09-06  9:08           ` Nikolai Weibull
2013-09-06  9:40             ` Suvayu Ali
2013-09-06  9:46               ` Nikolai Weibull
2013-09-06 10:05                 ` Suvayu Ali
2013-09-04 20:42 Nikolai Weibull
2013-09-05  0:26 ` Suvayu Ali
2013-09-05  6:36   ` Nikolai Weibull
2013-09-05  7:33     ` Suvayu Ali

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.