* bug#4427: 23.1; defun* don't work when compiled.
@ 2009-09-14 10:24 ` Thierry Volpiatto
2009-09-14 12:29 ` Thierry Volpiatto
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Thierry Volpiatto @ 2009-09-14 10:24 UTC (permalink / raw
To: bug-gnu-emacs
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.
Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.
Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:
Hi all,
In traverselisp.el, i use cl stuff with
(eval-when-compile (require 'cl)) at start of file.
I have functions that are like:
(defun* foo (&key a b)...
They all work fine after compiling file.
However, i have one new function that don't work when compiling file but
work as normal when loading the .el file, or evaluate the function with
C-M x.
I wonder why.
It seem that variables coming from key arg and evaluated in a cond clause
don't work when compiled and evaluated from compiled file (.elc).
Here is the output of:
(symbol-function 'traverse-auto-document-lisp-buffer)
After loading only .elc file.
--8<---------------cut here---------------start------------->8---
#[(&rest --cl-rest--) "\306\b>A@.\307\b>A@.\b.\v\2038.\v@\310>\203!.\vAA\211.\202.\203Y.\344
.C\"\203\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210\202\345. \360=\203\222.\354\355.C!!\204\345.
\203\210.\344
.C\"\203\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210\202\345. \361=\203\270.
\203\256.\344
.C\"\203\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210\202\345. \362=\203\336.
\203\324.\344
.C\"\203\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210+.?A\211.?\204.\x01. \312\207" [--cl-rest-- type prefix --cl-keys-- boundary-regexp regexp :type :prefix (:type :prefix :allow-other-keys) :allow-other-keys nil error ...] 9 ("/home/thierry/elisp/traverselisp.elc" . 45818)]
--8<---------------cut here---------------end--------------->8---
Here is the same after evaluation of .el file or function with C-M x:
--8<---------------cut here---------------start------------->8---
(lambda (&rest --cl-rest--) "Not documented
(fn &key TYPE PREFIX)" (let* ((type ...) (prefix ...)) (let (...) (while --cl-keys-- ...)) (block traverse-auto-document-lisp-buffer (let* ... ... ... ... ... ...))))
--8<---------------cut here---------------end--------------->8---
So here it is normal and the function work as intended.
When using the function from .elc file, i have no error, the function
just return nil, even with debug-on-error turned on.
Here the function:
,----
| (defun* traverse-auto-document-lisp-buffer (&key type prefix)
| (let* ((boundary-regexp "^;;=*LIMIT.*")
| (regexp (case type
| ('nested "^ +\(def\\(un\\|subst\\|advice\\)")
| ('command "\(def\\(un\\|subst\\)")
| ('internal-variable "\(defvar")
| ('user-variable "\(defcustom")
| ('faces "\(defface")
| ('function "\(def\\(un\\|subst\\|advice\\)")
| (t (error "Unknow type"))))
| (fn-list (traverse-find-readlines
| (current-buffer)
| regexp
| :insert-fn 'buffer))
| beg end)
| (insert "\n") (setq beg (point))
| (save-excursion (when (re-search-forward boundary-regexp)
| (forward-line -1) (setq end (point))))
| (delete-region beg end)
| (dolist (i fn-list)
| (let* ((elm (cadr i))
| (elm-mod (replace-regexp-in-string regexp "" elm))
| (elm-fin (replace-regexp-in-string "\(\\|\)" ""(car (split-string elm-mod)))))
| (cond ((eq type 'command)
| (when (commandp (intern elm-fin))
| (if prefix
| (when (string-match prefix elm-fin)
| (insert (concat ";; \`" elm-fin "\'\n")))
| (insert (concat ";; \`" elm-fin "\'\n")))))
| ((eq type 'function)
| (when (not (commandp (intern elm-fin)))
| (if prefix
| (when (string-match prefix elm-fin)
| (insert (concat ";; \`" elm-fin "\'\n")))
| (insert (concat ";; \`" elm-fin "\'\n")))))
| ((eq type 'internal-variable)
| (if prefix
| (when (string-match prefix elm-fin)
| (insert (concat ";; \`" elm-fin "\'\n")))
| (insert (concat ";; \`" elm-fin "\'\n"))))
| ((eq type 'nested)
| (if prefix
| (when (string-match prefix elm-fin)
| (insert (concat ";; \`" elm-fin "\'\n")))
| (insert (concat ";; \`" elm-fin "\'\n"))))
| (t
| (insert (concat ";; \`" elm-fin "\'\n"))))))))
`----
If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
`bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/share/emacs/23.1/etc/DEBUG for instructions.
In GNU Emacs 23.1.1 (i686-pc-linux-gnu, GTK+ Version 2.16.5)
of 2009-07-31 on tux
Windowing system distributor `The X.Org Foundation', version 11.0.10503000
configured using `configure '--prefix=/usr' '--build=i686-pc-linux-gnu' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--program-suffix=-emacs-23' '--infodir=/usr/share/info/emacs-23' '--with-sound' '--with-x' '--without-toolkit-scroll-bars' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xpm' '--with-xft' '--without-libotf' '--without-m17n-flt' '--with-x-toolkit=gtk' '--without-hesiod' '--without-kerberos' '--without-kerberos5' '--with-gpm' '--with-dbus' 'build_alias=i686-pc-linux-gnu' 'host_alias=i686-pc-linux-gnu' 'CFLAGS=-march=i686 -pipe -O2' 'LDFLAGS=-Wl,-O1''
Important settings:
value of $LC_ALL: fr_FR.UTF-8
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: fr_FR.UTF-8
value of $XMODIFIERS: nil
locale-coding-system: utf-8-unix
default-enable-multibyte-characters: t
Major mode: Lisp Interaction
Minor modes in effect:
eldoc-mode: t
icomplete-mode: t
icicle-mode: t
delete-selection-mode: t
minibuffer-depth-indicate-mode: t
auto-image-file-mode: t
shell-dirtrack-mode: t
partial-completion-mode: t
show-paren-mode: t
display-battery-mode: t
display-time-mode: t
diff-auto-refine-mode: t
outline-minor-mode: t
recentf-mode: t
savehist-mode: t
desktop-save-mode: t
tooltip-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
global-auto-composition-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
M-x M-p <return> <f11> a <down> <return> <up> <up>
C-SPC C-n C-n C-w <up> M-e C-h e <f11> s c M-> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> C-SPC C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n C-x r s a C-g M-x r e p o r
t - e m a c s - b u <tab> <return>
Recent messages:
Type C-x 4 C-o RET to restore the other window, C-M-v to scroll help. [2 times]
Parsing BBDB... (frobnicating...done)
Loading /home/thierry/.emacs.d/yaoddmuse-cache.el (source)...done
Mark set
nil
Auto-saving...done
Mark set [2 times]
Quit
Computing completion candidates...
--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#4427: 23.1; defun* don't work when compiled.
2009-09-14 10:24 ` Thierry Volpiatto
@ 2009-09-14 12:29 ` Thierry Volpiatto
2010-03-12 3:19 ` Glenn Morris
2010-03-12 7:07 ` Thierry Volpiatto
2 siblings, 0 replies; 6+ messages in thread
From: Thierry Volpiatto @ 2009-09-14 12:29 UTC (permalink / raw
To: bug-gnu-emacs
Complete information on this bug (if it is one).
Of course when this function is defined as macro, and
(eval-when-compile (require 'cl)) is used, the code is evaluated by the
byte-compiler and things work as expected.
But i wonder why the other "defun*" with &key that are in traverselisp
works and specially this function doesn't work.
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> Please write in English if possible, because the Emacs maintainers
> usually do not have translators to read other languages for them.
>
> Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
> and to the gnu.emacs.bug news group.
>
> Please describe exactly what actions triggered the bug
> and the precise symptoms of the bug:
>
> Hi all,
>
> In traverselisp.el, i use cl stuff with
> (eval-when-compile (require 'cl)) at start of file.
> I have functions that are like:
> (defun* foo (&key a b)...
>
> They all work fine after compiling file.
>
> However, i have one new function that don't work when compiling file but
> work as normal when loading the .el file, or evaluate the function with
> C-M x.
>
> I wonder why.
> It seem that variables coming from key arg and evaluated in a cond clause
> don't work when compiled and evaluated from compiled file (.elc).
>
> Here is the output of:
>
> (symbol-function 'traverse-auto-document-lisp-buffer)
> After loading only .elc file.
>
> #[(&rest --cl-rest--) "\306\b>A@.\307\b>A@.\b.\v\2038.\v@\310>\203!.\vAA\211.\202.\203Y.\344
> .C\"\203\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210\202\345. \360=\203\222.\354\355.C!!\204\345.
> \203\210.\344
> .C\"\203\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210\202\345. \361=\203\270.
> \203\256.\344
> .C\"\203\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210\202\345. \362=\203\336.
> \203\324.\344
> .C\"\203\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210\202\345.\356.C\357Qc\210+.?A\211.?\204... \312\207" [--cl-rest-- type prefix --cl-keys-- boundary-regexp regexp :type :prefix (:type :prefix :allow-other-keys) :allow-other-keys nil error ...] 9 ("/home/thierry/elisp/traverselisp.elc" . 45818)]
>
> Here is the same after evaluation of .el file or function with C-M x:
>
> (lambda (&rest --cl-rest--) "Not documented
>
> (fn &key TYPE PREFIX)" (let* ((type ...) (prefix ...)) (let (...) (while --cl-keys-- ...)) (block traverse-auto-document-lisp-buffer (let* ... ... ... ... ... ...))))
>
> So here it is normal and the function work as intended.
> When using the function from .elc file, i have no error, the function
> just return nil, even with debug-on-error turned on.
>
> Here the function:
>
> ,----
> | (defun* traverse-auto-document-lisp-buffer (&key type prefix)
> | (let* ((boundary-regexp "^;;=*LIMIT.*")
> | (regexp (case type
> | ('nested "^ +\(def\\(un\\|subst\\|advice\\)")
> | ('command "\(def\\(un\\|subst\\)")
> | ('internal-variable "\(defvar")
> | ('user-variable "\(defcustom")
> | ('faces "\(defface")
> | ('function "\(def\\(un\\|subst\\|advice\\)")
> | (t (error "Unknow type"))))
> | (fn-list (traverse-find-readlines
> | (current-buffer)
> | regexp
> | :insert-fn 'buffer))
> | beg end)
> | (insert "\n") (setq beg (point))
> | (save-excursion (when (re-search-forward boundary-regexp)
> | (forward-line -1) (setq end (point))))
> | (delete-region beg end)
> | (dolist (i fn-list)
> | (let* ((elm (cadr i))
> | (elm-mod (replace-regexp-in-string regexp "" elm))
> | (elm-fin (replace-regexp-in-string "\(\\|\)" ""(car (split-string elm-mod)))))
> | (cond ((eq type 'command)
> | (when (commandp (intern elm-fin))
> | (if prefix
> | (when (string-match prefix elm-fin)
> | (insert (concat ";; \`" elm-fin "\'\n")))
> | (insert (concat ";; \`" elm-fin "\'\n")))))
> | ((eq type 'function)
> | (when (not (commandp (intern elm-fin)))
> | (if prefix
> | (when (string-match prefix elm-fin)
> | (insert (concat ";; \`" elm-fin "\'\n")))
> | (insert (concat ";; \`" elm-fin "\'\n")))))
> | ((eq type 'internal-variable)
> | (if prefix
> | (when (string-match prefix elm-fin)
> | (insert (concat ";; \`" elm-fin "\'\n")))
> | (insert (concat ";; \`" elm-fin "\'\n"))))
> | ((eq type 'nested)
> | (if prefix
> | (when (string-match prefix elm-fin)
> | (insert (concat ";; \`" elm-fin "\'\n")))
> | (insert (concat ";; \`" elm-fin "\'\n"))))
> | (t
> | (insert (concat ";; \`" elm-fin "\'\n"))))))))
> `----
>
> If Emacs crashed, and you have the Emacs process in the gdb debugger,
> please include the output from the following gdb commands:
> `bt full' and `xbacktrace'.
> If you would like to further debug the crash, please read the file
> /usr/share/emacs/23.1/etc/DEBUG for instructions.
>
>
> In GNU Emacs 23.1.1 (i686-pc-linux-gnu, GTK+ Version 2.16.5)
> of 2009-07-31 on tux
> Windowing system distributor `The X.Org Foundation', version 11.0.10503000
> configured using `configure '--prefix=/usr' '--build=i686-pc-linux-gnu' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--program-suffix=-emacs-23' '--infodir=/usr/share/info/emacs-23' '--with-sound' '--with-x' '--without-toolkit-scroll-bars' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xpm' '--with-xft' '--without-libotf' '--without-m17n-flt' '--with-x-toolkit=gtk' '--without-hesiod' '--without-kerberos' '--without-kerberos5' '--with-gpm' '--with-dbus' 'build_alias=i686-pc-linux-gnu' 'host_alias=i686-pc-linux-gnu' 'CFLAGS=-march=i686 -pipe -O2' 'LDFLAGS=-Wl,-O1''
>
> Important settings:
> value of $LC_ALL: fr_FR.UTF-8
> value of $LC_COLLATE: nil
> value of $LC_CTYPE: nil
> value of $LC_MESSAGES: nil
> value of $LC_MONETARY: nil
> value of $LC_NUMERIC: nil
> value of $LC_TIME: nil
> value of $LANG: fr_FR.UTF-8
> value of $XMODIFIERS: nil
> locale-coding-system: utf-8-unix
> default-enable-multibyte-characters: t
>
> Major mode: Lisp Interaction
>
> Minor modes in effect:
> eldoc-mode: t
> icomplete-mode: t
> icicle-mode: t
> delete-selection-mode: t
> minibuffer-depth-indicate-mode: t
> auto-image-file-mode: t
> shell-dirtrack-mode: t
> partial-completion-mode: t
> show-paren-mode: t
> display-battery-mode: t
> display-time-mode: t
> diff-auto-refine-mode: t
> outline-minor-mode: t
> recentf-mode: t
> savehist-mode: t
> desktop-save-mode: t
> tooltip-mode: t
> mouse-wheel-mode: t
> file-name-shadow-mode: t
> global-font-lock-mode: t
> font-lock-mode: t
> global-auto-composition-mode: t
> auto-composition-mode: t
> auto-encryption-mode: t
> auto-compression-mode: t
> line-number-mode: t
> transient-mark-mode: t
>
> Recent input:
> M-x M-p <return> <f11> a <down> <return> <up> <up>
> C-SPC C-n C-n C-w <up> M-e C-h e <f11> s c M-> <up>
> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
> <up> <up> <up> <up> <up> <up> <up> <up> C-SPC C-n C-n
> C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
> C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
> C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
> C-n C-n C-n C-n C-n C-n C-x r s a C-g M-x r e p o r
> t - e m a c s - b u <tab> <return>
>
> Recent messages:
> Type C-x 4 C-o RET to restore the other window, C-M-v to scroll help. [2 times]
>
> Parsing BBDB... (frobnicating...done)
> Loading /home/thierry/.emacs.d/yaoddmuse-cache.el (source)...done
> Mark set
> nil
> Auto-saving...done
> Mark set [2 times]
> Quit
> Computing completion candidates...
--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#4427: 23.1; defun* don't work when compiled.
@ 2009-09-18 23:56 Chong Yidong
2010-03-10 20:50 ` Thierry Volpiatto
0 siblings, 1 reply; 6+ messages in thread
From: Chong Yidong @ 2009-09-18 23:56 UTC (permalink / raw
To: Thierry Volpiatto; +Cc: 4427
> In traverselisp.el, i use cl stuff with
> (eval-when-compile (require 'cl)) at start of file.
> I have functions that are like:
> (defun* foo (&key a b)...
>
> They all work fine after compiling file.
>
> However, i have one new function that don't work when compiling file but
> work as normal when loading the .el file, or evaluate the function with
> C-M x.
Could you try to make a small, self-contained test case? Your example
is not small, and it is not self-contained (it calls
traverse-find-readlines). This makes it difficult to debug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#4427: 23.1; defun* don't work when compiled.
2009-09-18 23:56 bug#4427: 23.1; defun* don't work when compiled Chong Yidong
@ 2010-03-10 20:50 ` Thierry Volpiatto
2009-09-14 10:24 ` Thierry Volpiatto
0 siblings, 1 reply; 6+ messages in thread
From: Thierry Volpiatto @ 2010-03-10 20:50 UTC (permalink / raw
To: Chong Yidong; +Cc: 4427
Hi, sorry for very late reply, but i couldn't make a small recipe
reproducing that, however that lead to another bug with defsubst*.
Here a file foo.el that contain this very useful code:
(eval-when-compile (require 'cl))
(defsubst* compare-a-b (a b &key (test 'eq))
(funcall test a b))
1) save the file
2) Go in emacs -Q
3) load the file (foo.el)
,----
| Loading /home/thierry/tmp/foo.el (source)...
| Load error for /home/thierry/tmp/foo.el:
| (void-function defsubst*)
`----
That is the same if you (require 'cl) instead of (eval-when-compile...)
Now compile (always in emacs -Q) the file and load it (foo.elc)
That work as expected.
Chong Yidong <cyd@stupidchicken.com> writes:
>> In traverselisp.el, i use cl stuff with
>> (eval-when-compile (require 'cl)) at start of file.
>> I have functions that are like:
>> (defun* foo (&key a b)...
>>
>> They all work fine after compiling file.
>>
>> However, i have one new function that don't work when compiling file but
>> work as normal when loading the .el file, or evaluate the function with
>> C-M x.
>
> Could you try to make a small, self-contained test case? Your example
> is not small, and it is not self-contained (it calls
> traverse-find-readlines). This makes it difficult to debug.
>
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#4427: 23.1; defun* don't work when compiled.
2009-09-14 10:24 ` Thierry Volpiatto
2009-09-14 12:29 ` Thierry Volpiatto
@ 2010-03-12 3:19 ` Glenn Morris
2010-03-12 7:07 ` Thierry Volpiatto
2 siblings, 0 replies; 6+ messages in thread
From: Glenn Morris @ 2010-03-12 3:19 UTC (permalink / raw
To: 4427-done
Thierry Volpiatto wrote:
> | Loading /home/thierry/tmp/foo.el (source)...
> | Load error for /home/thierry/tmp/foo.el:
> | (void-function defsubst*)
Fixed in emacs-23 branch by adding an autoload cookie for defsubst*.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#4427: 23.1; defun* don't work when compiled.
2009-09-14 10:24 ` Thierry Volpiatto
2009-09-14 12:29 ` Thierry Volpiatto
2010-03-12 3:19 ` Glenn Morris
@ 2010-03-12 7:07 ` Thierry Volpiatto
2 siblings, 0 replies; 6+ messages in thread
From: Thierry Volpiatto @ 2010-03-12 7:07 UTC (permalink / raw
To: bug-gnu-emacs
Glenn Morris <rgm@gnu.org> writes:
> Thierry Volpiatto wrote:
>
>> | Loading /home/thierry/tmp/foo.el (source)...
>> | Load error for /home/thierry/tmp/foo.el:
>> | (void-function defsubst*)
>
> Fixed in emacs-23 branch by adding an autoload cookie for defsubst*.
Nice, thanks.
--
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-03-12 7:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-18 23:56 bug#4427: 23.1; defun* don't work when compiled Chong Yidong
2010-03-10 20:50 ` Thierry Volpiatto
2009-09-14 10:24 ` Thierry Volpiatto
2009-09-14 12:29 ` Thierry Volpiatto
2010-03-12 3:19 ` Glenn Morris
2010-03-12 7:07 ` Thierry Volpiatto
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.