[Top][All Lists]

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

Re: An experiment with buttons

From: Jean Louis
Subject: Re: An experiment with buttons
Date: Fri, 6 Jan 2023 08:08:55 +0300
User-agent: Mutt/2.2.9+54 (af2080d) (2022-11-21)

* Eduardo Ochs <> [2023-01-02 23:07]:
> Hi Jean Louis,
> Can you test the code below?
> It's a prototype based on the ideas that we were discussing in private...

Yes, so far so good. It works.

>   Cheers,
>      E. =)
;; Tests:
;; (ee-button-sexp-text nil        nil)
;; (ee-button-sexp-text nil      "foo")
;; (ee-button-sexp-text '(+ 1 2)   nil)
;; (ee-button-sexp-text '(+ 1 2) "foo")
(defun ee-button-sexp-text (sexp text)
  (if sexp
      (if text
  "ok" ; if      sexp  and      text
(setq text (ee-S sexp))) ; if      sexp  and (not text)
    (if text
(setq sexp (read text)) ; if (not sexp) and      text
      (setq sexp nil text " "))) ; if (not sexp) and (not text)
  (list sexp text))

;; See: (find-kla-intro "9. `cl-defun'")
(cl-defun ee-makebutton
    (&key sexp text help-echo)
  (let ((st (ee-button-sexp-text sexp text)))
    (setq sexp (car st))
    (setq text (cadr st)))
  (let ((callback `(lambda (_) ,sexp)))
    (buttonize text callback nil help-echo)))

;; Tests:
;; (find-eemakebutton :sexp '(message "foo") :text "Foo")
;; (find-eemakebutton :sexp '(find-efunctiondescr 'car))
;; (find-eemakebutton :sexp '(find-efunctiondescr 'car) :help-echo "HELP")
(defun find-eemakebutton (&rest rest)
  (find-estring (apply 'ee-makebutton rest)))

(defun ee-B (sexp)
  (ee-H (ee-makebutton :sexp sexp)))

;; The sexp below is commented out with a "'".
;; To test it go to its last line and type `M-e'.
' (find-elinks
     (find-efunctiondescr 'car)
     ,(ee-H "plic")
     ,(ee-H (ee-makebutton :sexp '(+ 1 2)))
     ,(ee-H (ee-makebutton :sexp '(find-efunctiondescr 'car)))
     (find-efunctiondescr 'car)
     ,(ee-B '(find-efunctiondescr 'car))


Take action in Free Software Foundation campaigns:

In support of Richard M. Stallman

reply via email to

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