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?
Try file-name-sans-extension
. For more details, read the File Name Components section of the manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With