* How to avoid warning, with undefined functions in a package
@ 2020-10-19 5:58 Jean Louis
2020-10-19 8:34 ` Daniel Martín
2020-10-19 15:16 ` Drew Adams
0 siblings, 2 replies; 5+ messages in thread
From: Jean Louis @ 2020-10-19 5:58 UTC (permalink / raw)
To: help-gnu-emacs
Let us say I have some speech functions, but do not want to
(require 'festival) for the package rcd-utilities.el
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’
In end of data:
rcd-utilities.el:205:1: Warning: the function ‘festival-say-string’ is not
known to be defined.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to avoid warning, with undefined functions in a package
2020-10-19 5:58 How to avoid warning, with undefined functions in a package Jean Louis
@ 2020-10-19 8:34 ` Daniel Martín
2020-10-19 15:16 ` Drew Adams
1 sibling, 0 replies; 5+ messages in thread
From: Daniel Martín @ 2020-10-19 8:34 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs
Jean Louis <bugs@gnu.support> writes:
> Let us say I have some speech functions, but do not want to
> (require 'festival) for the package rcd-utilities.el
>
> 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’
>
> In end of data:
> rcd-utilities.el:205:1: Warning: the function ‘festival-say-string’ is not
> known to be defined.
There are several possible techniques. The Elisp manual explains some of
them:
C-h i m Elisp RET i byte-compiler warnings RET
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: How to avoid warning, with undefined functions in a package
2020-10-19 5:58 How to avoid warning, with undefined functions in a package Jean Louis
2020-10-19 8:34 ` Daniel Martín
@ 2020-10-19 15:16 ` Drew Adams
2020-10-19 17:57 ` Jean Louis
1 sibling, 1 reply; 5+ messages in thread
From: Drew Adams @ 2020-10-19 15:16 UTC (permalink / raw)
To: Jean Louis, help-gnu-emacs
> 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)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to avoid warning, with undefined functions in a package
2020-10-19 15:16 ` Drew Adams
@ 2020-10-19 17:57 ` Jean Louis
2020-10-19 18:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 5+ messages in thread
From: Jean Louis @ 2020-10-19 17:57 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs
* 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-10-19 18:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-19 5:58 How to avoid warning, with undefined functions in a package Jean Louis
2020-10-19 8:34 ` Daniel Martín
2020-10-19 15:16 ` Drew Adams
2020-10-19 17:57 ` Jean Louis
2020-10-19 18:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.