elisp的是一个良好的语言,我觉得它可以处理所有类型的工作,但我可以用它像一个shell脚本?
即从控制台执行一些* .el文件,而无需启动Emacs的。 或启动Emacs的,但不进入交互模式。
elisp的是一个良好的语言,我觉得它可以处理所有类型的工作,但我可以用它像一个shell脚本?
即从控制台执行一些* .el文件,而无需启动Emacs的。 或启动Emacs的,但不进入交互模式。
您可以在不启动编辑器界面最肯定运行在Emacs elisp的脚本。
以下是在SO从几个非常有用的Q&作为对这里的主题复制我做了笔记/(尤其是以下两种)。
其中许多信息,多之外,还覆盖在下面的很好的概述,这是推荐阅读:
;;;; Elisp executable scripts
;; --batch vs --script
;; M-: (info "(emacs) Initial Options") RET
;; M-: (info "(elisp) Batch Mode") RET
;; Processing command-line arguments (boiler-plate)
;; http://stackoverflow.com/questions/6238331/#6259330 (and others)
;;
;; 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 to exit explicitly with `kill-emacs' at
;; the end of the script (to prevent Emacs from carrying on with other
;; processing, and/or visiting non-option arguments as files).
;;
;; #!/bin/sh
;; ":"; exec emacs -Q --script "$0" -- "$@" # -*-emacs-lisp-*-
;; (pop argv) ; Remove the "--" argument
;; ;; (setq debug-on-error t) ; if a backtrace is wanted
;; (defun stdout (msg &optional args) (princ (format msg args)))
;; (defun stderr (msg &optional args) (princ (format msg args)
;; #'external-debugging-output))
;; ;; [script body here]
;; Always exit explicitly. This returns the desired exit
;; status, and also avoids the need to (setq argv nil).
;; (kill-emacs 0)
;; Processing with STDIN and STDOUT via --script:
;; https://stackoverflow.com/questions/2879746/#2906967
;;
;; #!/bin/sh
;; ":"; exec emacs -Q --script "$0" -- "$@" # -*-emacs-lisp-*-
;; (pop argv) ; Remove the "--" argument
;; (setq debug-on-error t) ; if a backtrace is wanted
;; (defun stdout (msg &optional args) (princ (format msg args)))
;; (defun stderr (msg &optional args) (princ (format msg args)
;; #'external-debugging-output))
;; (defun process (string)
;; "Reverse STRING."
;; (concat (nreverse (string-to-list string))))
;;
;; (condition-case nil
;; (let (line)
;; (while (setq line (read-from-minibuffer ""))
;; (stdout "%s\n" (process line))))
;; (error nil))
;;
;; ;; Always exit explicitly. This returns the desired exit
;; ;; status, and also avoids the need to (setq argv nil).
;; (kill-emacs 0)
Emacs的一边,只有其他的elisp解释/编译我所知道的是狡诈。 如果你热衷于在elisp的一般编码,这应该是值得一试(特别是如果性能是一个问题)。