all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Make command use specific functions for button action
@ 2024-07-02 19:54 Heime
  2024-07-02 22:04 ` Stephen Berman
  0 siblings, 1 reply; 2+ messages in thread
From: Heime @ 2024-07-02 19:54 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I have this function that displays two buttons, and calls the
corresponding functions lsk1g and lsk1d.  I would really like to have
the capability to instruct mondu to use specific function names
rather than the hardwired lsk1g and lsk1d.

For instance I want to make a call to mondu that will use lsk2g and
lsk2d rather than lsk1g and lsk1d.

(defun mondu ( monbf )

  (with-current-buffer (get-buffer-create monbf)

    (insert " DU \n\n")

    (insert " ")
    (insert-button "[-]" 'action 'lsk1g)
    (insert " lsk1g   ")

    (insert-button "[-]" 'action 'lsk1d)
    (insert " lsk1d  ") )

  (pop-to-buffer monbf) )





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Make command use specific functions for button action
  2024-07-02 19:54 Make command use specific functions for button action Heime
@ 2024-07-02 22:04 ` Stephen Berman
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Berman @ 2024-07-02 22:04 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Tue, 02 Jul 2024 19:54:18 +0000 Heime <heimeborgia@protonmail.com> wrote:

> I have this function that displays two buttons, and calls the
> corresponding functions lsk1g and lsk1d.  I would really like to have
> the capability to instruct mondu to use specific function names
> rather than the hardwired lsk1g and lsk1d.
>
> For instance I want to make a call to mondu that will use lsk2g and
> lsk2d rather than lsk1g and lsk1d.
>
> (defun mondu ( monbf )
>
>   (with-current-buffer (get-buffer-create monbf)
>
>     (insert " DU \n\n")
>
>     (insert " ")
>     (insert-button "[-]" 'action 'lsk1g)
>     (insert " lsk1g   ")
>
>     (insert-button "[-]" 'action 'lsk1d)
>     (insert " lsk1d  ") )
>
>   (pop-to-buffer monbf) )

Pass a list of symbols of the functions you want on each invocation:

(defun mondu (monbf funs)
  ...
  (let ((fun1 (nth 0 funs)))
    (insert-button "[-]" 'action fun1)
    (insert-button (concat " " (symbol-name fun1) "  ")))
  ...)

(mondu "Mondu" '(lsk2g lsk2d))

Steve Berman



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-02 22:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-02 19:54 Make command use specific functions for button action Heime
2024-07-02 22:04 ` Stephen Berman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.