emacs - How to output elisp bytecode to a custom directory? -


i need output elisp bytecode generated batch-compile custom directory. customisation value byte-compile-dest-file-function seems relevant this:

(defcustom byte-compile-dest-file-function nil   "function function `byte-compile-dest-file' call. should take 1 argument, name of emacs lisp source file name, , return name of compiled file."   :group 'bytecomp   :type '(choice (const nil) function)   :version "23.2") 

i went far /opt/local/bin/emacs -batch --eval '(defun my-dest-file-function (filename) (let ((pwd (expand-file-name ".")) (basename (replace-regexp-in-string ".*/" "" filename))) (concat (file-name-as-directory pwd) basename "c"))) (setq byte-compile-dest-file-function (quote my-dest-file-function)) (batch-byte-compile)' /users/michael/workshop/project/example/elisp/example1.el

the elisp code easier read in unwrapped form:

(defun my-dest-file-function (filename)  (let ((pwd (expand-file-name "."))        (basename (replace-regexp-in-string ".*/" "" filename)))  (concat (file-name-as-directory pwd) basename "c"))) (setq byte-compile-dest-file-function (quote my-dest-file-function)) (batch-byte-compile) 

the function my-dest-file-function computes correct filenames not seem used @ all, nor (batch-byte-compile) function used @ all.

how can correct elisp code above produce desired effect? want avoid single quote in elisp code work shell , makefiles.

my emacs version 24.5.1.

you need wrap whole thing in progn:

(progn   (defun my-dest-file-function (filename)     (let ((pwd (expand-file-name "."))           (basename (replace-regexp-in-string ".*/" "" filename)))       (concat (file-name-as-directory pwd) basename "c")))   (setq byte-compile-dest-file-function (quote my-dest-file-function))   (batch-byte-compile)) 

before, executing first statement, defun, nothing on own.