unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Complications with using buttons for inserting text
@ 2023-08-29  1:08 Heime
  0 siblings, 0 replies; only message in thread
From: Heime @ 2023-08-29  1:08 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

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))



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-29  1:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-29  1:08 Complications with using buttons for inserting text Heime

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).