Last active
September 19, 2024 21:09
-
-
Save adlai/eb29616be321f351d72a to your computer and use it in GitHub Desktop.
package hackery for moving classes between packages
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
(defgeneric rehome-class (class new-home) | |
(:method ((class symbol) new-home) | |
(rehome-class (find-class class) (find-package new-home))) | |
(:method ((class class) (new-home package)) | |
(let ((old-home (symbol-package (class-name class))) | |
(symbols `(,(class-name class) | |
,@(mapcar 'sb-mop:slot-definition-name | |
(sb-mop:class-direct-slots class))))) | |
(mapc (lambda (symbol) (unintern symbol old-home)) symbols) | |
(import symbols new-home) | |
(import symbols old-home)))) | |
;;; `(,'car ,@'(cadr caddr)) = (list* 'car '(cadr caddr)) |
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
(defun rehome-symbol | |
(symbol new-home &aux (old-home (symbol-package symbol))) | |
(unintern symbol old-home) | |
(import (list symbol) new-home) | |
(import (list symbol) old-home)) | |
;;; try to avoid triggering `C-u M-q' and `C-x f' within lisp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated to import instead of intern