emacs-devel
[Top][All Lists]
Advanced

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

Byte-compiler warnings for todo-mode.el


From: Stephen Berman
Subject: Byte-compiler warnings for todo-mode.el
Date: Sun, 05 Aug 2018 22:57:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

After changes I made in master f7d65a5, byte-compiling todo-mode.el now
produces these warnings:

  todo-mode.el:4048:1:Warning: Unused lexical variable ‘sfnlist’

  In end of data:
  todo-mode.el:6785:1:Warning: the function ‘hl-line-highlight’ might not be
      defined at runtime.

The first warning is due to code containing the following lines:

  (let (... falist sfnlist ...)
    (dolist (f files)
       ...
       (push (...) falist))
    (setq sfnlist (mapcar #'car falist))
    (setq file (completing-read "Choose a filtered items file: "
                                falist nil t nil 'sfnlist (caar falist)))
    ...)

So sfnlist is a list produced on the fly as the HIST argument of
completing-read, which is required to be a symbol.  I checked a few
examples in the emacs sources and all instances of the HIST argument
were defvar'd variables.  In the above todo-mode.el case, it seems like
overkill to add a global variable that has no other use than the above.
Given this, is it acceptable to leave the warning or is it preferable to
add a defvar to suppress it?

The second warning is due to this line:

(if (and (boundp 'hl-line-mode) hl-line-mode) (hl-line-highlight))

The warning can be prevented with (eval-and-compile (require 'hl-line)).
In fact, I use that elsewhere in todo-mode.el when hl-line-mode is
actually enabled, so that when the function the above line of code is
part of is executed, either hl-line.el is already loaded and
hl-line-highlight is defined, or hl-line-mode is nil, so
(hl-line-highlight) won't be evaluated and hence it doesn't matter if
it's not defined.  Given this, is it acceptable to leave the warning or
is it preferable to suppress it?  (I already added the above boundp
check to suppress the warning "reference to free variable
`hl-line-mode'"; would it have been acceptable to leave this warning as
well?)

Steve Berman



reply via email to

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