2011-12-14 10 views
2

私はlatexの数を調べるために使用する関数を持っていて、通常はbriefというコマンドを使うのが好きです。 "-inc" "-brief"で実行する代わりに、これを入力オプションに変更する方法を教えてください。ミニバッファに自分のパラメータセットを入力して、texcountコマンドで実行することができました。ほとんどの場合、コマンドがコンマで区切られ、次に、以下の形式に変換された方がよいでしょう。または、私は自分ですべてを入力することができます"-inc" "-brief"必要な場合。Emacsでtexcountを使ってLatexやtexファイルの単語数を調べる(オプションのパラメータが必要な場合)

(defun latex-word-count() 
(interactive) 
    (let* ((this-file (buffer-file-name)) 
    (word-count 
     (with-output-to-string 
     (with-current-buffer standard-output 
      (call-process "texcount" nil t nil "-inc" "-brief" this-file))))) 
(string-match "\n$" word-count) 
(message (replace-match "" nil nil word-count)))) 

答えて

0

未テスト:あなたが好きなようにしたいために、あなたに多くのオプションとして入力することができます

 
    (defun latex-word-count() 
     (interactive) 
     (let* ((this-file (buffer-file-name)) 
      (options (let ((opts ()) 
           opt) 
          (while (not (equal (setq opt (read-string "Option: ")) 
               "")) 
          (push opt opts)) 
          (nreverse opts))) 
      (word-count (with-output-to-string 
          (with-current-buffer standard-output 
           (apply 'call-process "texcount" nil t nil 
             (append options (list this-file))))))) 
     (string-match "\n$" word-count) 
     (message (replace-match "" nil nil word-count)))) 

。タイプ入力なしのRETを押すと終了します。

あなたはオプションがtexcountに受け入れられるものを知っている場合は、そのCOLLECTION引数としてこれらのオプションのリストを提供し、read-stringの代わりにcompleting-readを使用することができます。 HTH。

関連する問題