unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Design of interactive function with buttons in help-buffer
@ 2023-08-30  3:08 uzibalqa
  0 siblings, 0 replies; only message in thread
From: uzibalqa @ 2023-08-30  3:08 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor


I need some suggestions regarding the following code - so that I simplify it
and enhance it.  qrh-organis is the interactive call for users.  

I pass button as argument to organis-selk, which is then passed to 
organis-selk-f8, organis-selk-b8, and organis-selk-menu.  Is such strategy a
good way or can all this be improved in its design ?

(defconst organis-b8 "\n Some text \n")
(defconst organis-b8 "\n Some more text \n")

(defun organis-selk-f8 (button)
  "Function to be executed when the button is clicked."
  (with-help-window (help-buffer)
    (insert " > Graphical Organisation \n")
    (insert "    ")
    (insert-button "[Next]"
      'action 'organis-selk-b8 'follow-link t)
    (insert " *** \n")
    (insert organis-f8)))

(defun organis-selk-b8 (button)
  "Function to be executed when the button is clicked."
  (with-help-window (help-buffer)
    (insert-button "[Prev]"
      'action 'organis-selk-f8 'follow-link t)
    (insert " Frames, Windows, Buffers\n")
    (insert organis-b8)))

(defun organis-selk-menu (button)
  "Function to be executed when the button is clicked."
  (with-help-window (help-buffer)
    (insert-button "[F8]" 'action 'organis-selk-f8 'follow-link t)
    (insert " Frames, Windows, Buffers \n")
    (insert-button "[B8]" 'action 'organis-selk-b8 'follow-link t)
    (insert " *** \n")))

(defun organis-selk (button)
  "Function to be executed when the button is clicked."
  (pcase (button-label button)  ; Test button property first
    ("[F8]" (organis-selk-f8 button))
    ("[B8]" (organis-selk-b8 button))
    (_      (organis-selk-menu button))) )


(defun qrh-organis ()
  "Prints information about frames."
  (interactive)
  (with-help-window (help-buffer)
    (insert-button "[F8]" 'action 'organis-selk 'follow-link t)
    (insert " Frames, Windows, Buffers \n")
    (insert-button "[B8]" 'action 'organis-selk 'follow-link t)
    (insert " *** \n") ))
 





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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-30  3:08 Design of interactive function with buttons in help-buffer uzibalqa

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