From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Byte-compiler warnings for todo-mode.el Date: Sun, 05 Aug 2018 21:23:42 -0400 Message-ID: References: <87zhy0fs69.fsf@gmx.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1533518549 14952 195.159.176.226 (6 Aug 2018 01:22:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Aug 2018 01:22:29 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 06 03:22:24 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmUE3-0003o6-3O for ged-emacs-devel@m.gmane.org; Mon, 06 Aug 2018 03:22:23 +0200 Original-Received: from localhost ([::1]:60264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmUG9-00078U-NJ for ged-emacs-devel@m.gmane.org; Sun, 05 Aug 2018 21:24:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmUFY-00078N-M6 for emacs-devel@gnu.org; Sun, 05 Aug 2018 21:23:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmUFV-0007pF-I1 for emacs-devel@gnu.org; Sun, 05 Aug 2018 21:23:56 -0400 Original-Received: from [195.159.176.226] (port=55625 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmUFV-0007od-9X for emacs-devel@gnu.org; Sun, 05 Aug 2018 21:23:53 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fmUDM-0003CE-Bd for emacs-devel@gnu.org; Mon, 06 Aug 2018 03:21:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 54 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:XaZnfI45gaIudVtCisXcF/aWq8o= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:228202 Archived-At: > (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))) > ...) The above will not pass the value of `sfnlist` to `completing-read`. I.e. the warning saying "Unused lexical variable ‘sfnlist’" is true: that variable is *not* used. Instead `completing-read` will look at the symbol-value of the symbol `sfnlist` which is something completely separate from the value of the lexical variable `sfnlist`. > Given this, is it acceptable to leave the warning or is it preferable to > add a defvar to suppress it? Rename the var to `todo--sfnlist` and add a `defvar` for it, otherwise the code will not do what you expect. > The second warning is due to this line: > > (if (and (boundp 'hl-line-mode) hl-line-mode) (hl-line-highlight)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (bound-and-true-p hl-line-mode) > The warning can be prevented with (eval-and-compile (require 'hl-line)). This ideally shouldn't remove the warning (i.e. if it does, as you say, then it's probably the result of a bug or misfeature in the compiler). > 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? Your call. You can suppress the warning with (declare-function hl-line-highlight ...) or (if (and (boundp 'hl-line-mode) hl-line-mode (fboundp 'hl-line-highlight)) (hl-line-highlight)) but the warning here is a false alarm, so if you don't mind seeing the warning you can leave it (ideally, the byte-compiler should be made to understand the connection between `hl-line-mode` and `hl-line-highlight` so that your code doesn't trigger a warning). Stefan