unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Nicolas Petton <nicolas@petton.fr>
Cc: Damien Cassou <damien@cassou.me>, 30039@debbugs.gnu.org
Subject: bug#30039: 26.0.90; [26.1] Making my code warning free is impossible with when-let
Date: Wed, 10 Jan 2018 14:11:47 -0500	[thread overview]
Message-ID: <CAM-tV--8fKwvC0LwoyZK2QfSZErwmLSK50tFuv3Bes__evZ6rQ@mail.gmail.com> (raw)
In-Reply-To: <87h8rv1m7p.fsf@petton.fr>

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

On Tue, Jan 9, 2018 at 3:16 AM, Nicolas Petton <nicolas@petton.fr> wrote:

>> - un-deprecate when-let (and if-let) in Emacs 26 and re-deprecate it
>>   later.
>
> I'm facing the same issue, un-deprecating when-let would also make my CI
> happier.

How about adding a variable which suppresses deprecation warnings from
a specified version and up. Attached is a work-in-progress patch which
would allow you to set byte-compile-not-obsolete-since to "25.1" in
your CI script (or file-locally) and thus ignore deprecation warnings
from 26.1 or newer.

Alternatively, or additionally, we could let
`byte-compile-not-obsolete-funcs' apply to macros as well (currently
macroexp-macroexpand doesn't consult it).

[-- Attachment #2: v1-0001-WIP-Allow-suppressing-obsoletion-warnings-per-ver.patch --]
[-- Type: application/octet-stream, Size: 3826 bytes --]

From 4920c1a8e967b8317a3272feb6bf63b99301be2a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Wed, 10 Jan 2018 14:07:27 -0500
Subject: [PATCH v1] [WIP] Allow suppressing obsoletion warnings per-version
 (Bug#30039)

* lisp/emacs-lisp/bytecomp.el (byte-compile-not-obsolete-since): New
variable.
(byte-compile-warn-obsolete):
* lisp/emacs-lisp/macroexp.el (macroexp-macroexpand): Check it.

TODO: NEWS, test, other FIXMEs in source.
---
 lisp/emacs-lisp/bytecomp.el | 18 +++++++++++++++---
 lisp/emacs-lisp/macroexp.el | 20 ++++++++++++++------
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index acba9e2..f6ea25b 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -392,6 +392,14 @@ byte-compile-global-not-obsolete-vars
 (defvar byte-compile-not-obsolete-funcs nil
   "List of functions that shouldn't be reported as obsolete.")
 
+(defvar byte-compile-not-obsolete-since nil
+  ;; FIXME: shorter summary line
+  "If set, only report obsolete symbols that were obsoleted
+  earlier than this version.")
+
+;;;###autoload
+(put 'byte-compile-not-obsolete-since 'safe-local-variable #'stringp)
+
 (defcustom byte-compile-generate-call-tree nil
   "Non-nil means collect call-graph information when compiling.
 This records which functions were called and from where.
@@ -1243,12 +1251,16 @@ byte-compile-warn-obsolete
   "Warn that SYMBOL (a variable or function) is obsolete."
   (when (byte-compile-warning-enabled-p 'obsolete)
     (let* ((funcp (get symbol 'byte-obsolete-info))
+           (var-info (get symbol 'byte-obsolete-variable))
            (msg (macroexp--obsolete-warning
                  symbol
-                 (or funcp (get symbol 'byte-obsolete-variable))
+                 (or funcp var-info)
                  (if funcp "function" "variable"))))
-      (unless (and funcp (memq symbol byte-compile-not-obsolete-funcs))
-	(byte-compile-warn "%s" msg)))))
+      (unless (or (and funcp (memq symbol byte-compile-not-obsolete-funcs))
+                  (and (stringp byte-compile-not-obsolete-since)
+                       (version<= byte-compile-not-obsolete-since
+                                  (nth 2 (or funcp var-info)))))
+        (byte-compile-warn "%s" msg)))))
 
 (defun byte-compile-report-error (error-info &optional fill)
   "Report Lisp error in compilation.
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index b2ac8be..e64e439 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -189,12 +189,20 @@ macroexp-macroexpand
                  (byte-compile-warning-enabled-p 'obsolete)))
         (let* ((fun (car form))
                (obsolete (get fun 'byte-obsolete-info)))
-          (macroexp--warn-and-return
-           (macroexp--obsolete-warning
-            fun obsolete
-            (if (symbolp (symbol-function fun))
-                "alias" "macro"))
-           new-form))
+          (unless (or
+                   ;; FIXME: Deduplicate with `byte-compile-warn-obsolete'.
+                   (and fun (memq fun (and (boundp 'byte-compile-not-obsolete-funcs)
+                                           byte-compile-not-obsolete-funcs)))
+                   (and (boundp 'byte-compile-not-obsolete-since)
+                        (stringp byte-compile-not-obsolete-since)
+                        (version< byte-compile-not-obsolete-since
+                                  (nth 2 obsolete))))
+            (macroexp--warn-and-return
+             (macroexp--obsolete-warning
+              fun obsolete
+              (if (symbolp (symbol-function fun))
+                  "alias" "macro"))
+             new-form)))
       new-form)))
 
 (defun macroexp--expand-all (form)
-- 
2.6.2.windows.1


  reply	other threads:[~2018-01-10 19:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09  7:27 bug#30039: 26.0.90; [26.1] Making my code warning free is impossible with when-let Damien Cassou
2018-01-09  8:16 ` Nicolas Petton
2018-01-10 19:11   ` Noam Postavsky [this message]
2018-01-10 21:50     ` Nicolas Petton
2018-01-11  9:19     ` Damien Cassou
2018-01-19 20:00       ` Noam Postavsky
2018-01-19 20:26         ` Eli Zaretskii
2018-01-19 20:40           ` Noam Postavsky
2018-01-20  7:42             ` Eli Zaretskii
2018-01-09 14:05 ` Noam Postavsky
2018-01-09 14:23   ` Damien Cassou
2018-01-09 14:43 ` Noam Postavsky
2018-01-10 12:13   ` Damien Cassou
2018-01-10 15:45     ` Eli Zaretskii
2018-01-10 16:24       ` Nicolas Petton
2018-01-10 17:24         ` Glenn Morris
2018-01-10 18:46         ` Eli Zaretskii
2018-01-10 21:48           ` Nicolas Petton
2018-01-10 22:05             ` Eric Abrahamsen
2018-01-10 22:23               ` Noam Postavsky
2018-01-10 22:40                 ` Nicolas Petton
2018-01-10 22:57                   ` Eric Abrahamsen
2018-01-10 23:06                     ` Noam Postavsky
2018-01-11  0:03                       ` Eric Abrahamsen
2018-01-11  9:02                     ` Nicolas Petton
2018-04-14 20:17                       ` Lars Ingebrigtsen
2018-04-15 11:53                         ` Michael Heerdegen
2018-02-21 22:28 ` Michael Heerdegen
2018-02-22  7:42   ` Damien Cassou
2018-03-06 15:12     ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM-tV--8fKwvC0LwoyZK2QfSZErwmLSK50tFuv3Bes__evZ6rQ@mail.gmail.com \
    --to=npostavs@users.sourceforge.net \
    --cc=30039@debbugs.gnu.org \
    --cc=damien@cassou.me \
    --cc=nicolas@petton.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).