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

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

Design of interactive function with buttons in help-buffer


From: uzibalqa
Subject: Design of interactive function with buttons in help-buffer
Date: Wed, 30 Aug 2023 03:08:29 +0000

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





reply via email to

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