unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* dynamic prompt
@ 2012-05-05 17:07 Joe Corneli
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Corneli @ 2012-05-05 17:07 UTC (permalink / raw)
  To: help-gnu-emacs

I'd like to have a prompt that shows the number of characters entered
in the response

Prompt (3): bla
Prompt (7): bla bla

Is that in any way possible?



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

* Re: dynamic prompt
       [not found] <mailman.608.1336237635.855.help-gnu-emacs@gnu.org>
@ 2012-05-06  1:50 ` Stefan Monnier
  2012-05-06  2:37   ` Barry Margolin
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2012-05-06  1:50 UTC (permalink / raw)
  To: help-gnu-emacs

> I'd like to have a prompt that shows the number of characters entered
> in the response

> Prompt (3): bla
> Prompt (7): bla bla

> Is that in any way possible?

Of course: the prompt is normal text present in the (mini)buffer, which
itself is a perfectly normal buffer (tho displayed in a special
(mini)window) and you can edit it like any other buffer text.


        Stefan


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

* Re: dynamic prompt
  2012-05-06  1:50 ` dynamic prompt Stefan Monnier
@ 2012-05-06  2:37   ` Barry Margolin
  2012-05-06 14:56     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Barry Margolin @ 2012-05-06  2:37 UTC (permalink / raw)
  To: help-gnu-emacs

In article <jwvzk9m13ms.fsf-monnier+gnu.emacs.help@gnu.org>,
 Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> > I'd like to have a prompt that shows the number of characters entered
> > in the response
> 
> > Prompt (3): bla
> > Prompt (7): bla bla
> 
> > Is that in any way possible?
> 
> Of course: the prompt is normal text present in the (mini)buffer, which
> itself is a perfectly normal buffer (tho displayed in a special
> (mini)window) and you can edit it like any other buffer text.

I suspect he wants the character count to be updated automatically. 
Seems like he needs to enable a hook when he goes into the mini-buffer, 
that modifies the prompt after each command.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: dynamic prompt
  2012-05-06  2:37   ` Barry Margolin
@ 2012-05-06 14:56     ` Stefan Monnier
  2012-05-06 16:02       ` Joe Corneli
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2012-05-06 14:56 UTC (permalink / raw)
  To: help-gnu-emacs

>> > I'd like to have a prompt that shows the number of characters entered
>> > in the response
>> > Prompt (3): bla
>> > Prompt (7): bla bla
>> > Is that in any way possible?
>> Of course: the prompt is normal text present in the (mini)buffer, which
>> itself is a perfectly normal buffer (tho displayed in a special
>> (mini)window) and you can edit it like any other buffer text.
> I suspect he wants the character count to be updated automatically.

Of course.  But that can use any of the standard hooks for that:
post-command-hook or after-change-functions.

> Seems like he needs to enable a hook when he goes into the mini-buffer, 
> that modifies the prompt after each command.

minibuffer-setup-hook should do the trick, or minibuffer-with-setup-hook
depending on whether he wants it in one particular case or in all cases.


        Stefan


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

* Re: dynamic prompt
  2012-05-06 14:56     ` Stefan Monnier
@ 2012-05-06 16:02       ` Joe Corneli
  2012-05-07  0:32         ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Joe Corneli @ 2012-05-06 16:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Thanks, here's my ugly code that seems to work:

(defun status (msg)
  (interactive
   (list (substring (let ((count 0)
			  (inhibit-read-only t))
		      (minibuffer-with-setup-hook
			  (lambda ()
			    (delete-region 8 (point-max))
			    (add-hook
			     'post-command-hook
			     (lambda ()
			       (save-excursion
				 (goto-char (point-min))
				 (when (looking-at "\\([0-9() ]*\\)Prompt:")
				   (delete-region (point-min) (match-end 1)))
				 (let ((str
					(format "(%s) "
						(length
						 (buffer-substring-no-properties
						  8
						  (point-max))))))
				   (insert str))))))
			(read-string "Prompt:  ")))
		    7)))
  ;; post to identica
  (shell-command (concat "/home/jac2349/laconica.sh ") msg))

On Sun, May 6, 2012 at 3:56 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> > I'd like to have a prompt that shows the number of characters entered
>>> > in the response
>>> > Prompt (3): bla
>>> > Prompt (7): bla bla
>>> > Is that in any way possible?
>>> Of course: the prompt is normal text present in the (mini)buffer, which
>>> itself is a perfectly normal buffer (tho displayed in a special
>>> (mini)window) and you can edit it like any other buffer text.
>> I suspect he wants the character count to be updated automatically.
>
> Of course.  But that can use any of the standard hooks for that:
> post-command-hook or after-change-functions.
>
>> Seems like he needs to enable a hook when he goes into the mini-buffer,
>> that modifies the prompt after each command.
>
> minibuffer-setup-hook should do the trick, or minibuffer-with-setup-hook
> depending on whether he wants it in one particular case or in all cases.
>
>
>        Stefan



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

* Re: dynamic prompt
  2012-05-06 16:02       ` Joe Corneli
@ 2012-05-07  0:32         ` Stefan Monnier
  2012-05-07  9:49           ` Joe Corneli
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2012-05-07  0:32 UTC (permalink / raw)
  To: Joe Corneli; +Cc: help-gnu-emacs

> 			(length
> 			 (buffer-substring-no-properties
> 			  8
> 			  (point-max))))))

aka (- (point-max) 8)


        Stefan



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

* Re: dynamic prompt
  2012-05-07  0:32         ` Stefan Monnier
@ 2012-05-07  9:49           ` Joe Corneli
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Corneli @ 2012-05-07  9:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

> aka (- (point-max) 8)

Thanks, that contributes nicely to the un-uglification.



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

end of thread, other threads:[~2012-05-07  9:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.608.1336237635.855.help-gnu-emacs@gnu.org>
2012-05-06  1:50 ` dynamic prompt Stefan Monnier
2012-05-06  2:37   ` Barry Margolin
2012-05-06 14:56     ` Stefan Monnier
2012-05-06 16:02       ` Joe Corneli
2012-05-07  0:32         ` Stefan Monnier
2012-05-07  9:49           ` Joe Corneli
2012-05-05 17:07 Joe Corneli

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).