18
elisp的是一個良好的語言,我覺得它可以處理所有類型的工作,但我可以用它像一個shell腳本?運行沒有Emacs的elisp程序?
即從控制檯執行一些* .el文件,而無需啓動Emacs的。或者啓動Emacs,但不要進入交互模式。
elisp的是一個良好的語言,我覺得它可以處理所有類型的工作,但我可以用它像一個shell腳本?運行沒有Emacs的elisp程序?
即從控制檯執行一些* .el文件,而無需啓動Emacs的。或者啓動Emacs,但不要進入交互模式。
可以最肯定不啓動編輯器界面運行在Emacs elisp的腳本。
這裏是在S.O.從幾個非常有用的Q &複製爲關於這個問題我在這裏所做的筆記/ (特別是以下兩個)。
;;;; Elisp executable scripts
;; --batch vs --script
;; M-: (info "(emacs) Initial Options") RET
;; M-: (info "(elisp) Batch Mode") RET
;; Passing additional command-line arguments to Emacs:
;; https://stackoverflow.com/questions/6238331/#6259330
;;
;; For robustness, it's important to both pass '--' as an argument
;; (to prevent Emacs from trying to process option arguments intended
;; for the script), and also set "argv" to nil at the end of the script
;; (to prevent Emacs from visiting the non-option arguments as files).
;;
;; #!/bin/sh
;; ":"; exec emacs --no-site-file --script "$0" -- "[email protected]" # -*-emacs-lisp-*-
;; (print (+ 2 2))
;; (setq argv nil) ;; always end with this
;; Processing with STDIN and STDOUT via --script:
;; https://stackoverflow.com/questions/2879746/#2906967
;;
;; #!/usr/local/bin/emacs --script
;; ;;-*- mode: emacs-lisp;-*-
;;
;; (defun process (string)
;; "just reverse the string"
;; (concat (nreverse (string-to-list string))))
;;
;; (condition-case nil
;; (let (line)
;; ;; commented out b/c not relevant for `cat`, but potentially useful
;; ;; (princ "argv is ")
;; ;; (princ argv)
;; ;; (princ "\n")
;; ;; (princ "command-line-args is")
;; ;; (princ command-line-args)
;; ;; (princ "\n")
;;
;; (while (setq line (read-from-minibuffer ""))
;; (princ (process line))
;; (princ "\n")))
;; (error nil))
Emacs的一邊,只有其他的elisp解釋/編譯我所知道的是狡詐。如果你熱衷於在elisp的一般編碼,這應該是值得一試(特別是如果性能是一個問題)。
感謝您的幫助。 – 2012-04-18 14:40:11