help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Complications with using buttons for inserting text


From: Heime
Subject: Complications with using buttons for inserting text
Date: Tue, 29 Aug 2023 01:08:52 +0000

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 via email to

[Prev in Thread] Current Thread [Next in Thread]