2012-01-03 18 views
7

移植可能なLaTeXコンパイラとSweaveにリンクする移植可能なemacsのショートカットを作成しようとしていますが、.emacs(これはLispですか?)で使用される言語はほとんど分かりません.emacsで拡張子なしのバッファファイル名を取得する

私は( USBDRIVE/Documentsである) .emacsへのパスを取得するために http://xahlee.org/emacs/elisp_relative_path.htmlから得られ fullpath-relative-to-current-fileを使用しています

現在は、コンパイラへの相対パスを取得し、拡張子の拡張子を含む完全なパスとファイル名ですbuffer-file-nameでそれを呼び出します。

(global-set-key (kbd "C-c s") 
     (lambda() 
      (interactive) 
      (cond ((string-equal (file-name-extension (buffer-file-name)) "tex") 
       (shell-command (concat (fullpath-relative-to-current-file "../PortableApps/miktex/miktex/bin/pdflatex ") buffer-file-name))) 
      ) 
      (cond ((string-equal (file-name-extension (buffer-file-name)) "Rnw") 
       (shell-command (concat (fullpath-relative-to-current-file "../PortableApps/R/R-2.14.1/bin/R CMD Sweave ") buffer-file-name " --pdf"))) 
      ) 
     ) 
) 

これにより、ファイルでLaTeXを実行し、RnwファイルでSweaveを実行するのにC-c sを使用することができます。今、私はbibtexへの呼び出しを含めたいと思っていますが、そのためには拡張子なしでtexファイルのファイル名とパスが必要です。どうやってやるの?

答えて

22

Try file-name-sans-extension詳細については、マニュアルのFile Name Componentsのセクションを参照してください。

+2

ありがとうございました。 '(ファイル名-sans-extensionバッファーファイル名)'が機能しました。 –

関連する問題