unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to avoid "unknown function" warning for *very* optional functional
@ 2024-02-09 22:25 Konstantin Kharlamov
  2024-02-10  0:08 ` Joost Kremers
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Kharlamov @ 2024-02-09 22:25 UTC (permalink / raw)
  To: emacs-devel

I'm fixing warnings in some of Emacs packages I'm using, and I found in
`meson-mode` this construct:

    (defun meson-lookup-doc (identifier)
    …
            (when (bound-and-true-p evil-mode)
              (evil-local-set-key 'normal (kbd "q") 'bury-buffer)))
    …

This basically a small help to those using both evil-mode and `meson-mode`. And this
triggers a byte-compilation warning:

    meson-mode.el:958:12: Warning: the function ‘evil-local-set-key’ is not known to be defined.

I'm not exactly sure what's the proper way to fix this? It's not even an optional
package, so `require` or `(cl-eval-when 'compile …` are not suitable here. It's just
that: "change behavior in this one function if another mode is present".



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to avoid "unknown function" warning for *very* optional functional
  2024-02-09 22:25 How to avoid "unknown function" warning for *very* optional functional Konstantin Kharlamov
@ 2024-02-10  0:08 ` Joost Kremers
  2024-02-10  8:55   ` Konstantin Kharlamov
  0 siblings, 1 reply; 3+ messages in thread
From: Joost Kremers @ 2024-02-10  0:08 UTC (permalink / raw)
  To: Konstantin Kharlamov; +Cc: emacs-devel


On Sat, Feb 10 2024, Konstantin Kharlamov wrote:
> I'm fixing warnings in some of Emacs packages I'm using, and I found in
> `meson-mode` this construct:
>
>     (defun meson-lookup-doc (identifier)
>     …
>             (when (bound-and-true-p evil-mode)
>               (evil-local-set-key 'normal (kbd "q") 'bury-buffer)))
>     …
>
> This basically a small help to those using both evil-mode and `meson-mode`. And this
> triggers a byte-compilation warning:
>
>     meson-mode.el:958:12: Warning: the function ‘evil-local-set-key’ is not known to be defined.
>
> I'm not exactly sure what's the proper way to fix this? It's not even an optional
> package, so `require` or `(cl-eval-when 'compile …` are not suitable here. It's just
> that: "change behavior in this one function if another mode is present".

You can use `declare-function` to let the byte-compiler know that the function
exists but that there is no need to actually check to make sure.


-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to avoid "unknown function" warning for *very* optional functional
  2024-02-10  0:08 ` Joost Kremers
@ 2024-02-10  8:55   ` Konstantin Kharlamov
  0 siblings, 0 replies; 3+ messages in thread
From: Konstantin Kharlamov @ 2024-02-10  8:55 UTC (permalink / raw)
  To: Joost Kremers; +Cc: emacs-devel

Thank you, that works!

On Sat, 2024-02-10 at 01:08 +0100, Joost Kremers wrote:
> 
> On Sat, Feb 10 2024, Konstantin Kharlamov wrote:
> > I'm fixing warnings in some of Emacs packages I'm using, and I
> > found in
> > `meson-mode` this construct:
> > 
> >     (defun meson-lookup-doc (identifier)
> >     …
> >             (when (bound-and-true-p evil-mode)
> >               (evil-local-set-key 'normal (kbd "q") 'bury-buffer)))
> >     …
> > 
> > This basically a small help to those using both evil-mode and
> > `meson-mode`. And this
> > triggers a byte-compilation warning:
> > 
> >     meson-mode.el:958:12: Warning: the function ‘evil-local-set-
> > key’ is not known to be defined.
> > 
> > I'm not exactly sure what's the proper way to fix this? It's not
> > even an optional
> > package, so `require` or `(cl-eval-when 'compile …` are not
> > suitable here. It's just
> > that: "change behavior in this one function if another mode is
> > present".
> 
> You can use `declare-function` to let the byte-compiler know that the
> function
> exists but that there is no need to actually check to make sure.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-10  8:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-09 22:25 How to avoid "unknown function" warning for *very* optional functional Konstantin Kharlamov
2024-02-10  0:08 ` Joost Kremers
2024-02-10  8:55   ` Konstantin Kharlamov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).