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

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

Re: How to avoid warning, with undefined functions in a package


From: Jean Louis
Subject: Re: How to avoid warning, with undefined functions in a package
Date: Mon, 19 Oct 2020 20:57:49 +0300
User-agent: Mutt/1.10.1 (2018-07-13)

* Drew Adams <drew.adams@oracle.com> [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.



reply via email to

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