Skip to content

Instantly share code, notes, and snippets.

@k0f1sh
Last active August 10, 2017 04:20
Show Gist options
  • Save k0f1sh/7915851 to your computer and use it in GitHub Desktop.
Save k0f1sh/7915851 to your computer and use it in GitHub Desktop.
emacs lisp をスクリプトとして使うサンプル
#!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