~pkal/public-inbox

1

setup.el: How to inhibit byte compilation errors about require file include customized keyword

Details
Message ID
<87plubknxn.fsf@brsvh.org>
DKIM signature
permerror
Download raw message
Hi,

I try to use setup.el to define a keyword that is a simple customized
wrapper of `keymap-set'.

~/foo.el:

```emacs-lisp
(require 'setup)

(setup-define :keymap-set
  (lambda (key definition)
    `(keymap-set ,(setup-get 'map) ,key ,definition))
  :documentation "Set KEY to DEFINITION.
See `keymap-set'."
  :debug '(key sexp)
  :repeatable t)

(defvar ctl-c-map (make-keymap))
(defvar ctl-c-v-map (make-keymap))

(setup my-maps
  (:with-map ctl-c-map
    (:keymap-set "v" ctl-c-v-map)))

(provide 'foo)
```

~/bar.el:

```emacs-lisp
(require 'foo)

(provide 'bar)
```

When I attempting to execute with:

     emacs -q -l /path/to/setup.el \
       --eval "(add-to-list 'load-path \"~/\")" \
         --batch -f batch-byte-compile bar.el

I encountered the following error:

  Error: Symbol's function definition is void: :keymap-set

I don't know how to resolve this problem, could you provide some advice
on how to fix this?

Regards,

-- 
Burgess Chang
Pronouns: He/Him/His
OpenPGP: 7B740DB9F2AC6D3B226BC53078D74502D92E0218
Details
Message ID
<87o79vov2r.fsf@posteo.net>
In-Reply-To
<87plubknxn.fsf@brsvh.org> (view parent)
DKIM signature
pass
Download raw message
Burgess Chang <bsc@brsvh.org> writes:

> Hi,

Hi,

> I try to use setup.el to define a keyword that is a simple customized
> wrapper of `keymap-set'.
>
> ~/foo.el:
>
> ```emacs-lisp
> (require 'setup)
>
> (setup-define :keymap-set
>   (lambda (key definition)
>     `(keymap-set ,(setup-get 'map) ,key ,definition))
>   :documentation "Set KEY to DEFINITION.
> See `keymap-set'."
>   :debug '(key sexp)
>   :repeatable t)
>
> (defvar ctl-c-map (make-keymap))
> (defvar ctl-c-v-map (make-keymap))
>
> (setup my-maps
>   (:with-map ctl-c-map
>     (:keymap-set "v" ctl-c-v-map)))
>
> (provide 'foo)
> ```
>
>
> ~/bar.el:
>
> ```emacs-lisp
> (require 'foo)
>
> (provide 'bar)
> ```
>
> When I attempting to execute with:
>
>      emacs -q -l /path/to/setup.el \
>        --eval "(add-to-list 'load-path \"~/\")" \
>          --batch -f batch-byte-compile bar.el
>
> I encountered the following error:
>
>   Error: Symbol's function definition is void: :keymap-set
>
> I don't know how to resolve this problem, could you provide some advice
> on how to fix this?

I couldn't exactly reproduce the issue, but I suspect part of the
problem is that setup-define is a function that is not called during
macro-expansion/byte-compilation.  If you wrap that form, along with the
(require 'setup) in an (eval-and-compile ...) block, does that change
anything for you?

> Regards,

-- 
	Philip Kaludercic on peregrine
Reply to thread Export thread (mbox)