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 11:26:02 +0200 Message-ID: <877ce5bh05.fsf@gmx.net> References: <87cyny3wts.fsf@gmx.net> <87bk3hbl9x.fsf@gmx.net> 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="4234"; 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 11:26:48 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 1sODJ9-0000tk-OQ for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 01 Jul 2024 11:26:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sODId-0004ab-TA; Mon, 01 Jul 2024 05:26:15 -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 1sODIb-0004aD-7g for help-gnu-emacs@gnu.org; Mon, 01 Jul 2024 05:26:13 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sODIV-0007js-7B for help-gnu-emacs@gnu.org; Mon, 01 Jul 2024 05:26:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1719825963; x=1720430763; i=stephen.berman@gmx.net; bh=dGNC6ytqpg9oG5+4TI0lvDZXr5hn7oZbv7SYdKxWh4Y=; 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=NUUmmm7QjtI3sdySFfrfxK83bHOt8iSiuEJLei2s5EbIv33yTgou1qVinT9QowJM 47VcX65zpDTHzyJbdn8lnVTAJjV7jit24/1FyZyPtFCjVPIbYHwvQP7toE1w23pe4 N7JH7PeApIBl1TgtxlAuIpMrhy13XHYgX9FpDyvTaX5nkGD/ByTSSCJd1JwY6wNat 3gmU2Z/+9rKtECunXrGwGI4tf3SseLhO9hDnZQQxuhp384CPyBI4R2DycTb5rgY9z a5J8BfMVqsOEI9PZJVML065kNCOs5b0NNIkPO9RDsHvko59i3a4wTjz7NmXI3ZFMq UiHRsYluOI1g4mZv2A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([88.130.48.46]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MbRfv-1rrddC1MDJ-00nOx7; Mon, 01 Jul 2024 11:26:03 +0200 In-Reply-To: (Heime's message of "Mon, 01 Jul 2024 08:52:34 +0000") X-Provags-ID: V03:K1:SFQGMR4p5dvNeGEuMepIuUQBPk2zBWi6Pt1qCW/kjb6Inz/G2Xk L03EMbeqyj2sfMzG0EEqMBUuwZHI+z1YYk/GedLcGgFdPwg56xU0tFa/uqFFzNXYOs2KVvS Gbi58ocTlqtKfKKefKIgSTRP+Ik+tgsVGd5+sI1diZMUbPV/jp2M2WU/OpfTYS6q7k6GY9D a7Wr0JZSCNgbnpv19GXFw== UI-OutboundReport: notjunk:1;M01:P0:n4z87yLeXa8=;0O4VQIPZOTmRjrcgpZDWM6i3FAZ ntBdfEKB2pEpU/qAuf+9h74M44ZkZJjz9+17SbPkdgW1DKmtxYuXgquDejK05FAXZdmnWA8/0 xaGrS0v5D5jXk/ySs7Ys3EHYR4QUox52UeyxKAmvEzl0ludUptkLh4innnwXT4v4iUwLGggWg fUOnvGj0zZlxByS+vBzoZwkOOplR018ey78ygPalFdooSvZP/JS8iTcXxeZLKE+wScqIuqwBO 7X8bbUOhTJJ8k4hq2KUjSF40C0KiA020JXMW3zoPoHFH2VDfTILUwLweJURZwviMl/vKA2Sps RfmQ6IMsWDvff7KYQIFfRW+sWGth+AUCQ+Pn7+LrLQc9PmFQescaYGauumXJVkC4feflh0qi+ W7dfrXi10n4PVenVdDHpaCm6QGB6DWunVbG3l8LHCzvswLbi7nK1K5iwpyL0/+USo1lf30fRa EmVyYkZ8rKRTk0UqE6NTckpnOtIBysJ2Q0u3xM+BogkgEEvo/cjf4BsWfdu53JynbK7CAIF2H RqqSYrAVZ3nSMlCOMsStoAI6QFcsFtE6w8gcdNJD8D511wylLwNMT6HQDIMXro1ayMKguftbQ QnZqIOnmWBCyIOtlh7wbwaWmzzEKterQ7g78jrSUk1RabzgWpOSodLzWHku/6MSj6iRBw92xc REetPaVX1aek5EcPWQS7w65jnfiKJ9Iy417GbBwKc4iOzFhDAawosOjS77jwDzz0cWy3uYbAI KDXFap0UqgA7+v6jf8uOVqxoXShNu5ulkeDkCuLqI99fcSNqcRjQLHWM8oUAuD4thBlyZ927 Received-SPF: pass client-ip=212.227.15.19; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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:147040 Archived-At: On Mon, 01 Jul 2024 08:52:34 +0000 Heime wrot= e: > On Monday, July 1st, 2024 at 7:53 AM, Stephen Berman wrote: > >> On Sun, 30 Jun 2024 22:32:24 +0000 Heime heimeborgia@protonmail.com wro= te: >> >> > On Sunday, June 30th, 2024 at 10:11 PM, Stephen Berman >> > stephen.berman@gmx.net wrote: >> > >> > > On Sun, 30 Jun 2024 21:52:12 +0000 Heime heimeborgia@protonmail.com= wrote: >> > > >> > > > On Sunday, June 30th, 2024 at 8:00 PM, Heime >> > > > heimeborgia@protonmail.com wrote: >> > > > >> > > > > I have the function monde that displays some buttons with assoc= iated text >> > > > > describing what the button does. >> > > > > >> > > > > I would like to highlight the description text corresponding to= the button >> > > > > 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 tha= t is printed >> > > > 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 m= ultiple >> > > > 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 >> > >> > Steve, your function highlights everything, not only the text next to >> > where the button was pressed. >> >> >> Do you mean the background color? That was just an example; if you >> don't want it, then just don't include it in the value of the `face' >> property. E.g., if you just want the text next to the button to be >> red, just use '(:foreground "red") as the value of the` face' property. >> >> Steve Berman > > It is more complicated. When one presses the button "OUTBD", only the > word "OUTBD" gets coloured red. The other string are reset with no colo= r. > Meaning that the highlight is only applied to the text to which the key > was pressed. I guess you're talking not about the code I posted but about your second version that uses the function `mondu-color-text'. With that code what I see is that the text next to the pressed button turns red and the text next to the other buttons is left alone, i.e., if it is already red, it remains red, does not get reset. (However, since you didn't supply the code for `montejura-insert-colorat', I just replaced that with `insert', so maybe that's why I don't see what you describe.) If that's not what you want, you should explain more precisely what you want. (I thought you just wanted the text next to each button fontified to begin with (i.e, not just upon pressing the associated button), which is what the code I posted does, but it seems you want something else.) Steve Berman