Subject: bug#14529: gv--defsetter, advice--set-buffer-local compilation warnings

From: Stefan Monnier <[email-masked]>
Date: Fri, 23 Mar 2018 19:25:01 -0400

Glenn Morris <[email-masked]> writes:

> Stefan Monnier wrote:
>
>>>   the function `gv--defsetter' might not be defined at runtime.
>>>   (image-mode, winner, avl-tree []
>>
>> gv--setter is used inside a function placed on the `gv-expander'
>> property of some symbols, which should never be used except by gv.el
>> code (at which point gv--defsetter will be defined).
>
> These warnings have come back following 97b7e58.
> Obviously they can be declare-functioned away, but it would be nicer if
> there was a general solution that did not require modifying each file
> that declares a gv-setter.

I'd love to have a general way to say things like "code on symbol
property `gv-expand' can use any function provided by gv.el", but in the
mean time would the patch below work?

        Stefan

diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index 1e5347d206..230d59f189 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -216,6 +216,8 @@ gv-define-setter
   (declare (indent 2) (debug (&define name sexp body)))
   `(gv-define-expander ,name
      (lambda (do &rest args)
+       (declare-function
+        gv--defsetter "gv" (name setter do args &optional vars))
        (gv--defsetter ',name (lambda ,arglist ,@body) do args))))
 
 ;;;###autoload