短いスクリプトなら --batch --eval
$ emacs --batch --eval '(print (+ 2 (* 6 3)))' 20
外部スクリプトを読むときには --script (emacs 23以降)
(princ "Hello, World!")
$ emacs --script hello.el Hello, World!
(with-temp-buffer (insert-file-contents-literally (car argv)) (search-forward "Japan") (search-forward "Japan") (search-forward "Japan") (let ((point (point))) (search-forward ".") (princ "Japan") (princ (buffer-substring point (1- (point)))) (princ ".\n")))
$ cat japan.txt Japan is an island nation in East Asia. Located in the Pacific Ocean, it lies to the east of the Sea of Japan, China, North Korea, South Korea an d Russia, stretching from the Sea of Okhotsk in the north to the East China Sea and Taiwan in the south. The characters that make up Japan's name mean "sun-origin", which is why the country is sometimes referred to as the "Land of the Rising Sun". Japan is an archipelago of 6,852 islands, the four largest being Honshu, Hokkaido, Kyushu and Shikoku. Together, these four islands hold about 97 percent of the country's land area. Japan has the world's tenth-largest population, with more than 126 million people. Honshū's Greater Tokyo Area includes the de facto capital city of T okyo and several surrounding prefectures. It is the largest metropolitan area in the world, with more than 30 million residents. $ emacs --script dquote.el japan.txt Japan's name mean "sun-origin", which is why the country is sometimes referred to as the "Land of the Rising Sun".