From: Heime <heimeborgia@protonmail.com>
To: Jean Louis <bugs@gnu.support>
Cc: Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Re: Dedicated buffer with buttons that show messages in a central display area
Date: Sat, 12 Nov 2022 07:58:26 +0000 [thread overview]
Message-ID: <Q5JECwwSYixV1IUl1SX6qSmihLi3bcnyy-DDIqAkcw454_oAautCHF530r9lNLwMZV0u-mrnejkiq5JI8ELM9X3zwvtKHImok3v96fhGqbE=@protonmail.com> (raw)
In-Reply-To: <Y26WsjxIJ/5x9OBH@protected.localdomain>
Sent with Proton Mail secure email.
------- Original Message -------
On Friday, November 11th, 2022 at 6:38 PM, Jean Louis <bugs@gnu.support> wrote:
> * Heime heimeborgia@protonmail.com [2022-11-11 17:35]:
>
> > I would like to have a dedicated buffer that has a number of buttons that display messages in a central display area
> > when pressed. Can this be done?
>
>
> It can be done, but you do not define your desires clearly.
>
> Each buffer in Emacs is dedicated, that I know.
>
> "number of buttons", what kind of buttons? Do you mean like button
> links as explained in (info "(elisp) Buttons") ?
>
> 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:
>
> (defun rcd-button-insert (button-text action-function &optional how-many revert-key revert-value)
> "Insert button BUTTON-TEXT with ACTION-FUNCTION.
>
> 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)))))
>
> Which uses this one:
>
> (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))))
>
> Then you go like this:
>
> (rcd-button-insert "Display my message"
> (lambda () (message "My message"))) <-- evaluate it here
>
> or like this:
>
> (rcd-button-insert "Display my message"
> (lambda () (message "My message")) 21)Display my message²¹
>
> Function is made so that buttons displayed may be reverted, but that
> is not subject of your interest now.
>
> (defun rcd-button-revert-source (&optional revert-key)
> "Revert the button source.
>
> 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 "⟦ (hyperscope 123) ⟧")
> (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)))
>
> --
> Jean
>
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
>
> In support of Richard M. Stallman
> https://stallmansupport.org/
next prev parent reply other threads:[~2022-11-12 7:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 14:33 Dedicated buffer with buttons that show messages in a central display area Heime
2022-11-11 15:15 ` Emanuel Berg
2022-11-11 18:38 ` Jean Louis
2022-11-12 7:58 ` Heime [this message]
2022-11-12 8:31 ` Jean Louis
2022-11-13 10:02 ` Heime
2022-11-13 15:42 ` Jean Louis
2022-11-15 0:54 ` Emanuel Berg
2022-11-15 19:39 ` Heime
2022-11-13 11:26 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='Q5JECwwSYixV1IUl1SX6qSmihLi3bcnyy-DDIqAkcw454_oAautCHF530r9lNLwMZV0u-mrnejkiq5JI8ELM9X3zwvtKHImok3v96fhGqbE=@protonmail.com' \
--to=heimeborgia@protonmail.com \
--cc=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).