hns - 日記自動生成システム - Version 2.19.9

先月 2010年04月 来月
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
Namazu for hns による簡易全文検索
詳しくは 詳細指定/ヘルプを参照して下さい
検索式:

2010年04月08日(木) 旧暦 [n年日記] [更新:"2010/04/08 08:32:52"]

#1 [Emacs] batch M-x sort-lines

batch で、譜の内容を emacs 内部コードで整列するには、 どうすれば良いのだろうか。
(provide 'batch-sort-file)

(defun batch-sort-file()
  "Just sort file, important thing is: done by emacs internal code order"
   (interactive)
   (insert-file-contents "/tmp/1")
   (sort-lines nil (point-min) (point-max))
   (write-file "/tmp/1.out")
)
以上のようなものを batch-sort-file.el という名前で 用意しておいて、次のように入力すると、
emacs -batch -q -no-site-file -l batch-sort-file.el -f batch-sort-file
/tmp/1 -> /tmp/1.out に期待される動作をするけれど、この /tmp/1, /tmp/1.out に任意の名前を与えるにはどうすれば良いのだろう。
command-line-args-left という変数に引数のリストが入るらしい

次のように書いておいて、

(provide 'batch-sort-file)

(defun batch-sort-file()
  "Just sort file, important thing is: done by emacs internal code order"
   (interactive)
   (set 'in_file (car command-line-args-left))
   (set 'out_file(car (cdr command-line-args-left)))
   (insert-file-contents in_file)
   (sort-lines nil (point-min) (point-max))
   (write-file out_file)
)
;;; batch-sort-file.el ends here
次のようにシェルで起動すれば input-file -> output-file と書替えてくれる
emacs -batch -q -no-site-file -l batch-sort-file.el -f batch-sort-file  \
  input-file output-file



最近の日記
2024年03月10日
停電 (瞬電)
2024年03月03日
the second try on bare-metal
useradd
2024年02月29日
opendkim and senmail
2024年01月24日
chat/iam 0.0.8
2024年01月21日
uselocale vs setlocale (textproc/R-readxl)
以上、1 日分です。
タイトル一覧
カテゴリ分類
Powered by hns-2.19.9, HyperNikkiSystem Project

Count.cgi (since 2000/02/05)