From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to avoid warning, with undefined functions in a package Date: Mon, 19 Oct 2020 20:57:49 +0300 Message-ID: <20201019175749.GK19325@protected.rcdrun.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2515"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: help-gnu-emacs@gnu.org To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 19 19:58:31 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUZQV-0000XQ-2o for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 19 Oct 2020 19:58:31 +0200 Original-Received: from localhost ([::1]:40854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUZQU-0001WH-4N for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 19 Oct 2020 13:58:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUZPw-0001WA-Sl for help-gnu-emacs@gnu.org; Mon, 19 Oct 2020 13:57:56 -0400 Original-Received: from static.rcdrun.com ([95.85.24.50]:48875) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUZPv-0000Sj-9i for help-gnu-emacs@gnu.org; Mon, 19 Oct 2020 13:57:56 -0400 Original-Received: from localhost ([::ffff:41.202.241.51]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by static.rcdrun.com with ESMTPSA id 00000000002A0C8F.000000005F8DD3A0.00000CE8; Mon, 19 Oct 2020 17:57:51 +0000 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=95.85.24.50; envelope-from=bugs@gnu.support; helo=static.rcdrun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 12:25:27 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124585 Archived-At: * Drew Adams [2020-10-19 18:17]: > > Those are undefined functions and variables, but I would not like > > defining them, or requiring them, unless user has that other package. > > > > What would be good approach to solve that, and that there are no > > compiler warnings? > > > > In rcd-speak-festival: > > rcd-utilities.el:121:23: Warning: reference to free variable > > ‘festival-program-name’ > > For the undefined variable warnings: If you are convinced that your code does the right thing, so those warnings are spurious, add an empty `defvar' for each such variable warning. E.g., for variable foo, add this: > > ;; No initial value. Just tells the byte compiler > ;; that this is a special variable. > ;; > (defvar foo) Thank you, that is also good to know. What I did is that I made like: (defvar rcd-festival-function 'festival-say-string "Which festival function to be called") (setq rcd-speech-function 'rcd-speak-festival) and I use bound-and-true-p to avoid the warning down. (defun rcd-speak-festival (string) "Returns speech by using festival if the `rcd-speech' variables is true and `festival-program-name' has some value" (if (and rcd-speech (bound-and-true-p festival-program-name)) (funcall rcd-festival-function string))) In case there are different festival functions, it is configurable. That is my idea of it. Now there are no warning.