Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtain buffer file name without extension in .emacs

Tags:

emacs

lisp

elisp

I am trying to make shortcuts for portable emacs linking to a portable LaTeX compiler and R for Sweave, but I know very little about the language used in .emacs (this is Lisp?)

Currently I am using fullpath-relative-to-current-file obtained from http://xahlee.org/emacs/elisp_relative_path.html to get the path to .emacs (which is in USBDRIVE/Documents), then get the relative path to the compiler and call it on buffer-file-name which is the full path and filename including extension of the extension:

(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")))
            )
        )
)   

This allows me to use C-c s to run LaTeX on a tex file and Sweave on an Rnw file. Now I would like to include calls to bibtex, but for that I need the filename and path of the tex file without extension. How can I do that?

like image 413
Sacha Epskamp Avatar asked Jan 03 '12 17:01

Sacha Epskamp


1 Answers

Try file-name-sans-extension. For more details, read the File Name Components section of the manual.

like image 194
Trey Jackson Avatar answered Oct 08 '22 05:10

Trey Jackson