all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#16319: 24.3.50; `case' macro not expanded in advice
@ 2014-01-01 22:05 Drew Adams
  2014-01-02 15:14 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Drew Adams @ 2014-01-01 22:05 UTC (permalink / raw)
  To: 16319

1. This bug:

emacs -Q

Put this in a file foo.el and byte-compile it.

(eval-when-compile (require 'cl)) ;; case, 

(when (fboundp 'file-cache-add-file)
  (defadvice file-cache-add-file (around bmkp-autofile-filecache activate)
    "Respect option `bmkp-autofile-filecache'."
    (case bmkp-autofile-filecache
      (autofile-only     (bmkp-autofile-set (ad-get-arg 0) nil nil 'NO-UPDATE-P))
      (autofile+cache    (progn ad-do-it  (bmkp-autofile-set (ad-get-arg 0) nil nil 'NO-UPDATE-P 'MSG-P)))
      (cache-only        ad-do-it))))

emacs -Q
M-x load-file foo.elc

M-: (file-cache-add-file "foo.el")

Debugger entered--Lisp error: (void-function case)
  (case bmkp-autofile-filecache (autofile-only (bmkp-autofile-set file 
    nil nil (quote NO-UPDATE-P))) (autofile+cache (progn (setq
    ad-return-value (with-no-warnings (funcall ad--addoit-function
    file))) (bmkp-autofile-set file nil nil (quote NO-UPDATE-P) (quote
    MSG-P)))) (cache-only (setq ad-return-value (with-no-warnings
    (funcall ad--addoit-function file))))) 
  (let (ad-return-value) (case bmkp-autofile-filecache (autofile-only
    (bmkp-autofile-set file nil nil (quote NO-UPDATE-P)))
    (autofile+cache (progn (setq ad-return-value (with-no-warnings
    (funcall ad--addoit-function file))) (bmkp-autofile-set file nil nil
    (quote NO-UPDATE-P) (quote MSG-P)))) (cache-only (setq
    ad-return-value (with-no-warnings (funcall ad--addoit-function
    file))))) ad-return-value) 
  ad-Advice-file-cache-add-file(#[...])
  file-cache-add-file("foo.el")
  eval((file-cache-add-file "foo.el") nil)
  eval-expression((file-cache-add-file "foo.el") nil)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

2. Another (minor), related bug:

As a workaround, I defined a helper function, which has just the
`case' sexp, and I use that in the defadvice.  But then I get a
warning about `ad-do-it' being an undefined variable.  So I work
around that by adding (defvar ad-do-it).  But that's not right
either, since `ad-do-it' is not a variable.

Fixing #1 will take care of #2.  If you do not fix #1 then at least
the byte-compiler should not flag `ad-do-it' as an undefined
variable.

In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2013-12-27 on ODIEONE
Bzr revision: 115778 rgm@gnu.org-20131228000456-1797o8z6veuyozs0
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/binary --enable-checking=yes,glyphs
 'CFLAGS=-O0 -g3' LDFLAGS=-Lc:/Devel/emacs/lib
 CPPFLAGS=-Ic:/Devel/emacs/include'





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

* bug#16319: 24.3.50; `case' macro not expanded in advice
  2014-01-01 22:05 bug#16319: 24.3.50; `case' macro not expanded in advice Drew Adams
@ 2014-01-02 15:14 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2014-01-02 15:14 UTC (permalink / raw)
  To: Drew Adams; +Cc: 16319-done

Indeed macros in defadvice are expanded only at run-time.
Use advice-add which does not suffer from this problem.


        Stefan





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

end of thread, other threads:[~2014-01-02 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-01 22:05 bug#16319: 24.3.50; `case' macro not expanded in advice Drew Adams
2014-01-02 15:14 ` Stefan Monnier

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.