* bug#40731: [PATCH] Make emacsclient fail if --eval is used and no Emacs server connection established
@ 2020-04-20 12:22 Ilya Ostapyshyn
2020-04-22 7:23 ` bug#40731: Followup Ilya Ostapyshyn
0 siblings, 1 reply; 3+ messages in thread
From: Ilya Ostapyshyn @ 2020-04-20 12:22 UTC (permalink / raw)
To: 40731
[-- Attachment #1: Type: text/plain, Size: 301 bytes --]
Hello,
This patch makes emacsclient quit with an error message if both --eval
and --alternate-editor were specified.
According to the current implementation, the emacsclient runs
alternate-editor, treating the eval expression as the filename, which
is IMO not very intuitive.
Kind regards,
Illia.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: PATCH --]
[-- Type: text/x-patch, Size: 1296 bytes --]
From dcc18914c7109c06d570790d24b44f99ceb2a5d7 Mon Sep 17 00:00:00 2001
From: Ilya Ostapyshyn <ilya.ostapyshyn@gmail.com>
Date: Mon, 20 Apr 2020 15:06:07 +0300
Subject: [PATCH] exit if no connection and --eval used
---
lib-src/emacsclient.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 380be95222..d74750ea5d 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -691,14 +691,21 @@ print_help_and_exit (void)
exit (EXIT_SUCCESS);
}
-/* Try to run a different command, or --if no alternate editor is
+/* If args were to be evaluated exit immediately with an error code.
+ Try to run a different command, or --if no alternate editor is
defined-- exit with an error code.
Uses argv, but gets it from the global variable main_argv. */
static _Noreturn void
fail (void)
{
- if (alternate_editor)
+ if (eval)
+ {
+ /* No way to evaluate Lisp expressions if there is
+ no connection to an Emacs server. */
+ message (true, "%s: unable evaluate ELisp expressions.\n", progname);
+ }
+ else if (alternate_editor)
{
size_t extra_args_size = (main_argc - optind + 1) * sizeof (char *);
size_t new_argv_size = extra_args_size;
--
2.26.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#40731: Followup
2020-04-20 12:22 bug#40731: [PATCH] Make emacsclient fail if --eval is used and no Emacs server connection established Ilya Ostapyshyn
@ 2020-04-22 7:23 ` Ilya Ostapyshyn
2020-08-08 12:39 ` Lars Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Ilya Ostapyshyn @ 2020-04-22 7:23 UTC (permalink / raw)
To: 40731
I have found a commit ~6fe661342a24edcaea255c3ba9a37613031554da~ which
addressed the same issue but in a different way.
However, the commit was reverted
(hash ~f198a5c5144fdded1400df6e8454e4b1b912c7de~) with the following message:
> The alternate editor may be Emacs, which is useful when you want to
> eval something in an existing Emacs (if it exists), or in a new Emacs
> if there's no server running.
I beg to differ. In fact, the --eval is not an optarg parameter, instead
it tells emacsclient to treat the whole FILE argument as lisp
expressions for evaluation.
Therefore, invoking
emacsclient -a emacs -e '(emacs-version)'
just opens a file named "(emacs-version)" in a new instance of Emacs if
server is not running.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#40731: Followup
2020-04-22 7:23 ` bug#40731: Followup Ilya Ostapyshyn
@ 2020-08-08 12:39 ` Lars Ingebrigtsen
0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-08 12:39 UTC (permalink / raw)
To: Ilya Ostapyshyn; +Cc: 40731
Ilya Ostapyshyn <ilya.ostapyshyn@gmail.com> writes:
> I have found a commit ~6fe661342a24edcaea255c3ba9a37613031554da~ which
> addressed the same issue but in a different way.
>
> However, the commit was reverted
> (hash ~f198a5c5144fdded1400df6e8454e4b1b912c7de~) with the following message:
>
>> The alternate editor may be Emacs, which is useful when you want to
>> eval something in an existing Emacs (if it exists), or in a new Emacs
>> if there's no server running.
>
> I beg to differ. In fact, the --eval is not an optarg parameter, instead
> it tells emacsclient to treat the whole FILE argument as lisp
> expressions for evaluation.
>
> Therefore, invoking
> emacsclient -a emacs -e '(emacs-version)'
> just opens a file named "(emacs-version)" in a new instance of Emacs if
> server is not running.
Hm. Unfortunately the reverting commit doesn't refer to the test case
that somebody had for this, but there was a complaint after the change
that the change ruined their work flow.
There was a test case for this, but it wasn't included in the reversion
commit, and I don't recall what it was now...
emacsclient -a "emacs -e" -e '(emacs-version)'
or something?
In any case, we can't regress this work flow, so we can't fix this
somewhat illogical way emacsclient works, so I'm closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-08 12:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 12:22 bug#40731: [PATCH] Make emacsclient fail if --eval is used and no Emacs server connection established Ilya Ostapyshyn
2020-04-22 7:23 ` bug#40731: Followup Ilya Ostapyshyn
2020-08-08 12:39 ` Lars Ingebrigtsen
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).