unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* cl-case is not autoloaded in Emacs 27
@ 2021-07-21 17:18 Daniele Nicolodi
  2021-07-21 18:40 ` Bozhidar Batsov
  2021-07-21 19:18 ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Daniele Nicolodi @ 2021-07-21 17:18 UTC (permalink / raw)
  To: emacs-devel

Hello,

I have been trying to understand why some ERT unit tests I wrote fail in
Emacs 27 while they suceed in Emacs 26. After some head scratching I
found that the problem is caused by the fact that Emacs 27 does not seem
to know about the cl-case macro unless I (require 'cl-macs).

Indeed, if I try to byte-compile some trivial code like

(let ((x ?c))
  (cl-case x
    (?a 0)
    (?b 1)))

in Emacs 27.1 or Emacs 27.2 I obtain these warnings:

In toplevel form:
test.el:1:1:Warning: ‘97’ is a malformed function
test.el:1:1:Warning: ‘98’ is a malformed function

In end of data:
test.el:7:1:Warning: the function ‘cl-case’ is not known to be defined.

Adding a (require cl-macs) to my code solves my problem, however, the
doc string of cl-case would suggest that this should not be necessary.

Am I missing something?

Thank you.

Best,
Dan



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

* Re: cl-case is not autoloaded in Emacs 27
  2021-07-21 17:18 cl-case is not autoloaded in Emacs 27 Daniele Nicolodi
@ 2021-07-21 18:40 ` Bozhidar Batsov
  2021-07-21 19:32   ` Daniele Nicolodi
  2021-07-21 19:18 ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Bozhidar Batsov @ 2021-07-21 18:40 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

To my knowledge nothing from cl-lib has ever been autoloaded (as those functions/macros are not commands it doesn't really make sense to autoload them). You need to require cl-lib, not cl-macs. Most of the time some package that you've loaded will have required cl-lib, that's why probably you didn't notice that it's not required by default. 

On Wed, Jul 21, 2021, at 8:18 PM, Daniele Nicolodi wrote:
> Hello,
> 
> I have been trying to understand why some ERT unit tests I wrote fail in
> Emacs 27 while they suceed in Emacs 26. After some head scratching I
> found that the problem is caused by the fact that Emacs 27 does not seem
> to know about the cl-case macro unless I (require 'cl-macs).
> 
> Indeed, if I try to byte-compile some trivial code like
> 
> (let ((x ?c))
>   (cl-case x
>     (?a 0)
>     (?b 1)))
> 
> in Emacs 27.1 or Emacs 27.2 I obtain these warnings:
> 
> In toplevel form:
> test.el:1:1:Warning: ‘97’ is a malformed function
> test.el:1:1:Warning: ‘98’ is a malformed function
> 
> In end of data:
> test.el:7:1:Warning: the function ‘cl-case’ is not known to be defined.
> 
> Adding a (require cl-macs) to my code solves my problem, however, the
> doc string of cl-case would suggest that this should not be necessary.
> 
> Am I missing something?
> 
> Thank you.
> 
> Best,
> Dan
> 
> 

[-- Attachment #2: Type: text/html, Size: 2021 bytes --]

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

* Re: cl-case is not autoloaded in Emacs 27
  2021-07-21 17:18 cl-case is not autoloaded in Emacs 27 Daniele Nicolodi
  2021-07-21 18:40 ` Bozhidar Batsov
@ 2021-07-21 19:18 ` Stefan Monnier
  2021-07-21 20:02   ` [External] : " Drew Adams
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2021-07-21 19:18 UTC (permalink / raw)
  To: Daniele Nicolodi; +Cc: emacs-devel

> found that the problem is caused by the fact that Emacs 27 does not seem
> to know about the cl-case macro unless I (require 'cl-macs).

All those `cl-<foo>` thingies come from `cl-lib`, so yes you need to
(require 'cl-lib) before you can use them.

And please don't require `cl-macs` since the subdivision of labor
between the different files that comprise `cl-lib` is an
internal detail subject to change.


        Stefan




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

* Re: cl-case is not autoloaded in Emacs 27
  2021-07-21 18:40 ` Bozhidar Batsov
@ 2021-07-21 19:32   ` Daniele Nicolodi
  2021-07-21 20:06     ` Stefan Monnier
  2021-07-21 20:17     ` Glenn Morris
  0 siblings, 2 replies; 8+ messages in thread
From: Daniele Nicolodi @ 2021-07-21 19:32 UTC (permalink / raw)
  To: emacs-devel

On 21/07/2021 20:40, Bozhidar Batsov wrote:
> To my knowledge nothing from cl-lib has ever been autoloaded (as those
> functions/macros are not commands it doesn't really make sense to
> autoload them).

Well, the docstring says:

cl-case is an autoloaded Lisp macro in ‘cl-macs.el’.

thus I would expect it to be autoloaded.



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

* RE: [External] : Re: cl-case is not autoloaded in Emacs 27
  2021-07-21 19:18 ` Stefan Monnier
@ 2021-07-21 20:02   ` Drew Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2021-07-21 20:02 UTC (permalink / raw)
  To: Stefan Monnier, Daniele Nicolodi; +Cc: emacs-devel@gnu.org

> All those `cl-<foo>` thingies come from `cl-lib`, so yes you need to
> (require 'cl-lib) before you can use them.
> 
> And please don't require `cl-macs` since the subdivision of labor
> between the different files that comprise `cl-lib` is an
> internal detail subject to change.

You can consider the division an internal detail, but
if all someone (or some library) needs is, say, macro
`cl-case' then loading just `cl-macs' at compile time
can make sense.  That was true many moon ago, and I
don't see why it wouldn't remain true.

Seems like keeping the macro defs in their own file
can make sense for users as well as for Emacs dev.
Why/when wouldn't that be wanted?

Of course, it doesn't _hurt_ to require `cl-lib' at
compile time (except that it can add unneeded stuff
to the session that does the compiling).  And the
general case that you describe is no doubt the more
common one: more users want more from `cl-lib.el'
than just macro `cl-case'.



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

* Re: cl-case is not autoloaded in Emacs 27
  2021-07-21 19:32   ` Daniele Nicolodi
@ 2021-07-21 20:06     ` Stefan Monnier
  2021-07-21 20:17     ` Glenn Morris
  1 sibling, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2021-07-21 20:06 UTC (permalink / raw)
  To: Daniele Nicolodi; +Cc: emacs-devel

Daniele Nicolodi [2021-07-21 21:32:24] wrote:
> On 21/07/2021 20:40, Bozhidar Batsov wrote:
>> To my knowledge nothing from cl-lib has ever been autoloaded (as those
>> functions/macros are not commands it doesn't really make sense to
>> autoload them).
>
> Well, the docstring says:
> cl-case is an autoloaded Lisp macro in ‘cl-macs.el’.
> thus I would expect it to be autoloaded.

It only says so after you've loaded `cl-lib`.  ;-)


        Stefan




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

* Re: cl-case is not autoloaded in Emacs 27
  2021-07-21 19:32   ` Daniele Nicolodi
  2021-07-21 20:06     ` Stefan Monnier
@ 2021-07-21 20:17     ` Glenn Morris
  2021-07-21 21:17       ` Daniele Nicolodi
  1 sibling, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2021-07-21 20:17 UTC (permalink / raw)
  To: Daniele Nicolodi; +Cc: emacs-devel

Daniele Nicolodi wrote:

> Well, the docstring says:
>
> cl-case is an autoloaded Lisp macro in 'cl-macs.el'.
>
> thus I would expect it to be autoloaded.

https://debbugs.gnu.org/26782



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

* Re: cl-case is not autoloaded in Emacs 27
  2021-07-21 20:17     ` Glenn Morris
@ 2021-07-21 21:17       ` Daniele Nicolodi
  0 siblings, 0 replies; 8+ messages in thread
From: Daniele Nicolodi @ 2021-07-21 21:17 UTC (permalink / raw)
  To: emacs-devel

On 21/07/2021 22:17, Glenn Morris wrote:
> Daniele Nicolodi wrote:
> 
>> Well, the docstring says:
>>
>> cl-case is an autoloaded Lisp macro in 'cl-macs.el'.
>>
>> thus I would expect it to be autoloaded.
> 
> https://debbugs.gnu.org/26782

I'm happy to see that is not my understanding that is lacking and that
others find the note about autoload in the function documentation confusing.

Cheers,
Dan






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

end of thread, other threads:[~2021-07-21 21:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 17:18 cl-case is not autoloaded in Emacs 27 Daniele Nicolodi
2021-07-21 18:40 ` Bozhidar Batsov
2021-07-21 19:32   ` Daniele Nicolodi
2021-07-21 20:06     ` Stefan Monnier
2021-07-21 20:17     ` Glenn Morris
2021-07-21 21:17       ` Daniele Nicolodi
2021-07-21 19:18 ` Stefan Monnier
2021-07-21 20:02   ` [External] : " Drew Adams

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).