elisp是一种很好的语言,我发现它可以处理所有类型的工作,但是我可以像shell脚本一样使用它吗?
即从控制台执行一些*.el文件,而不启动Emacs.或者启动Emacs,但不要进入交互模式.
在Python中,你可能会做类似的事情
fout = open('out','w')
fin = open('in')
for line in fin:
fout.write(process(line)+"\n")
fin.close()
fout.close()
Run Code Online (Sandbox Code Playgroud)
(我认为它在许多其他语言中也会类似).在Emacs Lisp中,你会做类似的事吗?
(find-file 'out')
(setq fout (current-buffer)
(find-file 'in')
(setq fin (current-buffer)
(while moreLines
(setq begin (point))
(move-end-of-line 1)
(setq line (buffer-substring-no-properties begin (point))
;; maybe
(print (process line) fout)
;; or
(save-excursion
(set-buffer fout)
(insert (process line)))
(setq moreLines (= 0 (forward-line 1))))
(kill-buffer fin)
(kill-buffer fout)
Run Code Online (Sandbox Code Playgroud)
我从Emacs Lisp获得灵感(和代码):逐行处理文件.或者我应该尝试完全不同的东西?以及如何""从print语句中删除?
如何传递参数 -q -d -Q -t -L -fg -bg --color 等?
执行像emacs --script -Q <scriptname> <arguments>definetely 这样的操作不会传递emacs 中使用的参数。那么该怎么做呢?