From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime Newsgroups: gmane.emacs.help Subject: Re: Dedicated buffer with buttons that show messages in a central display area Date: Sat, 12 Nov 2022 07:58:26 +0000 Message-ID: References: <7JoMGtkVaj2vOMXLHgljVCzArGL8AADy9AiTLvPrnQ80fWENK2Lv73o5DxLfZ4PwAt6G3PgqgBC_tzkSVMsrC3fQd7vW7WNHGHJchNejiW0=@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37843"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 12 08:59:15 2022 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 1otlQ2-0009ek-Av for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 12 Nov 2022 08:59:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otlPX-0007jy-0K; Sat, 12 Nov 2022 02:58:43 -0500 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 1otlPV-0007g6-4q for help-gnu-emacs@gnu.org; Sat, 12 Nov 2022 02:58:41 -0500 Original-Received: from mail-4318.protonmail.ch ([185.70.43.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otlPS-00008W-Tv for help-gnu-emacs@gnu.org; Sat, 12 Nov 2022 02:58:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1668239915; x=1668499115; bh=1vVFegZJp9Ebn28P5LN4488Rl7l4y9f9Hk0NCotEupo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=PCeEZHt0KY/nChmN6OHGvkd6EN41VBL1Uz1oDqM96GCad0/jJpFuli+JYD+pBAvSJ 288TNSuEcRzIKgtoET/rdG+dyXhDPNrU19Gq5shIhQaZSPVwj89zyKqh+bAUBnYWdT 8VxoCTrYRl+EzofKHS6XmGfYjX6QNKynZh8u/OYoHNil5M31ldwAJKiD6AsYFtNJ5y YfrImDGTM5BQrbqCp+oMnxofdtShxiw5VIdHrI5SRqHIAyjPwXBhK5xOVPJ+sYtGeg 1SuNV0mxa8ChJ4SlfuXmCcEYn/GF01HaltsZOBRSOOmbVeClTPHqQKUgeFSKhjKSFv Gf17SjggILdPQ== In-Reply-To: Feedback-ID: 57735886:user:proton Received-SPF: pass client-ip=185.70.43.18; envelope-from=heimeborgia@protonmail.com; helo=mail-4318.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-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:140914 Archived-At: Sent with Proton Mail secure email. ------- Original Message ------- On Friday, November 11th, 2022 at 6:38 PM, Jean Louis wr= ote: > * Heime heimeborgia@protonmail.com [2022-11-11 17:35]: >=20 > > I would like to have a dedicated buffer that has a number of buttons th= at display messages in a central display area > > when pressed. Can this be done? >=20 >=20 > It can be done, but you do not define your desires clearly. >=20 > Each buffer in Emacs is dedicated, that I know. >=20 > "number of buttons", what kind of buttons? Do you mean like button > links as explained in (info "(elisp) Buttons") ? >=20 > Define "central display area", do you mean center of the visible > window? Or center of the buffer? Horizontally and vertically to window > or buffer? Or center of the text width before wrap? To look like MCDU (Multi-Function Control Display Unit) on aircraft. https://www.uasc.com/home/shop/avionics/mcdu > I have this function: >=20 > (defun rcd-button-insert (button-text action-function &optional how-many = revert-key revert-value) > "Insert button BUTTON-TEXT with ACTION-FUNCTION. >=20 > Optional number HOW-MANY adds superscript digits to BUTTON-TEXT." > (let* ((revert-key (or revert-key "revert-key")) > (revert-key (intern revert-key)) > (rever-value (or revert-value button-text))) > (insert-text-button button-text > 'action > action-function > 'follow-link t > revert-key revert-value) > (when how-many > (insert (rcd-superscript-digits how-many))))) >=20 > Which uses this one: >=20 > (defun rcd-superscript-digits (number) > "Return unicode digits for NUMBER." > (let* ((string (cond ((numberp number) (number-to-string number)) > ((stringp number) number))) > (digits (split-string string "" t " "))) > (with-temp-buffer > (while digits > (insert (rcd-superscript-digit-1 (string-to-number (pop digits))))) > (buffer-string)))) >=20 > Then you go like this: >=20 > (rcd-button-insert "Display my message" > (lambda () (message "My message"))) <-- evaluate it here >=20 > or like this: >=20 > (rcd-button-insert "Display my message" > (lambda () (message "My message")) 21)Display my message=C2=B2=C2=B9 >=20 > Function is made so that buttons displayed may be reverted, but that > is not subject of your interest now. >=20 > (defun rcd-button-revert-source (&optional revert-key) > "Revert the button source. >=20 > REVERT-KEY is optional and by default the symbol 'REVERT-KEY. The > value of REVERT-KEY will be returned as source." > ;; (rcd-button-insert "Hello" (lambda (_) (message-box "Hello")) nil nil = "=E2=9F=A6 (hyperscope 123) =E2=9F=A7") > (let ((point (point)) > (revert-key (or revert-key 'revert-key))) > (save-excursion > (goto-char (point-min)) > (let (my-prop) > (while (setq my-prop > (text-property-search-forward > revert-key)) > (when my-prop > (let ((begin (prop-match-beginning my-prop)) > (end (prop-match-end my-prop)) > (value (prop-match-value my-prop))) > (set-text-properties (1- begin) end nil) > (delete-region begin end) > (goto-char begin) > (insert (format "%s" value))))))) > (goto-char point))) >=20 > -- > Jean >=20 > Take action in Free Software Foundation campaigns: > https://www.fsf.org/campaigns >=20 > In support of Richard M. Stallman > https://stallmansupport.org/