I have this code:
(defmacro with-ignore-mouse-events (&rest body)
"Macro to ignore mouse events before evaluating BODY."
`(progn
(when (input-pending-p)
(let ((event (read-event)))
(if (mouse-event-p event)
(let ((button (event-basic-type event)))
(if (eq button 'mouse-1)
(ignore)
(setq unread-command-events (list event))))
(setq unread-command-events (list event)))))
,@body))
(defun mwe-function-1 ()
"MWE function 1"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 1 executed")))
(defun mwe-function-2 ()
"MWE function 3"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 2 executed")))
(defun mwe-function-3 ()
"MWE function 3"
(interactive)
(unwind-protect
(query-replace "foo" "bar" nil (point-min) (point-max))
;; UNWINDFORMS
(read-string "function 3 executed")))
(defvar mwe-function-names '(mwe-function-1 mwe-function-2 mwe-function-3))
I want to generate modified version of the functions like in the following example:
(defun mwe-function-1* ()
(interactive)
(with-ignore-mouse-events
(mwe-function-1)))
I tried:
(defmacro generate-mwe-star-functions (&rest function-names)
"Macro to generate mwe-function-* functions."
`(dolist (func-name ,@function-names)
(message "%s*" func-name) ;; The string built here is correct...
(defun ,(make-symbol (format "%s*" func-name)) ()
(interactive)
(with-ignore-mouse-events
(intern func-name)))
))
(generate-mwe-star-functions mwe-function-names)
But I'm getting lost in the mechanism of back quoting (at least).
Where am I wrong?
Edit. The question suggested as a duplicated of mine does not explain how to loop a list of functions to define other functions. I thing this make the task a bit more complicated.
This is evidenced by the fact that the solution proposed by the user who (probably) flagged my question as a duplicate does not work.