emacs lisp(elisp)程序像脚本一样运行
2014-01-22 19:03
211 查看
elisp程序的运行被称为取值,一般的过程是打开一个emacs编辑器,然后用快捷键C-x C-e 调用函数eval-current-buffer运行当前buffer里的elisp程序。
emacs 22以后支持#!/usr/bin/emacs --script像脚本一样执行elisp程序,这样就没必要打开一个emacs编辑器后再执行了。
下面是一个程序实例,见我的GitHub链接
在终端里运行:
或者直接运行
结果如下:
emacs 22以后支持#!/usr/bin/emacs --script像脚本一样执行elisp程序,这样就没必要打开一个emacs编辑器后再执行了。
下面是一个程序实例,见我的GitHub链接
#!/usr/bin/emacs --script ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; NAME ;; kit.el ---- an example elisp script, which is ;; used to calculate intern salary. ;; ;; USAGE ;; emacs -Q --script kit.el iday ;; ./kit.el iday ;; ;; NOTE ;; #!/ shebang works for emacs22 and later. ;; ;; AUTHOR ;; Aborn Jiang (aborn.jiang@gmail.com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;(print argv) (message "input argument are %s" argv) (message "system-type:%s system-name:%s" system-type system-name) (defun cal-salary (iday) "Calculate the salary for intern in shanghai" (interactive "p") (setq total (* iday 180)) (if (> total 800) (setq value (+ 800 (* 0.8 (- total 800))) tvalue (- total value)) ;; if true (setq value total ;; else part tvalue 0)) (message "You have worked %d day(s), and salary is %d, tax is %d." iday value tvalue) ) (cal-salary (string-to-number (elt argv 0)))
在终端里运行:
emacs -Q --script kit.el 10
或者直接运行
./kit.el 10
结果如下:
相关文章推荐
- 在Windows上让Python脚本像程序一样可以双击运行
- ccl命令行运行lisp脚本
- 解决EntityFrameworkCore “无法将“Add-Migration”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。”
- ASP.NET也像WinForm程序一样运行
- CentOS开机自动运行程序的脚本
- 用shell脚本运行Java程序
- 无法将“Invoke-SqlCmd”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。
- 玄学········为什么在eclipse上更改程序之后运行之后好像没更改一样
- 通过脚本判断一个程序是否在运行
- C++程序通过SpiderMonkey也可以运行javascript脚本了
- CentOS开机自动运行程序的脚本
- 使用Windows的任务计划程序 自动运行脚本设置
- ASP.NET也像WinForm程序一样运行的实现方法
- 脚本,查看一次性快速运行的程序的进程虚拟地址空间
- 怎么在程序运行的时候出现和DELPHI下一样的调试信息???
- 在用Emacs Lisp调用外部程序
- java程序运行脚本
- 使用脚本引擎增加程序运行时动态执行能力(Java篇)
- service.bat : 无法将“service.bat”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。
- linux下并行运行脚本与让程序可靠运行