all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* by default, point should not enter the minibuffer prompt
@ 2008-10-08  0:34 Drew Adams
  2008-10-08  1:59 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Drew Adams @ 2008-10-08  0:34 UTC (permalink / raw
  To: emacs-devel

How about making including `point-entered minibuffer-avoid-prompt' in the
default value of `minibuffer-prompt-properties'?

That is, turn on the check box `Don't Enter' by default.

FWIW, I actually got an Icicles bug report about this (no relation with
Icicles). It took me a while to figure out why I didn't see the problem in my
own setup but did in Emacs -Q. It was because I had customized
`minibuffer-prompt-properties'.

Users shouldn't have to customize `minibuffer-prompt-properties' just to make
`C-a' not enter the prompt, etc.

BTW, I don't even see `minibuffer-avoid-prompt' in the Elisp manual, and there
is nothing helpful about `minibuffer-prompt-properties' in the Emacs manual.
That would be OK if the default value was good.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: by default, point should not enter the minibuffer prompt
  2008-10-08  0:34 by default, point should not enter the minibuffer prompt Drew Adams
@ 2008-10-08  1:59 ` Stefan Monnier
  2008-10-08  2:07 ` Miles Bader
  2008-10-08 20:22 ` Richard M. Stallman
  2 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2008-10-08  1:59 UTC (permalink / raw
  To: Drew Adams; +Cc: emacs-devel

> How about making including `point-entered minibuffer-avoid-prompt' in the
> default value of `minibuffer-prompt-properties'?

No: the small benefit is not worth the cost of not being able to copy
(part of) the prompt like any other piece of text.


        Stefan




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: by default, point should not enter the minibuffer prompt
  2008-10-08  0:34 by default, point should not enter the minibuffer prompt Drew Adams
  2008-10-08  1:59 ` Stefan Monnier
@ 2008-10-08  2:07 ` Miles Bader
  2008-10-08  6:08   ` Drew Adams
  2008-10-08 20:22 ` Richard M. Stallman
  2 siblings, 1 reply; 12+ messages in thread
From: Miles Bader @ 2008-10-08  2:07 UTC (permalink / raw
  To: Drew Adams; +Cc: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:
> Users shouldn't have to customize `minibuffer-prompt-properties' just to make
> `C-a' not enter the prompt, etc.

They don't have to.

If that is not the behavior you observe, please provide more detailed
info.  Remember to use emacs -Q.

-Miles

-- 
Defenceless, adj. Unable to attack.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: by default, point should not enter the minibuffer prompt
  2008-10-08  2:07 ` Miles Bader
@ 2008-10-08  6:08   ` Drew Adams
  2008-10-08  8:08     ` Miles Bader
  0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2008-10-08  6:08 UTC (permalink / raw
  To: 'Miles Bader'; +Cc: emacs-devel

> > Users shouldn't have to customize 
> > `minibuffer-prompt-properties' just to make
> > `C-a' not enter the prompt, etc.
> 
> They don't have to.
> 
> If that is not the behavior you observe, please provide more detailed
> info.  Remember to use emacs -Q.

This will seem contorted ;-), but here goes (same for Emacs 22.3 and Emacs 23
from Oct 3):

emacs -Q
(setq enable-recursive-minibuffers t)

C-x C-f jjjjjjjjjj C-q kkkkkkkkkkk

So you see this in the minibuffer, with point after the k's:

Find file: /current/dir/jjjjjjjjjj
kkkkkkkkkkk

M-: (forward-line -1)

The cursor ends up on the F of Find file, not at the start of the input after
the prompt.

I'm not saying that a user will typically go through such contortions.

This arose because in Icicles C-a in the minibuffer does (forward-line 0) but if
repeated does (forward-line -1), so that you can move up at line beginnings by
repeating C-a (C-e does the same for line endings but moving down). It's not
that unusual to have multiple-line input in Icicles, so it's not unusual to move
to the beginning of the input with repeated C-a (not for file names, but for
other input).

If `minibuffer-prompt-properties' includes `point-entered
minibuffer-avoid-prompt' there is no such problem (which is why I didn't see the
behavior myself, since I had customized it to include that).

It's not a big deal. I can easily work around this for Icicles, but I didn't
want to trample on user preferences for `minibuffer-prompt-properties' (e.g. if
a user really did want to move to the prompt beginning).

However, it sounds like there might be some disagreement over what the default
behavior is or should be. Stefan seems to say that by default users should be
able to move to the prompt beginning (so they can copy prompt text), but Miles
seems to say - and it appears to be generally true (except multi-line cases such
as that shown above), that by default you cannot move the cursor over the prompt
(using C-a at least).






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: by default, point should not enter the minibuffer prompt
  2008-10-08  6:08   ` Drew Adams
@ 2008-10-08  8:08     ` Miles Bader
  2008-10-08 15:13       ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Miles Bader @ 2008-10-08  8:08 UTC (permalink / raw
  To: Drew Adams; +Cc: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:
> Find file: /current/dir/jjjjjjjjjj
> kkkkkkkkkkk
>
> M-: (forward-line -1)
>
> The cursor ends up on the F of Find file, not at the start of the input after
> the prompt.

The problem is that you are using `forward-line'.  It is a low-level
function that does not do any sort of checking.  Emacs commands intended
for user use (C-a, C-p, etc) should act correctly and avoid the prompt.

> However, it sounds like there might be some disagreement over what the default
> behavior is or should be. Stefan seems to say that by default users should be
> able to move to the prompt beginning (so they can copy prompt text), but Miles
> seems to say - and it appears to be generally true (except multi-line cases such
> as that shown above), that by default you cannot move the cursor over the prompt
> (using C-a at least).

Normal user commands are designed so that in normal usage, the cursor
won't end up in the prompt inadvertently.  However, if the user tries to
force the issue, by using an unusual command sequence (e.g., "C-a C-b"),
he can do so.

The aim is to make normal usage convenient (by avoiding the prompt),
while still giving the user freedom to access that text if he really
wants to.

-Miles

-- 
=====
(^o^;
(()))
*This is the cute octopus virus, please copy it into your sig so it can spread.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: by default, point should not enter the minibuffer prompt
  2008-10-08  8:08     ` Miles Bader
@ 2008-10-08 15:13       ` Drew Adams
  2008-10-08 16:24         ` Miles Bader
  2008-10-08 16:34         ` Drew Adams
  0 siblings, 2 replies; 12+ messages in thread
From: Drew Adams @ 2008-10-08 15:13 UTC (permalink / raw
  To: 'Miles Bader'; +Cc: emacs-devel

> The problem is that you are using `forward-line'.  It is a
> low-level function that does not do any sort of checking.
> Emacs commands intended for user use (C-a, C-p, etc) should
> act correctly and avoid the prompt.
...
> The aim is to make normal usage convenient (by avoiding the prompt),
> while still giving the user freedom to access that text if he really
> wants to.

Got it.

I'll change my minibuffer C-a command to DTRT. Thx.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: by default, point should not enter the minibuffer prompt
  2008-10-08 15:13       ` Drew Adams
@ 2008-10-08 16:24         ` Miles Bader
  2008-10-08 16:52           ` Drew Adams
  2008-10-08 16:34         ` Drew Adams
  1 sibling, 1 reply; 12+ messages in thread
From: Miles Bader @ 2008-10-08 16:24 UTC (permalink / raw
  To: Drew Adams; +Cc: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:
> I'll change my minibuffer C-a command to DTRT. Thx.

If you just use the default C-a binding (move-beginning-of-line), it
should work correctly.

-Miles

-- 
We have met the enemy, and he is us.  -- Pogo




^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: by default, point should not enter the minibuffer prompt
  2008-10-08 15:13       ` Drew Adams
  2008-10-08 16:24         ` Miles Bader
@ 2008-10-08 16:34         ` Drew Adams
  2008-10-09  0:22           ` Miles Bader
  1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2008-10-08 16:34 UTC (permalink / raw
  To: 'Miles Bader'; +Cc: emacs-devel

> > The problem is that you are using `forward-line'.  It is a
> > low-level function that does not do any sort of checking.
> > Emacs commands intended for user use (C-a, C-p, etc) should
> > act correctly and avoid the prompt.
> 
> Got it. I'll change my minibuffer C-a command to DTRT. Thx.

A little help please.

I tried simply binding `minibuffer-prompt-properties' so that it included
`point-entered minibuffer-avoid-prompt' during my `C-a', but that had no effect.

When is `minibuffer-prompt-properties' examined? Is it too late once the
minibuffer is activated and a minibuffer key is hit?

Simple test:

(defun beg-line ()
  (interactive)
  (let ((minibuffer-prompt-properties
	 (append '(point-entered minibuffer-avoid-prompt)
		   minibuffer-prompt-properties)))
    (forward-line -1)))

(define-key minibuffer-local-completion-map "\C-a" 'beg-line)

The binding has no effect - doesn't prevent C-a from moving to the prompt
beginning. This code is not really what I'd use, but it's a simplified version.
My code needs to use `forward-line', in any case. I'm just ignorant of how to
prevent point from moving into the prompt.

I grepped the Lisp Emacs files for `minibuffer-prompt-properties', but there is
no real use of it, beyond initialization. I looked at the C source code in
cmds.c for `beginning-of-line', but I don't see (understand) how it's done.
What's the secret? ;-)

If it can't be done by simply binding `minibuffer-prompt-properties', what is
the way to go? Do I need to explicitly move to `minibuffer-prompt-end', or is
there a simple, elegant way to DTRT here.

I'm not really familiar with fields and such. Suggestions appreciated. Thx.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: by default, point should not enter the minibuffer prompt
  2008-10-08 16:24         ` Miles Bader
@ 2008-10-08 16:52           ` Drew Adams
  0 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2008-10-08 16:52 UTC (permalink / raw
  To: 'Miles Bader'; +Cc: emacs-devel

> > I'll change my minibuffer C-a command to DTRT. Thx.
> 
> If you just use the default C-a binding (move-beginning-of-line), it
> should work correctly.

Not a possibility. If I wanted the default C-a I never would have written a
different command. ;-)

The command I want moves to bol (modulo the prompt) the first time, but to bol
of the previous line if repeated. And it respects the N prefix arg (like
`beginning-of-line').

It's not important, but here is the command, so you get the idea:

;; Bound to `C-a' in minibuffer and in *Completions*.
(defun icicle-beginning-of-line+ (&optional n)
  "Move cursor to beginning of current line or next line if repeated.
This is the similar to `beginning-of-line', but:
1. With arg N, the direction is the opposite: this command moves
   backward, not forward, N lines.
2. If called interactively with no prefix arg:
      If the previous command was also `beginning-of-line+', then move
      to the beginning of the previous line.  Else, move to the
      beginning of the current line.
   Otherwise, move to the beginning of the Nth previous line (Nth next
      line if N<0).  Command `beginning-of-line', by contrast, moves to
      the beginning of the (N-1)th next line."
  (interactive
   (list (if current-prefix-arg
             (prefix-numeric-value current-prefix-arg)
           0)))
  (unless n (setq n  0)) ; non-interactive with no arg
  (let ((minibuffer-prompt-properties ; Unfortunately, has no effect
         (append '(point-entered minibuffer-avoid-prompt)
                 minibuffer-prompt-properties)))
    (if (and (eq this-command last-command)
             (not current-prefix-arg))
        (forward-line -1)
      (forward-line (- n)))))

C-e in the minibuffer and *Completions* works similarly but it moves down when
repeated, not up.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: by default, point should not enter the minibuffer prompt
  2008-10-08  0:34 by default, point should not enter the minibuffer prompt Drew Adams
  2008-10-08  1:59 ` Stefan Monnier
  2008-10-08  2:07 ` Miles Bader
@ 2008-10-08 20:22 ` Richard M. Stallman
  2 siblings, 0 replies; 12+ messages in thread
From: Richard M. Stallman @ 2008-10-08 20:22 UTC (permalink / raw
  To: Drew Adams; +Cc: emacs-devel

It is useful to be able to copy text from the minibuffer prompt.
That is why we don't absolutely make it impossible to enter.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: by default, point should not enter the minibuffer prompt
  2008-10-08 16:34         ` Drew Adams
@ 2008-10-09  0:22           ` Miles Bader
  2008-10-09 16:03             ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Miles Bader @ 2008-10-09  0:22 UTC (permalink / raw
  To: Drew Adams; +Cc: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:
> A little help please.
>
> I tried simply binding `minibuffer-prompt-properties' so that it included
> `point-entered minibuffer-avoid-prompt' during my `C-a', but that had no effect.
>
> When is `minibuffer-prompt-properties' examined? Is it too late once the
> minibuffer is activated and a minibuffer key is hit?

It is used when generating the prompt.

I would suggest you make your new command a wrapper around the normal
command; that way you can take advantage of any special handling it
does.

E.g.

(defun move-bol-or-prev-bol (&optional arg)
  (interactive "p")
  (let ((orig-point (point)))
    (move-beginning-of-line arg)
    (when (= (point) orig-point)
      (goto-char (line-beginning-position 0)))))

-Miles

-- 
Freemason, n. An order with secret rites, grotesque ceremonies and fantastic
costumes, which, originating in the reign of Charles II, among working
artisans of London, has been joined successively by the dead of past centuries
in unbroken retrogression until now it embraces all the generations of man on
the hither side of Adam and is drumming up distinguished recruits among the
pre-Creational inhabitants of Chaos and Formless Void. The order was founded
at different times by Charlemagne, Julius Caesar, Cyrus, Solomon, Zoroaster,
Confucious, Thothmes, and Buddha. Its emblems and symbols have been found in
the Catacombs of Paris and Rome, on the stones of the Parthenon and the
Chinese Great Wall, among the temples of Karnak and Palmyra and in the
Egyptian Pyramids -- always by a Freemason.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: by default, point should not enter the minibuffer prompt
  2008-10-09  0:22           ` Miles Bader
@ 2008-10-09 16:03             ` Drew Adams
  0 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2008-10-09 16:03 UTC (permalink / raw
  To: 'Miles Bader'; +Cc: emacs-devel

> > When is `minibuffer-prompt-properties' examined? Is it too 
> > late once the minibuffer is activated and a minibuffer key is hit?
> 
> It is used when generating the prompt.

So I guess it's useless to modify it on the fly after the minibuffer is entered,
e.g. in `minibuffer-setup-hook', or after a minibuffer key is hit. Too bad.

> I would suggest you make your new command a wrapper around the normal
> command; that way you can take advantage of any special handling it
> does.
> 
> (defun move-bol-or-prev-bol (&optional arg)
>   (interactive "p")
>   (let ((orig-point (point)))
>     (move-beginning-of-line arg)
>     (when (= (point) orig-point)
>       (goto-char (line-beginning-position 0)))))

OK, thanks for the suggestion.
FWIW, I'm using this, which works for all Emacs versions:

(defun icicle-beginning-of-line+ (&optional n)
  (interactive
   (list (if current-prefix-arg
             (prefix-numeric-value current-prefix-arg)
           0)))
  (unless n (setq n  0))
  (if (and (eq this-command last-command)
           (not current-prefix-arg))
      (forward-line -1)
    (forward-line (- n)))
  (when (bobp)
    (goto-char (if (fboundp 'minibuffer-prompt-end)
                   (minibuffer-prompt-end)
                 (point-min)))))






^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-10-09 16:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-08  0:34 by default, point should not enter the minibuffer prompt Drew Adams
2008-10-08  1:59 ` Stefan Monnier
2008-10-08  2:07 ` Miles Bader
2008-10-08  6:08   ` Drew Adams
2008-10-08  8:08     ` Miles Bader
2008-10-08 15:13       ` Drew Adams
2008-10-08 16:24         ` Miles Bader
2008-10-08 16:52           ` Drew Adams
2008-10-08 16:34         ` Drew Adams
2008-10-09  0:22           ` Miles Bader
2008-10-09 16:03             ` Drew Adams
2008-10-08 20:22 ` Richard M. Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.