GNU bug report logs - #47603
comint sets '(rear-nonsticky t) on entire prompt, disabling 'cursor-intangible

Previous Next

Package: emacs;

Reported by: JD Smith <jdtsmith <at> gmail.com>

Date: Mon, 5 Apr 2021 18:08:01 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: JD Smith <jdtsmith <at> gmail.com>
Subject: bug#47603: closed (Re: bug#47603: comint sets '(rear-nonsticky t)
 on entire prompt, disabling 'cursor-intangible)
Date: Tue, 13 Apr 2021 02:51:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#47603: comint sets '(rear-nonsticky t) on entire prompt, disabling 'cursor-intangible

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 47603 <at> debbugs.gnu.org.

-- 
47603: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=47603
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: JD Smith <jdtsmith <at> gmail.com>
Cc: 47603-done <at> debbugs.gnu.org
Subject: Re: bug#47603: comint sets '(rear-nonsticky t) on entire prompt,
 disabling 'cursor-intangible
Date: Mon, 12 Apr 2021 22:49:55 -0400
> Comint sets ‘(rear-nonsticky t) on the entire detected prompt text, which
> prevents `cursor-intangible from functioning correctly when applied to the
> prompt.  As Stefan put it:

I fixed it a while back but forgot the `font-lock-face` property in the
list of properties to add to `rear-nonstick` so I just added the
patch below to `master`.
I believe this should now do it.


        Stefan


diff --git a/lisp/comint.el b/lisp/comint.el
index 2745c5a26f..b90e6354d8 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1797,6 +1797,9 @@ comint-add-to-input-history
 			(min size (- comint-input-ring-size size)))))
     (ring-insert comint-input-ring cmd)))
 
+(defconst comint--prompt-rear-nonsticky
+  '(field inhibit-line-move-field-capture read-only font-lock-face))
+
 (defun comint-send-input (&optional no-newline artificial)
   "Send input to process.
 After the process output mark, sends all text from the process mark to
@@ -1916,8 +1919,8 @@ comint-send-input
             (unless (or no-newline comint-use-prompt-regexp)
               ;; Cover the terminating newline
               (add-text-properties end (1+ end)
-                                   '(rear-nonsticky
-                                     (field inhibit-line-move-field-capture read-only)
+                                   `(rear-nonsticky
+                                     ,comint--prompt-rear-nonsticky
                                      field boundary
                                      inhibit-line-move-field-capture t)))))
 
@@ -2124,10 +2127,10 @@ comint-output-filter
 	    (unless comint-use-prompt-regexp
               (with-silent-modifications
                 (add-text-properties comint-last-output-start (point)
-                                     '(front-sticky
+                                     `(rear-nonsticky
+				       ,comint--prompt-rear-nonsticky
+				       front-sticky
 				       (field inhibit-line-move-field-capture)
-				       rear-nonsticky
-				       (field inhibit-line-move-field-capture read-only)
 				       field output
 				       inhibit-line-move-field-capture t))))
 
@@ -2157,8 +2160,8 @@ comint-output-filter
 					       'font-lock-face
 					       'comint-highlight-prompt)
 	      (add-text-properties prompt-start (point)
-	                           '(rear-nonsticky
-	                             (field inhibit-line-move-field-capture read-only))))
+	                           `(rear-nonsticky
+	                             ,comint--prompt-rear-nonsticky)))
 	    (goto-char saved-point)))))))
 
 (defun comint-preinput-scroll-to-bottom ()


[Message part 3 (message/rfc822, inline)]
From: JD Smith <jdtsmith <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: comint sets '(rear-nonsticky t) on entire prompt, disabling
 'cursor-intangible
Date: Mon, 5 Apr 2021 14:07:17 -0400
[Message part 4 (text/plain, inline)]
Comint sets ‘(rear-nonsticky t) on the entire detected prompt text, which prevents `cursor-intangible from functioning correctly when applied to the prompt.  As Stefan put it:

I suspect the issue comes from the difference between `get-pos-property` and `get-char-property`: positions (like `point`) are not placed on a character but between two characters.  But text properties only apply to characters.  So the properties that are "on a position" are based on what properties would a character inherit if it where inserted at that position.

By default text properties are front-nonstick and rear-sticky, so basically a position gets its properties from the char right before it. But if you set (rear-nonsticky t), then you get no properties at all at that position.

This causes issues when "applying (rear-nonsticky t) a bit too generously, e.g. to all the chars in the prompt rather than only to the last one."
[Message part 5 (text/html, inline)]

This bug report was last modified 4 years and 44 days ago.

Previous Next


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