GNU bug report logs - #646
emacsclient with no args to behave like -a

Previous Next

Package: emacs;

Reported by: "J. Pablo Fernández" <pupeno <at> pupeno.com>

Date: Mon, 4 Aug 2008 10:20:03 UTC

Severity: wishlist

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 646 in the body.
You can then email your comments to 646 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#646; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "J. Pablo Fernández" <pupeno <at> pupeno.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "J. Pablo Fernández" <pupeno <at> pupeno.com>
To: bug-gnu-emacs <at> gnu.org
Subject: No arguments
Date: Mon, 4 Aug 2008 12:10:42 +0200
Hello,

It would be nice if emacsclient, when called with no arguments, would
just run the alternate editor. I've configured emacs as my alternate
editor so emacsclient for me is basically a "open this in an existing
emacs or run one otherwise", the only problem for that to work
completely is having it working with no arguments.

Thanks.
-- 
J. Pablo Fernández <pupeno <at> pupeno.com> (http://pupeno.com)
 Temporarily using pupeno <at> gmail.com.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#646; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: "J. Pablo Fernández" <pupeno <at> pupeno.com>,
        646 <at> debbugs.gnu.org
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#646: No arguments
Date: Mon, 04 Aug 2008 16:27:22 +0200
J. Pablo Fernández wrote:
> Hello,
> 
> It would be nice if emacsclient, when called with no arguments, would
> just run the alternate editor. I've configured emacs as my alternate
> editor so emacsclient for me is basically a "open this in an existing
> emacs or run one otherwise", the only problem for that to work
> completely is having it working with no arguments.

The patched version of emacsclient that I distribute with Emacs+EmacsW32 
does that. If you are on another platform it would be nice if you tested 
that code there.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#646; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#646; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "J. Pablo\" Fernández" <pupeno <at> pupeno.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #20 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "J. Pablo\" Fernández" <pupeno <at> pupeno.com>
To: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
Cc: 646 <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
Subject: Re: bug#646: No arguments
Date: Tue, 05 Aug 2008 07:31:16 +0200
[Message part 1 (text/plain, inline)]
On Mon, 2008-08-04 at 16:27 +0200, Lennart Borgman (gmail) wrote:
> J. Pablo Fernández wrote:
> > Hello,
> > 
> > It would be nice if emacsclient, when called with no arguments, would
> > just run the alternate editor. I've configured emacs as my alternate
> > editor so emacsclient for me is basically a "open this in an existing
> > emacs or run one otherwise", the only problem for that to work
> > completely is having it working with no arguments.
> 
> The patched version of emacsclient that I distribute with Emacs+EmacsW32 
> does that. If you are on another platform it would be nice if you tested 
> that code there.

I use a pre-packaged Emacs, but I can try to give it a chance, where can
I get the patch?

Thanks.
-- 
J. Pablo Fernández <pupeno <at> pupeno.com> http://pupeno.com
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#646; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "J. Pablo\" Fernández" <pupeno <at> pupeno.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#646; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #30 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: "" <pupeno <at> pupeno.com>
Cc: 646 <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
Subject: Re: bug#646: No arguments
Date: Tue, 05 Aug 2008 11:33:30 +0200
J. Pablo" Fernández wrote:
> On Mon, 2008-08-04 at 16:27 +0200, Lennart Borgman (gmail) wrote:
>> J. Pablo Fernández wrote:
>>> Hello,
>>>
>>> It would be nice if emacsclient, when called with no arguments, would
>>> just run the alternate editor. I've configured emacs as my alternate
>>> editor so emacsclient for me is basically a "open this in an existing
>>> emacs or run one otherwise", the only problem for that to work
>>> completely is having it working with no arguments.
>> The patched version of emacsclient that I distribute with Emacs+EmacsW32 
>> does that. If you are on another platform it would be nice if you tested 
>> that code there.
> 
> I use a pre-packaged Emacs, but I can try to give it a chance, where can
> I get the patch?

I will send them to you privately.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#646; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Severity set to `wishlist' from `normal' Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> emacsbugs.donarmstrong.com. (Mon, 18 Aug 2008 19:35:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#646; Package emacs. (Fri, 27 Aug 2021 03:33:02 GMT) Full text and rfc822 format available.

Message #40 received at 646 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "J. Pablo "Fernández\"" <pupeno <at> pupeno.com>
Cc: 646 <at> debbugs.gnu.org
Subject: Re: bug#646: emacsclient with no args to behave like -a
Date: Fri, 27 Aug 2021 05:31:52 +0200
"J. Pablo "Fernández\"" <pupeno <at> pupeno.com> writes:

> It would be nice if emacsclient, when called with no arguments, would
> just run the alternate editor. I've configured emacs as my alternate
> editor so emacsclient for me is basically a "open this in an existing
> emacs or run one otherwise", the only problem for that to work
> completely is having it working with no arguments.

(I'm going through old bug reports that unfortunately weren't
resolved at the time.)

It seems like this has been fixed in the 13 years since it was reported.

I did:

larsi <at> elva:~/src/emacs/trunk$ export ALTERNATE_EDITOR=nano
larsi <at> elva:~/src/emacs/trunk$ ./lib-src/emacsclient /tmp/foo

and that opened nano.

So I'm closing this bug report.  If there's more to be done here, please
respond to the debbugs address and we'll reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 646 <at> debbugs.gnu.org and "J. Pablo Fernández" <pupeno <at> pupeno.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 27 Aug 2021 03:33:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#646; Package emacs. (Fri, 27 Aug 2021 04:01:02 GMT) Full text and rfc822 format available.

Message #45 received at 646 <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>,
 J. Pablo Fernández\ <pupeno <at> pupeno.com>
Cc: 646 <at> debbugs.gnu.org
Subject: Re: bug#646: emacsclient with no args to behave like -a
Date: Thu, 26 Aug 2021 21:00:12 -0700
On 8/26/2021 8:31 PM, Lars Ingebrigtsen wrote:
> "J. Pablo "Fernández\"" <pupeno <at> pupeno.com> writes:
> 
>> It would be nice if emacsclient, when called with no arguments, would
>> just run the alternate editor. I've configured emacs as my alternate
>> editor so emacsclient for me is basically a "open this in an existing
>> emacs or run one otherwise", the only problem for that to work
>> completely is having it working with no arguments.
> 
> (I'm going through old bug reports that unfortunately weren't
> resolved at the time.)
> 
> It seems like this has been fixed in the 13 years since it was reported.
> 
> I did:
> 
> larsi <at> elva:~/src/emacs/trunk$ export ALTERNATE_EDITOR=nano
> larsi <at> elva:~/src/emacs/trunk$ ./lib-src/emacsclient /tmp/foo
> 
> and that opened nano.

It sounds to me like the "args" in question would be "/tmp/foo" in this 
case. On Emacs 27.2 and 28.0.50, I see:

  $ export ALTERNATE_EDITOR=nano
  $ lib-src/emacsclient
  lib-src/emacsclient: file name or argument required
  Try 'lib-src/emacsclient --help' for more information

From my reading, this is the original reporter's preferred behavior:

  1) If Emacs is not currently running
     a) `emacsclient file.txt' starts Emacs and opens file.txt
     b) `emacsclient' starts Emacs (as though running `emacs')
  2) If Emacs is currently running
     a) `emacsclient file.txt' opens file.txt in the existing Emacs session
     b) `emacsclient' brings some frame in the existing Emacs session 
to the foreground




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#646; Package emacs. (Fri, 27 Aug 2021 04:16:02 GMT) Full text and rfc822 format available.

Message #48 received at 646 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: J. Pablo Fernández <pupeno <at> pupeno.com>,
 646 <at> debbugs.gnu.org
Subject: Re: bug#646: emacsclient with no args to behave like -a
Date: Fri, 27 Aug 2021 06:14:56 +0200
Jim Porter <jporterbugs <at> gmail.com> writes:

> From my reading, this is the original reporter's preferred behavior:
>
>   1) If Emacs is not currently running
>      a) `emacsclient file.txt' starts Emacs and opens file.txt
>      b) `emacsclient' starts Emacs (as though running `emacs')
>   2) If Emacs is currently running
>      a) `emacsclient file.txt' opens file.txt in the existing Emacs session
>      b) `emacsclient' brings some frame in the existing Emacs session
>      to the foreground

That's not my reading.  The bug reporter said "It would be nice if
emacsclient, when called with no arguments, would just run the alternate
editor."  I.e., emulate the "-a" parameter when called with no
parameters.

(He's also using Emacs as the alternate, but that's just a detail.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#646; Package emacs. (Fri, 27 Aug 2021 05:07:02 GMT) Full text and rfc822 format available.

Message #51 received at 646 <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: J. Pablo Fernández <pupeno <at> pupeno.com>,
 646 <at> debbugs.gnu.org
Subject: Re: bug#646: emacsclient with no args to behave like -a
Date: Thu, 26 Aug 2021 22:06:18 -0700
On 8/26/2021 9:14 PM, Lars Ingebrigtsen wrote:
> Jim Porter <jporterbugs <at> gmail.com> writes:
> 
>>  From my reading, this is the original reporter's preferred behavior:
>>
>>    1) If Emacs is not currently running
>>       a) `emacsclient file.txt' starts Emacs and opens file.txt
>>       b) `emacsclient' starts Emacs (as though running `emacs')
>>    2) If Emacs is currently running
>>       a) `emacsclient file.txt' opens file.txt in the existing Emacs session
>>       b) `emacsclient' brings some frame in the existing Emacs session
>>       to the foreground
> 
> That's not my reading.  The bug reporter said "It would be nice if
> emacsclient, when called with no arguments, would just run the alternate
> editor."  I.e., emulate the "-a" parameter when called with no
> parameters.
> 
> (He's also using Emacs as the alternate, but that's just a detail.)

Indeed, it's not 100% clear, especially since this is from so long ago 
that I can't quite remember how emacsclient worked back then. However, I 
did a bit of archaeology and found the following passage in a blog post 
from around the same time:

"First, I recommend using the W32 package. W32 has hacked the 
emacsclient in several useful ways. It will start Emacs if it isn't 
already running, it will call "raise-frame" on the Emacs window when 
started, and it permits starting emacsclient without a filename. "[1]

The last bit confirms that Lennart's patched emacsclient *could* work as 
in (2b) above.[2] Whether that's what the original reporter wanted is 
another story (though it's how I interpret it)...

[1] http://emacs-fu.blogspot.com/2009/03/windows-and-daemons.html
[2] Unfortunately, I couldn't find the sources for Emacs+EmacsW32 to 
confirm this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#646; Package emacs. (Fri, 27 Aug 2021 14:51:01 GMT) Full text and rfc822 format available.

Message #54 received at 646 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: "J. Pablo Fernández" <pupeno <at> pupeno.com>,
 646 <at> debbugs.gnu.org
Subject: Re: bug#646: emacsclient with no args to behave like -a
Date: Fri, 27 Aug 2021 16:50:10 +0200
Jim Porter <jporterbugs <at> gmail.com> writes:

> "First, I recommend using the W32 package. W32 has hacked the
> emacsclient in several useful ways. It will start Emacs if it isn't
> already running, it will call "raise-frame" on the Emacs window when
> started, and it permits starting emacsclient without a filename. "[1]

I think that's how emacsclient works these days -- if you set
ALTERNATE_EDITOR to the empty string.  (It starts a new daemon Emacs and
then connects to it.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#646; Package emacs. (Fri, 27 Aug 2021 17:19:01 GMT) Full text and rfc822 format available.

Message #57 received at 646 <at> debbugs.gnu.org (full text, mbox):

From: Jim Porter <jporterbugs <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: J. Pablo Fernández <pupeno <at> pupeno.com>,
 646 <at> debbugs.gnu.org
Subject: Re: bug#646: emacsclient with no args to behave like -a
Date: Fri, 27 Aug 2021 10:18:07 -0700
On 8/27/2021 7:50 AM, Lars Ingebrigtsen wrote:
> Jim Porter <jporterbugs <at> gmail.com> writes:
> 
>> "First, I recommend using the W32 package. W32 has hacked the
>> emacsclient in several useful ways. It will start Emacs if it isn't
>> already running, it will call "raise-frame" on the Emacs window when
>> started, and it permits starting emacsclient without a filename. "[1]
> 
> I think that's how emacsclient works these days -- if you set
> ALTERNATE_EDITOR to the empty string.  (It starts a new daemon Emacs and
> then connects to it.)

I tested this on Emacs 28.0.50, and a filename is still required. 
Otherwise emacsclient errors out as before.

[As an aside: the main difference that I see is that with 
ALTERNATE_EDITOR=emacs, `emacsclient file.txt' opens emacs directly (so 
there's no emacsclient process hanging around, only emacs). With 
ALTERNATE_EDITOR as the empty string, `emacsclient file.txt' starts a 
daemon Emacs (so there are emacsclient and `emacs --daemon' processes 
running).]

That said, you can call `emacsclient -c' to create a new Emacs frame. 
That works if you wanted to make a desktop shortcut to do something 
similar to the Emacs+EmacsW32 patched version of emacsclient, but that 
means it'll always open a new frame, even if you pass it some files. 
That's not necessarily the behavior people want.

No-args support in emacsclient could be nice for scripting or for things 
like the etc/emacsclient.desktop shortcut. Currently that uses a 
conditional to decide what to call based on whether it was passed any 
files (reformatted here for clarity):

  if [ -n "$*" ]; then
    exec emacsclient --alternate-editor= --display="$DISPLAY" "$@";
  else
    exec emacsclient --alternate-editor= --create-frame;
  fi

Fixing this issue could simplify that to something like: `emacsclient 
--alternate-editor= %F'. However, since emacsclient.desktop handles this 
already (albeit with a somewhat complex incantation), maybe that's enough.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#646; Package emacs. (Sat, 28 Aug 2021 15:03:02 GMT) Full text and rfc822 format available.

Message #60 received at 646 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: "J. Pablo Fernández" <pupeno <at> pupeno.com>,
 646 <at> debbugs.gnu.org
Subject: Re: bug#646: emacsclient with no args to behave like -a
Date: Sat, 28 Aug 2021 17:02:17 +0200
Jim Porter <jporterbugs <at> gmail.com> writes:

> I tested this on Emacs 28.0.50, and a filename is still
> required. Otherwise emacsclient errors out as before.

Oh, I interpreted "no args" as "no -a arg".  :-)  A filename is
required; yes.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 26 Sep 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 211 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.