How to find if an Emacs lisp function is setf-able?
-
30-05-2021 - |
سؤال
Emacs Lisp setf macro allows you to set generalized variables. You can, for example change the size of the current window with the following form:
(setf (window-height) 10)
The macro will translate the above code to:
(progn
(enlarge-window
(- 10
(window-height)))
10)
My question: Is there a way to find out dynamically whether an Emacs function is "setf-able" like window-height is?
I searched in the GNU EMacs Common Lisp Emulation manual and could not find and answer to my question.
المحلول
Check the value of symbol's gv-expander
property, for "setf-able" functions, the value is non-nil (and a function), e.g.,
(functionp (get 'window-height 'gv-expander))
;; => t
for other functions, the value is nil, e.g.,
(get 'length 'gv-expander)
;; => nil
لا تنتمي إلى apple.stackexchange