unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Zack Weinberg <zack@owlfolio.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 64232@debbugs.gnu.org
Subject: bug#64232: 28.2; Incorrect(?) byte compilation warning about ‘ansi-color-apply-on-region’
Date: Sat, 24 Jun 2023 14:49:43 +0300	[thread overview]
Message-ID: <83o7l5yt9k.fsf@gnu.org> (raw)
In-Reply-To: <874jmzs23h.wl-zack@owlfolio.org> (message from Zack Weinberg on Thu, 22 Jun 2023 15:56:18 -0400)

> Date: Thu, 22 Jun 2023 15:56:18 -0400
> From: Zack Weinberg <zack@owlfolio.org>
> 
> 
> With Emacs 28.2, this test .el file
> 
> ```
> ;; -*- lexical-binding: t; coding: utf-8 -*-
> 
> (declare-function ansi-color-apply-on-region "ansi-color"
>                   (begin end &optional preserve-sequences))
> (autoload 'ansi-color-apply-on-region "ansi-color")
> 
> (eval-when-compile
>   (check-declare-file byte-compile-current-file))
> 
> (defun zw-colorize-compilation-buffer ()
>   "Interpret ANSI color escapes in a compilation-mode buffer, which
> gets them out of the way of the error detector.  Intended for use via
> compilation-filter-hook."
>   (interactive)
>   (let ((inhibit-read-only t))
>     (ansi-color-apply-on-region (point-min) (point-max))))
> ```
> 
> provokes a byte compilation warning:
> 
> ```
> $ emacs -Q --batch -f batch-byte-compile test.el
> uncompressing ansi-color.el.gz...
> uncompressing ansi-color.el.gz...done
> 
> In end of data:
> test.el:16:6: Warning: the function ‘ansi-color-apply-on-region’ might not be
>     defined at runtime.
> ```
> 
> The combination of `declare-function` and `autoload` is intended to
> ensure both that the byte compiler understands what’s going on, and
> that `ansi-color-apply-on-region` really is guaranteed to be available
> at runtime.  Also, I triple-checked that ansi-color.el really does
> define this function.  Why is the compiler still complaining?

The problem is this part:

  (eval-when-compile
    (check-declare-file byte-compile-current-file))

Remove it, and the problem will go away.  So there's actually no
problem here with 'autoload' and 'declare-function'.

I don't understand why you are calling check-declare-file, and
moreover don't understand the argument you pass check-declare-file.
check-declare-file is a command supposed to be used interactively to
verify the 'declare' calls are valid in a given file; it shows the
results, if any, as delayed-warnings.  Can you explain why you do this
in the eval-when-compile form?





  reply	other threads:[~2023-06-24 11:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 19:56 bug#64232: 28.2; Incorrect(?) byte compilation warning about ‘ansi-color-apply-on-region’ Zack Weinberg
2023-06-24 11:49 ` Eli Zaretskii [this message]
2023-06-24 15:15   ` Zack Weinberg
2023-06-28  2:10     ` Michael Heerdegen
2023-06-28 13:41       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-29  3:43         ` Michael Heerdegen
2023-06-29  4:51           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-30  4:02             ` Michael Heerdegen
2023-06-30  6:00               ` Eli Zaretskii
2023-07-06  6:43                 ` Eli Zaretskii
2023-07-07 16:10                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-07 18:15                     ` Eli Zaretskii
2023-06-29  4:17 ` 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=83o7l5yt9k.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=64232@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=zack@owlfolio.org \
    /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).