Silence unknown slot warnings reddit / emacs ---------------------------------------------------------------------- jigarthanda-paal · 2022-01-25 15:43 Hi - I have emacs 28.0.9 with native comp. I wrote a package which defines some classes ``` (defclass myclass () ((package-name :initarg package-name))) ``` With `oref` and `oset`, I get a lot of warnings about unknown slots. How do I silence these? ---------------------------------------------------------------------- ieure · 2022-01-25 16:43 What's the specific warning you're getting? ---------------------------------------------------------------------- _pkal · 2022-01-25 17:00 Do you get the same issues when using `with-slots` and `(slot-value ..)`/`(setf (slot-value ..) ..)`? ---------------------------------------------------------------------- jigarthanda-paal · 2022-01-25 17:01 ``` Warning (comp): custom-package.el:60:39: Warning: Unknown slot ‘:package-name’ Disable showing Disable logging ``` ---------------------------------------------------------------------- jigarthanda-paal · 2022-01-25 18:50 Can you share an example? I understand the setf method but not the slot-value one ---------------------------------------------------------------------- _pkal · 2022-01-25 19:39 `slot-value` is just the "getter", and `(setf (slot-value ..) ..)` the "setter". `slot-value` is basically the same as `oref`, you just need to quote the slot symbol. ---------------------------------------------------------------------- ieure · 2022-01-25 20:18 The slot name is `package-name`, but you're passing `:package-name` to `oref`. Here's some working example code for you: (defclass my/class () ((package-name :initarg :package-name))) (oref (my/class :package-name "foo") package-name) ; "foo" (let ((c (my/class))) (oset c package-name "foo") (oref c package-name))