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 09:53:46 +0200 Message-ID: <87bk3hbl9x.fsf@gmx.net> References: <87cyny3wts.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="14666"; 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 09:54:38 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 1sOBry-0003eF-Po for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 01 Jul 2024 09:54:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOBrF-0007nl-N2; Mon, 01 Jul 2024 03:53:53 -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 1sOBrE-0007nb-9q for help-gnu-emacs@gnu.org; Mon, 01 Jul 2024 03:53:52 -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 1sOBrC-0002qX-5S for help-gnu-emacs@gnu.org; Mon, 01 Jul 2024 03:53:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1719820427; x=1720425227; i=stephen.berman@gmx.net; bh=mt6/W7u/Sh4UdrU9Jyd3C74x+5zyufGEmHGnjRXsCis=; 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=Iijj0cAK+kREoDHKI+T3E6hJZVCTp2xdTiXXRWc+fd+drUf1rqCUmbD83QkIaTk3 FFdRUSeegJpIuGfp0RQx/1ju5QfVMi/T5PCVA/lD87BiMxj5HghkbUVc3mAvdQEh4 Bi/jNOGXq8a+xdZSi/IiOtigsemxOI8E5xyz7m5Nn1fsSWXrZ4wgGFZXbv3nMgS2L IsS1D6KPXl+pMSYjOOB/px+D21dt0fHlhSp+HvSyAjIL31orY1ed8PreXkxSj6gNY nmAoQhd9gL978PKOIpIZTmKa3yIt78RlQdbarmZpgd+T/ha7VHG7oAQtl0FFRKFdk JUb3bG3aJQvR6GIUgA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([88.130.48.46]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M7Jza-1sVv5r0W2W-007MnY; Mon, 01 Jul 2024 09:53:47 +0200 In-Reply-To: (Heime's message of "Sun, 30 Jun 2024 22:32:24 +0000") X-Provags-ID: V03:K1:Y7yD6c1PVd3tyhqP+oXxd2/8ESUY7Bwykgj5UKVCUexdq07kQ/8 MvxeJcG1+ngdCsIDB/B+DZFMQovRcm4p92cngK1puQm/xph//Gf4nSUsJmqazvU8xLF5+G4 IlwGUKQXVXCcCHng2iV1WXB8gH+I8KjPFd9g+Bb/yatIPl7265ZT9dArFj2sClY5wD+CZuc e4O3RAItRTYKgaa2Pf06g== UI-OutboundReport: notjunk:1;M01:P0:hOVruyATPhQ=;Yj/qTtH2SbNKdd7elpFnsSZ2907 mevznbKKazh33r94G5r1UfkUFXmbYBhWbsfdyR/fnKEWaoZfev+6ve7l2mlw3dIVN08Xq9Boa 2hSamjtsc5RJy9niiq4JkBk/jUCRTMcY+semcBxA4gIM8dUrufc2A6YIeEls+o+x4MXPJ5lye Wd1uBd2SFnYfw0nWuK/jPlAjWgvZ1WQ9upYZD0MmenuQn8XB2kCJ89eiNruuCMY48bRGimwTA KXFg2RR2Sexo0LxnOaDX9zlVBDJwaYyhpY7arUCgVLJCMSCnvrPg2OHs1kuwzIfvgH6N47BeU b4rD9w/4q2tNOIQkooF8gUmqPfADBbnlZVNKg7ApWjqU2c0vLm1uFHuPyXUlatET9OWSzzPHx eywBctI5qzcTc6vvTCUTk3HnSW1b5kchH0XavSXr3CuKyXW30yw4rMZfuQDm7SXav+0iBBBqf JnarhnqpH/eKmmhBac0El+8NoTUVMckOpoIRwKXa/x3dj+zlszh7vYWQbysa5UVI9qs9KYr2Q s8WT+uyYDDC4QY2v16TCvEUjqaYxluXCcmRX1F80pN0vVXdxbcI35QUui+tfX3Hcw8Td5BIwL 0ClhTU3Gp1AJiC4vSz/ZId4PWcgotiPwBzaUm+1Ra/Xsnme/KSKqfFVMFUDKFk5w9GhHbshMC qvCwhLiAjIZj7UQ5v63dy0efIxaU8z8asviyA2cjy0QJrpCW47WxgSiVrqZhKWKE9OTqCtqpt /4RToLYyjpE+5TN+kKmuQmiZXq+xvwbwNL0WF5lItIwtTyJCYe6WhajtYmXTf5oOqPC76+xX Received-SPF: pass client-ip=212.227.15.19; 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_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:147038 Archived-At: On Sun, 30 Jun 2024 22:32:24 +0000 Heime wrot= e: > On Sunday, June 30th, 2024 at 10:11 PM, Stephen Berman > wrote: > >> On Sun, 30 Jun 2024 21:52:12 +0000 Heime heimeborgia@protonmail.com wro= te: >> >> > On Sunday, June 30th, 2024 at 8:00 PM, Heime heimeborgia@protonmail.c= om wrote: >> > >> > > I have the function monde that displays some buttons with associate= d 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 func= tion. >> > > 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= 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 multi= ple >> > 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