From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Jay Kamat Newsgroups: gmane.emacs.bugs Subject: bug#29821: Ensure quick substitution only occurs at start of line Date: Fri, 22 Dec 2017 15:57:08 -0800 Message-ID: <87fu8272h6.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1513986974 8864 195.159.176.226 (22 Dec 2017 23:56:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 22 Dec 2017 23:56:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) To: 29821@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 23 00:56:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSXAf-0001xd-2r for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Dec 2017 00:56:09 +0100 Original-Received: from localhost ([::1]:39503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSXCd-0006vJ-L1 for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Dec 2017 18:58:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSXCY-0006vE-0m for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2017 18:58:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSXCU-0006gL-UN for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2017 18:58:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eSXCU-0006g9-PT for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2017 18:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eSXCU-00063p-Ea for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2017 18:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jay Kamat Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Dec 2017 23:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 29821 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.151398704723251 (code B ref -1); Fri, 22 Dec 2017 23:58:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Dec 2017 23:57:27 +0000 Original-Received: from localhost ([127.0.0.1]:48473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSXBt-00062v-Ei for submit@debbugs.gnu.org; Fri, 22 Dec 2017 18:57:25 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36285) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSXBr-00062h-C4 for submit@debbugs.gnu.org; Fri, 22 Dec 2017 18:57:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSXBk-0006O6-JF for submit@debbugs.gnu.org; Fri, 22 Dec 2017 18:57:17 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:56744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eSXBk-0006Nu-Es for submit@debbugs.gnu.org; Fri, 22 Dec 2017 18:57:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSXBj-0006n5-2J for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2017 18:57:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSXBg-0006L0-18 for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2017 18:57:15 -0500 Original-Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]:32787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eSXBf-0006Jh-O0 for bug-gnu-emacs@gnu.org; Fri, 22 Dec 2017 18:57:11 -0500 Original-Received: by mail-pf0-x235.google.com with SMTP id y89so15880580pfk.0 for ; Fri, 22 Dec 2017 15:57:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:message-id:date:user-agent:mime-version; bh=6VUoQ4HSNBP6sVqJ/8A4OMNi60H3rmjrs9bV5P+dVVw=; b=TiLZ7J2aQJtU5T2YWCvjvAhJDDtV5T8MjjYmXD3w8YtuipDlQUSEdFkTt4F3TFMWwL 25IrcEe6LOBU8hcCR5vYYfcCDMfTMSr0rB+CtyD8g+j17Bp+PbiN3Yr30DHKd0EcPsge 1oAbdsNQBsG7ieVwZyuGRc7k1Bjyg2Bm+GOBVIZE++vU4VrxHXZt94qKTKPg3sWsyIB2 msk9arqgeuqTUaE9EisGhyg19aIwzU0Ir90+kYlZXileYeZhL6Psb3XatS0UamESfT8w Pb+/LfMwt73D8wNuo33Abv2SkUN3hs4PuGw0lDEda9wOczncKLXM+i/ccao3O+32wQF3 uWVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version; bh=6VUoQ4HSNBP6sVqJ/8A4OMNi60H3rmjrs9bV5P+dVVw=; b=V/HzgXbxb0Ij5gpVHgQfY76Ah+8JyhVnOf11z5dW/F2U3AcqQNxbkBjNgIQRww+SRM Hla+j7wHOdkdXeKe4bNfaNyUqpo6TxAKOZ/1HbuwsI+DDlsznwE7nUkikuIV13dyn6US 78Hfn9FZEHFp30AIHBaLaHoMLSvrrDge712ZoK5SmezHRO2L++8D2ICVznB3Hc3FNfwL nQz6NqyR+mM3YD8+TIGijcaNkNVj3e71p+TsShSaTQsHNyIyIglIMMV9kvnXVzcJpphR Yw2jwCDK2ixDsSfivr/K58I85gUwhrAIDYYyLNsJ/Zz6rt9y9gT+l6kjN7MOb0rcN2im /Yqg== X-Gm-Message-State: AKGB3mLy/f84I83O42c4s5RUYv21D9DHiGKzVwpLJ4hGm8jlklZAgzOm +g6aO0K6g7LngfYMSiQwtW248bOD X-Google-Smtp-Source: ACJfBovcCpFAbJrd+nIRujVnBDVN3N2yzMS0TYt/yNcGc0z3KxPa+Th2LMO8uYzBCUt6LfB9yjk5Lg== X-Received: by 10.99.143.67 with SMTP id r3mr13970609pgn.224.1513987030050; Fri, 22 Dec 2017 15:57:10 -0800 (PST) Original-Received: from laythe (c-67-161-9-47.hsd1.ca.comcast.net. [67.161.9.47]) by smtp.gmail.com with ESMTPSA id s68sm46805900pfj.81.2017.12.22.15.57.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Dec 2017 15:57:09 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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: 208.118.235.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:141403 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi! I'm filing this separately from #29157, because I think that issue got a bit overloaded with multiple eshell problems and is very hard to follow. I recently noticed the changes in #29157, and I'm disappointed that we came to the conclusion to disable history expansion completely. I find it's rather useful, especially for things like: $ mv one.txt two.txtt # whoops! $ mv !!:$ two.txt This is preferred (in my opinion) over lisp functions to keep muscle memory working between shells. If anything, I would suggest disabling quick substitution (as I don't find it more useful than using history directly most of the time) I've created a patch to try to fix the bug found in #29157, which was: > echo $PATH | sed "s/[^o]foo[^o]/bar/g" > Unknown predicate character =E2=80=98b=E2=80=99 The fix is rather simple, it simply limits the quick substitution to the start of the line only (as observed in bash, as Andreas noted in the previous thread). I hope that we reconsider the decision to disable history expansion by default, it's a nice feature of eshell (which I have another patch I would like to submit later to try to expand it's functionality a bit more). Please let me know if you think this is a poor way of solving this issue (or if anything else seems wrong or missing), and I'll try to follow up. Thanks, -Jay --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Prevent-expansion-of-quick-substitutions-when-not-at.patch >From 2c14085989a1edb5d3420150dcf91bc0914f012b Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Fri, 22 Dec 2017 15:34:44 -0800 Subject: [PATCH] Prevent expansion of quick substitutions when not at start of line See bug #29157 for an initial report * lisp/eshell/em-hist.el (eshell-expand-history-references): Calculate and send a start-of-line variable to eshell-history-reference (eshell-history-reference): Use start-of-line variable to force expansion of quick substitutions only on start of line --- lisp/eshell/em-hist.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index df462a7058..9561d8b988 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el @@ -588,8 +588,9 @@ eshell-expand-history-references (pose (nreverse (nth 2 result)))) (save-excursion (while textargs - (let ((str (eshell-history-reference (car textargs)))) - (unless (eq str (car textargs)) + (let ((str (eshell-history-reference (car textargs) + (not (cdr-safe textargs))))) + (unless (eq str (car textargs)) (goto-char (car posb)) (insert-and-inherit str) (delete-char (- (car pose) (car posb))))) @@ -630,7 +631,7 @@ eshell-complete-history-reference (setq history (cdr history))) (cdr fhist))))))) -(defun eshell-history-reference (reference) +(defun eshell-history-reference (reference start-of-line) "Expand directory stack REFERENCE. The syntax used here was taken from the Bash info manual. Returns the resultant reference, or the same string REFERENCE if none @@ -638,7 +639,8 @@ eshell-history-reference ;; `^string1^string2^' ;; Quick Substitution. Repeat the last command, replacing ;; STRING1 with STRING2. Equivalent to `!!:s/string1/string2/' - (if (and (eshell-using-module 'eshell-pred) + (if (and start-of-line + (eshell-using-module 'eshell-pred) (string-match "\\^\\([^^]+\\)\\^\\([^^]+\\)\\^?\\s-*$" reference)) (setq reference (format "!!:s/%s/%s/" -- 2.11.0 --=-=-=--