unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: "J. Pablo Fernández" <pupeno@pupeno.com>, 646@debbugs.gnu.org
Subject: bug#646: emacsclient with no args to behave like -a
Date: Fri, 27 Aug 2021 10:18:07 -0700	[thread overview]
Message-ID: <f0d33609-cdd6-9f31-3532-2dafbb1b61f3@gmail.com> (raw)
In-Reply-To: <87v93rndr1.fsf@gnus.org>

On 8/27/2021 7:50 AM, Lars Ingebrigtsen wrote:
> Jim Porter <jporterbugs@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.





  reply	other threads:[~2021-08-27 17:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-04 10:10 bug#646: No arguments J. Pablo Fernández 
2008-08-04 14:27 ` Lennart Borgman (gmail)
2008-08-05  5:31   ` J. Pablo" Fernández 
2008-08-05  9:33     ` Lennart Borgman (gmail)
2021-08-27  3:31 ` bug#646: emacsclient with no args to behave like -a Lars Ingebrigtsen
2021-08-27  4:00   ` Jim Porter
2021-08-27  4:14     ` Lars Ingebrigtsen
2021-08-27  5:06       ` Jim Porter
2021-08-27 14:50         ` Lars Ingebrigtsen
2021-08-27 17:18           ` Jim Porter [this message]
2021-08-28 15:02             ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f0d33609-cdd6-9f31-3532-2dafbb1b61f3@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=646@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=pupeno@pupeno.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).