16

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 Link 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?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Sacha Epskamp
  • 46,463
  • 20
  • 113
  • 131

1 Answers1

31

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

Trey Jackson
  • 73,529
  • 11
  • 197
  • 229