0

Have made an interactive function qrh so that I can use buttons to display some strings contained in organis-f8 and organis-b8.

Can all this be simplified ? It seems to me that a button always requires a function that can be passed a button. Meaning that I cannot introduce the functionalities of organis-selk-f8 and organis-selk-b8 into organis-selk. Could I do something with organis-selk and qrh though ?

(defun organis-selk-f8 (button)
  (with-help-window (help-buffer)
    (insert organis-f8)))

(defun organis-selk-b8 (button)
  (with-help-window (help-buffer)
    (insert organis-b8)))

(defun organis-selk (button)
  (pcase (button-label button)
    ("[F8]" (organis-selk-f8 button))
    ("[B8]" (organis-selk-b8 button))
    (_      (message "something"))))

(defun qrh ()
  (interactive)
  (with-help-window (help-buffer)
    (insert-button "[F8]" 
      'action 'organis-selk 'follow-link t)
    (insert-button "[B8]" 
      'action 'organis-selk 'follow-link t)))
Dilna
  • 1,173
  • 3
  • 10
  • You could just call `organis-selk-f8` and `organis-selk-b8` from your `F8` and `B8` buttons directly. Also, I think you don't need the `'follow-link t`. – dalanicolai Aug 30 '23 at 10:54
  • Everything works as it was, after removing `'follow-link t`. – Dilna Aug 30 '23 at 11:08

1 Answers1

0

Can all this be simplified ? It seems to me that a button always requires a function that can be passed a button. Meaning that I cannot introduce the functionalities of organis-selk-f8 and organis-selk-b8 into organis-selk.

You can. Change your code to this:

;;; Delete them:
;;
;; (defun organis-selk-f8 (button)
;;   ...)
;; (defun organis-selk-b8 (button)
;;   ...)
;; (defun organis-selk (button)
;;   ...)

(defun qrh ()
  (interactive)
  (with-help-window (help-buffer)
    (insert-button "[F8]" 
      'action (lambda (button)
                ;; Put your `organis-selk-f8' definition here:
                ...)
      'follow-link t)
    (insert-button "[B8]" 
      'action (lambda (button)
                ;; Put your `organis-selk-b8' definition here:
                ...)
      'follow-link t)))

(I didn't check your code for correctness.)


BTW, if the purpose of you creating this new account is to hide your identity, then I suggest that you also need to change your tone, the style of your code, etc.

shynur
  • 4,065
  • 1
  • 3
  • 23
  • The purpose is to get opinions and suggestions that I can scrutinise, nothing else. – Dilna Aug 30 '23 at 14:11
  • Did I do well in passing `button` from `snapshot-selk` to `snapshot-selk-*` ? – Dilna Aug 30 '23 at 16:37
  • @Dilna: I can't judge it because I haven't fully read through your configuration/library code, and it's unlikely that I will read it, as the workload is too large. – shynur Aug 30 '23 at 18:33
  • @dilna Please note that emacs.SE is a Q&A site and is not a good place to gather opinions and suggestions. There are other forums that are better suited to this purpose. – Trevoke Aug 31 '23 at 12:04