GNU bug report logs - #40596
28.0.50; Function with more than one key gives "wrong number of arguments" error

Previous Next

Package: emacs;

Reported by: Jean Louis <bugs <at> gnu.support>

Date: Mon, 13 Apr 2020 12:21:01 UTC

Severity: normal

Found in version 28.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 40596 in the body.
You can then email your comments to 40596 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#40596; Package emacs. (Mon, 13 Apr 2020 12:21:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jean Louis <bugs <at> gnu.support>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 13 Apr 2020 12:21:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; Function with more than one key gives "wrong number of
 arguments" error
Date: Mon, 13 Apr 2020 14:19:10 +0300
Here is something that could be a bug, I cannot know at this moment, as
I am researching yet if I can use &key with Emacs's `defun':

(defun tmp-function-1 (text html &key one)
  "This one works fine"
  (message one))

(tmp-function-1 "text" "<html>" :one "Hello")

(defun tmp-function-2 (text html &key one two)
  "This one does not work, wrong number of arguments"
  (message one))

(tmp-function-1 "text" "<html>" :one "Hello" :two "But not alright")

Evaluating the last function does not work, it gives the error:

Debugger entered--Lisp error: (wrong-number-of-arguments ((t) (text html &key one) "This one works fine" (message one)) 6)
  tmp-function-1("text" "<html>" :one "Hello" :two "But not alright")
  eval((tmp-function-1 "text" "<html>" :one "Hello" :two "But not alright") nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

I have tried searching the manual for Emacs Lisp for anything related to
`&key' and I cannot find any references, in my opinion the description
of `defun' in the Emacs Lisp manual is not satisfactorily.

Jean



In GNU Emacs 28.0.50 (build 5, x86_64-pc-linux-gnu, X toolkit, cairo version 1.14.8, Xaw3d scroll bars)
 of 2020-03-28 built on protected.rcdrun.com
Repository revision: dceba13ce57ed0cb726e89566197f77359a38d91
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11907000
System Description: Hyperbola GNU/Linux-libre

Recent messages:
Mark set
tmp-function-2
Entering debugger...
Back to top level
tmp-function-2
Entering debugger...
previous-line: Beginning of buffer [4 times]
Back to top level
kill-line: End of buffer [6 times]
Mark set

Configured using:
 'configure --prefix=/package/text/emacs-2020-03-28 --with-modules
 --without-gpm --with-x-toolkit=lucid
 PKG_CONFIG_PATH=/home/data1/protected/GNUstep/Library/Libraries/pkgconfig:/usr/lib/pkgconfig'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM MODULES THREADS JSON PDUMPER
LCMS2 GMP

Important settings:
  value of $LC_ALL: de_DE.UTF-8
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort hashcash mail-extr emacsbug message rmc puny dired
dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived
epg epg-config gnus-util rmail rmail-loaddefs text-property-search
time-date subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
help-fns radix-tree cl-print debug backtrace help-mode easymenu
find-func cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core term/tty-colors frame
minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite charscript charprop case-table epa-hook jka-cmpr-hook help
simple abbrev obarray cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo x-toolkit x multi-tty make-network-process
emacs)

Memory information:
((conses 16 52165 9031)
 (symbols 48 6514 1)
 (strings 32 18090 1316)
 (string-bytes 1 578502)
 (vectors 16 10940)
 (vector-slots 8 141658 11450)
 (floats 8 27 48)
 (intervals 56 546 84)
 (buffers 1000 13))

-- 
Thanks,
Jean Louis




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40596; Package emacs. (Mon, 13 Apr 2020 12:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 40596 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jean Louis <bugs <at> gnu.support>
Cc: 40596 <at> debbugs.gnu.org
Subject: Re: bug#40596: 28.0.50;
 Function with more than one key gives "wrong number of arguments"
 error
Date: Mon, 13 Apr 2020 15:30:21 +0300
> From: Jean Louis <bugs <at> gnu.support>
> Date: Mon, 13 Apr 2020 14:19:10 +0300
> 
> Here is something that could be a bug, I cannot know at this moment, as
> I am researching yet if I can use &key with Emacs's `defun':
> 
> (defun tmp-function-1 (text html &key one)
>   "This one works fine"
>   (message one))
> 
> (tmp-function-1 "text" "<html>" :one "Hello")
> 
> (defun tmp-function-2 (text html &key one two)
>   "This one does not work, wrong number of arguments"
>   (message one))
> 
> (tmp-function-1 "text" "<html>" :one "Hello" :two "But not alright")
> 
> Evaluating the last function does not work, it gives the error:

You need to use cl-defun, not defun.  The latter doesn't support &key.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40596; Package emacs. (Mon, 13 Apr 2020 13:11:02 GMT) Full text and rfc822 format available.

Message #11 received at 40596 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 40596 <at> debbugs.gnu.org
Subject: Re: bug#40596: 28.0.50; Function with more than one key gives "wrong
 number of arguments" error
Date: Mon, 13 Apr 2020 16:02:30 +0300
* Eli Zaretskii <eliz <at> gnu.org> [2020-04-13 15:31]:
> > From: Jean Louis <bugs <at> gnu.support>
> > Date: Mon, 13 Apr 2020 14:19:10 +0300
> > 
> > Here is something that could be a bug, I cannot know at this moment, as
> > I am researching yet if I can use &key with Emacs's `defun':
> > 
> > (defun tmp-function-1 (text html &key one)
> >   "This one works fine"
> >   (message one))
> > 
> > (tmp-function-1 "text" "<html>" :one "Hello")
> > 
> > (defun tmp-function-2 (text html &key one two)
> >   "This one does not work, wrong number of arguments"
> >   (message one))
> > 
> > (tmp-function-1 "text" "<html>" :one "Hello" :two "But not alright")
> > 
> > Evaluating the last function does not work, it gives the error:
> 
> You need to use cl-defun, not defun.  The latter doesn't support &key.

I understand and not that I need it. Then if the Emacs Lisp `defun'
does not support &key, why is then this below working?

(defun tmp-function-1 (text html &key one)
  "This one works fine"
  (message one))

(tmp-function-1 "text" "<html>" :one "Hello")

It should not work, if Emacs Lisp does not support &key

Isn't it?

Jean




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40596; Package emacs. (Mon, 13 Apr 2020 13:39:02 GMT) Full text and rfc822 format available.

Message #14 received at 40596 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jean Louis <bugs <at> gnu.support>
Cc: 40596 <at> debbugs.gnu.org
Subject: Re: bug#40596: 28.0.50; Function with more than one key gives "wrong
 number of arguments" error
Date: Mon, 13 Apr 2020 16:37:51 +0300
> Date: Mon, 13 Apr 2020 16:02:30 +0300
> From: Jean Louis <bugs <at> gnu.support>
> Cc: 40596 <at> debbugs.gnu.org
> 
> I understand and not that I need it. Then if the Emacs Lisp `defun'
> does not support &key, why is then this below working?
> 
> (defun tmp-function-1 (text html &key one)
>   "This one works fine"
>   (message one))
> 
> (tmp-function-1 "text" "<html>" :one "Hello")

I think it interprets &key as a name of a simple argument.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Mon, 13 Apr 2020 13:59:02 GMT) Full text and rfc822 format available.

Notification sent to Jean Louis <bugs <at> gnu.support>:
bug acknowledged by developer. (Mon, 13 Apr 2020 13:59:02 GMT) Full text and rfc822 format available.

Message #19 received at 40596-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jean Louis <bugs <at> gnu.support>
Cc: 40596-done <at> debbugs.gnu.org
Subject: Re: bug#40596: 28.0.50; Function with more than one key gives "wrong
 number of arguments" error
Date: Mon, 13 Apr 2020 16:57:46 +0300
> Date: Mon, 13 Apr 2020 16:43:49 +0300
> From: Jean Louis <bugs <at> gnu.support>
> Cc: 40596 <at> debbugs.gnu.org
> 
> > > (tmp-function-1 "text" "<html>" :one "Hello")
> > 
> > I think it interprets &key as a name of a simple argument.
> 
> A yes, close.

Done.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40596; Package emacs. (Mon, 13 Apr 2020 14:42:02 GMT) Full text and rfc822 format available.

Message #22 received at 40596 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 40596 <at> debbugs.gnu.org
Subject: Re: bug#40596: 28.0.50; Function with more than one key gives "wrong
 number of arguments" error
Date: Mon, 13 Apr 2020 16:43:49 +0300
* Eli Zaretskii <eliz <at> gnu.org> [2020-04-13 16:38]:
> > Date: Mon, 13 Apr 2020 16:02:30 +0300
> > From: Jean Louis <bugs <at> gnu.support>
> > Cc: 40596 <at> debbugs.gnu.org
> > 
> > I understand and not that I need it. Then if the Emacs Lisp `defun'
> > does not support &key, why is then this below working?
> > 
> > (defun tmp-function-1 (text html &key one)
> >   "This one works fine"
> >   (message one))
> > 
> > (tmp-function-1 "text" "<html>" :one "Hello")
> 
> I think it interprets &key as a name of a simple argument.

A yes, close.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40596; Package emacs. (Mon, 13 Apr 2020 15:02:01 GMT) Full text and rfc822 format available.

Message #25 received at 40596 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Jean Louis <bugs <at> gnu.support>
Cc: 40596 <at> debbugs.gnu.org
Subject: RE: bug#40596: 28.0.50; Function with more than one key gives "wrong
 number of arguments" error
Date: Mon, 13 Apr 2020 08:01:33 -0700 (PDT)
> I think it interprets &key as a name of a simple argument.

This can be a gotcha, for someone coming from
another Lisp dialect that supports lambda lists
with &key.

Perhaps Emacs Lisp could post a warning (e.g. from
the byte-compiler) if a lambda list uses one of the
`&' keywords supported by, say, Common Lisp (&key,
&aux, &allow-other-keys)?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40596; Package emacs. (Tue, 14 Apr 2020 02:17:03 GMT) Full text and rfc822 format available.

Message #28 received at 40596 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: eliz <at> gnu.org, bugs <at> gnu.support, 40596 <at> debbugs.gnu.org
Subject: Re: bug#40596: 28.0.50;
 Function with more than one key gives "wrong number of arguments"
 error
Date: Mon, 13 Apr 2020 22:16:00 -0400
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Perhaps Emacs Lisp could post a warning (e.g. from
  > the byte-compiler) if a lambda list uses one of the
  > `&' keywords supported by, say, Common Lisp (&key,
  > &aux, &allow-other-keys)?

I think that is a good idea.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 12 May 2020 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 42 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.