2008年12月23日星期二

放Emacs到U盘上

参考: http://at-aka.blogspot.com/2006/06/portable-emacs-22050-on-usb.html

Emacs for Windows looks for your .emacs file in c:/Document and Setting/USERNAME by default. But USB application must find its init files in the USB memony.

Here the tips!

Put the following codes into f:/emacs+auctex-w32-<date>/Emacs/site-lisp/site-start.el.

 (defvar usb-drive-letter (substring data-directory 0 3)) (defvar usb-home-dir (concat usb-drive-letter "home/"))  (setenv "HOME" usb-home-dir) 

In this section, I use f: for the drive letter of USB flash memory. But please remmember that the drive letter will be changed by each of machines. Do not write the drive letter directly to your init files. Use the variable usb-drive-letter for the drive letter.

Now make directory home in f:/. This is the simple .emacs file in f:/home/

 ;; Portable Emacs init file. ;;;  (setq user-full-name "YOUR NAME") (setq user-mail-address "YOUR EMAIL ADDRESS")  ;; ;; Set environment ;; (defvar usb-site-lisp-dir (expand-file-name "site-lisp" usb-home-dir)) (setq load-path (cons usb-site-lisp-dir load-path)) (let ((dir (delete nil (mapcar (lambda (f)      (unless (string-match "\\.elc?\\'" f) f))           (cddr (directory-files usb-site-lisp-dir t))))))   (setq load-path (append dir load-path))) 

Additional Elisp files should be saved in f:/home/site-lisp/.