From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Towards a cleaner build Date: Tue, 28 May 2019 17:11:28 +0200 Message-ID: References: <831s0xd3z1.fsf@gnu.org> <83pnohbhny.fsf@gnu.org> <83zhn6zkgf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="55140"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, npostavs@gmail.com, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 28 17:13:58 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hVdnZ-000E8x-HR for ged-emacs-devel@m.gmane.org; Tue, 28 May 2019 17:13:57 +0200 Original-Received: from localhost ([127.0.0.1]:36548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVdnY-0003ki-Gn for ged-emacs-devel@m.gmane.org; Tue, 28 May 2019 11:13:56 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:59051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVdlL-0002eG-Gk for emacs-devel@gnu.org; Tue, 28 May 2019 11:11:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVdlJ-0000Ju-VW for emacs-devel@gnu.org; Tue, 28 May 2019 11:11:39 -0400 Original-Received: from quimby.gnus.org ([80.91.231.51]:46832) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVdlJ-0000GU-MO; Tue, 28 May 2019 11:11:37 -0400 Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hVdlB-0006VZ-0X; Tue, 28 May 2019 17:11:32 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEWf2fWpjHSAACul3fPS 6YSyyL5yP05ZCD/X8pHRAAACZ0lEQVQ4ja2SzXObMBDF16PiXFkM4mrwcDeozp2pQq9AhuRqdWzp Gk+J9O93JYKbzrS37oy/9qe3+x4ylP8o+I+g1Sl2SrtZ9rDWcZomkPKScuvBE3yqrwRyZbS2c8pj ACaR3oCJiEDnbjO/zRd+Zlkq26dJHIUQkErp9CzzWfHLFymllvJJeDBLaYyVXKEOAFdgpfxuXNpx Sf5IjtgSOAkwNNbZubOyo7ZXtFch6gm62W+3kqalrUxbbNsrE7UBzFU6DO7Sah4UnIJ9q1GD1vo6 GGduWvm+7CTxzliw1HTOKq2VUpzMcfIlWw4u1E07bRxRk2uOyhj3AaxbizuX+4YH5jbld5AvIChU Nr36RUFKn3oF7pa9uk+lzQpc9rKcXSrNF0CLd5TE5uGw1VZ6/4CYOfdc53rm+sYRFQVFpxVIJIM7 ASe6Z7p1NuHURyhToB9oruJ+2T3dLV3u0X/HyV7XfnQd4k0Pkz/JxMnxOyjGYtzD0YOIgFn/VFHV 4JABBMULuun5A7C4zsaKBRBRkvPjqoiHDOMPxeTc2+Y+KsFkD8EVOyn3ti5niEkSi7Cc1b17v+eg nKeQhF6PkN+WbhLM1TGIoMjh4Q/QxIui1rBVYTGMvd9aL4A9vkOE4Xzc9EMVlVERe7siPy+AlVXz XBZjuSn3jMCLpSHeFSuKZlcU4zgUFSlYThk2AWDW7AZ6VtFhT2Bw1NuGHFnWxD/2pyqq/KgQeruM wmZXHZpxUx1IYf3ZhwBo8a4sm2Qo9mT3pwcbl4UdySEpm3IsvSKArTv7p9xPO8QaT0WxKn7XMUQj s3CGvxb7BRzM3DGfuAfPAAAAAElFTkSuQmCC In-Reply-To: <83zhn6zkgf.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 28 May 2019 18:07:28 +0300") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.91.231.51 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:237107 Archived-At: Eli Zaretskii writes: >> From: Lars Ingebrigtsen >> Cc: Eli Zaretskii , Stefan Monnier >> , Emacs developers >> Date: Tue, 28 May 2019 13:39:46 +0200 >> >> And Eli hasn't OK'd the with-suppressed-warnings yet. :-) Did that >> patch look OK? > > Not sure what this alludes to. I may have missed some question? It's this patch. It adds the syntax (with-suppressed-warnings (obsolete some-function) (some-function la la la)) which is very similar to with-no-warnings, only it specifies precisely which warning on what function we're suppressing. diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 842d1d48b4..9a9d93367b 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -494,6 +494,18 @@ with-no-warnings ;; The implementation for the interpreter is basically trivial. (car (last body))) +(defmacro with-suppressed-warnings (warnings &rest body) + "Like `progn', but prevents compiler warnings in the body." + (declare (indent 1)) + ;; The implementation for the interpreter is basically trivial. + `(with-suppressed-warnings-1 ',warnings (progn ,@body))) + +(defun with-suppressed-warnings-1 (_ &rest body) + "Like `progn', but prevents compiler warnings in the body." + (declare (indent 1)) + ;; The implementation for the interpreter is basically trivial. + (car (last body))) + (defun byte-run--unescaped-character-literals-warning () "Return a warning about unescaped character literals. diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index e76baf5ed0..1285ef9037 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -331,18 +331,26 @@ byte-compile-warnings ,@(mapcar (lambda (x) `(const ,x)) byte-compile-warning-types)))) +(defvar byte-compile-suppressed-warnings nil) + ;;;###autoload (put 'byte-compile-warnings 'safe-local-variable (lambda (v) (or (symbolp v) (null (delq nil (mapcar (lambda (x) (not (symbolp x))) v)))))) -(defun byte-compile-warning-enabled-p (warning) +(defun byte-compile-warning-enabled-p (warning &optional symbol) "Return non-nil if WARNING is enabled, according to `byte-compile-warnings'." - (or (eq byte-compile-warnings t) - (if (eq (car byte-compile-warnings) 'not) - (not (memq warning byte-compile-warnings)) - (memq warning byte-compile-warnings)))) + (let ((suppress nil)) + (dolist (elem byte-compile-suppressed-warnings) + (when (and (eq (car elem) warning) + (memq symbol (cdr elem))) + (setq suppress t))) + (and (not suppress) + (or (eq byte-compile-warnings t) + (if (eq (car byte-compile-warnings) 'not) + (not (memq warning byte-compile-warnings)) + (memq warning byte-compile-warnings)))))) ;;;###autoload (defun byte-compile-disable-warning (warning) @@ -2518,6 +2526,15 @@ byte-compile-file-form-with-no-warnings (mapc 'byte-compile-file-form (cdr form)) nil)) +(put 'with-suppressed-warnings-1 'byte-hunk-handler + 'byte-compile-file-form-with-suppressed-warnings) +(defun byte-compile-file-form-with-suppressed-warnings (form) + ;; cf byte-compile-file-form-progn. + (let ((byte-compile-suppressed-warnings + (append (cadadr form) byte-compile-suppressed-warnings))) + (mapc 'byte-compile-file-form (cddr form)) + nil)) + ;; Automatically evaluate define-obsolete-function-alias etc at top-level. (put 'make-obsolete 'byte-hunk-handler 'byte-compile-file-form-make-obsolete) (defun byte-compile-file-form-make-obsolete (form) @@ -3150,7 +3167,7 @@ byte-compile-form (when (and (byte-compile-warning-enabled-p 'suspicious) (macroexp--const-symbol-p fn)) (byte-compile-warn "`%s' called as a function" fn)) - (when (and (byte-compile-warning-enabled-p 'interactive-only) + (when (and (byte-compile-warning-enabled-p 'interactive-only fn) interactive-only) (byte-compile-warn "`%s' is for interactive use only%s" fn @@ -4765,6 +4782,14 @@ byte-compile-no-warnings (let (byte-compile-warnings) (byte-compile-form (cons 'progn (cdr form))))) +(byte-defop-compiler-1 with-suppressed-warnings-1 + byte-compile-suppressed-warnings) +(defun byte-compile-suppressed-warnings (form) + (let ((byte-compile-suppressed-warnings + (append (cadadr form) byte-compile-suppressed-warnings))) + (mapc 'byte-compile-file-form (cddr form)) + nil)) + ;; Warn about misuses of make-variable-buffer-local. (byte-defop-compiler-1 make-variable-buffer-local byte-compile-make-variable-buffer-local) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no