From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Samer Masterson Newsgroups: gmane.emacs.bugs Subject: bug#18960: Fwd: bug#18960: 24.4; Eshell history substitution causes error Date: Tue, 9 Dec 2014 14:49:40 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c16bc2f0e7530509d05cfa X-Trace: ger.gmane.org 1418165499 28415 80.91.229.3 (9 Dec 2014 22:51:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2014 22:51:39 +0000 (UTC) To: 18960@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 09 23:51:33 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XyTcz-00006f-3f for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Dec 2014 23:51:33 +0100 Original-Received: from localhost ([::1]:42803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyTcy-0008Cv-Ox for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Dec 2014 17:51:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyTcZ-0007sO-JZ for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 17:51:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyTcU-000417-OL for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 17:51:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyTcU-000413-LE for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 17:51:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XyTcU-0000xx-70 for bug-gnu-emacs@gnu.org; Tue, 09 Dec 2014 17:51:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Samer Masterson Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Dec 2014 22:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18960 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18960-submit@debbugs.gnu.org id=B18960.14181654063639 (code B ref 18960); Tue, 09 Dec 2014 22:51:02 +0000 Original-Received: (at 18960) by debbugs.gnu.org; 9 Dec 2014 22:50:06 +0000 Original-Received: from localhost ([127.0.0.1]:60045 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XyTbZ-0000wd-B6 for submit@debbugs.gnu.org; Tue, 09 Dec 2014 17:50:05 -0500 Original-Received: from mail-qc0-f176.google.com ([209.85.216.176]:64659) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XyTbV-0000w8-BX for 18960@debbugs.gnu.org; Tue, 09 Dec 2014 17:50:02 -0500 Original-Received: by mail-qc0-f176.google.com with SMTP id i17so1304366qcy.35 for <18960@debbugs.gnu.org>; Tue, 09 Dec 2014 14:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=DRseq+D9spUkzc2+Rsw8dCGAHs1AMbD6/Fs9GarbTUE=; b=EyPSAYbbH8KxMfNAz/WYzsFrPuuQSkpd6nXvqGAmXccFzSbprB8oGqQ+fDP3ExK+Ky r1+DrU32QkqgeKAOdJwgrsShdgkeITH64UNkmWMAX//YStLCgV7e10BZiw4AVmy3d2qG FPUyvQ8Tq82f0tisu9jOOBo0eeZpps0ol+tJvoj/SFUSRY5ZOipD8oWiWKj1RkYMeBlS BqrPmL3VdpVR9uyOxRqda7pbKimkBlkNmTA0ogSWgND+DGZlpuTO/R3aardiNaqjA3BO N/vt3X7LWCc/W9Ziop9DqlOGD6fpZKRie7STCJVXTlK2tPU9XTwMgn9e9RTZKB2CRjMS S1Jw== X-Received: by 10.140.102.144 with SMTP id w16mr1689295qge.59.1418165400690; Tue, 09 Dec 2014 14:50:00 -0800 (PST) Original-Received: by 10.140.93.84 with HTTP; Tue, 9 Dec 2014 14:49:40 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97114 Archived-At: --001a11c16bc2f0e7530509d05cfa Content-Type: text/plain; charset=UTF-8 On Tue, Dec 9, 2014 at 2:16 PM, Stefan Monnier wrote: > > Modified lisp/eshell/em-hist.el > > diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el > > index b721b5d..e7e9a1e 100644 > > --- a/lisp/eshell/em-hist.el > > +++ b/lisp/eshell/em-hist.el > > @@ -724,7 +724,7 @@ matched." > > (setq nth (eshell-hist-word-reference nth))) > > (unless (numberp mth) > > (setq mth (eshell-hist-word-reference mth))) > > - (cons (mapconcat 'identity (eshell-sublist textargs nth mth) "") > > + (cons (mapconcat 'identity (eshell-sublist textargs nth mth) " ") > > end)))) > > Can you explain why this is needed? > (eshell-sublist) will return a sublist of textargs, which might look like ("ehco" "hi" "there"). The call to mapconcat would join that list without adding whitespace between the args previously, e.g. into "echohithere", which is incorrect. This then gets fed into eshell-hist-parse-modifier as event on line 663. eshell-hist-parse-modifier would then make the substitution on "echohithere". > > > @@ -737,7 +737,7 @@ matched." > > (goto-char (point-min)) > > (let ((modifiers (cdr (eshell-parse-modifiers)))) > > (dolist (mod modifiers) > > - (setq hist (funcall mod hist))) > > + (setq hist (car (funcall mod (list hist))))) > > hist)) > > (delete-region here (point))))) > > The docstring of eshell-parse-modifiers says: > > Parse value modifiers and predicates at point. > If ALLOW-PREDS is non-nil, predicates will be parsed as well. > Return a cons cell of the form > > (PRED-FUNC-LIST . MOD-FUNC-LIST) > > NEW-STRING is STRING minus any modifiers. PRED-FUNC-LIST is a list of > predicate functions. MOD-FUNC-LIST is a list of result modifier > functions. PRED-FUNCS take a filename and return t if the test > succeeds; MOD-FUNCS take any string and preform a modification, > returning the resultant string. > > If I read this right, `mod' (which is one of MOD-FUNCS) should take > a string and return a string, IIUC. So, maybe the right fix is not to > change this code but to change the functions returned by > `eshell-parse-modifiers'. > Ah, I should have read the docstring for eshell-parse-modifiers instead of simply looking at the function it returns :) I'll make that change. Also, I assume that NEW-STRING and ALLOW-PREDS both refer to variables that were removed when this file was made lexically scoped, and will remove them from the docstring. > > > > Stefan > --001a11c16bc2f0e7530509d05cfa Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Tue, Dec 9, 201= 4 at 2:16 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Modified=C2=A0 =C2= =A0lisp/eshell/em-hist.el
> diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
> index b721b5d..e7e9a1e 100644
> --- a/lisp/eshell/em-hist.el
> +++ b/lisp/eshell/em-hist.el
> @@ -724,7 +724,7 @@ matched."
>=C2=A0 =C2=A0(setq nth (eshell-hist-word-reference nth)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (numberp mth)
>=C2=A0 =C2=A0(setq mth (eshell-hist-word-reference mth)))
> -=C2=A0 =C2=A0 =C2=A0 (cons (mapconcat 'identity (eshell-sublist t= extargs nth mth) "")
> +=C2=A0 =C2=A0 =C2=A0 (cons (mapconcat 'identity (eshell-sublist t= extargs nth mth) " ")
>=C2=A0 =C2=A0 =C2=A0 end))))

Can you explain why this is needed?

<= /span>
(eshell-sublist) will return a sublist of textargs, which might = look like ("ehco" "hi" "there"). The call to = mapconcat would join that list without adding whitespace between the args p= reviously, e.g. into "echohithere", which is incorrect. This then= gets fed into eshell-hist-parse-modifier as event on line 663. eshell-hist= -parse-modifier would then make the substitution on "echohithere"= .
=C2=A0

> @@ -737,7 +737,7 @@ matched."
>=C2=A0 =C2=A0 (goto-char (point-min))
>=C2=A0 =C2=A0 (let ((modifiers (cdr (eshell-parse-modifiers))))
>=C2=A0 =C2=A0 =C2=A0 (dolist (mod modifiers)
> -=C2=A0 =C2=A0 =C2=A0 (setq hist (funcall mod hist)))
> +=C2=A0 =C2=A0 =C2=A0 (setq hist (car (funcall mod (list hist)))))
>=C2=A0 =C2=A0 =C2=A0 hist))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 (delete-region here (point)))))

The docstring of eshell-parse-modifiers says:

=C2=A0 =C2=A0Parse value modifiers and predicates at point.
=C2=A0 =C2=A0If ALLOW-PREDS is non-nil, predicates will be parsed as well.<= br> =C2=A0 =C2=A0Return a cons cell of the form

=C2=A0 =C2=A0 =C2=A0(PRED-FUNC-LIST . MOD-FUNC-LIST)

=C2=A0 =C2=A0NEW-STRING is STRING minus any modifiers.=C2=A0 PRED-FUNC-LIST= is a list of
=C2=A0 =C2=A0predicate functions.=C2=A0 MOD-FUNC-LIST is a list of result m= odifier
=C2=A0 =C2=A0functions.=C2=A0 PRED-FUNCS take a filename and return t if th= e test
=C2=A0 =C2=A0succeeds; MOD-FUNCS take any string and preform a modification= ,
=C2=A0 =C2=A0returning the resultant string.

If I read this right, `mod' (which is one of MOD-FUNCS) should take
a string and return a string, IIUC.=C2=A0 So, maybe the right fix is not to=
change this code but to change the functions returned by
`eshell-parse-modifiers'.
=C2=A0Ah, I shoul= d have read the docstring for eshell-parse-modifiers instead of simply look= ing at the function it returns :) I'll make that change. Also, I assume= that NEW-STRING and ALLOW-PREDS both refer to variables that were removed = when this file was made lexically scoped, and will remove them from the doc= string.



=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan


--001a11c16bc2f0e7530509d05cfa--