Last active
August 10, 2017 04:20
-
-
Save k0f1sh/7915851 to your computer and use it in GitHub Desktop.
emacs lisp をスクリプトとして使うサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!escript | |
;; ライブラリの読み込み | |
;; Loading...と標準エラー出力に出てしまう(escript側で出ないようにしている) | |
(load-file (expand-file-name "~/.emacs.d/cli-util.el")) | |
(load-file (expand-file-name "~/.emacs.d/el-get/dash/dash.el")) | |
(load-file (expand-file-name "~/.emacs.d/el-get/s/s.el")) | |
;; 組み込みライブラリの読み込み | |
(require 'json) | |
(setq a (json-encode-alist '(("a" ("hoge" "fuga")) | |
("b" "piyo")))) | |
;; 出力 | |
(pp a) | |
;; argv = 引数リスト | |
(pp argv) | |
;; 標準入力から一行読み込み | |
(setq b (read-string "string: ")) | |
(pp b) | |
;; 実行結果 | |
;; $ ./script.el a b c | |
;; "{\"a\":{\"hoge\":[\"fuga\"]}, \"b\":[\"piyo\"]}" | |
;; ("a" "b" "c") | |
;; string: emacs! | |
;; "emacs!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment