Macro Expansion is a Dud

I’ve defined the following macro code for defining alternate tools:

(defun drn/deftool-function-current-file-code (ident)
  "Define a interactive function that calls a tool command identified by IDENT on the current file."
  `(defun ,(make-symbol (concat "drn/open-current-file-with-" (symbol-name ident))) ()
     ,(concat "Open the current file with " (drn/alternate-tool-name ident))
     (interactive)
     (drn/open-file-with-command (drn/current-filename) ,(drn/alternate-tool-command ident))))


(defun drn/deftool-function-current-project-code (ident)
  "Define a interactive function that calls a tool command identified by IDENT on the current project."
  `(defun ,(make-symbol (concat "drn/open-current-project-with-" (symbol-name ident))) ()
     ,(concat "Open the current project with " (drn/alternate-tool-name ident))
     (interactive)
     (drn/open-file-with-command (drn/current-project-path) ,(drn/alternate-tool-command ident))))


(defmacro drn/deftool (ident name command &optional options)
  (let ((tool (drn/add-tool ident name command options)))
    (if (drn/tool-has? tool 'project-only)
        (drn/deftool-function-current-project-code ident)
        `(progn
          ,(drn/deftool-function-current-project-code ident)
          ,(drn/deftool-function-current-file-code ident)))))

The macro seems to expand properly:

(drn/deftool vscode "Visual Studio Code" "code %s")
; =>
; (progn
;   (defun drn/open-current-project-with-vscode nil "Open the current project with Visual Studio Code"
;          (interactive)
;          (drn/open-file-with-command
;           (drn/current-project-path)
;           "code %s"))
;   (defun drn/open-current-file-with-vscode nil "Open the current file with Visual Studio Code"
;          (interactive)
;          (drn/open-file-with-command
;           (drn/current-filename)
;           "code %s")))

When I manually evaluate this code in my ELISP REPL it works as expected (I’m able to M-x to find “drn/open-current-file-with-vscode”). But when I evaluate in the buffer or reload my configuration it does nothing. Any thoughts? Thank you!

System information


Loading data dump...

This topic was automatically closed after 90 days. New replies are no longer allowed.