Skip to content

Commit

Permalink
nit(emacs): rename a macro argument
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 14, 2023
1 parent 054940b commit 833b03d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions core/me-loaddefs.el
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ Return the region or the thing at point.")
(autoload '+webjump "../elisp/+emacs" "\
Like `webjump', with initial query filled from `+region-org-thing-at-point'." t)
(autoload '+def-dedicated-tab! "../elisp/+emacs" "\
Define +NAME command to run BODY in a dedicated tab.
If not specified, BODY defaults to `(NAME)'.
Define +CMD command to run BODY in a dedicated tab.
If not specified, BODY defaults to `(CMD)'.
You can pass an exit hook or exit function on which, the created workspace will
be deleted.
Expand Down
20 changes: 10 additions & 10 deletions elisp/+emacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,25 @@ prefix or universal argument, it waits for a moment (defined by
(webjump))))

;;;###autoload
(defmacro +def-dedicated-tab! (name &rest body)
"Define +NAME command to run BODY in a dedicated tab.
If not specified, BODY defaults to `(NAME)'.
(defmacro +def-dedicated-tab! (cmd &rest body)
"Define +CMD command to run BODY in a dedicated tab.
If not specified, BODY defaults to `(CMD)'.
You can pass an exit hook or exit function on which, the created workspace will
be deleted.
\(fn NAME [[:exit-hook HOOK] [:exit-func FUNC]] FORMS...)"
(let* ((name (+unquote name))
(fn-name (intern (format "+%s" name)))
(fn-doc (format "Launch %s in a dedicated workspace." name))
(tab-name (intern (format "+%s-tab-name" name)))
(exit-fn-name (intern (format "+%s--close-workspace" name)))
(let* ((cmd (+unquote cmd))
(fn-name (intern (format "+%s" cmd)))
(fn-doc (format "Launch %s in a dedicated workspace." cmd))
(tab-name (intern (format "+%s-tab-name" cmd)))
(exit-fn-name (intern (format "+%s--close-workspace" cmd)))
exit-func exit-hook sexp fn-body)
(while (keywordp (car body))
(pcase (pop body)
(:exit-func (setq exit-func (+unquote (pop body))))
(:exit-hook (setq exit-hook (+unquote (pop body))))))
(setq sexp (if (null body) `((,name)) body))
(setq sexp (if (null body) `((,cmd)) body))
(when (or exit-func exit-hook)
(setq
fn-body
Expand All @@ -171,7 +171,7 @@ be deleted.
(when exit-func (add-to-list 'fn-body `(advice-add ',exit-func :after #',exit-fn-name) t))
(when exit-hook (add-to-list 'fn-body `(add-hook ',exit-hook #',exit-fn-name) t)))
`(progn
(defvar ,tab-name ,(format "*%s*" name))
(defvar ,tab-name ,(format "*%s*" cmd))
(defun ,fn-name ()
,fn-doc
(interactive)
Expand Down

0 comments on commit 833b03d

Please sign in to comment.