문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 apple.stackexchange
scroll top