GNU bug report logs - #51095
28.0.50; Counter-intuitive `cursor-intangible-mode' behavior

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: Brahimi Saifullah <brahimi.saifullah@HIDDEN>; Keywords: moreinfo; dated Fri, 8 Oct 2021 14:59:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 51095) by debbugs.gnu.org; 9 Oct 2021 13:18:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 09 09:18:00 2021
Received: from localhost ([127.0.0.1]:52482 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mZCEh-0002yT-Nz
	for submit <at> debbugs.gnu.org; Sat, 09 Oct 2021 09:18:00 -0400
Received: from quimby.gnus.org ([95.216.78.240]:33526)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1mZCEb-0002y2-V2
 for 51095 <at> debbugs.gnu.org; Sat, 09 Oct 2021 09:17:58 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=ZXnJ0zU6gJcqPVN/b+uN86hhbHyH5bAylB4wCuDqcUA=; b=rvGBu8YXd8NMTLsBEjT1r1rRNN
 TONWgLpbk7N/VFtGwD94WvOm2ZwpMtn5tEM3rVrLPhHqmeI6GJc22Vg9cyEnqYpy/1cW5lijMAcmb
 Uqzun7UPTg40Ys7f+7MlTZ7TafOlnaGcQnqPev7+0favtQWSjDO3Xcz421pQ4hT+K51E=;
Received: from [84.212.220.105] (helo=elva)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1mZCET-0005iv-Bx; Sat, 09 Oct 2021 15:17:47 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Brahimi Saifullah <brahimi.saifullah@HIDDEN>
Subject: Re: bug#51095: 28.0.50; Counter-intuitive `cursor-intangible-mode'
 behavior
References: <84y273mvog.fsf@HIDDEN>
X-Now-Playing: Tom Robinson's _North by Northwest_: "Atmospherics"
Date: Sat, 09 Oct 2021 15:17:44 +0200
In-Reply-To: <84y273mvog.fsf@HIDDEN> (Brahimi Saifullah's message of "Fri, 
 08 Oct 2021 11:35:11 -0300")
Message-ID: <8735panxqf.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Brahimi Saifullah <brahimi.saifullah@HIDDEN> writes: >
 Let's start with the following example: > emacs -Q > M-: (insert "|"
 (propertize
 "xxxxx" 'cursor-intangible t) "|") > M-x cursor-intangible-mode > > Result:
 > |xxxxx| > ^^^^^ You can't move the curs [...] 
 Content analysis details:   (-2.3 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 0.6 FUZZY_AMBIEN           BODY: Attempt to obfuscate words in spam
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51095
Cc: 51095 <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 (---)

Brahimi Saifullah <brahimi.saifullah@HIDDEN> writes:

> Let's start with the following example:
> emacs -Q
> M-: (insert "|" (propertize "xxxxx" 'cursor-intangible t) "|")
> M-x cursor-intangible-mode
>
> Result:
> |xxxxx|
>   ^^^^^ You can't move the cursor here
>
> What I expected:
> |xxxxx|
>  ^^^^^ You can't move the cursor here

I can reproduce the behaviour, but unless I misunderstand something,
this seems like it's working as designed.

The cursor is really "between" two characters conceptually -- this is
easier to understand if you use a "bar" cursor.  So if you put the point
here:

|xxxxx|
 ^

then it's before the first x and after the first |.  (You can confirm by
entering a character when it's at that point.)

The behaviour at the end is more puzzling, but as you've found out, it's
because the properties don't have rear-nonsticky, so you can't put point
right after the final x.

So I think everything here is working as designed.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




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

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


Received: (at submit) by debbugs.gnu.org; 8 Oct 2021 14:58:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 08 10:58:24 2021
Received: from localhost ([127.0.0.1]:51707 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mYrKK-0006Zc-8z
	for submit <at> debbugs.gnu.org; Fri, 08 Oct 2021 10:58:24 -0400
Received: from lists.gnu.org ([209.51.188.17]:52758)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <brahimi.saifullah@HIDDEN>) id 1mYqzS-00062m-0R
 for submit <at> debbugs.gnu.org; Fri, 08 Oct 2021 10:36:50 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:58016)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <brahimi.saifullah@HIDDEN>)
 id 1mYqzR-0004oK-QC
 for bug-gnu-emacs@HIDDEN; Fri, 08 Oct 2021 10:36:49 -0400
Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]:34400)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <brahimi.saifullah@HIDDEN>)
 id 1mYqzP-000461-VU
 for bug-gnu-emacs@HIDDEN; Fri, 08 Oct 2021 10:36:49 -0400
Received: by mail-qk1-x731.google.com with SMTP id t63so4862588qkf.1
 for <bug-gnu-emacs@HIDDEN>; Fri, 08 Oct 2021 07:36:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:subject:date:message-id:mime-version;
 bh=Wr8Z7tR9ZTjdYaKTyken8cAmKlwlKmdl1BDLQifsefo=;
 b=V3iAABAbeySfArg/VGuXJ2NR4COhjW1j7eW7jfZmJUAQ85my0Czx1KBoXO5QxTmBcc
 FTPE3ReJ7pxERC8YWIMq6y6tzYaYoNqFqgUPs9F1AmR7Knpc5qQQ7ECBg0fWxG9w0Ddk
 wi0+nQif2W+qsgJCK+/dH6ITMd6Nm3P9LXv+wNgSoO4go+gjqThlf2NXk0T6yjQGQoJw
 F6NTH9dvxjJp3tFR2h6dM/OTIL71wJWuHx+NrPR/yutf2tKT965WY5Lfk8sUITmRSzCF
 bGsrYsfKU9vMyGrAehxMU2J9bl9FQNGcH3brSqNQyBYXEh//6+m7eOGgz5s74neWD16L
 4D+w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version;
 bh=Wr8Z7tR9ZTjdYaKTyken8cAmKlwlKmdl1BDLQifsefo=;
 b=uOWMjWegTbfAQQ54/OxMKjDVEoHsdQgFrEGgCrAu4jMShHuQylUAid5L+fpq4GVofM
 kCNN6ZFzARiOGNh63GjkA0hh1Hn4dJDX1tTgRjmFopMu9QARgLzVLLhiyLYmF2LMj8+D
 w2kzMggcGre9yFMe//lNtKOsDPZexNzLn5LJ6hsFUPaHd/ftyeZKY7GpAv5JRjMUBwHO
 yIpAavRS/HiwNuuGzR9g+zpn5aV7IEobGgSBkobk9FJWKnW1bU+/k9CZc0W4yutUMhdC
 JNbyW6VzvFgO2YtnELqxplcM1DLl16wd5n3tgxIa8U9VffUWmdT+zIvWry/Kj9Vklw3A
 f/tQ==
X-Gm-Message-State: AOAM5336hLYhxv5OfCOnqHf3EAdJl/h1lG9D3nyVJp05wquGGbXO7Gnr
 WRGfoH3GCfie5PMht8pGRgN2ByeWWVM=
X-Google-Smtp-Source: ABdhPJwJ3HaSI9+0ZrluPFU8W6c7UflfA/xB9GFutAFMqBVO3Mgr0sCHvLVoutUWqGXdgm0bJ86o6w==
X-Received: by 2002:ae9:de02:: with SMTP id s2mr3235018qkf.215.1633703806165; 
 Fri, 08 Oct 2021 07:36:46 -0700 (PDT)
Received: from COMPUTADOR ([2804:14d:90bc:8726:1da9:2155:f519:6465])
 by smtp.googlemail.com with ESMTPSA id o13sm2196369qkl.102.2021.10.08.07.36.45
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 Oct 2021 07:36:45 -0700 (PDT)
From: Brahimi Saifullah <brahimi.saifullah@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 28.0.50; Counter-intuitive `cursor-intangible-mode' behavior
Date: Fri, 08 Oct 2021 11:35:11 -0300
Message-ID: <84y273mvog.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2607:f8b0:4864:20::731;
 envelope-from=brahimi.saifullah@HIDDEN; helo=mail-qk1-x731.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,
 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.3 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 08 Oct 2021 10:58:22 -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: -2.3 (--)

Let's start with the following example:
emacs -Q
M-: (insert "|" (propertize "xxxxx" 'cursor-intangible t) "|")
M-x cursor-intangible-mode

Result:
|xxxxx|
  ^^^^^ You can't move the cursor here

What I expected:
|xxxxx|
 ^^^^^ You can't move the cursor here

To clarify, although all the `X's are set to be intangible, you can still move
your cursor to the first one.  Furthermore, even though neither `|' has a text
property, you cannot move your cursor to the last one.

I tracked this behavior to the following function:
(from cursor-sensor.el, attached for convenience)

(defun cursor-sensor--intangible-p (pos)
  (let ((p (get-pos-property pos 'cursor-intangible)))
    (if p
        (let (a b)
          (if (and (setq a (get-char-property pos 'cursor-intangible))
                   (setq b (if (> pos (point-min))
                               (get-char-property (1- pos) 'cursor-intangible)))
                   (not (eq a b)))
              ;; If we're right between two different intangible thingies,
              ;; we can stop here.  This is not quite consistent with the
              ;; interpretation of "if it's sticky, then this boundary is
              ;; itself intangible", but it's convenient (and it better matches
              ;; the behavior of `intangible', making it easier to port code).
              nil p))
      p)))

This is the result of using `get-pos-property' instead of `get-char-property'.
If my understanding is correct, the difference in the former is its handling of
stickiness.  Thus I came up with the following:

(insert "|"
        (propertize
         (concat
          (propertize "x" 'front-sticky t)
          "xxx"
          (propertize "x" 'rear-nonsticky t))
         'cursor-intangible t)
        "|")

Basically, make the first character front-sticky, and the last character
rear-nonsticky.  Now it works as expected.

The question is: Is this behavior intuitive?
Is a Lisp program supposed to know that the portion of the text it has set to
be intangible is not actually accurate and must be manually adjusted?
To me it sounds not only unintuitive, but also like a bug.



In GNU Emacs 28.0.50 (build 1, x86_64-w64-mingw32)
 of 2021-09-21 built on COMPUTADOR
Repository revision: e4a9aa940beb032e97de6d4e4a23c2c9d94fdeb6
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10.0.19041
System Description: Microsoft Windows 10 Enterprise (v10.0.2004.19041.1237)

Configured using:
 'configure --with-native-compilation --with-json --with-imagemagick
 --without-pop'

Configured features:
ACL DBUS GIF GMP GNUTLS HARFBUZZ IMAGEMAGICK JPEG JSON LCMS2 LIBXML2
MODULES NATIVE_COMP NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS XPM ZLIB

Important settings:
  value of $LC_CTYPE: pt_BR.UTF-8
  value of $LANG: PTB
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  cursor-intangible-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
cursor-sensor pp cl-extra seq byte-opt gv bytecomp byte-compile cconv
cl-print time-date subr-x thingatpt help-fns radix-tree help-mode
cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads w32notify dbusbind w32 lcms2
multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 79446 8863)
 (symbols 48 7032 0)
 (strings 32 23818 1385)
 (string-bytes 1 730132)
 (vectors 16 14529)
 (vector-slots 8 305875 14414)
 (floats 8 30 40)
 (intervals 56 288 1)
 (buffers 992 13))




Acknowledgement sent to Brahimi Saifullah <brahimi.saifullah@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#51095; 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: Sat, 9 Oct 2021 13:30:02 UTC

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