GNU bug report logs - #21874
`backward-char' can move point into minibuffer prompt by default

Previous Next

Package: emacs;

Reported by: David Reitter <david.reitter <at> gmail.com>

Date: Tue, 10 Nov 2015 23:28:01 UTC

Severity: wishlist

Found in version 25.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21874 in the body.
You can then email your comments to 21874 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Tue, 10 Nov 2015 23:28:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Reitter <david.reitter <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 10 Nov 2015 23:28:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Reitter <david.reitter <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; point-entered no longer works
Date: Tue, 10 Nov 2015 18:27:22 -0500
Emacs -q

C-a avoids the minibuffer prompt, but cursor movement with left-arrow is still possible.  That seems to be intentional (and still a questionable default - a discussion on emacs-devel has been seen).

Setting minibuffer-prompt-properties to the new `cursor-intangible'  fixes the cursor movement issue and C-x h.

However,

(setq minibuffer-prompt-properties '(read-only t  point-entered minibuffer-avoid-prompt))

fails to work as intended.  That seems to be a bug, because `minibuffer-avoid-prompt' is just obsolete (since 25.1), and the NEWS file lists `point-entered' as obsolete, too.  So it should still work.

Feature suggestion:  Why can't Emacs see that a user had (point-entered minibuffer-avoid-prompt) and simply translate that to (cursor-intangible t)?

Another feature suggestion:  When the cursor is in a read-only area, why can’t self-insert-command jump to the next area where input is allowed?  When a region contains read-only areas, and delete is pressed or delete-selection-mode would cause the region to be killed, could Emacs just kill all the writeable text and leave the read-only portion (e.g., mini buffer prompts!) in place?  It would be so nice if Emacs could “do the right thing”!




In GNU Emacs 25.0.50.1 (x86_64-apple-darwin15.0.0, NS appkit-1404.13 Version 10.11.1 (Build 15B42))
 of 2015-11-10
Repository revision: 25775a12c5168b0494dff15639ac25d8e1017530
Windowing system distributor 'Apple', version 10.3.1404
Configured features:
ACL ZLIB TOOLKIT_SCROLL_BARS NS

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  diff-auto-refine-mode: t
  tooltip-mode: t
  global-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
  transient-mark-mode: t

Recent messages:
completing-read-default: Command attempted to use minibuffer while in minibuffer
Mark saved where search started
(read-only t point-entered minibuffer-avoid-prompt) [2 times]
C-h <left> is undefined
Quit
Mark set [3 times]
s-2 is undefined
Quit [2 times]
Mark set
(read-only t point-entered minibuffer-avoid-prompt)
Quit

Load-path shadows:
./ae24.git/.dir-locals hides ./aquamacs-emacs/.dir-locals
./ae24.git/.dir-locals hides ./emacs/.dir-locals
./ae24.git/.dir-locals hides /Users/dr/emacs/nextstep/Emacs.app/Contents/Resources/lisp/gnus/.dir-locals

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils
noutline outline eieio-opt speedbar sb-image ezimage dframe
character-fold misearch multi-isearch vc vc-dispatcher vc-git diff-mode
easy-mmode map seq cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs find-func pp thingatpt url-parse
auth-source cl-seq eieio byte-opt bytecomp byte-compile cconv eieio-core
cl-macs gv gnus-util mm-util mail-prsvr password-cache url-vars
cursor-sensor cus-edit cus-start cus-load wid-edit cl-extra help-fns
help-mode easymenu cl-loaddefs pcase cl-lib time-date mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
ns-win term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame 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 charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 141432 5750)
 (symbols 48 24818 0)
 (miscs 40 259 376)
 (strings 32 32647 16953)
 (string-bytes 1 998901)
 (vectors 16 18301)
 (vector-slots 8 530698 2662)
 (floats 8 190 305)
 (intervals 56 494 41)
 (buffers 976 18))





Added indication that bug 21874 blocks19759 Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 11 Nov 2015 18:56:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Wed, 23 Mar 2016 20:08:01 GMT) Full text and rfc822 format available.

Message #10 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: 21874 <at> debbugs.gnu.org
Subject: Re: 25.0.50; point-entered no longer works
Date: Wed, 23 Mar 2016 16:06:29 -0400
[Message part 1 (text/plain, inline)]
I confirm this bug in the latest build of emacs-25 branch.

I can confirm that evaluating below:

(setq minibuffer-prompt-properties '(read-only t  point-entered
minibuffer-avoid-prompt face minibuffer-prompt))

"does the right thing" in the minibuffer in emacsen 24.3, 24.4 and 24.5.

That is, arrow key navigation and C-x h does not enter the part of the
minibuffer that should be read-only.

To test it,

1. emacs -Q
2. C-x C-f
3. Pressing left arrow key will take the cursor to the left most area
within the read-only area "Find file:"
4. Now evaluate "(setq minibuffer-prompt-properties '(read-only t
 point-entered minibuffer-avoid-prompt face minibuffer-prompt))"
5. C-x C-f
6. Now the cursor will stop to the right of the colon in "Find file:" when
the left arrow key is kept pressed.

Note that above works as expected in emacsen 24.3, 24.4 and 24.5.

But it does NOT work in the latest build of emacs-25 branch. On emacs-25
build, instead of Step 6 behavior, we see Step 3 behavior. Setting
point-entered does nothing.



--
Kaushal Modi
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Wed, 23 Mar 2016 20:31:02 GMT) Full text and rfc822 format available.

Message #13 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: 21874 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: 25.0.50; point-entered no longer works
Date: Wed, 23 Mar 2016 16:30:05 -0400
[Message part 1 (text/plain, inline)]
Then I tried the below (which sort of works):

(progn
  (setq minibuffer-prompt-properties '(read-only t cursor-intangible t face
minibuffer-prompt))

  (defun turn-on-cursor-intangible-mode ()
    "Turns on cursor-intangible-mode."
    (interactive)
    (cursor-intangible-mode 1))
  (define-globalized-minor-mode global-cursor-intangible-mode
cursor-intangible-mode turn-on-cursor-intangible-mode)

  (global-cursor-intangible-mode 1))

Start emacs -Q and eval the above progn form.
The caveat is (and I cannot understand why) is that the cursor
intangibility does not kick in when you do C-x C-f for the first time! It
kicks in only from the second C-x C-f onwards.

The following steps try to explain what I mean (on latest build of
emacs-25):
1. emacs -Q
2. Eval the above progn form
3. C-x C-f C-x h (The read-only portion also gets selected!)
4. C-g
5. C-x C-f C-x h (NOW the read-only portion does not get selected as
expected)

So why is the cursor-intangible-mode not enabled in the minibuffer the
first time (Step 3)?

Also, would it be wise to enable cursor-intangible-mode globally? If not,
how can we have that mode always enabled in the minibuffer?


-------------------------

On the other hand, I have tested the below as an alternate solution
(probably better too as I am not enabling the mode globally) to always work:

(progn
  (setq minibuffer-prompt-properties '(read-only t cursor-intangible t face
minibuffer-prompt))
  (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode))

If we want emacs to "do the right thing", should the above be made default?
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Wed, 23 Mar 2016 21:29:01 GMT) Full text and rfc822 format available.

Message #16 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 21874 <at> debbugs.gnu.org
Subject: Re: 25.0.50; point-entered no longer works
Date: Wed, 23 Mar 2016 17:28:53 -0400
>   (defun turn-on-cursor-intangible-mode ()
>     "Turns on cursor-intangible-mode."
>     (interactive)
>     (cursor-intangible-mode 1))

   (defalias 'turn-on-cursor-intangible-mode #'cursor-intangible-mode)

would work just as well.  Better yet: just use `cursor-intangible-mode'
instead and skip turn-on-cursor-intangible-mode altogether, since it's
just redundant.

> 3. C-x C-f C-x h (The read-only portion also gets selected!)

The minibuffer is not placed in any kind of major mode, so it doesn't
enable any globalized minor mode when you enter it.

> 5. C-x C-f C-x h (NOW the read-only portion does not get selected as
> expected)

This is probably because I introduced minibuffer-inactive-mode which
does setup a major mode in the minibuffer, tho not when you enter it, but
when you leave it, so the globalized mode ends up activated in the
*next* minibuffer.

> Also, would it be wise to enable cursor-intangible-mode globally? If not,
> how can we have that mode always enabled in the minibuffer?

(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

> If we want Emacs to "do the right thing", should the above be made default?

I personally like the fact that I can occasionally move into the prompt
and copy portions of it like any other chunk of text, so I think we
should generally (by default) refrain from making text intangible except
when *really* needed.


        Stefan


PS: What's with the `point-entered' in the subject?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Wed, 23 Mar 2016 21:39:02 GMT) Full text and rfc822 format available.

Message #19 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>,
 David Reitter <david.reitter <at> gmail.com>
Cc: 21874 <at> debbugs.gnu.org
Subject: Re: 25.0.50; point-entered no longer works
Date: Wed, 23 Mar 2016 17:38:10 -0400
[Message part 1 (text/plain, inline)]
On Wed, Mar 23, 2016 at 5:28 PM, Stefan Monnier <monnier <at> iro.umontreal.ca>
wrote:

> (defalias 'turn-on-cursor-intangible-mode #'cursor-intangible-mode)
>
> would work just as well.  Better yet: just use `cursor-intangible-mode'
> instead and skip turn-on-cursor-intangible-mode altogether, since it's
> just redundant.
>

Thanks!

> Also, would it be wise to enable cursor-intangible-mode globally? If not,
> > how can we have that mode always enabled in the minibuffer?
> (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)


Yes, that's what I ended up doing :) The last part of my previous email was
an after-thought or an "aha" moment as I was typing the question "how can
we have that mode always enabled in the minibuffer?"

I personally like the fact that I can occasionally move into the prompt
> and copy portions of it like any other chunk of text, so I think we
> should generally (by default) refrain from making text intangible except
> when *really* needed.


OK


> PS: What's with the `point-entered' in the subject?


I believe that the OP (David)'s primary question was how to get the
"cursor-intangible" behavior working in emacs 25.1 because the below does
not work as it used to in emacs 24.5:

(setq minibuffer-prompt-properties '(read-only t point-entered
minibuffer-avoid-prompt))

The secondary question I believe is how to get the above to work in
emacs 25.1 (even though point-entered and minibuffer-avoid-prompt are
obsolete).

@David The fact that the below get the behavior you want, would you
consider this bug as closed?

(progn
  (setq minibuffer-prompt-properties '(read-only t cursor-intangible t
face minibuffer-prompt))
  (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode))

--
Kaushal Modi
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Wed, 23 Mar 2016 21:56:02 GMT) Full text and rfc822 format available.

Message #22 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: Kaushal Modi <kaushal.modi <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>,
 David Reitter <david.reitter <at> gmail.com>
Cc: 21874 <at> debbugs.gnu.org
Subject: Re: 25.0.50; point-entered no longer works
Date: Wed, 23 Mar 2016 17:55:10 -0400
[Message part 1 (text/plain, inline)]
@Stefan With respect to:

>
> I personally like the fact that I can occasionally move into the prompt
> and copy portions of it like any other chunk of text, so I think we
> should generally (by default) refrain from making text intangible except
> when *really* needed.


How about setting the below as default:

    (setq minibuffer-prompt-properties '(read-only t cursor-intangible t
face minibuffer-prompt))

I find having the above very risky in user config because it simply
overrides whatever the default value of minibuffer-prompt-properties would
be. Also using setq/defcustom is the best way; append/add-to-list/setcdr
will not work very well because of the format of this variable's value.
What I mean is that the list manipulation would have been much more
convenient from the user end without risking complete override of the
default value, had it been in an alist format like below:

    (setq minibuffer-prompt-properties '((read-only t)
                                         (cursor-intangible t)
                                         (face minibuffer-prompt)))


The user then needs to add just one line to their config if they want to
make the minibuffer prompts untouchable.

    (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

If you don't have that add-hook in your config, you will get the behavior
you want, correct?

Summary:
(1) Proposal to set the default value of minibuffer-prompt-properties
to '(read-only
t cursor-intangible t face minibuffer-prompt). I believe this should go in
emacs-25, not master.
(2) User can then put the following in their config to get untouchable
minibuffer prompts: (add-hook 'minibuffer-setup-hook
#'cursor-intangible-mode)
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Thu, 24 Mar 2016 00:28:02 GMT) Full text and rfc822 format available.

Message #25 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: David Reitter <david.reitter <at> gmail.com>, 21874 <at> debbugs.gnu.org
Subject: Re: 25.0.50; point-entered no longer works
Date: Wed, 23 Mar 2016 20:27:36 -0400
>     (setq minibuffer-prompt-properties '((read-only t)
>                                          (cursor-intangible t)
>                                          (face minibuffer-prompt)))
>
> The user then needs to add just one line to their config if they want to
> make the minibuffer prompts untouchable.

I kind of find it a poor choice, since it sets a property which just
happens to be unused.

>     (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

A user might do this for other reasons and might find the
side-effect unexpected.

Note that setting minibuffer-prompt-properties via Custom will
automatically do this `add-hook' when needed.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Thu, 24 Mar 2016 02:15:01 GMT) Full text and rfc822 format available.

Message #28 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: David Reitter <david.reitter <at> gmail.com>
To: Kaushal Modi <kaushal.modi <at> gmail.com>
Cc: 21874 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: 25.0.50; point-entered no longer works
Date: Wed, 23 Mar 2016 22:14:30 -0400
On Mar 23, 2016, at 5:38 PM, Kaushal Modi <kaushal.modi <at> gmail.com> wrote:
> 
> @David The fact that the below get the behavior you want, would you consider this bug as closed?

Well, it was surprising that cursor-intangible as a property wasn’t sufficient until the mode was enabled.  I can see why one would design it that way.

So, in order to not have people bump into errors all the time (which, IIRC, also are displayed in the echo area, overwriting the mini buffer that the user is working on at that very moment), I would still suggest that this protection be made default.  (I’ve had that in Aquamacs for a long time.)

Stefan’s desire to copy the prompt is the exception (perhaps because he’s working on and maybe teaching Emacs).  The user who wants to delete the whole text behind the prompt to replace it, or mark-all and delete selection, or C-a to the beginning and so on, this user is the norm.  We should think about that use case first.

- D



Removed indication that bug 21874 blocks Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Sun, 22 May 2016 02:08:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Sun, 22 May 2016 02:14:01 GMT) Full text and rfc822 format available.

Message #33 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 21874 <at> debbugs.gnu.org
Subject: Re: 25.0.50; point-entered no longer works
Date: Sat, 21 May 2016 19:13:32 -0700
Bug#21874 was listed as a blocker for Emacs 25, but in looking over it it 
appears to be more of a wishlist item. Eli suggested in 
<http://lists.gnu.org/archive/html/emacs-devel/2016-05/msg00460.html> to unblock 
it and I tend to agree, so I've done that.




Removed indication that bug 21874 blocks Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 22 May 2016 16:36:02 GMT) Full text and rfc822 format available.

Changed bug title to '`backward-char' can move point into minibuffer prompt by default' from '25.0.50; point-entered no longer works' Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 29 Jan 2017 23:31:02 GMT) Full text and rfc822 format available.

Severity set to 'wishlist' from 'normal' Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 29 Jan 2017 23:31:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21874; Package emacs. (Tue, 15 Feb 2022 10:53:02 GMT) Full text and rfc822 format available.

Message #42 received at 21874 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: David Reitter <david.reitter <at> gmail.com>
Cc: 21874 <at> debbugs.gnu.org
Subject: Re: bug#21874: `backward-char' can move point into minibuffer
 prompt by default
Date: Tue, 15 Feb 2022 11:52:36 +0100
David Reitter <david.reitter <at> gmail.com> writes:

> Setting minibuffer-prompt-properties to the new `cursor-intangible'
> fixes the cursor movement issue and C-x h.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

`C-x h' only copies the bit after the prompt in Emacs 28.

>>     (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
>
> A user might do this for other reasons and might find the
> side-effect unexpected.
>
> Note that setting minibuffer-prompt-properties via Custom will
> automatically do this `add-hook' when needed.

Skimming this bug report, I think everything here works as designed, and
I'm therefore closing it.

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




bug closed, send any further explanations to 21874 <at> debbugs.gnu.org and David Reitter <david.reitter <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 15 Feb 2022 10:53:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 15 Mar 2022 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 14 days ago.

Previous Next


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