【问题标题】:Obtain buffer file name without extension in .emacs在 .emacs 中获取不带扩展名的缓冲区文件名
【发布时间】:2012-01-03 17:17:57
【问题描述】:

我正在尝试为可移植的 emacs 链接到可移植的 LaTeX 编译器和用于 Sweave 的 R 创建快捷方式,但我对 .emacs 中使用的语言知之甚少(这是 Lisp?)

目前我正在使用从http://xahlee.org/emacs/elisp_relative_path.html 获得的fullpath-relative-to-current-file 获取.emacs 的路径(在USBDRIVE/Documents 中),然后获取编译器的相对路径并在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")))
            )
        )
)   

这允许我使用C-c stex 文件上运行LaTeX,并在Rnw 文件上使用Sweave。现在我想包括对 bibtex 的调用,但为此我需要 tex 文件的文件名和路径,不带扩展名。我该怎么做?

【问题讨论】:

    标签: emacs lisp elisp


    【解决方案1】:

    试试file-name-sans-extension。有关详细信息,请阅读手册的File Name Components 部分。

    【讨论】:

    • 谢谢。 (file-name-sans-extension buffer-file-name) 工作。
    猜你喜欢
    • 1970-01-01
    • 2011-06-15
    • 2011-10-02
    • 2011-05-25
    • 2015-05-20
    • 1970-01-01
    • 2015-05-13
    相关资源
    最近更新 更多