From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Adding use-package to ELPA Date: Mon, 07 Mar 2022 19:24:39 +0000 Message-ID: <87ilsp4lc8.fsf@posteo.net> References: <87k0dbi7ol.fsf@posteo.net> <871qzgyfuo.fsf@posteo.net> <87ilsre5jf.fsf@posteo.net> <87zgm2bpez.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33291"; mail-complaints-to="usenet@ciao.gmane.io" Cc: chad , EMACS development team To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 07 20:41:08 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRJEC-0008Tj-98 for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Mar 2022 20:41:08 +0100 Original-Received: from localhost ([::1]:46662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRJEB-0002RF-7k for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Mar 2022 14:41:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRIyX-00024v-Pt for emacs-devel@gnu.org; Mon, 07 Mar 2022 14:24:58 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:42773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRIyT-00071B-64 for emacs-devel@gnu.org; Mon, 07 Mar 2022 14:24:56 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id A5EF6240028 for ; Mon, 7 Mar 2022 20:24:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1646681081; bh=TtRyIcE3CdvwAD3Ogwx9FW8kz1sPuy5LgHfIrsOoxwA=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=lsTgAPyImC2HOWmu2SiwucVBUis6xaeahvWZajen6w9sweknjRbyfunQ0ODP1121Y Nek3PND227JqfFFp0g5KfnAKEvKngCT9V0GMsYugRlHt02ByK0G1KC+5lvABwEvl1+ 6u6AGUilz13bDaqjD+OU2UJ/kEHdq9iFXWzB9pxiOxMb0vK+lKZd63s+mR1PjDIR5b uHaVA1jQX3gbGyvML+GRO7QPBOcJzLt2gm8j7T/sHTig1vopj81ybTYdt9/pbWu3nQ H8sw6fH0qOfb0MnsaSVVhpbhhrAlNfZ8chhzjHfnPCZyNNYmDLrNcVZFuLwO4TX08N CX3kz0Z//aRaA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4KC7gr5Wh7z9rxV; Mon, 7 Mar 2022 20:24:40 +0100 (CET) Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB In-Reply-To: (Stefan Monnier's message of "Mon, 07 Mar 2022 13:01:49 -0500") Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286902 Archived-At: Stefan Monnier writes: >> I'll just throw in a request of mine: make it so `flymake-mode` gets >> usable feedback when used in an init file. > > To make it more concrete. > Currently if your init file contains just: > > ;;; -*- lexical-binding: t -*- > (setq smtpmail-smtp-service 587) > > and you enable `flymake-mode`, it will complain: > > assignment to free variable =E2=80=98smtpmail-smtp-service=E2=80=99 > > There's no much we can do about it in general. > With Setup/Leaf/use-package, OTOH, the user would presumably write > something like: > > ;;; -*- lexical-binding: t -*- > (setup smtpmail > (setq smtpmail-smtp-service 587)) > which does provide the link between `smtpmail-smtp-service` and the > `smtpmail.el` file necessary for Emacs to be able in theory to discover > that `smtpmail-smtp-service` is not just some unknown free variable. > > Currently, the above snippet using Setup still gives the same > warning, tho. True, because the above examples just expands to (setq smtpmail-smtp-service 587) I'd usually recommend to use a local macro to avoid these issues, because something like (setup smtpmail (:option smtpmail-smtp-service 587)) would expand to a `customize-set-variable'-like code, where `smtpmail-smtp-service' would appear as a quoted symbol. > So `setup.el` could maybe do something like: > > (defmacro setup (pkg &rest args) > (when (we-are-byte-compiling-p) > (require (byte-run-strip-symbol-positions pkg))) > ...) What is the point of using byte-run-strip-symbol-positions here? I just tried something like this, but it doesn't seem to work. > so as to silence the warning. > > > Stefan > "John Wiegley" writes: >>>>>> "SM" =3D=3D Stefan Monnier writes: > >>> I'll just throw in a request of mine: make it so `flymake-mode` gets us= able >>> feedback when used in an init file. > > SM> To make it more concrete. > SM> Currently if your init file contains just: > > SM> ;;; -*- lexical-binding: t -*- > SM> (setq smtpmail-smtp-service 587) > > SM> and you enable `flymake-mode`, it will complain: > > SM> assignment to free variable =E2=80=98smtpmail-smtp-service=E2=80= =99 > > Ah, I understand what you mean now. > > In use-package, this is exactly what the `:defines` keyword was created f= or, > so that you can indicate to the byte-compiler which variables will be def= ined > when the module is loaded. I guess the issue here is that you would have to mention every variable twice, declaring it with :defines before using it, while it could actually be inferred, as Stefan points out. > This special handling is done in `use-package-normalize-keywords`, so one > could advise that function to intercept the list yielded by :defines and = do > what's necessary to satisfy flymake. That is, if :defines itself isn't al= ready > enough. AFAIK flymake just reports the issues generated by the byte-compiler, so if that is fixed, flymake shouldn't complain either. --=20 Philip Kaludercic