unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: uzibalqa <uzibalqa@proton.me>
To: uzibalqa via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Design of interactive function with buttons in help-buffer
Date: Wed, 30 Aug 2023 03:08:29 +0000	[thread overview]
Message-ID: <kdZIAlaxNkPB1hx2abMGeiTmvlFQd2dpEsMvsubk9RPEFPxCRdfq93FS6qgyprAZZIpiHCmRToIxa697q3LyUYT-9cbMXl9T1sA3yEwv6vc=@proton.me> (raw)


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	other threads:[~2023-08-30  3: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='kdZIAlaxNkPB1hx2abMGeiTmvlFQd2dpEsMvsubk9RPEFPxCRdfq93FS6qgyprAZZIpiHCmRToIxa697q3LyUYT-9cbMXl9T1sA3yEwv6vc=@proton.me' \
    --to=uzibalqa@proton.me \
    --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).