unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Complications with using buttons for inserting text
Date: Tue, 29 Aug 2023 01:08:52 +0000	[thread overview]
Message-ID: <0qLx4NgyIgddTGUIyCUsinPoyFhBXfrSWyJpMZDUdNT2dsy40Wv0D0ATLn2Z4GTOUTrNXFV1kLnPXAeCIv-8cro7fOAVDvNZ1YvBgM48QOo=@protonmail.com> (raw)

Most likely, I have complicated things too much, and would like some criticism 
about it, with possible improvements.

I have made the following design for displaying buttons ("[F5]" and "[B5]") 
to show some text using (insert this-text) and (insert that-text).  The
button "[Next]" displays the next piece of text, whilst the button "[*]"
displays both buttons "[F5]" and "[B5]".

I call the functionality via two interactive functions, 'qrh-maces-snapshot'
(which displays only the snapshot related text) and 'qrh-maces' (which displays
a separate "action-release" and action-snapshot).

The interactive function 'qrh-maces' has the possibility of either calling
'action-snapshot' or 'qrh-maces-snapshot' for the same thing.

(defun action-snapshot-f5 (button)
  (insert-button "[Next]"
    'action 'action-snapshot-b5 'follow-link t)
  (insert this-text) ))

(defun action-snapshot-b5 (button)
  (insert-button "[Next]"
    'action 'action-snapshot-f6 'follow-link t)
  (insert that-text) ))

(defun action-snapshot (button)
  (pcase (button-label button)
    ("[F5]"
       (insert-button "[Next]"
         'action 'action-snapshot-b5 'follow-link t)
       (insert this-text))
    ("[B5]"
       (insert-button "[Next]"
         'action 'action-snapshot-f6 'follow-link t)
       (insert that-text))
    ("[*]"
       (insert-button "[F5]"
         'action 'action-snapshot-f5 'follow-link t)
       (insert-button "[B5]"
         'action 'action-snapshot-b5 'follow-link t)) ))

(defun qrh-maces-snapshot (&optional button)
  (interactive)
  (insert-button "[F5]" 'action 'action-snapshot 'follow-link t)
  (insert-button "[B5]" 'action 'action-snapshot 'follow-link t))

(defun qrh-maces  ()
  (interactive)
  (insert-button "[*]" 'action 'action-release 'follow-link t)
  (insert-button "[*]" 'action 'action-snapshot 'follow-link t)
  (insert-button "[*]" 'action 'qrh-maces-snapshot 'follow-link t))



                 reply	other threads:[~2023-08-29  1:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='0qLx4NgyIgddTGUIyCUsinPoyFhBXfrSWyJpMZDUdNT2dsy40Wv0D0ATLn2Z4GTOUTrNXFV1kLnPXAeCIv-8cro7fOAVDvNZ1YvBgM48QOo=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --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).