From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joe Corneli Newsgroups: gmane.emacs.help Subject: Re: dynamic prompt Date: Sun, 6 May 2012 17:02:31 +0100 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1336320162 20786 80.91.229.3 (6 May 2012 16:02:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 6 May 2012 16:02:42 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 06 18:02:41 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SR3uz-0001Ki-4m for geh-help-gnu-emacs@m.gmane.org; Sun, 06 May 2012 18:02:41 +0200 Original-Received: from localhost ([::1]:51134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SR3uy-000504-II for geh-help-gnu-emacs@m.gmane.org; Sun, 06 May 2012 12:02:40 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SR3ut-0004zr-LE for help-gnu-emacs@gnu.org; Sun, 06 May 2012 12:02:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SR3ur-00025l-Ow for help-gnu-emacs@gnu.org; Sun, 06 May 2012 12:02:35 -0400 Original-Received: from mail-ob0-f169.google.com ([209.85.214.169]:34039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SR3ur-00025Y-IM for help-gnu-emacs@gnu.org; Sun, 06 May 2012 12:02:33 -0400 Original-Received: by obbwd18 with SMTP id wd18so8646359obb.0 for ; Sun, 06 May 2012 09:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=dHFxG5JykBmfWnjAYJXAEVUE+/Hcj/GE6qC7TQ/QkCY=; b=XUFUVxkn1FAB5pElVRsA7bP5UkKKradXTtMzcJfZs/mHarSDo10rzjPlpnyhJ32gGV Mb4NeDlgXGUJd5H6X45agRloJ+LjtC021q2yRMj6aQN2KeMEx8oJZqHwq1VMJWuRWnn+ NeAH5K+PucmuqKGwo2kscUYInWxiseU+2/b2XNRZD3lSxfhPdCYON7W9RakKOkEuOjrL bymqxnYN/HYuHJnfppvYVcUatZVsggazgZnpxx3qvTRZsJw2gdCm4IntYT/rUHxuu4Kq BiOyJCjzkqhfVh2WFJ6X1meWIcaNaXWVWJ/0/L+ZOSgP6zWqfgWh8jd5Z5D6yutnhVvQ +pkg== Original-Received: by 10.182.52.105 with SMTP id s9mr17772948obo.48.1336320151716; Sun, 06 May 2012 09:02:31 -0700 (PDT) Original-Received: by 10.182.55.138 with HTTP; Sun, 6 May 2012 09:02:31 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84737 Archived-At: 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 w= rote: >>> > 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. =A0But 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. > > > =A0 =A0 =A0 =A0Stefan