From unknown Thu Aug 14 21:49:41 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#63748 <63748@debbugs.gnu.org> To: bug#63748 <63748@debbugs.gnu.org> Subject: Status: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts Reply-To: bug#63748 <63748@debbugs.gnu.org> Date: Fri, 15 Aug 2025 04:49:41 +0000 retitle 63748 30.0.50; eshell-previous-prompt doesn't work for multiline pr= ompts reassign 63748 emacs submitter 63748 Tony Zorman severity 63748 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sat May 27 04:38:29 2023 Received: (at submit) by debbugs.gnu.org; 27 May 2023 08:38:29 +0000 Received: from localhost ([127.0.0.1]:51372 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2pRU-0006sV-IE for submit@debbugs.gnu.org; Sat, 27 May 2023 04:38:29 -0400 Received: from lists.gnu.org ([209.51.188.17]:55476) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2pRT-0006sO-Jw for submit@debbugs.gnu.org; Sat, 27 May 2023 04:38:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2pRT-0001wc-DR for bug-gnu-emacs@gnu.org; Sat, 27 May 2023 04:38:27 -0400 Received: from mout-p-103.mailbox.org ([80.241.56.161]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1q2pRP-0006tA-QY for bug-gnu-emacs@gnu.org; Sat, 27 May 2023 04:38:27 -0400 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4QSwD54xyjz9sX7 for ; Sat, 27 May 2023 10:38:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1685176693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Yvd5zPQJ9Mxm0hxdn9wmSPNBbqyUIBL6xW7ItFU8ec4=; b=tgXcBJ+0KD2NgrU4TShgVGIytPUYvbwDQY8/LcSAWpxbi5VGiVCmNkIWPoYrMyNVEHeSfS yocT0nEXKLbj6Tcii7ZOyqdb7OdMXUcN6SwYS+uKudat9cmHuqKtQPFUAU3pkXbkhvs7bU qe06BPpJ3WMfuLch8gP9+pNp/fja0fJSvQ4/IkBewnXWUTN2Wi+VzENQUgKQfC0/wjWiPF sih97mzGzphBNmdIrPaO3bOwFnx+XZHc+MmXX3ljsYEnHEUuqfTIr1Eb+iW91gH/M2bUqN 1Nb8YkmR+/qJAPXVz/AuWUVKkDwZMKS2LUHi0YTNW/9BDHe4t+VYuRmu1GJkAA== From: Tony Zorman To: bug-gnu-emacs@gnu.org Subject: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts Date: Sat, 27 May 2023 10:38:11 +0200 Message-ID: <87ilcew4ng.fsf@hyperspace> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-MBO-RS-ID: 826ccdd27562ed900af X-MBO-RS-META: 4h6smwax1xbxp954hbb7cfuu5m8j51cy Received-SPF: pass client-ip=80.241.56.161; envelope-from=soliditsallgood@mailbox.org; helo=mout-p-103.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi, in commit c257fd3a406d6aa83be60b96217e42b49b62cf5f, the way prompt navigation in eshell is done was changed; it now works via a text property search instead of searching for the prompt regexp. When backwards searching with a prompt that spans multiple lines, however, one doesn't get off the ground because the current prompt isn't properly skipped. More precisely: define a custom prompt (defun my/default-prompt-function () (concat "=E2=94=8C=E2=94=80" (user-login-name) "@" (system-name) " " (abbreviate-file-name (eshell/pwd)) " \n" "=E2=94=94=E2=94=80" (if (zerop (user-uid)) "#" "$") " ")) and enable it by setting (setq eshell-prompt-function #'my/default-prompt-function) (setq eshell-prompt-regexp "=E2=94=94=E2=94=80[$#] ") ; For good measu= re.=20 This will result in the point not moving backwards to the last prompt on C-c C-p (eshell-previous-prompt), but instead it gets "stuck" on the very left of the line it is on. A solution to this (I think) is to actually search for the beginning of the current prompt, instead of using forward-line by itself. I.e., something like diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index 9f9e58e83d..b6c873b41d 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -180,7 +180,8 @@ eshell-next-prompt (text-property-search-forward 'field 'prompt t)) (setq n (1- n))) (let (match this-match) - (forward-line 0) ; Don't count prompt on current line. + ;; Don't count prompt on current line. + (text-property-search-backward 'field 'prompt t) (while (and (< n 0) (setq this-match (text-property-search-backward 'field 'prompt t))) This is a tiny change, so I suppose it can be applied immediately (if I haven't overlooked anything, of course), or I can prepare a proper patch (that perhaps adds a test for multiline prompts to the right place). Tony ----------------------------------------------------------------------- In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-musl, cairo version 1.16.0) of 2023-05-17 built on pbox Repository revision: 6cb963b73c3768958e13e96b2534d1e99239a3ff Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101008 System Description: Void Linux Configured using: 'configure --with-x --without-x-toolkit --without-toolkit-scroll-bars --without-dbus --without-gconf --without-gsettings --with-modules --with-file-notification=3Dinotify --with-jpeg --with-tiff --with-gif --with-png --with-xpm --with-rsvg --without-imagemagick --with-cairo --with-gnutls --with-sound --with-json --with-harfbuzz --with-gpm --with-native-compilation --without-compress-install --with-xinput2 --with-small-ja-dic --without-tree-sitter 'CFLAGS=3D-O2 -pipe -march=3Dnative -mtune=3Dnative -fomit-frame-pointer'' Configured features: CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY OLDXMENU PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF WEBP X11 XDBE XIM XINPUT2 XPM ZLIB Important settings: value of $LC_ALL: en_US.UTF-8 value of $LC_COLLATE: C value of $LANG: en_GB locale-coding-system: utf-8-unix --=20 Tony Zorman | https://tony-zorman.com/ From debbugs-submit-bounces@debbugs.gnu.org Tue May 30 01:02:35 2023 Received: (at 63748) by debbugs.gnu.org; 30 May 2023 05:02:35 +0000 Received: from localhost ([127.0.0.1]:59768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3rVC-0007Mb-NT for submit@debbugs.gnu.org; Tue, 30 May 2023 01:02:35 -0400 Received: from mail-pf1-f179.google.com ([209.85.210.179]:61602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3rVA-0007MO-N0 for 63748@debbugs.gnu.org; Tue, 30 May 2023 01:02:33 -0400 Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-64d30ab1ef2so2968963b3a.2 for <63748@debbugs.gnu.org>; Mon, 29 May 2023 22:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685422946; x=1688014946; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=MQjzcxaShuTUO8cHi0X3ZTeP8wPKtzpsmh3xKmM4TOA=; b=qKvXslw9Ix+iDsmMKHx2IorEpc50PE6e//VV56CU1IrszCrmChJFe29LRsYS0FDhGv eVbXAVG/Lu0xgb0WRhdJ9pC4pLJkySwssQHXfaTXPhZAKQ2aH7h/H45L7PSHbjdBzI1y dAkKdQyQ+lphCFR95f5okJd+KZsggf5Wrrx3lqi2j3JdLUyRCnEllU8JdGvzdeY3Da2w 8jKSrPinurcQW5MXhU2PAbnXfU3sH8Apo/OSeBez96QaoaSK1Og9jPoOe+ks0TqBI1tW GUoH64LZfiN8h23cT4VjIYrayZwjKmqCwJtG7g19N7s0awW0eVAWnhdNq4UyCznmiH1k ZMAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685422946; x=1688014946; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MQjzcxaShuTUO8cHi0X3ZTeP8wPKtzpsmh3xKmM4TOA=; b=kbIW7TreZP2lwviLj+5tIAdwFtzEreuCu/KQaX0vEhLEhhu+vorL0BjcDpzYlRQuo2 g2rsXyg6T22MQbnbL+/ot6cosQVfWhfxQKqEHvkMy8FEst8mCCxHQL7IMuSK3HlUdtD9 4YMYN2qDMXbVrTcdg0g+zsx7Yi9qzWcw9ZwivcjhsLOtm8KuN8i324LRvDKp0p0sh4kG ONyhnAlNlAVH6nL1d7TmWVdOLvgCwFThCFhzGzX7Mh0Fe65zdDAZp+maknCvRKo+h2Z6 GPpWgPNKNUQ6koA7g5TZe1X3oe1FxPAAG6Kk6fXTTX+jvM91W6Nrcc8Dw3g/acnJO2tg 0fGA== X-Gm-Message-State: AC+VfDwfgH0DqgFYIe2n2/pTBSF6RLyYd+RUqZzTg3+PcQSU4I10ALpW cyMhX9tTDF0as4xS5jnXpHc= X-Google-Smtp-Source: ACHHUZ69ZsC49j5s3UhMZLIIBKFZpNUr7oxFiJuidx5uQDW9F/jTmS7hQX4ILWpkgF32gr+PNRT7lw== X-Received: by 2002:a05:6a00:13a3:b0:64d:30d2:f69e with SMTP id t35-20020a056a0013a300b0064d30d2f69emr1140279pfg.3.1685422946594; Mon, 29 May 2023 22:02:26 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id r2-20020a654982000000b0050bc4ca9024sm6942324pgs.65.2023.05.29.22.02.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 May 2023 22:02:26 -0700 (PDT) Message-ID: <14785aa0-e1a5-6f69-9d1f-fccdaac9a7fc@gmail.com> Date: Mon, 29 May 2023 22:02:26 -0700 MIME-Version: 1.0 Subject: Re: bug#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts Content-Language: en-US To: Tony Zorman , 63748@debbugs.gnu.org References: <87ilcew4ng.fsf@hyperspace> From: Jim Porter In-Reply-To: <87ilcew4ng.fsf@hyperspace> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63748 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 5/27/2023 1:38 AM, Tony Zorman via Bug reports for GNU Emacs, the > diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el > index 9f9e58e83d..b6c873b41d 100644 > --- a/lisp/eshell/em-prompt.el > +++ b/lisp/eshell/em-prompt.el > @@ -180,7 +180,8 @@ eshell-next-prompt > (text-property-search-forward 'field 'prompt t)) > (setq n (1- n))) > (let (match this-match) > - (forward-line 0) ; Don't count prompt on current line. > + ;; Don't count prompt on current line. > + (text-property-search-backward 'field 'prompt t) > (while (and (< n 0) > (setq this-match (text-property-search-backward > 'field 'prompt t))) > > This is a tiny change, so I suppose it can be applied immediately (if I > haven't overlooked anything, of course), or I can prepare a proper patch > (that perhaps adds a test for multiline prompts to the right place). Thanks for catching this. I think the change you propose makes sense (though I haven't actually tried it out). A test would be great. See "test/lisp/eshell/em-prompt-tests.el": another test based on 'em-prompt-test/next-previous-prompt' (and possibly 'em-prompt-test/forward-backward-matching-input' too) should be sufficient, I think. If you want to add a test yourself, go for it, and let me know if you run into any issues. Otherwise if you prefer, I can write a test case for this. From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 03 09:27:45 2023 Received: (at 63748) by debbugs.gnu.org; 3 Jun 2023 13:27:45 +0000 Received: from localhost ([127.0.0.1]:41821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5RIG-0002Sk-Cf for submit@debbugs.gnu.org; Sat, 03 Jun 2023 09:27:44 -0400 Received: from mout-p-101.mailbox.org ([80.241.56.151]:51542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5RIC-0002ST-GV for 63748@debbugs.gnu.org; Sat, 03 Jun 2023 09:27:42 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4QYLJh4PTzz9sVt; Sat, 3 Jun 2023 15:27:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1685798852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OJrm/SUtCZUDlSs+glE2fuUv9qBfEOquENYwFRJo8OQ=; b=kJCbJSS/ylL5+C57+20dmy23ShkiU1bJl0ATiqvojiMh3yfXhKVKAnnO89ni41l9hLx8N3 eK94go7c5QYzLIyAnkJPqItjTr49FD2bCMxqcoWWi4P/6Ik1jhd7I2CYcK2LUJ4LbX3PLy Jz+HPawPQ8JeLrEjzLBsTDPg/P3bApGn9GqAc1uylII5bYatucn8IHIjyyURDGZvAtvCHZ mqcuTvs4dZ5AJO7vI+Ge9IdZlaBBBeSdVQQjP8r8wp+iKafxNxlJgaz6otnAapNRCWzD2f hQz4/HGNqaSO79hhigpS1G9xcIV5ndLvg0NSUNKpWc/LGwJ0sp+h3bNuqTVxGg== From: Tony Zorman To: Jim Porter , 63748@debbugs.gnu.org Subject: [PATCH] bug#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts In-Reply-To: <14785aa0-e1a5-6f69-9d1f-fccdaac9a7fc@gmail.com> References: <87ilcew4ng.fsf@hyperspace> <14785aa0-e1a5-6f69-9d1f-fccdaac9a7fc@gmail.com> Date: Sat, 03 Jun 2023 15:27:30 +0200 Message-ID: <87bkhwllq5.fsf@hyperspace> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-MBO-RS-META: ztnesm3ozwixwocy7p1f8hcftoq13qcc X-MBO-RS-ID: 86dfef5a299a8dff107 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 63748 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain On Mon, May 29 2023 22:02, Jim Porter wrote: > A test would be great. See "test/lisp/eshell/em-prompt-tests.el": > another test based on 'em-prompt-test/next-previous-prompt' (and > possibly 'em-prompt-test/forward-backward-matching-input' too) should be > sufficient, I think. > > If you want to add a test yourself, go for it, and let me know if you > run into any issues. Otherwise if you prefer, I can write a test case > for this. Okay, I now added some hopefully sufficient tests for this based on both next-previous-prompt and forward-backward-matching-input (if that's not too overkill). Let me know what you think. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-eshell-next-prompt-More-precisely-navigate-to-the-pr.patch Content-Transfer-Encoding: quoted-printable >From 45b4e788fb60138516ed8e58a368d72d994da4c0 Mon Sep 17 00:00:00 2001 From: Tony Zorman Date: Sat, 3 Jun 2023 14:23:19 +0200 Subject: [PATCH] eshell-next-prompt: More precisely navigate to the prompt (bug#63748) * lisp/eshell/em-prompt.el (eshell-next-prompt): Navigate to the current prompt more accurately by using text properties instead of going to the beginning of the line. This is important for multiline prompts, as they don't necessarily start at the beginning of the current line. * test/lisp/eshell/em-prompt-tests.el (em-prompt-test/multiline): Test a given function with a multiline prompt. (em-prompt-test/next-previous-prompt-with): (em-prompt-test/forward-backward-matching-input-with): Helper functions for code reuse. (em-prompt-test/forward-backward-matching-input): (em-prompt-test/next-previous-prompt): Rewrite in terms of the appropriate helper functions. (em-prompt-test/next-previous-prompt-multiline): (em-prompt-test/forward-backward-matching-input-multiline): Add multiline variants of existing tests. --- lisp/eshell/em-prompt.el | 3 +- test/lisp/eshell/em-prompt-tests.el | 45 ++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index 9f9e58e83d..42f8f273b5 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -180,7 +180,8 @@ eshell-next-prompt (text-property-search-forward 'field 'prompt t)) (setq n (1- n))) (let (match this-match) - (forward-line 0) ; Don't count prompt on current line. + ;; Don't count the current prompt. + (text-property-search-backward 'field 'prompt t) (while (and (< n 0) (setq this-match (text-property-search-backward 'field 'prompt t))) diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prom= pt-tests.el index 257549e40f..7e3454a4d3 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el @@ -80,9 +80,27 @@ em-prompt-test/field-properties/no-highlight (apply #'propertize "hello\n" eshell-command-output-properties))))))) =20 -(ert-deftest em-prompt-test/next-previous-prompt () - "Check that navigating forward/backward through old prompts works correc= tly." +(defun em-prompt-test/multiline (test-fun) + "Execute TEST-FUN with a multiline prompt." + (funcall + test-fun + '(progn + (setq eshell-prompt-function + (lambda () + (concat "=E2=94=8C=E2=94=80" + (user-login-name) "@" (system-name) + " " (abbreviate-file-name (eshell/pwd)) " \n" + "=E2=94=94=E2=94=80" + (if (zerop (user-uid)) "#" "$") + " "))) + (setq eshell-prompt-regexp "=E2=94=94=E2=94=80[$#] ")))) + +(defun em-prompt-test/next-previous-prompt-with (&optional more) + "Helper for checking forward/backward navigation of old prompts. +Accepts an additional argument, to be executed inside of a +temporary eshell buffer." (with-temp-eshell + (eval more) (eshell-insert-command "echo one") (eshell-insert-command "echo two") (eshell-insert-command "echo three") @@ -98,9 +116,20 @@ em-prompt-test/next-previous-prompt (eshell-next-prompt 3) (should (equal (eshell-get-old-input) "echo fou")))) =20 -(ert-deftest em-prompt-test/forward-backward-matching-input () - "Check that navigating forward/backward via regexps works correctly." +(ert-deftest em-prompt-test/next-previous-prompt () + "Check that navigating forward/backward through old prompts works correc= tly." + (em-prompt-test/next-previous-prompt-with)) + +(ert-deftest em-prompt-test/next-previous-prompt-multiline () + "Check old prompt forward/backward navigation for multiline prompts." + (em-prompt-test/multiline #'em-prompt-test/next-previous-prompt-with)) + +(defun em-prompt-test/forward-backward-matching-input-with (&optional more) + "Helper for checking forward/backward navigation via regexps. +Accepts an additional argument, to be executed inside of a +temporary eshell buffer." (with-temp-eshell + (eval more) (eshell-insert-command "echo one") (eshell-insert-command "printnl something else") (eshell-insert-command "echo two") @@ -117,4 +146,12 @@ em-prompt-test/forward-backward-matching-input (eshell-forward-matching-input "echo" 3) (should (equal (eshell-get-old-input) "echo fou")))) =20 +(ert-deftest em-prompt-test/forward-backward-matching-input () + "Check that navigating forward/backward via regexps works correctly." + (em-prompt-test/forward-backward-matching-input-with)) + +(ert-deftest em-prompt-test/forward-backward-matching-input-multiline () + "Check forward/backward regexp navigation for multiline prompts." + (em-prompt-test/multiline #'em-prompt-test/forward-backward-matching-inp= ut-with)) + ;;; em-prompt-tests.el ends here --=20 2.40.1 --=-=-= Content-Type: text/plain -- Tony Zorman | https://tony-zorman.com/ --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 03 15:36:01 2023 Received: (at 63748) by debbugs.gnu.org; 3 Jun 2023 19:36:01 +0000 Received: from localhost ([127.0.0.1]:44338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5X2e-0003WG-QC for submit@debbugs.gnu.org; Sat, 03 Jun 2023 15:36:01 -0400 Received: from mail-ot1-f50.google.com ([209.85.210.50]:57764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5X2c-0003Vz-EE for 63748@debbugs.gnu.org; Sat, 03 Jun 2023 15:36:00 -0400 Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6af6f83fc49so3152201a34.3 for <63748@debbugs.gnu.org>; Sat, 03 Jun 2023 12:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685820952; x=1688412952; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=BxLL4lMPM9xf6yYlhl5jS7BS9/oLkrXh6azNA4R60tQ=; b=b39GWXchDSjN0njKkI09a8FMpiWGAIUWv8RltSb2OhuMGruNyiMB9lpKEQKFJA5MU5 D3SZ/pAkZVxgMcAbry8oNEPnl+XAvhxFLOgyVE1Zfl16L4kyXa71VJl64SsIsQTL/ULT AWiCiV7nA9QNXrCUavd5o1Lc9TXztrioX3OOhkk/7/hKMp7KBUMWTJVYjXQNWUXk6+GP dGOU9G2k7/C3yHpiOYybTCUihUvKIhDSlGJEQK7fRfkTE/ELeqfh5pIxNkf2n/WMq+Oa 3eN30WOg9F51eQP+FrYDjHJCyN43HtUUa5mzJhi1/kH78eG9IEqtsyXD3GkVQZ4TGtHZ duzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685820952; x=1688412952; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BxLL4lMPM9xf6yYlhl5jS7BS9/oLkrXh6azNA4R60tQ=; b=dxNPNi0NREtXGld85SqwAy0WX8KMKUl9IlNZHvghftXasFP4oCU7hJ9DE0qFKtSVX3 y5xThqK0l2hJ3isaxEWR8ShSZZ9BwMQ2tEvw6Xyc9kqIPxi4qYqhfTDqE861xsumelH7 RNe/lngbqZT1TqlfThhdnM1toXsG0dRCkU1FLH1Fr9TcMbar9q+VonHjUO/sJnRfAH7n X5J+cKuC7bdDZmceYZEN0B7ILsMTc6m9G2p27SeT14e5tv3RWyFGKE8JigUnJWo34fee XUB87bsBUXHMiNOAoq3/q5iKFMW7PJqSSZpkOTzCe0JCOfBBKnk7/zpRY9helOuq+XiA IwwA== X-Gm-Message-State: AC+VfDyBmmgK+L4tdOnhHU4kz3W7odQzzAecRDrakeBIGc3ZC5DoPiwi 1cRof+tyJLrIVbfZBKQdZlA= X-Google-Smtp-Source: ACHHUZ4jhJExDo9nVKJZnyJ0kNNlupP+XDrOX/jLh+E8Qc4QgJN5KhPlecXAHbchseEn4JE+G6yZlg== X-Received: by 2002:a05:6358:2812:b0:123:5664:e493 with SMTP id k18-20020a056358281200b001235664e493mr17576871rwb.27.1685820952335; Sat, 03 Jun 2023 12:35:52 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id g2-20020a17090a128200b0024e4f169931sm5084132pja.2.2023.06.03.12.35.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 03 Jun 2023 12:35:51 -0700 (PDT) Message-ID: <88ae9a36-c9f9-fe0a-80a2-d90ff1b3837a@gmail.com> Date: Sat, 3 Jun 2023 12:35:50 -0700 MIME-Version: 1.0 Subject: Re: bug#63748: [PATCH] bug#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts Content-Language: en-US To: Tony Zorman , 63748@debbugs.gnu.org References: <87ilcew4ng.fsf@hyperspace> <14785aa0-e1a5-6f69-9d1f-fccdaac9a7fc@gmail.com> <87bkhwllq5.fsf@hyperspace> From: Jim Porter In-Reply-To: <87bkhwllq5.fsf@hyperspace> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63748 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 6/3/2023 6:27 AM, Tony Zorman via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Okay, I now added some hopefully sufficient tests for this based on both > next-previous-prompt and forward-backward-matching-input (if that's not > too overkill). Let me know what you think. Thanks. You can probably simplify the multiline wrapper in your test to something like this: (defmacro em-prompt-test--with-multiline (&rest body) "Execute BODY with a multiline Eshell prompt." `(let ((eshell-prompt-function (lambda () "multiline prompt\n$ "))) ,@body)) Then use it like so: ;; Note: no arguments necessary. (defun em-prompt-test/forward-backward-matching-input-with () ;; ... ) (ert-deftest em-prompt-test/forward-backward-matching-input-multiline () (em-prompt-test--with-multiline (em-prompt-test/forward-backward-matching-input-with))) That should be safer than setq'ing the prompt function. (You also don't need to set the prompt regexp, since that's only useful if you want to navigate via '(forward|backward)-paragraph', and we don't test that here.) If you prefer, I can make that change myself and then merge your patch. From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 08 11:12:04 2023 Received: (at 63748) by debbugs.gnu.org; 8 Jun 2023 15:12:04 +0000 Received: from localhost ([127.0.0.1]:57202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q7HIx-0002ZO-N8 for submit@debbugs.gnu.org; Thu, 08 Jun 2023 11:12:04 -0400 Received: from mout-p-101.mailbox.org ([80.241.56.151]:54640) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q7HIt-0002Yr-TZ for 63748@debbugs.gnu.org; Thu, 08 Jun 2023 11:12:02 -0400 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4QcSNl5GNYz9snN; Thu, 8 Jun 2023 17:11:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1686237111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K+700GKEgzh6Y3cjoyudAfI4Z+jhM7aq+HhvG/Op2xc=; b=j68fGqxE47QNUz2dEQ52L3bRWkEaaP1ZV0LH8re9YctDq3RA2gBKgFiiHtU/rCgh20sx/1 tqeUpHHorHccIAoBxAtRZkoPrNhE2sb7Ic8oL5gmekdJYjwZDBruOF7UPKIcL0cKbPGJPM DwzXQlEdZUkg5FUtrSUm+Mt3nxAnJxOeaXU2XOH7gd8TaZQF4CPytjqmhcXcstVjnBfjbC MXFMhV6Jf5lP6tER2oaTZP96CZlSaHSLy0XL/SIvBy9agVjsWQJqNej22XF5H2TIBQVX4C 6HobI/V3oLwaSP9JAba0ejJoSnkxDQiW/l78sHcFlae+K6sSpQ/c/2/ogYwGsQ== From: Tony Zorman To: Jim Porter , 63748@debbugs.gnu.org Subject: Re: bug#63748: [PATCH] bug#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts In-Reply-To: <88ae9a36-c9f9-fe0a-80a2-d90ff1b3837a@gmail.com> References: <87ilcew4ng.fsf@hyperspace> <14785aa0-e1a5-6f69-9d1f-fccdaac9a7fc@gmail.com> <87bkhwllq5.fsf@hyperspace> <88ae9a36-c9f9-fe0a-80a2-d90ff1b3837a@gmail.com> Date: Thu, 08 Jun 2023 17:11:49 +0200 Message-ID: <878rcu0z0q.fsf@hyperspace> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-MBO-RS-ID: 953a708f360f1e5d0f4 X-MBO-RS-META: 5k6hxxsticfjheqwkrscgxqeghsfx79f X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 63748 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain On Sat, Jun 03 2023 12:35, Jim Porter wrote: > You can probably simplify the multiline wrapper in your test to > something like this: > > (defmacro em-prompt-test--with-multiline (&rest body) > "Execute BODY with a multiline Eshell prompt." > `(let ((eshell-prompt-function (lambda () "multiline prompt\n$ "))) > ,@body)) > > Then use it like so: > > ;; Note: no arguments necessary. > (defun em-prompt-test/forward-backward-matching-input-with () > ;; ... > ) > > (ert-deftest em-prompt-test/forward-backward-matching-input-multiline () > (em-prompt-test--with-multiline > (em-prompt-test/forward-backward-matching-input-with))) > > That should be safer than setq'ing the prompt function. (You also don't > need to set the prompt regexp, since that's only useful if you want to > navigate via '(forward|backward)-paragraph', and we don't test that here.) oh, this is pretty neat, thanks! Sorry for the slow response; I have attached the (hopefully properly) corrected patch now. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-eshell-next-prompt-More-precisely-navigate-to-the-pr.patch >From 37988ca00beb26c0ce22f1c5f0d16cc4df56662c Mon Sep 17 00:00:00 2001 From: Tony Zorman Date: Sat, 3 Jun 2023 14:23:19 +0200 Subject: [PATCH] eshell-next-prompt: More precisely navigate to the prompt (bug#63748) * lisp/eshell/em-prompt.el (eshell-next-prompt): Navigate to the current prompt more accurately by using text properties instead of going to the beginning of the line. This is important for multiline prompts, as they don't necessarily start at the beginning of the current line. * test/lisp/eshell/em-prompt-tests.el (em-prompt-test--with-multiline): Execute a given body with a multiline prompt. (em-prompt-test/next-previous-prompt-with): (em-prompt-test/forward-backward-matching-input-with): Helper functions for code reuse. (em-prompt-test/forward-backward-matching-input): (em-prompt-test/next-previous-prompt): Rewrite in terms of the appropriate helper functions. (em-prompt-test/next-previous-prompt-multiline): (em-prompt-test/forward-backward-matching-input-multiline): Add multiline variants of existing tests. --- lisp/eshell/em-prompt.el | 3 ++- test/lisp/eshell/em-prompt-tests.el | 31 +++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index 9f9e58e83d..42f8f273b5 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -180,7 +180,8 @@ eshell-next-prompt (text-property-search-forward 'field 'prompt t)) (setq n (1- n))) (let (match this-match) - (forward-line 0) ; Don't count prompt on current line. + ;; Don't count the current prompt. + (text-property-search-backward 'field 'prompt t) (while (and (< n 0) (setq this-match (text-property-search-backward 'field 'prompt t))) diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el index 257549e40f..93bf9d84ab 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el @@ -80,8 +80,13 @@ em-prompt-test/field-properties/no-highlight (apply #'propertize "hello\n" eshell-command-output-properties))))))) -(ert-deftest em-prompt-test/next-previous-prompt () - "Check that navigating forward/backward through old prompts works correctly." +(defmacro em-prompt-test--with-multiline (&rest body) + "Execute BODY with a multiline Eshell prompt." + `(let ((eshell-prompt-function (lambda () "multiline prompt\n$ "))) + ,@body)) + +(defun em-prompt-test/next-previous-prompt-with () + "Helper for checking forward/backward navigation of old prompts." (with-temp-eshell (eshell-insert-command "echo one") (eshell-insert-command "echo two") @@ -98,8 +103,17 @@ em-prompt-test/next-previous-prompt (eshell-next-prompt 3) (should (equal (eshell-get-old-input) "echo fou")))) -(ert-deftest em-prompt-test/forward-backward-matching-input () - "Check that navigating forward/backward via regexps works correctly." +(ert-deftest em-prompt-test/next-previous-prompt () + "Check that navigating forward/backward through old prompts works correctly." + (em-prompt-test/next-previous-prompt-with)) + +(ert-deftest em-prompt-test/next-previous-prompt-multiline () + "Check old prompt forward/backward navigation for multiline prompts." + (em-prompt-test--with-multiline + (em-prompt-test/next-previous-prompt-with))) + +(defun em-prompt-test/forward-backward-matching-input-with () + "Helper for checking forward/backward navigation via regexps." (with-temp-eshell (eshell-insert-command "echo one") (eshell-insert-command "printnl something else") @@ -117,4 +131,13 @@ em-prompt-test/forward-backward-matching-input (eshell-forward-matching-input "echo" 3) (should (equal (eshell-get-old-input) "echo fou")))) +(ert-deftest em-prompt-test/forward-backward-matching-input () + "Check that navigating forward/backward via regexps works correctly." + (em-prompt-test/forward-backward-matching-input-with)) + +(ert-deftest em-prompt-test/forward-backward-matching-input-multiline () + "Check forward/backward regexp navigation for multiline prompts." + (em-prompt-test--with-multiline + (em-prompt-test/forward-backward-matching-input-with))) + ;;; em-prompt-tests.el ends here -- 2.41.0 --=-=-= Content-Type: text/plain -- Tony Zorman | https://tony-zorman.com/ --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 15 12:46:52 2023 Received: (at 63748-done) by debbugs.gnu.org; 15 Jun 2023 16:46:52 +0000 Received: from localhost ([127.0.0.1]:47697 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9q7X-0001h0-Oy for submit@debbugs.gnu.org; Thu, 15 Jun 2023 12:46:52 -0400 Received: from mail-pj1-f54.google.com ([209.85.216.54]:53445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9q7W-0001gl-3H for 63748-done@debbugs.gnu.org; Thu, 15 Jun 2023 12:46:50 -0400 Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-25e7fe2fb51so1072936a91.2 for <63748-done@debbugs.gnu.org>; Thu, 15 Jun 2023 09:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686847604; x=1689439604; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=c+kO73JkDkhS4Zx6fiHfi4xsxeLAL8UiiXjNHht3EYA=; b=S3YReisV2brqVqZCPzNcZOvRjEg+2kmFWLK2DPTlY2KjR26q6hXgiGTu0BFXFxzvkO MuL4GDun9nw1QpmWDNyOux3atEq+B1x8f8MjwynTe/IYrbnu4exFA9lkb082Lk9lmwgL xydOF/z5Pj+yibRDSa9rFh7ug0ZA7pl1HhA4Kh79B71dZehI29Gwe/v3dxm7uiZaouKY io3u9YLNFdphjzMv5Qy/VWTVZ+B/6971EIr5rioS3oIJZv3G5Zy0OLWIu+MGB+9RDo8o c26X4w978Glifrlin7nDfq3kP1uPa2qaZF7139/ZAgGWZ/I7GzMf4NwnpoMC9fg8viFv X+WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686847604; x=1689439604; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=c+kO73JkDkhS4Zx6fiHfi4xsxeLAL8UiiXjNHht3EYA=; b=lurlL+YqXyLPD3qWbmHL64JyeG9d5+2ziYeoic71VysgfwvwEMNEVB/aOqnRSFXGl+ +nNrBmqx7VlUEWNsPwYBwRjF7ldWF0Lzws1Gyfk9lnp1osG+rSUxv09qc9Ihn0O6i4h7 G4yP0YebLyFY9HAK72HWNOp52CZbdR7izvD+CG2EBcLakg6drhetAFQp/52utZrY3HS9 iI/axdwncJJwvsG0wZglmBOzY4Ju/2m8D/2S730vfr/SIMG7NtQitTI0K3cOVm/gNbj6 6wk2DQke/FRBOEgP4d34KlyR5zgQRH1Y9j6zNUgdEMq0ApnLgqtohNP+/VXrP4buS6zx VgjA== X-Gm-Message-State: AC+VfDxb0MGcNr26qdZ8QKz+xKfsd3yQXftDDYZYOoQ6mnYnHXqu0Hmi beP6zhUz+Mt5v00BlVXmVxY= X-Google-Smtp-Source: ACHHUZ6WKmuYIh3btLK6lLnmxYPzUQAJX5X1yL1BOGPR/d0Md3wjazAEWbEH6OK2wajfL8CUFWk3fg== X-Received: by 2002:a17:90a:b28b:b0:259:343:86b5 with SMTP id c11-20020a17090ab28b00b00259034386b5mr4111564pjr.47.1686847604014; Thu, 15 Jun 2023 09:46:44 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id 38-20020a17090a0fa900b002565cd237cdsm2715608pjz.3.2023.06.15.09.46.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 09:46:43 -0700 (PDT) Message-ID: <29ac911c-4cc9-eaec-ad00-969c43f57caa@gmail.com> Date: Thu, 15 Jun 2023 09:46:41 -0700 MIME-Version: 1.0 Subject: Re: bug#63748: [PATCH] bug#63748: 30.0.50; eshell-previous-prompt doesn't work for multiline prompts To: Tony Zorman , 63748-done@debbugs.gnu.org References: <87ilcew4ng.fsf@hyperspace> <14785aa0-e1a5-6f69-9d1f-fccdaac9a7fc@gmail.com> <87bkhwllq5.fsf@hyperspace> <88ae9a36-c9f9-fe0a-80a2-d90ff1b3837a@gmail.com> <878rcu0z0q.fsf@hyperspace> Content-Language: en-US From: Jim Porter In-Reply-To: <878rcu0z0q.fsf@hyperspace> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63748-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 6/8/2023 8:11 AM, Tony Zorman via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > oh, this is pretty neat, thanks! > > Sorry for the slow response; I have attached the (hopefully properly) > corrected patch now. Thanks (and sorry for the slow response on my end too). This all looks good, so I've now merged it to master as f2aae8b879b. Closing this now. From unknown Thu Aug 14 21:49:41 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 14 Jul 2023 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator