From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Highlighting text next to button Date: Mon, 01 Jul 2024 00:11:27 +0200 Message-ID: <87cyny3wts.fsf@gmx.net> References: Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1017"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 01 00:12:24 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sO2mV-000Aas-AE for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 01 Jul 2024 00:12:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sO2lo-00020P-Ja; Sun, 30 Jun 2024 18:11:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sO2lm-0001zv-Ln for help-gnu-emacs@gnu.org; Sun, 30 Jun 2024 18:11:38 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sO2lk-0000ao-Jq for help-gnu-emacs@gnu.org; Sun, 30 Jun 2024 18:11:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1719785489; x=1720390289; i=stephen.berman@gmx.net; bh=171JXsVBCDLIqp2dtaOd5MG21XHIt/YvGiijk3dwIoY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=lXXB1yW6pp+F+kpBJb4WVrj+oRE4TTwwTXb0CfIpNaFumWRp+Y8VNNOd+GDCuozV OK7Srt7p8NCLMWOAQaw4X+faJ0mQj2XdtVq6Bk2mLrgPysNYm+vchxSIn3hSx61H7 87a3HfsjkV0QeUTlsW2d5YnXPKfKlCztlIS4fTJMSxqommCVXRoCGVR2xpAPM4WOW sxmmeiUJkNnQwrA1aFRWBz0SJ3/ZDSGcZDIIgRI9J6GHzlX3cqNf0x1xUD578KXwt NJxHG2PucdESwMvrvJxljp2mdBZSKLfMIO4dB5NWMbszkMKPS5RH/s3oQcwm2JaO6 Tfi38a6e5QZknyVx4A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([94.134.94.130]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MTRQq-1srhgD0AHc-00MnLb; Mon, 01 Jul 2024 00:11:29 +0200 In-Reply-To: (Heime's message of "Sun, 30 Jun 2024 21:52:12 +0000") X-Provags-ID: V03:K1:M1KKhnPg/NFWNdoyqqaSiJEZG9dbxUHSc959NtwKnNzDb2t/nnS N9dqF/qbJ3GR3WaLYpAvwsL3woqyqtnBkF0WFgHVYOhDgWUhsILe04q5meb/QGY4x9NbCny Gj9VeRjXuAewtJuwnTl37kqf9P92LIlv5uMPhZtmQ/PlMr7i1+6CpjOcwn6zs7qVCTnId8A JbIVS9jUUraxn5TNjHWvA== UI-OutboundReport: notjunk:1;M01:P0:GCVTr66CQW0=;sfYM8z2ct6BX6D4+Q70T2Bk2q5f e1vSElj8W/DB0KBq742IM9hylvN4sGcYdaFUw46Rmfykd3hT16VuwUhGzvGeeiP21sOWff8gL eIpZmKIU9zqPosCSjN4sj0oIuiDVBqSkWqE+gJ9fizmLVQmDvKtACWQKSCUJlLY4jemputIUk ncT//9UCGT7yNa1EqT6pfIuwEHjz/xy/SpTWskvBejkzriRMjUhbGmYK1rnYgYDGoRUVcfPTs qC7DbrwxcPQD2BgD/nUUVTCKwl0z212kbDL+SVRfceQ0IXinkP80uyVUA320NJTZcXsaE7Xre 3kUHCPZ6aGL9SuCq6X9fjSecjJuMFAehsnuHSkGUc4RJD+DPcSQNxbvJoN5CxVqXUkcyAbBuD +Rs8aRgK/r7b/e5WtUay3hg+QZyPP0IyDGQA9ynmaVZsvs35JYmjXudJL6MM6/dtBqWGhKlFy Y2/9NO8eFZ+Zh2S5t478GNqqf7QLs+ljU1m1qPIgJqQcsWYNNIWhCw0AxFQFp+e33I+H/31eZ hiXUrxd9gXh4G1UBOKO3CwyojzSutnRUx+L7X39ONKNa/mPmWxpjRFkzQN/380XWwpiYVNL+s 916EWprzJyC6ORkcTLWytUZQD2C7Me0FlisRRnSUbcdhmGKrXQnbuvpUrJCVSXVAMgJeCq37D 3/qX7xHGOlXuXVCOoePcN+R0jVORdZQC2+Y72XEALPMZ6FcQHmpQF33URLSrh68K5NWC6QZW+ ZkHE7KiNJK5MFNB+zwZ6BuNND4iXfYn8gpiXXWVQkkNtDRSNlziuwoAo6wjzaUZJjYmInAX4 Received-SPF: pass client-ip=212.227.17.20; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147035 Archived-At: On Sun, 30 Jun 2024 21:52:12 +0000 Heime wrot= e: > On Sunday, June 30th, 2024 at 8:00 PM, Heime wrote: > >> I have the function monde that displays some buttons with associated te= xt >> describing what the button does. >> >> I would like to highlight the description text corresponding to the but= ton >> that was pressed, with NORM being the default when calling the function= . >> What can I do ? >> >> (defun spaz (w) >> "Make a string of width W made of spaces." >> (make-string w ?\s)) >> >> (defun mondu () >> >> (interactive) >> >> (with-current-buffer (get-buffer-create "Mondu") >> >> (insert " MAIN PANEL DU \n\n") >> >> (insert " ") >> (insert-button "[-]" 'action 'mondu-outbd) >> (insert " OUTBD ") >> >> (insert-button "[-]" 'action 'mondu-norm) >> (insert " NORM ") >> >> ;;------------------------------------------------------------ >> >> (insert-button "[-]" 'action 'mondu-inbd-eng-pri) >> (insert " INBD ENG PRI \n") >> >> (insert (spaz 24)) >> (insert-button "[-]" 'action 'mondu-inbd-pfd) >> (insert " INBD PFD \n") >> >> (insert (spaz 24)) >> (insert-button "[-]" 'action 'mondu-inbd-hfd) >> (insert " INBD HFD \n") ) >> >> (pop-to-buffer "Mondu") ) > > Have made the following. But I also have to activate the text that is p= rinted > to the help buffer when pressing the button. > > > (defun mondu-color-text (text color) > "Color TEXT in the specified COLOR in the Mondu buffer." > > (with-current-buffer "Mondu" > (save-excursion > (goto-char (point-min)) > (when (search-forward text nil t) > (let ((start (match-beginning 0)) > (end (match-end 0))) > (add-text-properties start end `(face (:foreground ,color)))))= ))) > > > (defun mondu () > "Set up the Mondu buffer with buttons and text." > > (interactive) > > (with-current-buffer (get-buffer-create "Mondu") > > (erase-buffer) ;; Clear the buffer to avoid repeated content on mult= iple invocations > > (insert " MAIN PANEL DU \n\n") > > (insert " ") > (insert-button "[-]" > 'action (lambda (_) (mondu-color-text " OUTBD " "red"))) > (insert " OUTBD ") > > (insert-button "[-]" > 'action (lambda (_) (mondu-color-text " NORM " "red"))) > (montejura-insert-colorat " NORM " "red") > > (insert-button "[-]" > 'action (lambda (_) (mondu-color-text " INBD ENG PRI " "red"))) > (insert " INBD ENG PRI \n") > > (insert (espz 24)) > (insert-button "[-]" > 'action (lambda (_) (mondu-color-text " INBD PFD " "red"))) > (insert " INBD PFD \n") > > (insert (espz 24)) > (insert-button "[-]" > 'action (lambda (_) (mondu-color-text " INBD HFD " "red"))) > (insert " INBD HFD \n")) > > (pop-to-buffer "Mondu")) Perhaps this (based on the first version): (defun mondu () (interactive) (with-current-buffer (get-buffer-create "Mondu") (let ((make-desc (lambda (&optional description) (insert (propertize (or description " NORM ") 'face '( :weight bold :slant italic :background "lightgray")))))) (insert " MAIN PANEL DU \n\n") (insert " ") (insert-button "[-]" 'action 'mondu-outbd) (funcall make-desc " OUTBD ") (insert-button "[-]" 'action 'mondu-norm) (funcall make-desc) ;;------------------------------------------------------------ (insert-button "[-]" 'action 'mondu-inbd-eng-pri) (funcall make-desc " INBD ENG PRI \n") (insert (spaz 24)) (insert-button "[-]" 'action 'mondu-inbd-pfd) (funcall make-desc " INBD PFD \n") (insert (spaz 24)) (insert-button "[-]" 'action 'mondu-inbd-hfd) (funcall make-desc" INBD HFD \n"))) (pop-to-buffer "Mondu")) Steve Berman