unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Selecting default prompt text
@ 2009-02-11 23:29 Richard Riley
  2009-02-12  2:53 ` Kevin Rodgers
       [not found] ` <mailman.497.1234407233.31690.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Riley @ 2009-02-11 23:29 UTC (permalink / raw)
  To: help-gnu-emacs


I like my interactive functions to generally use the word or region at
point as a default. Is there a way to make the read-string mini buffer
input to pre-select the default value?

e.g

consider

(setq url (read-string (format "Url (%s) :" url) url nil url))

Here I would like to see at the input prompt

Url (xyz): xyz

with the default value of "xyz" already selected. In other words
the same behaviour as when you tab into a populated  entry field in most
of applications.


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

* Re: Selecting default prompt text
  2009-02-11 23:29 Selecting default prompt text Richard Riley
@ 2009-02-12  2:53 ` Kevin Rodgers
       [not found] ` <mailman.497.1234407233.31690.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2009-02-12  2:53 UTC (permalink / raw)
  To: help-gnu-emacs

Richard Riley wrote:
> I like my interactive functions to generally use the word or region at
> point as a default. Is there a way to make the read-string mini buffer
> input to pre-select the default value?
> 
> e.g
> 
> consider
> 
> (setq url (read-string (format "Url (%s) :" url) url nil url))
> 
> Here I would like to see at the input prompt
> 
> Url (xyz): xyz
> 
> with the default value of "xyz" already selected. In other words
> the same behaviour as when you tab into a populated  entry field in most
> of applications.

(let ((url-at-point (thing-at-point 'url)))
   (read-string (if url-at-point
		   (format "URL (%s): " url-at-point)
		 "URL: ")
	       nil nil url-at-point))

-- 
Kevin Rodgers
Denver, Colorado, USA





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

* Re: Selecting default prompt text
       [not found] ` <mailman.497.1234407233.31690.help-gnu-emacs@gnu.org>
@ 2009-02-12  9:54   ` Richard Riley
  2009-02-12 12:27     ` Andreas Politz
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Riley @ 2009-02-12  9:54 UTC (permalink / raw)
  To: help-gnu-emacs

Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:

> Richard Riley wrote:
>> I like my interactive functions to generally use the word or region at
>> point as a default. Is there a way to make the read-string mini buffer
>> input to pre-select the default value?
>>
>> e.g
>>
>> consider
>>
>> (setq url (read-string (format "Url (%s) :" url) url nil url))
>>
>> Here I would like to see at the input prompt
>>
>> Url (xyz): xyz
>>
>> with the default value of "xyz" already selected. In other words
>> the same behaviour as when you tab into a populated  entry field in most
>> of applications.
>
> (let ((url-at-point (thing-at-point 'url)))
>   (read-string (if url-at-point
> 		   (format "URL (%s): " url-at-point)
> 		 "URL: ")
> 	       nil nil url-at-point))

Hi Kevin,

Sorry if I was not clear. I don't mean a default value - I mean
pre-selected as in "in region". e.g when you tab to a field in a web
form for example - The data in the field is highlighted/selected. I
already had a default value set as "url" in the code above.

e.g

goto www.Google.com 

enter some text and tab to a button then tab back. The text in the
search field is selected.



-- 
 important and urgent problems of the technology of today are no longer the satisfactions of the primary needs or of archetypal wishes, but the reparation of the evils and damages by the technology of yesterday.  ~Dennis Gabor, Innovations:  Scientific, Technological and Social, 1970


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

* Re: Selecting default prompt text
  2009-02-12  9:54   ` Richard Riley
@ 2009-02-12 12:27     ` Andreas Politz
  2009-02-12 13:35       ` Richard Riley
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Politz @ 2009-02-12 12:27 UTC (permalink / raw)
  To: help-gnu-emacs

Richard Riley wrote:
> Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
> 
>> Richard Riley wrote:
>>> I like my interactive functions to generally use the word or region at
>>> point as a default. Is there a way to make the read-string mini buffer
>>> input to pre-select the default value?
>>>
>>> e.g
>>>
>>> consider
>>>
>>> (setq url (read-string (format "Url (%s) :" url) url nil url))
>>>
>>> Here I would like to see at the input prompt
>>>
>>> Url (xyz): xyz
>>>
>>> with the default value of "xyz" already selected. In other words
>>> the same behaviour as when you tab into a populated  entry field in most
>>> of applications.
>> (let ((url-at-point (thing-at-point 'url)))
>>   (read-string (if url-at-point
>> 		   (format "URL (%s): " url-at-point)
>> 		 "URL: ")
>> 	       nil nil url-at-point))
> 
> Hi Kevin,
> 
> Sorry if I was not clear. I don't mean a default value - I mean
> pre-selected as in "in region". e.g when you tab to a field in a web
> form for example - The data in the field is highlighted/selected. I
> already had a default value set as "url" in the code above.
> 
> e.g
> 
> goto www.Google.com 
> 
> enter some text and tab to a button then tab back. The text in the
> search field is selected.
> 
> 
> 

Something like this ?

(defun minibuffer-select-inital-input ()
   (let ((start (next-single-char-property-change 1 'read-only)))
     (when (< start (point-max))
       (set-mark start)
       (setq mark-active t))))

(add-hook 'minibuffer-setup-hook 'minibuffer-select-inital-input)
(read-string "> " "Hallo")

-ap


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

* Re: Selecting default prompt text
  2009-02-12 12:27     ` Andreas Politz
@ 2009-02-12 13:35       ` Richard Riley
  2009-02-12 17:34         ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Riley @ 2009-02-12 13:35 UTC (permalink / raw)
  To: help-gnu-emacs

Andreas Politz <politza@fh-trier.de> writes:

> Richard Riley wrote:
>> Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
>>
>>> Richard Riley wrote:
>>>> I like my interactive functions to generally use the word or region at
>>>> point as a default. Is there a way to make the read-string mini buffer
>>>> input to pre-select the default value?
>>>>
>>>> e.g
>>>>
>>>> consider
>>>>
>>>> (setq url (read-string (format "Url (%s) :" url) url nil url))
>>>>
>>>> Here I would like to see at the input prompt
>>>>
>>>> Url (xyz): xyz
>>>>
>>>> with the default value of "xyz" already selected. In other words
>>>> the same behaviour as when you tab into a populated  entry field in most
>>>> of applications.
>>> (let ((url-at-point (thing-at-point 'url)))
>>>   (read-string (if url-at-point
>>> 		   (format "URL (%s): " url-at-point)
>>> 		 "URL: ")
>>> 	       nil nil url-at-point))
>>
>> Hi Kevin,
>>
>> Sorry if I was not clear. I don't mean a default value - I mean
>> pre-selected as in "in region". e.g when you tab to a field in a web
>> form for example - The data in the field is highlighted/selected. I
>> already had a default value set as "url" in the code above.
>>
>> e.g
>>
>> goto www.Google.com 
>>
>> enter some text and tab to a button then tab back. The text in the
>> search field is selected.
>>
>>
>>
>
> Something like this ?
>
> (defun minibuffer-select-inital-input ()
>   (let ((start (next-single-char-property-change 1 'read-only)))
>     (when (< start (point-max))
>       (set-mark start)
>       (setq mark-active t))))
>
> (add-hook 'minibuffer-setup-hook 'minibuffer-select-inital-input)
> (read-string "> " "Hallo")
>
> -ap

Yes, thanks. But I released I was hoping for too much here since
region/mark etc works so many different ways depending on settings. As
"dim" in the #emacs said, probably best to rely on C-a C-k. e.g With my
setting hitting right arrow there results in "end of buffer" error.

Thanks for your time though!


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

* RE: Selecting default prompt text
  2009-02-12 13:35       ` Richard Riley
@ 2009-02-12 17:34         ` Drew Adams
  2009-02-12 17:48           ` Richard Riley
       [not found]           ` <mailman.573.1234460908.31690.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Drew Adams @ 2009-02-12 17:34 UTC (permalink / raw)
  To: 'Richard Riley', help-gnu-emacs

> > Something like this ?
> >
> > (defun minibuffer-select-inital-input ()
> >   (let ((start (next-single-char-property-change 1 'read-only)))
> >     (when (< start (point-max))
> >       (set-mark start) (setq mark-active t))))
> >
> > (add-hook 'minibuffer-setup-hook 'minibuffer-select-inital-input)
> > (read-string "> " "Hallo")
> >
> > -ap
> 
> Yes, thanks. But I released I was hoping for too much here since
> region/mark etc works so many different ways depending on settings. As
> "dim" in the #emacs said, probably best to rely on C-a C-k. 
> e.g With my setting hitting right arrow there results in
> "end of buffer" error.

1. I was going to suggest something like what ap said.

That seems to respond to your request, so I'm not sure what you meant above - in
particular about using the right arrow. If point is at the end of the input (end
of buffer), then why would you hit the right arrow? What would you like the
right arrow to do in that context?


2. [You won't like this related answer, but it might help someone else. ;-)]

In Icicles you can elect to always insert the default value as initial text. And
if you do that, you can also elect to automatically select it (as the active
region). And you can choose where to leave the cursor: before or after the
default text (whether or not you choose to auto-select it).

This means that if you use, say, Delete Selection mode, and you choose to
auto-select the default input, then you can just type other text to replace it,
or hit `C-d' or Backspace (DEL) to delete it.

And even if you choose not to auto-select the default text, you can use `M-k'
anytime to clear the minibuffer (easier than `C-a C-k').

http://www.emacswiki.org/emacs/Icicles_-_Customization_and_General_Tips#icicle-d
efault-value






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

* Re: Selecting default prompt text
  2009-02-12 17:34         ` Drew Adams
@ 2009-02-12 17:48           ` Richard Riley
       [not found]           ` <mailman.573.1234460908.31690.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Riley @ 2009-02-12 17:48 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Richard Riley', help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:

>> > Something like this ?
>> >
>> > (defun minibuffer-select-inital-input ()
>> >   (let ((start (next-single-char-property-change 1 'read-only)))
>> >     (when (< start (point-max))
>> >       (set-mark start) (setq mark-active t))))
>> >
>> > (add-hook 'minibuffer-setup-hook 'minibuffer-select-inital-input)
>> > (read-string "> " "Hallo")
>> >
>> > -ap
>> 
>> Yes, thanks. But I released I was hoping for too much here since
>> region/mark etc works so many different ways depending on settings. As
>> "dim" in the #emacs said, probably best to rely on C-a C-k. 
>> e.g With my setting hitting right arrow there results in
>> "end of buffer" error.
>
> 1. I was going to suggest something like what ap said.
>
> That seems to respond to your request, so I'm not sure what you meant above - in
> particular about using the right arrow. If point is at the end of the input (end
> of buffer), then why would you hit the right arrow? What would you like the
> right arrow to do in that context?

The way I use the kbd, right arrow to remove select and edit existing
text with cursor at end or any other (non directional) key to clear the
field. Try Google example : enter text, tab to button, shit tab back,
press right arrow.  But I see this is probably not a good idea to
enforce in emacs.





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

* Re: Selecting default prompt text
       [not found]           ` <mailman.573.1234460908.31690.help-gnu-emacs@gnu.org>
@ 2009-02-12 19:02             ` Richard Riley
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Riley @ 2009-02-12 19:02 UTC (permalink / raw)
  To: help-gnu-emacs

Richard Riley <rileyrgdev@googlemail.com> writes:

> "Drew Adams" <drew.adams@oracle.com> writes:
>
>>> > Something like this ?
>>> >
>>> > (defun minibuffer-select-inital-input ()
>>> >   (let ((start (next-single-char-property-change 1 'read-only)))
>>> >     (when (< start (point-max))
>>> >       (set-mark start) (setq mark-active t))))
>>> >
>>> > (add-hook 'minibuffer-setup-hook 'minibuffer-select-inital-input)
>>> > (read-string "> " "Hallo")
>>> >
>>> > -ap
>>> 
>>> Yes, thanks. But I released I was hoping for too much here since
>>> region/mark etc works so many different ways depending on settings. As
>>> "dim" in the #emacs said, probably best to rely on C-a C-k. 
>>> e.g With my setting hitting right arrow there results in
>>> "end of buffer" error.
>>
>> 1. I was going to suggest something like what ap said.
>>
>> That seems to respond to your request, so I'm not sure what you meant above - in
>> particular about using the right arrow. If point is at the end of the input (end
>> of buffer), then why would you hit the right arrow? What would you like the
>> right arrow to do in that context?
>
> The way I use the kbd, right arrow to remove select and edit existing
> text with cursor at end or any other (non directional) key to clear the
> field. Try Google example : enter text, tab to button, shit tab back,

Hmm. I must be more careful when typing "shift" .... Sorry.

> press right arrow.  But I see this is probably not a good idea to
> enforce in emacs.
>
>
>

-- 
 important and urgent problems of the technology of today are no longer the satisfactions of the primary needs or of archetypal wishes, but the reparation of the evils and damages by the technology of yesterday.  ~Dennis Gabor, Innovations:  Scientific, Technological and Social, 1970


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

end of thread, other threads:[~2009-02-12 19:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-11 23:29 Selecting default prompt text Richard Riley
2009-02-12  2:53 ` Kevin Rodgers
     [not found] ` <mailman.497.1234407233.31690.help-gnu-emacs@gnu.org>
2009-02-12  9:54   ` Richard Riley
2009-02-12 12:27     ` Andreas Politz
2009-02-12 13:35       ` Richard Riley
2009-02-12 17:34         ` Drew Adams
2009-02-12 17:48           ` Richard Riley
     [not found]           ` <mailman.573.1234460908.31690.help-gnu-emacs@gnu.org>
2009-02-12 19:02             ` Richard Riley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).