GNU bug report logs - #11474
emacsclient passes --eval arguments (but not the '--eval') to alternate editor

Previous Next

Package: emacs;

Reported by: Jason Lewis <jason <at> dickson.st>

Date: Tue, 15 May 2012 05:24:02 UTC

Severity: wishlist

Tags: fixed, patch, wontfix

Merged with 12154, 18517

Found in versions 24.1, 24.1.50, 24.3.93

Fixed in version 27.1

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

Bug is archived. No further changes may be made.

Full log


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

From: Scott Turner <srt19170 <at> gmail.com>
To: 11474 <at> debbugs.gnu.org
Subject: Patch for Emacsclient --eval bug
Date: Fri, 13 Dec 2013 10:30:17 -0500
[Message part 1 (text/plain, inline)]
In emacsclient, the --eval option tells emacsclient to treat all arguments
as Elisp to be evaluated by the Emacs server.

The --alternate-editor option specifies an program to start if emacsclient
cannot find an Emacs server.

If both options are used and a server is not found, a bug arises.
Emacsclient sends the arguments that are intended to be interpreted as
Elisp to the alternate editor.  If the alternate editor is Emacs, this
results in Emacs creating a buffer named after each argument.  So the
command:

emacsclient --alternate-editor "emacs" --eval "(make-frame-visible)"

results in an Emacs with a buffer named "(make-frame-visible)".

Sending the Elisp arguments to the alternate-editor as plain arguments is
clearly wrong.  If we knew that the alternate-editor was Emacs, we could
send the argument along with "--eval=" prepended to have the newly started
Emacs evaluate the Elisp, but of course the alternate editor could be
something else entirely, and it's probably not the case that you'd want to
execute the same Elisp on startup as on resume.

The patch provided below simply discards the Elisp arguments when
emacsclient falls through to the alternate editor.  There may be better
fixes, but this does the least harm while retaining compatibility.

*** emacsclient.c    Tue Jan  1 15:37:17 2013
--- emacsclient-strip-eval.c    Thu Dec 12 20:01:06 2013
***************
*** 694,700 ****
      {
        int i = optind - 1;

!       execvp (alternate_editor, main_argv + i);
        message (TRUE, "%s: error executing alternate editor \"%s\"\n",
             progname, alternate_editor);
      }
--- 694,713 ----
      {
        int i = optind - 1;

!       /*
!        *  If the --eval option has been used, then the remaining
!        *  arguments are Elisp expressions intended to be evaluated
!        *  by emacsclient.  It doesn't make any sense to pass them
!        *  along to the alternate_editor to be treated as files.
!        *
!        */
!       if (eval) {
!     char *t_argv[] = {alternate_editor, 0 };
!     execvp (alternate_editor, t_argv);
!       } else {
!     execvp (alternate_editor, main_argv + i);
!       };
!
        message (TRUE, "%s: error executing alternate editor \"%s\"\n",
             progname, alternate_editor);
      }
[Message part 2 (text/html, inline)]

This bug report was last modified 5 years and 255 days ago.

Previous Next


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