From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#11474: Patch for Emacsclient --eval bug Date: Thu, 27 Jun 2019 20:40:37 +0200 Message-ID: References: <86ehqmm2u2.fsf@dickson.st> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="126590"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 11474@debbugs.gnu.org, Scott Turner To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 27 20:41:41 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hgZL2-000Woh-Bw for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Jun 2019 20:41:40 +0200 Original-Received: from localhost ([::1]:53604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgZL1-00018D-Cp for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Jun 2019 14:41:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50042) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgZKT-0000fO-88 for bug-gnu-emacs@gnu.org; Thu, 27 Jun 2019 14:41:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgZKQ-00086W-Eq for bug-gnu-emacs@gnu.org; Thu, 27 Jun 2019 14:41:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54335) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hgZKQ-00086B-1L for bug-gnu-emacs@gnu.org; Thu, 27 Jun 2019 14:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hgZKP-0003yg-S7 for bug-gnu-emacs@gnu.org; Thu, 27 Jun 2019 14:41:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Jun 2019 18:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11474 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 11474-submit@debbugs.gnu.org id=B11474.156166084915260 (code B ref 11474); Thu, 27 Jun 2019 18:41:01 +0000 Original-Received: (at 11474) by debbugs.gnu.org; 27 Jun 2019 18:40:49 +0000 Original-Received: from localhost ([127.0.0.1]:39646 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgZKC-0003y4-V0 for submit@debbugs.gnu.org; Thu, 27 Jun 2019 14:40:49 -0400 Original-Received: from quimby.gnus.org ([80.91.231.51]:47188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgZK8-0003xq-Bh for 11474@debbugs.gnu.org; Thu, 27 Jun 2019 14:40:45 -0400 Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hgZK1-0000ZR-JP; Thu, 27 Jun 2019 20:40:40 +0200 In-Reply-To: (Stefan Monnier's message of "Thu, 27 Jun 2019 14:17:20 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:161639 Archived-At: Stefan Monnier writes: >> $ emacsclient -a nano --eval '(my-emacs-setup-thing)' >> >> The eval bit is meaningful in Emacs, and may be something that the user >> feels is something that Emacs should do when called from emacsclient. >> But if there's no server, then we should use nano. >> >> The current behaviour is to use nano with the file name >> '(my-emacs-setup-thing)', while you propose to call nano with >> --eval '(my-emacs-setup-thing)', which would be even worse, I think, >> while just dropping the parameters completely in the -a case would make >> this usable. > > I think that nowadays with the `-a ""` option the need to keep > the --eval is indeed not very high, so I retract my objection. Hm... the emacsclient source code has changed substantially over the years, I see... if (alternate_editor) { size_t extra_args_size = (main_argc - optind + 1) * sizeof (char *); size_t new_argv_size = extra_args_size; char **new_argv = xmalloc (new_argv_size); [...] /* Append main_argv arguments to new_argv. */ memcpy (&new_argv[toks], main_argv + optind, extra_args_size); execvp (*new_argv, new_argv); message (true, "%s: error executing alternate editor \"%s\"\n", progname, alternate_editor); } So it now picks out arguments from the -a="nano --foo" string, and then appends the rest of the arguments from emacsclient. The equivalent here would be to set extra_args_size to 0 if eval, I guess. But... hm.... then we'd lose the file argument too, wouldn't we? I mean, if you say $ ./lib-src/emacsclient -a "nano -v" --eval '(message "foo")' /tmp/a the you want nano to open /tmp/a... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no