GNU bug report logs - #78043
Cursor gets stuck after inline code input in comint buffer when using markdown-mode, bypassing prompt lines starting with '>'

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Kang Tu <tninja@HIDDEN>; dated Thu, 24 Apr 2025 15:48:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 78043 <at> debbugs.gnu.org:


Received: (at 78043) by debbugs.gnu.org; 25 Apr 2025 13:57:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 25 09:57:31 2025
Received: from localhost ([127.0.0.1]:50197 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u8JYX-00068A-6v
	for submit <at> debbugs.gnu.org; Fri, 25 Apr 2025 09:57:30 -0400
Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:44241)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <tninja@HIDDEN>) id 1u8JYJ-00067f-1m
 for 78043 <at> debbugs.gnu.org; Fri, 25 Apr 2025 09:57:23 -0400
Received: by mail-ej1-x634.google.com with SMTP id
 a640c23a62f3a-ac3eb3fdd2eso412150766b.0
 for <78043 <at> debbugs.gnu.org>; Fri, 25 Apr 2025 06:57:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1745589428; x=1746194228; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=6LUMt5//WEO8jbCIcwdEPl6iFnCU139tP5jp7xLrDwM=;
 b=a2CE03gjWzA+Vad19SlsdzdNTt955IY72frwoTPjytStCLRfZU6K1kuXUn+MegEtUt
 rTrisu17xwohc9EFl2LA7CR+N/UbpT5EvXNfm0D0OcESHBDKx6P0fs6EmGuvVGDy7D2t
 NJygyN8vNBtAmsP+ah/uv9MObnv4/taeHiQBAu+mxNMf2KRNw3RJKj1YF5727KWFF03P
 8e0fAcyrUngieHaDGEQ6JGgNOyyU7DZZy2oauM0a/vqrMy4Cchq3GUzHSZ+BfQUlAWFT
 4GI+jr4teyjBHC9NVMe5PwzFY8GyU8gkbZxG819uVexQ0zK8ffsEgmSjYpxF1TR+Re7z
 eaPA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1745589428; x=1746194228;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=6LUMt5//WEO8jbCIcwdEPl6iFnCU139tP5jp7xLrDwM=;
 b=EW0WVtG0Xeikw1x2Wp6N3FE89xTt62RfK56wfB0ZsDX62eDjDPkQrO1qEl4N8sDVAu
 5xllEjXjlaXnz+HDOdfOBCYxPj0m1BIMeFFNL7UOg2LUKvHIN2sPEf7LSFB4CP9WW1EM
 CUOQirtKMwT8X7pdZohtqA9J0UxubQ22pOprMqWSIvP/eElRi2szJ84k0TfGLyBs1Ihf
 5sb/fwXX6lKfjrcHKpHBb/QFntKQN6Kk7SiAlIQcQXp8McNU6A/Tsl1t39eZRAls4j/L
 CpyCzqyDFxlQCp7RMEE669sunCqscYCA89O10p4Lo69abLTOpZmrr+7tvDRj7oDSYz/L
 miXw==
X-Gm-Message-State: AOJu0YwSL/LxBuVHD8wMYTnzt1C05yLqVZGelx/MJp6Cz+e9a6zlUShU
 syc8al6jL0Ptk/rLZgjdne3cwfohndzzE7JcWLp5BTQAgV3erViemISwteNfJjYx36THtkj2FPz
 3uC7EmqbdMqWjlj+lxSlHtSH6pxDykCyHBr8=
X-Gm-Gg: ASbGncvh74srYxCXF5XjLFs4evE2b2y1YlHOrISFisoEoM3919BmntJ73IPTl3laALt
 nOyNC0HfRP2bSxplb4ZG6ZT86TRV2waAfyWsYjhGTifvsNACvXpPmbTgrepoDS0u5HBbMqkpwuD
 ENUK38MQEdNglG7Dd9j3pG0dAk4wqbT7vxtfBDvuham347lDRT5MJfaw==
X-Google-Smtp-Source: AGHT+IGwEtqdHF6rHacWyPc559I90BWiZu55eLjEJVxKmeOeQfQ4PpGHjhKXDpoPSIBkrVt7IDL/G7jgEt0WfjCZjpI=
X-Received: by 2002:a17:907:7289:b0:ace:6c29:a98c with SMTP id
 a640c23a62f3a-ace73b2376amr174012266b.37.1745589427974; Fri, 25 Apr 2025
 06:57:07 -0700 (PDT)
MIME-Version: 1.0
References: <CANMnL1p_sXVH-qgoLxr4bkvfP+wxqrnULPRW5LUMjJjJThc3NQ@HIDDEN>
 <86o6wkydk1.fsf@HIDDEN>
In-Reply-To: <86o6wkydk1.fsf@HIDDEN>
From: Kang Tu <tninja@HIDDEN>
Date: Fri, 25 Apr 2025 06:56:56 -0700
X-Gm-Features: ATxdqUFklzaRFD3RmiuibDP2txrTGRH8yo4xeDJlbkwA3UdcZXNZYDXAOCyS96s
Message-ID: <CANMnL1qhpEKRVjwBFzytOp=KuY5pk9B38pCq-9q-BKQ6d_AkMw@HIDDEN>
Subject: Re: bug#78043: Cursor gets stuck after inline code input in comint
 buffer when using markdown-mode, bypassing prompt lines starting with '>'
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: multipart/alternative; boundary="000000000000c7379906339ab5eb"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 78043
Cc: 78043 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--000000000000c7379906339ab5eb
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thanks for replying!

Actually we are wondering if it is a comint-mode bug. This line suppose to
suppress markdown-mode rendering on comint input line (start with >
character): https://github.com/tninja/aider.el/blob/main/aider-core.el#L67,
However it doesn't work as expected.

We are discussed in this github issue, and font-lock-defaults seems to be
right: https://github.com/tninja/aider.el/issues/126#issuecomment-281683914=
1,
so we suspect it is a comint-mode bug, for not being able to override on
comint input line.

Would you mind help take a look at this?

Regards

Kang

On Thu, Apr 24, 2025 at 11:12=E2=80=AFPM Eli Zaretskii <eliz@HIDDEN> wrote=
:

> > From: Kang Tu <tninja@HIDDEN>
> > Date: Thu, 24 Apr 2025 08:39:57 -0700
> >
> > To: bug-gnu-emacs@HIDDEN
> > Subject: Cursor gets stuck after inline code input in comint buffer whe=
n
> >  using markdown-mode, bypassing prompt lines starting with '>'
> > Description:
> >  To avoid interfering with input, I implemented logic to bypass markdow=
n
> >  rendering on prompt input lines, which start with '>'
> >
> >  I suspect this issue is related to the interaction between markdown-mo=
de
> >  rendering and comint input handling, especially regarding the bypass
> logic
> >  for prompt lines.
> >
> > Environment:
> >  > Please refactoring `main.go`
> >
> >  - Emacs version: 30.1
> >  - markdown-mode version: 2.5
> >  - OS: ubuntu 24.04 / mac osx
> >
> > Attachments:
> >  I am using Emacs comint buffer with markdown-mode enabled to render th=
e
> >  output as formatted Markdown.
> >
> >  Actual behavior:
> >  The cursor gets stuck after inline code input on the prompt line.
> >
> >  However, when I type inline code surrounded by backticks on a prompt
> line
> >  like:
> >
> >  Any advice or known fixes for this interaction issue between
> markdown-mode
> >  and comint would be much appreciated.
> >
> >  The cursor gets stuck after finishing the inline code and I cannot
> continue
> >  typing.
> >
> >  - Minimal input example
> >   - Please refactoring `main.go`
> >  - Relevant markdown-mode and comint configuration snippets (especially
> >  bypass logic for prompt lines)
> >  (defun aider--apply-markdown-highlighting ()
> >   "Set up markdown highlighting for aider buffer with optimized
> performance.
> >  Ignore lines starting with '>' (command prompts/input)."
> >   ;; 1) Use `markdown-mode`'s syntax table:
> >   (set-syntax-table (make-syntax-table markdown-mode-syntax-table))
> >   ;; 2) For multiline constructs (like fenced code blocks), enable
> >  `markdown-syntax-propertize`:
> >   (setq-local syntax-propertize-function #'markdown-syntax-propertize)
> >   ;; 3) Reuse `markdown-mode`'s font-lock keywords for highlighting,
> >   ;;    but add a rule to prevent markdown highlighting on lines starti=
ng
> >  with '>'.
> >   (setq-local font-lock-defaults
> >               (list (cons
> >                      ;; Rule to apply default face to prompt lines,
> without
> >  overriding.
> >                      ;; This aims to prevent subsequent markdown rules =
in
> >  this list
> >                      ;; from applying, while still allowing
> >  comint-highlight-input.
> >                      '("^>.*$" 0 'default nil) ;; =3D=3D> this line did
> bypass
> >  prompt input line, update nil to t doesn't help
> >                      ;; Original markdown keywords
> >                      markdown-mode-font-lock-keywords)
> >                     nil ;; KEYWORDS-ONLY
> >                     nil ;; CASE-FOLD
> >                     nil ;; SYNTAX-ALIST
> >                     nil)) ;; SYNTAX-BEGIN
> >   ;; 4) Enable fenced code block highlighting, and disable special font
> >  processing:
> >   (setq-local markdown-fontify-code-blocks-natively t)
> >   ;; https://github.com/tninja/aider.el/issues/113
> >   ;; TODO: temporary solution to disable bold, italic. need a better wa=
y
> >  than this, if we want to keep them in reply text
> >   ;; Note: The rule added above is a more targeted way to handle prompt=
s
> >  than disabling these globally.
> >   ;; Consider if these are still needed or can be re-enabled depending =
on
> >  desired appearance for non-prompt text.
> >   (setq-local markdown-regex-bold nil)
> >   (setq-local markdown-regex-italic nil)
> >   (setq-local markdown-regex-strike-through nil)
> >   ;; 5) Jit-lock and other
> >   (setq-local font-lock-multiline t)  ;; Handle multiline constructs
> >  efficiently
> >   (setq-local jit-lock-contextually nil)  ;; Disable contextual analysi=
s
> >   (setq-local font-lock-support-mode 'jit-lock-mode)  ;; Ensure JIT loc=
k
> is
> >  used
> >   (setq-local jit-lock-defer-time 0)
> >   ;; 6) Register font-lock explicitly:
> >   (font-lock-mode 1)
> >   ;; 7) Force immediate fontification of visible area:
> >   (font-lock-flush)
> >   (font-lock-ensure))
> >  - Screenshots if any
> >
> >  Steps to reproduce:
> >  1. Open a comint buffer (e.g., shell or custom comint).
> >  2. Enable markdown-mode for the buffer, with special handling to skip
> >  rendering lines starting with '>'.
> >  3. In the prompt line, type an inline code snippet with backticks, e.g=
.:
> >    > Please refactoring `main.go`
> >  4. Observe that after typing `main.go`, the cursor is stuck and cannot
> >  continue.
> >
> >  Expected behavior:
> >  The cursor should move freely and the input should work normally, with
> >  prompt lines properly bypassed from markdown rendering.
>
> Thanks.
>
> AFAIU, markdown-mode is not part of Emacs and not on GNU ELPA.  If so,
> would you please report this first to the developers of markdown-mode?
> If, after investigating the problem, they come to the conclusion that
> it's a bug in Emacs core, please come back here with the results of
> their investigations, and we will take a look at this.
>

--000000000000c7379906339ab5eb
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Thanks for replying!</div><div><br></div><div>Actuall=
y we are wondering if it is a comint-mode bug. This line suppose to suppres=
s markdown-mode rendering on comint input line (start with &gt; character):=
 <a href=3D"https://github.com/tninja/aider.el/blob/main/aider-core.el#L67"=
>https://github.com/tninja/aider.el/blob/main/aider-core.el#L67</a>, Howeve=
r it doesn&#39;t work as expected.</div><div><br></div><div>We are discusse=
d in this github issue, and=C2=A0<code class=3D"gmail-notranslate">font-loc=
k-defaults </code>seems to be right: <a href=3D"https://github.com/tninja/a=
ider.el/issues/126#issuecomment-2816839141">https://github.com/tninja/aider=
.el/issues/126#issuecomment-2816839141</a>, so we suspect it is a comint-mo=
de bug, for not being able to override on comint input line.</div><div><br>=
</div><div>Would you mind help take a look at this?</div><div><br></div><di=
v>Regards</div><div><br></div><div>Kang</div></div><br><div class=3D"gmail_=
quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, =
Apr 24, 2025 at 11:12=E2=80=AFPM Eli Zaretskii &lt;<a href=3D"mailto:eliz@g=
nu.org">eliz@HIDDEN</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204=
);padding-left:1ex">&gt; From: Kang Tu &lt;<a href=3D"mailto:tninja@HIDDEN=
om" target=3D"_blank">tninja@HIDDEN</a>&gt;<br>
&gt; Date: Thu, 24 Apr 2025 08:39:57 -0700<br>
&gt; <br>
&gt; To: <a href=3D"mailto:bug-gnu-emacs@HIDDEN" target=3D"_blank">bug-gnu=
-emacs@HIDDEN</a><br>
&gt; Subject: Cursor gets stuck after inline code input in comint buffer wh=
en<br>
&gt;=C2=A0 using markdown-mode, bypassing prompt lines starting with &#39;&=
gt;&#39;<br>
&gt; Description:<br>
&gt;=C2=A0 To avoid interfering with input, I implemented logic to bypass m=
arkdown<br>
&gt;=C2=A0 rendering on prompt input lines, which start with &#39;&gt;&#39;=
<br>
&gt; <br>
&gt;=C2=A0 I suspect this issue is related to the interaction between markd=
own-mode<br>
&gt;=C2=A0 rendering and comint input handling, especially regarding the by=
pass logic<br>
&gt;=C2=A0 for prompt lines.<br>
&gt; <br>
&gt; Environment:<br>
&gt;=C2=A0 &gt; Please refactoring `main.go`<br>
&gt; <br>
&gt;=C2=A0 - Emacs version: 30.1<br>
&gt;=C2=A0 - markdown-mode version: 2.5<br>
&gt;=C2=A0 - OS: ubuntu 24.04 / mac osx<br>
&gt; <br>
&gt; Attachments:<br>
&gt;=C2=A0 I am using Emacs comint buffer with markdown-mode enabled to ren=
der the<br>
&gt;=C2=A0 output as formatted Markdown.<br>
&gt; <br>
&gt;=C2=A0 Actual behavior:<br>
&gt;=C2=A0 The cursor gets stuck after inline code input on the prompt line=
.<br>
&gt; <br>
&gt;=C2=A0 However, when I type inline code surrounded by backticks on a pr=
ompt line<br>
&gt;=C2=A0 like:<br>
&gt; <br>
&gt;=C2=A0 Any advice or known fixes for this interaction issue between mar=
kdown-mode<br>
&gt;=C2=A0 and comint would be much appreciated.<br>
&gt; <br>
&gt;=C2=A0 The cursor gets stuck after finishing the inline code and I cann=
ot continue<br>
&gt;=C2=A0 typing.<br>
&gt; <br>
&gt;=C2=A0 - Minimal input example<br>
&gt;=C2=A0 =C2=A0- Please refactoring `main.go`<br>
&gt;=C2=A0 - Relevant markdown-mode and comint configuration snippets (espe=
cially<br>
&gt;=C2=A0 bypass logic for prompt lines)<br>
&gt;=C2=A0 (defun aider--apply-markdown-highlighting ()<br>
&gt;=C2=A0 =C2=A0&quot;Set up markdown highlighting for aider buffer with o=
ptimized performance.<br>
&gt;=C2=A0 Ignore lines starting with &#39;&gt;&#39; (command prompts/input=
).&quot;<br>
&gt;=C2=A0 =C2=A0;; 1) Use `markdown-mode`&#39;s syntax table:<br>
&gt;=C2=A0 =C2=A0(set-syntax-table (make-syntax-table markdown-mode-syntax-=
table))<br>
&gt;=C2=A0 =C2=A0;; 2) For multiline constructs (like fenced code blocks), =
enable<br>
&gt;=C2=A0 `markdown-syntax-propertize`:<br>
&gt;=C2=A0 =C2=A0(setq-local syntax-propertize-function #&#39;markdown-synt=
ax-propertize)<br>
&gt;=C2=A0 =C2=A0;; 3) Reuse `markdown-mode`&#39;s font-lock keywords for h=
ighlighting,<br>
&gt;=C2=A0 =C2=A0;;=C2=A0 =C2=A0 but add a rule to prevent markdown highlig=
hting on lines starting<br>
&gt;=C2=A0 with &#39;&gt;&#39;.<br>
&gt;=C2=A0 =C2=A0(setq-local font-lock-defaults<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list (cons<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 ;; Rule to apply default face to prompt lines, without<br>
&gt;=C2=A0 overriding.<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 ;; This aims to prevent subsequent markdown rules in<br>
&gt;=C2=A0 this list<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 ;; from applying, while still allowing<br>
&gt;=C2=A0 comint-highlight-input.<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 &#39;(&quot;^&gt;.*$&quot; 0 &#39;default nil) ;; =3D=3D&gt; this li=
ne did bypass<br>
&gt;=C2=A0 prompt input line, update nil to t doesn&#39;t help<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 ;; Original markdown keywords<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 markdown-mode-font-lock-keywords)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0nil ;; KEYWORDS-ONLY<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0nil ;; CASE-FOLD<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0nil ;; SYNTAX-ALIST<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0nil)) ;; SYNTAX-BEGIN<br>
&gt;=C2=A0 =C2=A0;; 4) Enable fenced code block highlighting, and disable s=
pecial font<br>
&gt;=C2=A0 processing:<br>
&gt;=C2=A0 =C2=A0(setq-local markdown-fontify-code-blocks-natively t)<br>
&gt;=C2=A0 =C2=A0;; <a href=3D"https://github.com/tninja/aider.el/issues/11=
3" rel=3D"noreferrer" target=3D"_blank">https://github.com/tninja/aider.el/=
issues/113</a><br>
&gt;=C2=A0 =C2=A0;; TODO: temporary solution to disable bold, italic. need =
a better way<br>
&gt;=C2=A0 than this, if we want to keep them in reply text<br>
&gt;=C2=A0 =C2=A0;; Note: The rule added above is a more targeted way to ha=
ndle prompts<br>
&gt;=C2=A0 than disabling these globally.<br>
&gt;=C2=A0 =C2=A0;; Consider if these are still needed or can be re-enabled=
 depending on<br>
&gt;=C2=A0 desired appearance for non-prompt text.<br>
&gt;=C2=A0 =C2=A0(setq-local markdown-regex-bold nil)<br>
&gt;=C2=A0 =C2=A0(setq-local markdown-regex-italic nil)<br>
&gt;=C2=A0 =C2=A0(setq-local markdown-regex-strike-through nil)<br>
&gt;=C2=A0 =C2=A0;; 5) Jit-lock and other<br>
&gt;=C2=A0 =C2=A0(setq-local font-lock-multiline t)=C2=A0 ;; Handle multili=
ne constructs<br>
&gt;=C2=A0 efficiently<br>
&gt;=C2=A0 =C2=A0(setq-local jit-lock-contextually nil)=C2=A0 ;; Disable co=
ntextual analysis<br>
&gt;=C2=A0 =C2=A0(setq-local font-lock-support-mode &#39;jit-lock-mode)=C2=
=A0 ;; Ensure JIT lock is<br>
&gt;=C2=A0 used<br>
&gt;=C2=A0 =C2=A0(setq-local jit-lock-defer-time 0)<br>
&gt;=C2=A0 =C2=A0;; 6) Register font-lock explicitly:<br>
&gt;=C2=A0 =C2=A0(font-lock-mode 1)<br>
&gt;=C2=A0 =C2=A0;; 7) Force immediate fontification of visible area:<br>
&gt;=C2=A0 =C2=A0(font-lock-flush)<br>
&gt;=C2=A0 =C2=A0(font-lock-ensure))<br>
&gt;=C2=A0 - Screenshots if any<br>
&gt; <br>
&gt;=C2=A0 Steps to reproduce:<br>
&gt;=C2=A0 1. Open a comint buffer (e.g., shell or custom comint).<br>
&gt;=C2=A0 2. Enable markdown-mode for the buffer, with special handling to=
 skip<br>
&gt;=C2=A0 rendering lines starting with &#39;&gt;&#39;.<br>
&gt;=C2=A0 3. In the prompt line, type an inline code snippet with backtick=
s, e.g.:<br>
&gt;=C2=A0 =C2=A0 &gt; Please refactoring `main.go`<br>
&gt;=C2=A0 4. Observe that after typing `main.go`, the cursor is stuck and =
cannot<br>
&gt;=C2=A0 continue.<br>
&gt; <br>
&gt;=C2=A0 Expected behavior:<br>
&gt;=C2=A0 The cursor should move freely and the input should work normally=
, with<br>
&gt;=C2=A0 prompt lines properly bypassed from markdown rendering.<br>
<br>
Thanks.<br>
<br>
AFAIU, markdown-mode is not part of Emacs and not on GNU ELPA.=C2=A0 If so,=
<br>
would you please report this first to the developers of markdown-mode?<br>
If, after investigating the problem, they come to the conclusion that<br>
it&#39;s a bug in Emacs core, please come back here with the results of<br>
their investigations, and we will take a look at this.<br>
</blockquote></div>

--000000000000c7379906339ab5eb--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#78043; Package emacs. Full text available.

Message received at 78043 <at> debbugs.gnu.org:


Received: (at 78043) by debbugs.gnu.org; 25 Apr 2025 06:12:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 25 02:12:57 2025
Received: from localhost ([127.0.0.1]:45886 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u8CIy-0002EO-Lm
	for submit <at> debbugs.gnu.org; Fri, 25 Apr 2025 02:12:57 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:47406)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u8CIv-0002Ds-V8
 for 78043 <at> debbugs.gnu.org; Fri, 25 Apr 2025 02:12:54 -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 <eliz@HIDDEN>)
 id 1u8CIq-0001Ru-FJ; Fri, 25 Apr 2025 02:12:48 -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=CGh5udf54UV9mn3fx4I5UaGpRZmAmiDoakTMLcXRtTw=; b=kqNtc6vAZA3c
 NFwH4MIRBQfe1kGBGamT3/LjCiUqlT47havoW+l5kXIebU26V+wFvd5kV2DacbzxPTjROH/ELBOFr
 vYHdpQAqPhM0CmTKSVWCOlleDcVXBuGYyBAj9QqGPYNzF6/+Xqldp+S4tHhQDeYcB9FWKWxvuC4MT
 1rh5SRsazxQSzJoYS+mk31jhGtQ3AHwhbXFD5TvNkQzmtk1MciBX5fpzNh4Whxpp46vclehArEgJi
 zodS04nHVGYlbV7dBMZcJUs7cezrj1LMjV+IniIoZ5e0QbwhDeS3aC004htCoeLp1AvNg3XlampxW
 bQj87V0SJfaHhYI1my1L4g==;
Date: Fri, 25 Apr 2025 09:12:46 +0300
Message-Id: <86o6wkydk1.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Kang Tu <tninja@HIDDEN>
In-Reply-To: <CANMnL1p_sXVH-qgoLxr4bkvfP+wxqrnULPRW5LUMjJjJThc3NQ@HIDDEN>
 (message from Kang Tu on Thu, 24 Apr 2025 08:39:57 -0700)
Subject: Re: bug#78043: Cursor gets stuck after inline code input in comint
 buffer
 when using markdown-mode, bypassing prompt lines starting with '>'
References: <CANMnL1p_sXVH-qgoLxr4bkvfP+wxqrnULPRW5LUMjJjJThc3NQ@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78043
Cc: 78043 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Kang Tu <tninja@HIDDEN>
> Date: Thu, 24 Apr 2025 08:39:57 -0700
> 
> To: bug-gnu-emacs@HIDDEN
> Subject: Cursor gets stuck after inline code input in comint buffer when
>  using markdown-mode, bypassing prompt lines starting with '>'
> Description:
>  To avoid interfering with input, I implemented logic to bypass markdown
>  rendering on prompt input lines, which start with '>'
> 
>  I suspect this issue is related to the interaction between markdown-mode
>  rendering and comint input handling, especially regarding the bypass logic
>  for prompt lines.
> 
> Environment:
>  > Please refactoring `main.go`
> 
>  - Emacs version: 30.1
>  - markdown-mode version: 2.5
>  - OS: ubuntu 24.04 / mac osx
> 
> Attachments:
>  I am using Emacs comint buffer with markdown-mode enabled to render the
>  output as formatted Markdown.
> 
>  Actual behavior:
>  The cursor gets stuck after inline code input on the prompt line.
> 
>  However, when I type inline code surrounded by backticks on a prompt line
>  like:
> 
>  Any advice or known fixes for this interaction issue between markdown-mode
>  and comint would be much appreciated.
> 
>  The cursor gets stuck after finishing the inline code and I cannot continue
>  typing.
> 
>  - Minimal input example
>   - Please refactoring `main.go`
>  - Relevant markdown-mode and comint configuration snippets (especially
>  bypass logic for prompt lines)
>  (defun aider--apply-markdown-highlighting ()
>   "Set up markdown highlighting for aider buffer with optimized performance.
>  Ignore lines starting with '>' (command prompts/input)."
>   ;; 1) Use `markdown-mode`'s syntax table:
>   (set-syntax-table (make-syntax-table markdown-mode-syntax-table))
>   ;; 2) For multiline constructs (like fenced code blocks), enable
>  `markdown-syntax-propertize`:
>   (setq-local syntax-propertize-function #'markdown-syntax-propertize)
>   ;; 3) Reuse `markdown-mode`'s font-lock keywords for highlighting,
>   ;;    but add a rule to prevent markdown highlighting on lines starting
>  with '>'.
>   (setq-local font-lock-defaults
>               (list (cons
>                      ;; Rule to apply default face to prompt lines, without
>  overriding.
>                      ;; This aims to prevent subsequent markdown rules in
>  this list
>                      ;; from applying, while still allowing
>  comint-highlight-input.
>                      '("^>.*$" 0 'default nil) ;; ==> this line did bypass
>  prompt input line, update nil to t doesn't help
>                      ;; Original markdown keywords
>                      markdown-mode-font-lock-keywords)
>                     nil ;; KEYWORDS-ONLY
>                     nil ;; CASE-FOLD
>                     nil ;; SYNTAX-ALIST
>                     nil)) ;; SYNTAX-BEGIN
>   ;; 4) Enable fenced code block highlighting, and disable special font
>  processing:
>   (setq-local markdown-fontify-code-blocks-natively t)
>   ;; https://github.com/tninja/aider.el/issues/113
>   ;; TODO: temporary solution to disable bold, italic. need a better way
>  than this, if we want to keep them in reply text
>   ;; Note: The rule added above is a more targeted way to handle prompts
>  than disabling these globally.
>   ;; Consider if these are still needed or can be re-enabled depending on
>  desired appearance for non-prompt text.
>   (setq-local markdown-regex-bold nil)
>   (setq-local markdown-regex-italic nil)
>   (setq-local markdown-regex-strike-through nil)
>   ;; 5) Jit-lock and other
>   (setq-local font-lock-multiline t)  ;; Handle multiline constructs
>  efficiently
>   (setq-local jit-lock-contextually nil)  ;; Disable contextual analysis
>   (setq-local font-lock-support-mode 'jit-lock-mode)  ;; Ensure JIT lock is
>  used
>   (setq-local jit-lock-defer-time 0)
>   ;; 6) Register font-lock explicitly:
>   (font-lock-mode 1)
>   ;; 7) Force immediate fontification of visible area:
>   (font-lock-flush)
>   (font-lock-ensure))
>  - Screenshots if any
> 
>  Steps to reproduce:
>  1. Open a comint buffer (e.g., shell or custom comint).
>  2. Enable markdown-mode for the buffer, with special handling to skip
>  rendering lines starting with '>'.
>  3. In the prompt line, type an inline code snippet with backticks, e.g.:
>    > Please refactoring `main.go`
>  4. Observe that after typing `main.go`, the cursor is stuck and cannot
>  continue.
> 
>  Expected behavior:
>  The cursor should move freely and the input should work normally, with
>  prompt lines properly bypassed from markdown rendering.

Thanks.

AFAIU, markdown-mode is not part of Emacs and not on GNU ELPA.  If so,
would you please report this first to the developers of markdown-mode?
If, after investigating the problem, they come to the conclusion that
it's a bug in Emacs core, please come back here with the results of
their investigations, and we will take a look at this.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#78043; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Apr 2025 15:47:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 24 11:47:18 2025
Received: from localhost ([127.0.0.1]:40362 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u7ynF-0006vb-KZ
	for submit <at> debbugs.gnu.org; Thu, 24 Apr 2025 11:47:18 -0400
Received: from lists.gnu.org ([2001:470:142::17]:33910)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <tninja@HIDDEN>) id 1u7ygZ-0006XC-1o
 for submit <at> debbugs.gnu.org; Thu, 24 Apr 2025 11:40:24 -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 <tninja@HIDDEN>) id 1u7ygT-0000jv-MW
 for bug-gnu-emacs@HIDDEN; Thu, 24 Apr 2025 11:40:17 -0400
Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <tninja@HIDDEN>) id 1u7ygR-0003YN-E6
 for bug-gnu-emacs@HIDDEN; Thu, 24 Apr 2025 11:40:17 -0400
Received: by mail-ed1-x531.google.com with SMTP id
 4fb4d7f45d1cf-5ed43460d6bso1811065a12.0
 for <bug-gnu-emacs@HIDDEN>; Thu, 24 Apr 2025 08:40:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1745509212; x=1746114012; darn=gnu.org;
 h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=zSy13pq++uYfo7xlALmjj209z7gXQFInOpQWT+lyYmM=;
 b=DAUO/wAQigj3XKUQHLiNadE4IeBjJn67JFqfWlxUvhnnTSnUlV7LFdT7CjDu/45G9n
 c8pEkkHnQ1YNuYnZ9dqMTJQxaHGYEdJXA4bw8hqNWzdFlTgpbPFQQte4Rj3RuZ0auRIL
 r1yxqysDBcbhUhQwjsAXaisoA3+uHDAzDWnfYRJmZLhGD+ARj6wKohJ9gx23NEChzytF
 2w1HH1VyshHzltM38Bkp5KGncxPAhINbsvQkuyZdOE4QXRASmpFpHIxJVaCaqMeCJe4i
 sFKwJUtBIITpiQElK6vrL9QTBQ4ZF71qO/Q+JRiSGVaVgMqPOAD+q7GAfHuzY2a60V9k
 zmbg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1745509212; x=1746114012;
 h=to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=zSy13pq++uYfo7xlALmjj209z7gXQFInOpQWT+lyYmM=;
 b=iQn9O2sPx5xVs474Yr7qsNs8/qxec2uYdFoaLLwKOMzXYwkx9gRI/FA62JyYz2Lv7L
 /f9uXt3e69RoFd6kUL2XfMjGHzNjvH+xDj2GknIxJSLbXWGi0nu01a9pmGcDyss/kZGs
 hMLXR47InLF97tQ+6dz44MUMnXqSLmQ4BLyA8TezU+5Z8QhcOIiX/bR9PD38/q/0otSN
 2yqwcW/hc8BAkzBzaDWPrdaY21BhjssEVHh3Y+OpFbSKSGHulV/rV50szN3p7EtyDlHG
 J8YNDuEyG6QzrQ6nnUtMCta3lqyjc3NfFnNj7onwKDLAa+fkGAr01sGQT7EfrHvMl7QY
 yLqA==
X-Gm-Message-State: AOJu0YypNIrz7FpuKTATnmWio8ShWB6u74M16gX7a/r+BfU7zGbloasK
 brc7a9ES+FcCPQ8HS8yt98ZauG/cwx5oeSBHPxVHXYEqKxSwetLOlXbih0ngqcpBsGvFtyktHcT
 Q0HVhhC6sVv+51E3MXAVbArO4u5phJtxDh+Y=
X-Gm-Gg: ASbGnctPNFNyhId5u1884NOa5Do8pfHs17ZqTQmroFkpygASJESb6OEePnlSEMdVA23
 9YB8l9CPn52s06t7NfL9XHpVwqTdFN9tp6763YVnNA2BDtmGqDBmhAwpze4aDLy6M4nMjVWJghO
 GydwCdzyAMILp3Sh7I2wzcN8dcsWlh5ANrNcAv24mzJIUsen5whlRdk1I=
X-Google-Smtp-Source: AGHT+IGYK4afCjF/yo8byLNHLA1M9l+afhxCXYVkBkCqn/YbAN3Ez5EB7KxbZcOM/r07uajzR/VoHjg/5rKlv6tYoeE=
X-Received: by 2002:a05:6402:3486:b0:5f4:d59a:81d0 with SMTP id
 4fb4d7f45d1cf-5f6df53e5abmr2572003a12.29.1745509211688; Thu, 24 Apr 2025
 08:40:11 -0700 (PDT)
MIME-Version: 1.0
From: Kang Tu <tninja@HIDDEN>
Date: Thu, 24 Apr 2025 08:39:57 -0700
X-Gm-Features: ATxdqUHUfy0ho5ip-flUwgh_Xy-BhiVCuAV4cx9QiW4VNQ7KxC1Hz0hET_HqsR8
Message-ID: <CANMnL1p_sXVH-qgoLxr4bkvfP+wxqrnULPRW5LUMjJjJThc3NQ@HIDDEN>
Subject: Cursor gets stuck after inline code input in comint buffer when using
 markdown-mode, bypassing prompt lines starting with '>'
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="00000000000083da900633880899"
Received-SPF: pass client-ip=2a00:1450:4864:20::531;
 envelope-from=tninja@HIDDEN; helo=mail-ed1-x531.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 24 Apr 2025 11:47:15 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--00000000000083da900633880899
Content-Type: text/plain; charset="UTF-8"

From: Kang Tu <tninja@HIDDEN>

To: bug-gnu-emacs@HIDDEN
Subject: Cursor gets stuck after inline code input in comint buffer when
 using markdown-mode, bypassing prompt lines starting with '>'
Description:
 To avoid interfering with input, I implemented logic to bypass markdown
 rendering on prompt input lines, which start with '>'

 I suspect this issue is related to the interaction between markdown-mode
 rendering and comint input handling, especially regarding the bypass logic
 for prompt lines.

Environment:
 > Please refactoring `main.go`

 - Emacs version: 30.1
 - markdown-mode version: 2.5
 - OS: ubuntu 24.04 / mac osx

Attachments:
 I am using Emacs comint buffer with markdown-mode enabled to render the
 output as formatted Markdown.

 Actual behavior:
 The cursor gets stuck after inline code input on the prompt line.

 However, when I type inline code surrounded by backticks on a prompt line
 like:

 Any advice or known fixes for this interaction issue between markdown-mode
 and comint would be much appreciated.

 The cursor gets stuck after finishing the inline code and I cannot continue
 typing.

 - Minimal input example
  - Please refactoring `main.go`
 - Relevant markdown-mode and comint configuration snippets (especially
 bypass logic for prompt lines)
 (defun aider--apply-markdown-highlighting ()
  "Set up markdown highlighting for aider buffer with optimized performance.
 Ignore lines starting with '>' (command prompts/input)."
  ;; 1) Use `markdown-mode`'s syntax table:
  (set-syntax-table (make-syntax-table markdown-mode-syntax-table))
  ;; 2) For multiline constructs (like fenced code blocks), enable
 `markdown-syntax-propertize`:
  (setq-local syntax-propertize-function #'markdown-syntax-propertize)
  ;; 3) Reuse `markdown-mode`'s font-lock keywords for highlighting,
  ;;    but add a rule to prevent markdown highlighting on lines starting
 with '>'.
  (setq-local font-lock-defaults
              (list (cons
                     ;; Rule to apply default face to prompt lines, without
 overriding.
                     ;; This aims to prevent subsequent markdown rules in
 this list
                     ;; from applying, while still allowing
 comint-highlight-input.
                     '("^>.*$" 0 'default nil) ;; ==> this line did bypass
 prompt input line, update nil to t doesn't help
                     ;; Original markdown keywords
                     markdown-mode-font-lock-keywords)
                    nil ;; KEYWORDS-ONLY
                    nil ;; CASE-FOLD
                    nil ;; SYNTAX-ALIST
                    nil)) ;; SYNTAX-BEGIN
  ;; 4) Enable fenced code block highlighting, and disable special font
 processing:
  (setq-local markdown-fontify-code-blocks-natively t)
  ;; https://github.com/tninja/aider.el/issues/113
  ;; TODO: temporary solution to disable bold, italic. need a better way
 than this, if we want to keep them in reply text
  ;; Note: The rule added above is a more targeted way to handle prompts
 than disabling these globally.
  ;; Consider if these are still needed or can be re-enabled depending on
 desired appearance for non-prompt text.
  (setq-local markdown-regex-bold nil)
  (setq-local markdown-regex-italic nil)
  (setq-local markdown-regex-strike-through nil)
  ;; 5) Jit-lock and other
  (setq-local font-lock-multiline t)  ;; Handle multiline constructs
 efficiently
  (setq-local jit-lock-contextually nil)  ;; Disable contextual analysis
  (setq-local font-lock-support-mode 'jit-lock-mode)  ;; Ensure JIT lock is
 used
  (setq-local jit-lock-defer-time 0)
  ;; 6) Register font-lock explicitly:
  (font-lock-mode 1)
  ;; 7) Force immediate fontification of visible area:
  (font-lock-flush)
  (font-lock-ensure))
 - Screenshots if any

 Steps to reproduce:
 1. Open a comint buffer (e.g., shell or custom comint).
 2. Enable markdown-mode for the buffer, with special handling to skip
 rendering lines starting with '>'.
 3. In the prompt line, type an inline code snippet with backticks, e.g.:
   > Please refactoring `main.go`
 4. Observe that after typing `main.go`, the cursor is stuck and cannot
 continue.

 Expected behavior:
 The cursor should move freely and the input should work normally, with
 prompt lines properly bypassed from markdown rendering.

 Thank you!
Date: Thu, 24 Apr 2025 08:35:23 -0700
Message-ID: <87h62do9ms.fsf@HIDDEN>

--00000000000083da900633880899
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">From: Kang Tu &lt;<a href=3D"mailto:tninja@HIDDEN">tnin=
ja@HIDDEN</a>&gt;<br><br>To: <a href=3D"mailto:bug-gnu-emacs@HIDDEN">bu=
g-gnu-emacs@HIDDEN</a><br>Subject: Cursor gets stuck after inline code inp=
ut in comint buffer when<br>=C2=A0using markdown-mode, bypassing prompt lin=
es starting with &#39;&gt;&#39;<br>Description:<br>=C2=A0To avoid interferi=
ng with input, I implemented logic to bypass markdown<br>=C2=A0rendering on=
 prompt input lines, which start with &#39;&gt;&#39;<br><br>=C2=A0I suspect=
 this issue is related to the interaction between markdown-mode<br>=C2=A0re=
ndering and comint input handling, especially regarding the bypass logic<br=
>=C2=A0for prompt lines.<br><br>Environment:<br>=C2=A0&gt; Please refactori=
ng `main.go`<br><br>=C2=A0- Emacs version: 30.1<br>=C2=A0- markdown-mode ve=
rsion: 2.5<br>=C2=A0- OS: ubuntu 24.04 / mac osx<br><br>Attachments:<br>=C2=
=A0I am using Emacs comint buffer with markdown-mode enabled to render the<=
br>=C2=A0output as formatted Markdown.<br><br>=C2=A0Actual behavior:<br>=C2=
=A0The cursor gets stuck after inline code input on the prompt line.<br><br=
>=C2=A0However, when I type inline code surrounded by backticks on a prompt=
 line<br>=C2=A0like:<br><br>=C2=A0Any advice or known fixes for this intera=
ction issue between markdown-mode<br>=C2=A0and comint would be much appreci=
ated.<br><br>=C2=A0The cursor gets stuck after finishing the inline code an=
d I cannot continue<br>=C2=A0typing.<br><br>=C2=A0- Minimal input example<b=
r>=C2=A0 - Please refactoring `main.go`<br>=C2=A0- Relevant markdown-mode a=
nd comint configuration snippets (especially<br>=C2=A0bypass logic for prom=
pt lines)<br>=C2=A0(defun aider--apply-markdown-highlighting ()<br>=C2=A0 &=
quot;Set up markdown highlighting for aider buffer with optimized performan=
ce.<br>=C2=A0Ignore lines starting with &#39;&gt;&#39; (command prompts/inp=
ut).&quot;<br>=C2=A0 ;; 1) Use `markdown-mode`&#39;s syntax table:<br>=C2=
=A0 (set-syntax-table (make-syntax-table markdown-mode-syntax-table))<br>=
=C2=A0 ;; 2) For multiline constructs (like fenced code blocks), enable<br>=
=C2=A0`markdown-syntax-propertize`:<br>=C2=A0 (setq-local syntax-propertize=
-function #&#39;markdown-syntax-propertize)<br>=C2=A0 ;; 3) Reuse `markdown=
-mode`&#39;s font-lock keywords for highlighting,<br>=C2=A0 ;; =C2=A0 =C2=
=A0but add a rule to prevent markdown highlighting on lines starting<br>=C2=
=A0with &#39;&gt;&#39;.<br>=C2=A0 (setq-local font-lock-defaults<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (list (cons<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Rule to apply=
 default face to prompt lines, without<br>=C2=A0overriding.<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; This a=
ims to prevent subsequent markdown rules in<br>=C2=A0this list<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; fro=
m applying, while still allowing<br>=C2=A0comint-highlight-input.<br>=C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&#39;=
(&quot;^&gt;.*$&quot; 0 &#39;default nil) ;; =3D=3D&gt; this line did bypas=
s<br>=C2=A0prompt input line, update nil to t doesn&#39;t help<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Ori=
ginal markdown keywords<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0markdown-mode-font-lock-keywords)<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 nil ;; KEYWORDS=
-ONLY<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 nil ;; CASE-FOLD<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 nil ;; SYNTAX-ALIST<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 nil)) ;; SYNTAX-BEGIN<br>=C2=A0 ;; 4=
) Enable fenced code block highlighting, and disable special font<br>=C2=A0=
processing:<br>=C2=A0 (setq-local markdown-fontify-code-blocks-natively t)<=
br>=C2=A0 ;; <a href=3D"https://github.com/tninja/aider.el/issues/113">http=
s://github.com/tninja/aider.el/issues/113</a><br>=C2=A0 ;; TODO: temporary =
solution to disable bold, italic. need a better way<br>=C2=A0than this, if =
we want to keep them in reply text<br>=C2=A0 ;; Note: The rule added above =
is a more targeted way to handle prompts<br>=C2=A0than disabling these glob=
ally.<br>=C2=A0 ;; Consider if these are still needed or can be re-enabled =
depending on<br>=C2=A0desired appearance for non-prompt text.<br>=C2=A0 (se=
tq-local markdown-regex-bold nil)<br>=C2=A0 (setq-local markdown-regex-ital=
ic nil)<br>=C2=A0 (setq-local markdown-regex-strike-through nil)<br>=C2=A0 =
;; 5) Jit-lock and other<br>=C2=A0 (setq-local font-lock-multiline t) =C2=
=A0;; Handle multiline constructs<br>=C2=A0efficiently<br>=C2=A0 (setq-loca=
l jit-lock-contextually nil) =C2=A0;; Disable contextual analysis<br>=C2=A0=
 (setq-local font-lock-support-mode &#39;jit-lock-mode) =C2=A0;; Ensure JIT=
 lock is<br>=C2=A0used<br>=C2=A0 (setq-local jit-lock-defer-time 0)<br>=C2=
=A0 ;; 6) Register font-lock explicitly:<br>=C2=A0 (font-lock-mode 1)<br>=
=C2=A0 ;; 7) Force immediate fontification of visible area:<br>=C2=A0 (font=
-lock-flush)<br>=C2=A0 (font-lock-ensure))<br>=C2=A0- Screenshots if any<br=
><br>=C2=A0Steps to reproduce:<br>=C2=A01. Open a comint buffer (e.g., shel=
l or custom comint).<br>=C2=A02. Enable markdown-mode for the buffer, with =
special handling to skip<br>=C2=A0rendering lines starting with &#39;&gt;&#=
39;.<br>=C2=A03. In the prompt line, type an inline code snippet with backt=
icks, e.g.:<br>=C2=A0 =C2=A0&gt; Please refactoring `main.go`<br>=C2=A04. O=
bserve that after typing `main.go`, the cursor is stuck and cannot<br>=C2=
=A0continue.<br><br>=C2=A0Expected behavior:<br>=C2=A0The cursor should mov=
e freely and the input should work normally, with<br>=C2=A0prompt lines pro=
perly bypassed from markdown rendering.<br><br>=C2=A0Thank you!<br>Date: Th=
u, 24 Apr 2025 08:35:23 -0700<br>Message-ID: &lt;<a href=3D"mailto:87h62do9=
ms.fsf@HIDDEN">87h62do9ms.fsf@HIDDEN</a>&gt;<br><br></div>

--00000000000083da900633880899--




Acknowledgement sent to Kang Tu <tninja@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#78043; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 25 Apr 2025 14:00:05 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.