help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: closure within closure, incorrect (?) byte-compiler warnings


From: Emanuel Berg
Subject: Re: closure within closure, incorrect (?) byte-compiler warnings
Date: Tue, 09 Nov 2021 00:09:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Stefan Monnier via Users list for the GNU Emacs text editor wrote:

>>   (let ((next 1))
>>     (defun australian-survivor (ep)
>>       (interactive (list (read-number prompt next)))
>
> IIRC the current compiler code doesn't support this kind of "interactive
> spec nested within a lexical scope".
>
> Your code makes sense, but AFAIK it may not always work correctly :-(

Indeed, it doesn't work after a restart when the byte-compiled
code (.elc) is loaded.

It causes no crash or error message until you use the
function, then it says

  call-interactively: Symbol’s value as variable is void:
  prompt

> You might want to `M-x report-emacs-bug` (and if so, please
> put me in the `X-Debbugs-Cc:`).

OK, I hope to do that soon ...

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   https://dataswamp.org/~incal/emacs-init/w3m/w3m-survivor.el

(require 'w3m-search)
(require 'cl-lib)

(declare-function australian-survivor nil)
(declare-function us-survivor         nil)

(let ((opts   "torrent 1080p")
      (show   "Survivor")
      (prompt "episode: ") )
  (let ((next 1))
    (defun australian-survivor (ep)
      (interactive (list (read-number prompt next)))
      (w3m-search
       w3m-search-default-engine
       (format "s08e%02d Australian %s %s" ep show opts) )
      (setq next (1+ ep)) ))
  (defalias 'aus #'australian-survivor)

  (let ((next 1))
    (defun us-survivor (ep)
      (interactive (list (read-number prompt next)))
      (w3m-search
       w3m-search-default-engine
       (format "s41%02d %s %s" ep show opts) )
      (setq next (1+ ep)) ))
  (defalias 'us #'us-survivor) )

;; In toplevel form:
;; w3m/w3m-survivor.el:12:1: Warning: Unused lexical variable `prompt'
;; w3m/w3m-survivor.el:12:1: Warning: Unused lexical variable `next'
;; w3m/w3m-survivor.el:26:39: Warning: reference to free variable ‘prompt’
;; w3m/w3m-survivor.el:26:46: Warning: reference to free variable ‘next’
;; w3m/w3m-survivor.el:22:14: Warning: Unused lexical variable `next'

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]