Created
January 31, 2022 14:58
-
-
Save DivineDominion/4488ba95e0cf55f967006e50aca979cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro ct/tab-bar-select-action-define (num) | |
`(defun ,(intern (format "ct/tab-bar-select-%i" num)) () | |
,(format "Select tab %i by its absolute number." num) | |
(interactive) | |
(tab-bar-select-tab ,num))) | |
;; Manual calls work | |
(progn | |
(ct/tab-bar-select-action-define 1) | |
(ct/tab-bar-select-action-define 2) | |
(ct/tab-bar-select-action-define 3) | |
(ct/tab-bar-select-action-define 4) | |
(ct/tab-bar-select-action-define 5) | |
(ct/tab-bar-select-action-define 6) | |
(ct/tab-bar-select-action-define 7) | |
(ct/tab-bar-select-action-define 8) | |
(ct/tab-bar-select-action-define 9)) | |
;; Helper to undefine the functions again | |
(progn | |
(fmakunbound 'ct/tab-bar-select-1) | |
(fmakunbound 'ct/tab-bar-select-2) | |
(fmakunbound 'ct/tab-bar-select-3) | |
(fmakunbound 'ct/tab-bar-select-4) | |
(fmakunbound 'ct/tab-bar-select-5) | |
(fmakunbound 'ct/tab-bar-select-6) | |
(fmakunbound 'ct/tab-bar-select-7) | |
(fmakunbound 'ct/tab-bar-select-8) | |
(fmakunbound 'ct/tab-bar-select-9)) | |
(ct/tab-bar-select-action-define 1) | |
(let (tab-number) | |
(dotimes (i 9) | |
(setq tab-number (+ 1 i)) | |
(message (format ">%i" tab-number)) | |
(ct/tab-bar-select-action-define tab-number))) | |
;; Compiler-macro error for cl--block-wrapper: (error "Format specifier doesn’t match argument type") | |
;; intern: Format specifier doesn’t match argument type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to @daviwil's feedback and documented fixed in https://gist.github.com/daviwil/3215f99db0ac0cb122a9a1850f400594 I realize that passing arguments to macros isn't worth the trouble when you have to inline the loop anyway -- so might as well do it directly:
This enabled SPC t 1--SPC t 9 to switch to the tab by number directly.