From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 02:52:32 2025 Received: (at submit) by debbugs.gnu.org; 13 Sep 2025 06:52:32 +0000 Received: from localhost ([127.0.0.1]:52831 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxK7b-0004ZC-UZ for submit@debbugs.gnu.org; Sat, 13 Sep 2025 02:52:32 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33746) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxK7W-0004YX-9D for submit@debbugs.gnu.org; Sat, 13 Sep 2025 02:52:30 -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 1uxK7Q-0005JM-FF for bug-gnu-emacs@gnu.org; Sat, 13 Sep 2025 02:52:20 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uxK7N-0002r4-HJ; Sat, 13 Sep 2025 02:52:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=SjV60yXooxxRSwv55RNpFvoFnKrD3GIitZf9lNoRDBg=; b=dU1/Zx/TbHSMbB R/ImhPoiyKS8KD0vnnhX29hKNyqzOQX8FhdKb/R7UYrvy2dbNBjy0AAwa7WsgLrjwZoDCH2Da1LFc Y3xPdL3gnkGmLmVess/i5QhG7IqLeiUIpaBKWWEqnpnjc3eB4RuBtk7TpQvtsD03sRbovWtWBRac7 aFe7sdTfMbQbwAr6jm8lYP47N1ed1SNtlzO2ANJou1thl6Y9CJJgkP3Dbs5scj4uLc35DAjXAS1kB xk4RkwP2o1wEDkPvltP19MYu3tC69DKKw9Yr2vwDJN5FGLAqYzccBtcvOnw2HgfUbHJGOg6RKmuTx 3fZqtaTIEO+lQDvxEyaA==; From: Janneke Nieuwenhuizen To: bug-gnu-emacs@gnu.org Subject: shell-resync-dirs breaks on PS1 with newline Organization: AvatarAcademy.nl X-Url: http://AvatarAcademy.nl Date: Sat, 13 Sep 2025 08:52:15 +0200 Message-ID: <875xdmc09s.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) 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: -1.0 (-) Hi! It's great that shell-resync-dirs no longer hangs, but now (30.2) it breaks on my prompt: --8<---------------cut here---------------start------------->8--- PS1=3D'$(_q=3D$?; if [ $_q !=3D 0 ]; then echo "[$_q] ";fi)\t \u@\h:\w'" $P= SG"'\n$ ' --8<---------------cut here---------------end--------------->8--- saying Couldn=E2=80=99t cd: (wrong-type-argument stringp nil) and failing to update the buffer's directory. I've been using it for ages: It shows the last exit value if non-zero, the time, the user, pwd and uses a newline always leave plenty of typing space. (PSG is set to "[env]" when inside a GUIX_ENVIRONMENT.) Anyway, typing: PS1=3D'$ ' (or even PS1=3D'\w$ ') fixes it, i.e., M-RET works again. To reproduce, a single character (that is not '.') and a newline suffices, typing something like: PS1=3D'0\n$ ' in an emacs shell and typing M-RET reproduces the problem. Greetings, Janneke --=20 Janneke Nieuwenhuizen | GNU LilyPond https://LilyPond.org Freelance IT https://www.JoyOfSource.com | Avatar=C2=AE https://AvatarAcade= my.com From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 06:49:52 2025 Received: (at 79441) by debbugs.gnu.org; 13 Sep 2025 10:49:52 +0000 Received: from localhost ([127.0.0.1]:53901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxNpH-0001QK-E4 for submit@debbugs.gnu.org; Sat, 13 Sep 2025 06:49:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50882) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxNpE-0001Pl-Sb for 79441@debbugs.gnu.org; Sat, 13 Sep 2025 06:49:49 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uxNp9-0008EO-Kk; Sat, 13 Sep 2025 06:49:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=aVus3r78pBuaKaNTURVKLHGRsJEUkzhjJAtDLHEAMKU=; b=h5Nrwe/eRnTqdarXVSSm F/1896w3H5oGK3S4Tts9x0cMBMNGB1XToOrwGJ7xtYrtY5Wu2S1a1UOSjEkTxiV9CuYtR9a2dX/zK sgu5pnz6+c9uT6IFj8K2ggYek66FpkI6tGkr4mvQxcP3mg/xSX0MJx1MmRx0Rv5ez3yDuBJ/jHa/4 SMRjrailZ4Fb+tYfBg40jKl90sqzt0oYRzL961Ch0/3C1SrLVHOK2j/khYDh6uABq0tYOo+3WjiR4 6a+TrNP/3b/r0PxtYwqhD7A0p1cCBPHY7b5G0PI6AFf/9DaIxo6On0q700XtxoVIfAIpm+exxHyKX FsqmfKbKtDmvAw==; Date: Sat, 13 Sep 2025 13:49:40 +0300 Message-Id: <867by2r5iz.fsf@gnu.org> From: Eli Zaretskii To: Janneke Nieuwenhuizen In-Reply-To: <875xdmc09s.fsf@gnu.org> (message from Janneke Nieuwenhuizen on Sat, 13 Sep 2025 08:52:15 +0200) Subject: Re: bug#79441: shell-resync-dirs breaks on PS1 with newline References: <875xdmc09s.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79441 Cc: 79441@debbugs.gnu.org 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: -3.3 (---) > From: Janneke Nieuwenhuizen > Date: Sat, 13 Sep 2025 08:52:15 +0200 > > Hi! > > It's great that shell-resync-dirs no longer hangs, but now (30.2) it > breaks on my prompt: > > --8<---------------cut here---------------start------------->8--- > PS1='$(_q=$?; if [ $_q != 0 ]; then echo "[$_q] ";fi)\t \u@\h:\w'" $PSG"'\n$ ' > --8<---------------cut here---------------end--------------->8--- > > saying > > Couldn’t cd: (wrong-type-argument stringp nil) > > and failing to update the buffer's directory. > > I've been using it for ages: It shows the last exit value if non-zero, > the time, the user, pwd and uses a newline always leave plenty of typing > space. (PSG is set to "[env]" when inside a GUIX_ENVIRONMENT.) > > Anyway, typing: > > PS1='$ ' > > (or even PS1='\w$ ') fixes it, i.e., M-RET works again. To reproduce, a > single character (that is not '.') and a newline suffices, typing > something like: > > PS1='0\n$ ' > > in an emacs shell and typing M-RET reproduces the problem. Can you suggest how to solve this? From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 13 11:02:01 2025 Received: (at 79441) by debbugs.gnu.org; 13 Sep 2025 15:02:01 +0000 Received: from localhost ([127.0.0.1]:55871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxRlI-0008PX-Kl for submit@debbugs.gnu.org; Sat, 13 Sep 2025 11:02:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42370) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxRlF-0008PI-NN for 79441@debbugs.gnu.org; Sat, 13 Sep 2025 11:01:58 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uxRl9-0004Zq-Nr; Sat, 13 Sep 2025 11:01:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=ppnz6yuobXiT7rvwyOZJR+jIPz3nCy9WgcdDQnV4sUg=; b=OiATombmzchn9C9gPtuL mJkpVvhKPMmmXCvSRdDwNxBoCkbis+4H52Wqo21exlxkcfoTCj9R4fGLs3mmZ9AwtuoJUnXPM116a CTEmMOgBzIC/YHfnd1rUYu99dAc4ti6rhCQEqdxsVwbIVASyp+thUEkol4mchsWOIFuraMHQwyNE9 tMhecX32nPTat1BdXRBI0OKIrzO8Cc2eqFVv4iIJRct2+zQKPYvpqwzbO1VO3vhQ6+MXaGBC0MPie lBa99uoLwsQDKXj+AO1cFXP/Y9w5tbPfpzMFPAdIkYlmj/j8SbYgI9mOx9bWO9cx0/8so10lljoiI vcaEq2DrET9AXA==; From: Janneke Nieuwenhuizen To: Eli Zaretskii Subject: [PATCH] Re: bug#79441: shell-resync-dirs breaks on PS1 with newline In-Reply-To: <867by2r5iz.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 13 Sep 2025 13:49:40 +0300") Organization: AvatarAcademy.nl References: <875xdmc09s.fsf@gnu.org> <867by2r5iz.fsf@gnu.org> X-Url: http://AvatarAcademy.nl Date: Sat, 13 Sep 2025 17:01:45 +0200 Message-ID: <871poa9z1i.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79441 Cc: 79441@debbugs.gnu.org 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: -3.3 (---) --=-=-= Content-Type: text/plain Eli Zaretskii writes: Hi Eli, [.] >> To reproduce, a >> single character (that is not '.') and a newline suffices, typing >> something like: >> >> PS1='0\n$ ' >> >> in an emacs shell and typing M-RET reproduces the problem. > > Can you suggest how to solve this? Good question! When I tried to add (message ...) debugging this morning, it started (and kept) looping; so I had no idea how to proceed. However, I tried again and got better results this time and have created a patch that "works for me" (see attached). The puzzle is that I don't know all the requirements, e.g., I have no idea why the code was (blindly) using `last' to set `dsl' from the shell-dirtrack-query's result, and only much later using file-directory-p. The code using `last' suggests to me that there could me more (partial?) directory-like elements coming back from `shell-dirtrack-query' and that in such a case, that I haven't oberved, the last must be the most relevant? Also, the nested while loops lateron with the concatenations suggest that `shell-dirtrack-query' may not always return the needed directory element as one string, but that it could be split up in parts that would need to be concatenated? Also, something that I didn't observe. So, I've changed the code to prefer `seq-find' with `file-directory-p' and reverse the list first, so that the last element remains the most relevant. Also, I've kept selecting the last element in case the `seq-find' does not return a result. Anyway, naively looking at my case only, it seems the code could be a lot simpler, using just the `seq-find' and without the nested `while' loops...so yeah, dunno ;) Greetings, Janneke --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-shell-resync-dirs-for-multi-line-prompt.patch >From f56b284e5423b2fe37d07a477008b12f6b1107c1 Mon Sep 17 00:00:00 2001 From: Janneke Nieuwenhuizen Date: Sat, 13 Sep 2025 16:30:42 +0200 Subject: [PATCH] Fix 'shell-resync-dirs' for multi-line prompt. * lisp/shell.el (shell-eval-command): Instead of always taking the last element from the shell-dirtrack-query command, first try selecting the last directory. (Bug#79441) --- lisp/shell.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/shell.el b/lisp/shell.el index 09d4161ba7a..927dec52304 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -1236,11 +1236,11 @@ shell-resync-dirs `shell-dirstack-query' (default \"dirs\"), reads the next line output and parses it to form the new directory stack." (interactive) - (let* ((dls (car - (last - (string-lines - (string-chop-newline - (shell-eval-command (concat shell-dirstack-query "\n"))))))) + (let* ((lines (nreverse + (string-lines + (shell-eval-command (concat shell-dirstack-query "\n"))))) + (dls (or (seq-find #'file-directory-p lines) + (car lines))) (dlsl nil) (pos 0) (ds nil)) -- 2.51.0 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Janneke Nieuwenhuizen | GNU LilyPond https://LilyPond.org Freelance IT https://www.JoyOfSource.com | Avatar=C2=AE https://AvatarAcade= my.com --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 14 01:50:54 2025 Received: (at 79441) by debbugs.gnu.org; 14 Sep 2025 05:50:54 +0000 Received: from localhost ([127.0.0.1]:59244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxfdW-0003I6-4c for submit@debbugs.gnu.org; Sun, 14 Sep 2025 01:50:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60092) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxfdS-0003Hk-Cz for 79441@debbugs.gnu.org; Sun, 14 Sep 2025 01:50:51 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uxfdL-00057I-8l; Sun, 14 Sep 2025 01:50:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=frCCyvSq8CByYzv6BvUT1JFHB4Q0E2zvoIE1Aa4/jQw=; b=gnRNxsfvCHul7g8FIv86 dSAKFvodSAFO2LOoU7gVJzDaz3/jwU4B7lfvPZPMFAMRRrNj5PtQJXr5ctzZANWJZipcmo1L6Wp4c jptamE0eTyzasJaALlaUM1p3PlnwtFUPVA5VlA1R4YZ+ayr+dju4VpotJpLxgwYssb+NOcbuLhXjL Oep6Et/JhgBZf59S0J1jbY4lUO91KOF2yhR2tVW2l9/xWZrCkbIjjRRT8fjzNHnkTgsW/3iO6eitj /BB0UKTHZecJ78XkM7GPGJB2Ht1/5jSSlQQJKkXfsTIBapZs/ZMCJJvgM0jktKVZVob9qWwYY4Px1 vcz6F+ai2lZncg==; From: Janneke Nieuwenhuizen To: Eli Zaretskii Subject: Re: bug#79441: [PATCH v2] Re: bug#79441: shell-resync-dirs breaks on PS1 with newline In-Reply-To: <871poa9z1i.fsf_-_@gnu.org> (Janneke Nieuwenhuizen's message of "Sat, 13 Sep 2025 17:01:45 +0200") Organization: AvatarAcademy.nl References: <875xdmc09s.fsf@gnu.org> <867by2r5iz.fsf@gnu.org> <871poa9z1i.fsf_-_@gnu.org> X-Url: http://AvatarAcademy.nl Date: Sun, 14 Sep 2025 07:50:38 +0200 Message-ID: <87v7ll8tw1.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79441 Cc: 79441@debbugs.gnu.org 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: -3.3 (---) --=-=-= Content-Type: text/plain Janneke Nieuwenhuizen writes: Hello! > [.] > >>> To reproduce, a >>> single character (that is not '.') and a newline suffices, typing >>> something like: >>> >>> PS1='0\n$ ' >>> >>> in an emacs shell and typing M-RET reproduces the problem. >> >> Can you suggest how to solve this? > > Good question! When I tried to add (message ...) debugging this > morning, it started (and kept) looping; so I had no idea how to proceed. > However, I tried again and got better results this time and have created > a patch that "works for me" (see attached). [..] Snip rationale that still holds...but ...initially I only used `seq-filter' in my patch, so I removed the stripping of the optional final newline. When I added the fall-back to takk the last element of the list, we'd need to bring back that final newline removal. Version 2 attached. Greetings, Janneke --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v2-0001-Fix-shell-resync-dirs-for-multi-line-prompt.patch >From a08fc315b30044c7feb86a04a135ea7de434bf11 Mon Sep 17 00:00:00 2001 From: Janneke Nieuwenhuizen Date: Sat, 13 Sep 2025 16:30:42 +0200 Subject: [PATCH v2] Fix 'shell-resync-dirs' for multi-line prompt. * lisp/shell.el (shell-eval-command): Instead of always taking the last element from the shell-dirtrack-query command, first try selecting the last directory. (Bug#79441) --- lisp/shell.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/shell.el b/lisp/shell.el index 09d4161ba7a..a9c71488f2d 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -1236,11 +1236,12 @@ shell-resync-dirs `shell-dirstack-query' (default \"dirs\"), reads the next line output and parses it to form the new directory stack." (interactive) - (let* ((dls (car - (last - (string-lines - (string-chop-newline - (shell-eval-command (concat shell-dirstack-query "\n"))))))) + (let* ((lines (nreverse + (string-lines + (string-chop-newline + (shell-eval-command (concat shell-dirstack-query "\n")))))) + (dls (or (seq-find #'file-directory-p lines) + (car lines))) (dlsl nil) (pos 0) (ds nil)) -- 2.51.0 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Janneke Nieuwenhuizen | GNU LilyPond https://LilyPond.org Freelance IT https://www.JoyOfSource.com | Avatar=C2=AE https://AvatarAcade= my.com --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 14 02:08:54 2025 Received: (at 79441) by debbugs.gnu.org; 14 Sep 2025 06:08:54 +0000 Received: from localhost ([127.0.0.1]:59308 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxfuv-0004sX-PM for submit@debbugs.gnu.org; Sun, 14 Sep 2025 02:08:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59444) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxfut-0004sK-J2 for 79441@debbugs.gnu.org; Sun, 14 Sep 2025 02:08:51 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uxfun-0006wW-OD; Sun, 14 Sep 2025 02:08:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=EZV0H4EId92acQya+67/KpSlPM1+BzB0UhH6Pt5Y8nc=; b=nORnmo+io5ZR OJDzkixgQ1w9nON31xd0rcvnEnrPUEmCqaJQhipRIRAiuLJlJnAvXwTj++N/4mSxp1F1PcAMxhRxS BxHk8qZL9GZDqzJli0WSvpE3Gp4i+oJGWvT+fy4CX/DAXYyLSssHT/SkjjJup4SibLCj6y1vomLFK ZQTq2jqN1q+z5ipWP+Jgj5vbTbnT6juasM7fU42Dq9LZncFKKjdgOAAaS7jilfL50/ptYc0oUcmNV Fa6iRl3ITAstwtpeJPBhme4IVaiopvziozMeFyMCSAVW1BZ4aUzUna0NUwOmhakRHr5y7lCgg+688 kwZKpdKVwQfAO/yqGByqzQ==; Date: Sun, 14 Sep 2025 09:08:42 +0300 Message-Id: <865xdlpnv9.fsf@gnu.org> From: Eli Zaretskii To: Janneke Nieuwenhuizen In-Reply-To: <871poa9z1i.fsf_-_@gnu.org> (message from Janneke Nieuwenhuizen on Sat, 13 Sep 2025 17:01:45 +0200) Subject: Re: [PATCH] Re: bug#79441: shell-resync-dirs breaks on PS1 with newline References: <875xdmc09s.fsf@gnu.org> <867by2r5iz.fsf@gnu.org> <871poa9z1i.fsf_-_@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79441 Cc: 79441@debbugs.gnu.org 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: -3.3 (---) > From: Janneke Nieuwenhuizen > Cc: 79441@debbugs.gnu.org > Date: Sat, 13 Sep 2025 17:01:45 +0200 > > > Can you suggest how to solve this? > > Good question! When I tried to add (message ...) debugging this > morning, it started (and kept) looping; so I had no idea how to proceed. > However, I tried again and got better results this time and have created > a patch that "works for me" (see attached). > > The puzzle is that I don't know all the requirements, e.g., I have no > idea why the code was (blindly) using `last' to set `dsl' from the > shell-dirtrack-query's result, and only much later using > file-directory-p. > > The code using `last' suggests to me that there could me more (partial?) > directory-like elements coming back from `shell-dirtrack-query' and that > in such a case, that I haven't oberved, the last must be the most > relevant? > > Also, the nested while loops lateron with the concatenations suggest > that `shell-dirtrack-query' may not always return the needed directory > element as one string, but that it could be split up in parts that would > need to be concatenated? Also, something that I didn't observe. Yes, these all can happen. I think if you use "git log -L" to show changes in the relevant portions of the code, you will find bug reports that describe those cases. > So, I've changed the code to prefer `seq-find' with `file-directory-p' > and reverse the list first, so that the last element remains the most > relevant. Also, I've kept selecting the last element in case the > `seq-find' does not return a result. > > Anyway, naively looking at my case only, it seems the code could be a > lot simpler, using just the `seq-find' and without the nested `while' > loops...so yeah, dunno ;) Thanks. However, if it doesn't handle the case of receiving a partial directory from the shell, it will cause regressions. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 14 06:47:22 2025 Received: (at 79441) by debbugs.gnu.org; 14 Sep 2025 10:47:22 +0000 Received: from localhost ([127.0.0.1]:60459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxkGQ-0004sO-A4 for submit@debbugs.gnu.org; Sun, 14 Sep 2025 06:47:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48186) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxkGM-0004rY-Cz for 79441@debbugs.gnu.org; Sun, 14 Sep 2025 06:47:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uxkGG-000451-O0; Sun, 14 Sep 2025 06:47:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=QwWZIceVdZtCW9aIK7rB2bFNyY3dXWvjxflq1jKtZ4M=; b=CRKVJn5wd8QZM67f1w7t IzL8RxmGvtr59Zd97ETvLmuo1xD+YsIteR35AllIOUHQZsV0mWc11TzCykFJGwOutEu8IGd/MSfiJ Xm3uonpM/vNCsxQK5kZzZZu0L059ZhvtpUWKp9+HrhKzOBeTXzoGUZpbTqEYudbOZNT/eYpxDQFhG A5Vu+MLEVKweYUTclu3hBnThTZHD4kwTx8vE3Pyr8QSw4IgTE/j/5DeU/LptDFI7GAmzK5RNdVnu5 NACaHOKveHVssZXLeSWTno4pDCcaUkoq2YxHcv/IdTeGpNezK+xWTUVX5kfZu+PWQ0ITqMrhakU4F T2083Kas7YMAlg==; From: Janneke Nieuwenhuizen To: Eli Zaretskii Subject: Re: bug#79441: [PATCH] Re: bug#79441: shell-resync-dirs breaks on PS1 with newline In-Reply-To: <865xdlpnv9.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 14 Sep 2025 09:08:42 +0300") Organization: AvatarAcademy.nl References: <875xdmc09s.fsf@gnu.org> <867by2r5iz.fsf@gnu.org> <871poa9z1i.fsf_-_@gnu.org> <865xdlpnv9.fsf@gnu.org> X-Url: http://AvatarAcademy.nl Date: Sun, 14 Sep 2025 12:47:06 +0200 Message-ID: <87qzw98g5x.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79441 Cc: 79441@debbugs.gnu.org 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: -3.3 (---) Eli Zaretskii writes: >> From: Janneke Nieuwenhuizen >> Cc: 79441@debbugs.gnu.org >> Date: Sat, 13 Sep 2025 17:01:45 +0200 >>=20 >> > Can you suggest how to solve this? >>=20 >> Good question! [..] >> Also, the nested while loops lateron with the concatenations suggest >> that `shell-dirtrack-query' may not always return the needed directory >> element as one string, but that it could be split up in parts that would >> need to be concatenated? Also, something that I didn't observe. > > Yes, these all can happen. I think if you use "git log -L" to show > changes in the relevant portions of the code, you will find bug > reports that describe those cases. Okay. I did not attempt to simplify the code, just tried to address the regression. --=20 Janneke Nieuwenhuizen | GNU LilyPond https://LilyPond.org Freelance IT https://www.JoyOfSource.com | Avatar=C2=AE https://AvatarAcade= my.com