Skip to main content
5 of 5
added 37 characters in body
gavenkoa
  • 3.6k
  • 21
  • 37

Fix for "Invalid function:" error when external function become a macro

For:

(defun my-w3m-view-url ()
  (interactive)
  (browse-url (w3m-anchor)))
(eval-after-load 'w3m
  (define-key w3m-minor-mode-map (kbd "RET") #'my-w3m-view-url))

when byte-compiled I get error on key binding RET usage:

my-w3m-view-url: Invalid function: w3m-anchor

This because w3m-anchor isn't a function but become macro. I try to add:

(eval-when-compile
  (require 'w3m-util nil :no-error))

before lines that uses w3m-anchor. But this doesn't help me.

I load .emacs-my.elc file made by:

emacs -Q --batch --eval='(byte-compile-file "~/.emacs.d/.emacs-my")'

UPDATE As suggest @Iqbal Ansari I further debug issue. For some reason byte compiled file have function call instead of expanded macro:

$ strings .emacs-my.elc | grep w3m-anchor
840:(defalias 'my-w3m-view-url #[nil "\300\301 !\207" [browse-url w3m-anchor] 2 nil nil])

Full .emacs-my file source code is available at https://sourceforge.net/u/gavenkoa/dot-emacs/ci/default/tree/.emacs-my Corresponding installation steps are available at https://sourceforge.net/u/gavenkoa/dot-emacs/ci/default/tree/Makefile

gavenkoa
  • 3.6k
  • 21
  • 37