You are not logged in.

#1 2008-11-08 00:04:10

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Emacs Lisp question

How do I get the filename of the file open in the active buffer? I'm trying to make a function to compile a LaTeX file into a PDF - when I do this i can uninstall Texmaker. Here is what I have so far:

; My LaTeX Wizard
(defun latex-wizard ()
  (interactive)
  (insert "\\documentclass[12pt,a4paper,oneside]{article}\n")
  (insert "\\usepackage[latin1]{inputenc}\n")
  (insert "\\usepackage{amsmath}\n")
  (insert "\\usepackage{amsfonts}\n")
  (insert "\\usepackage{amssymb}\n")
  (insert "\\author{Michael Walker}\n")
  (insert "\\title{}\n")
  (insert "\\begin{document}\n")
  (insert "\n")
  (insert "\\maketitle{}\n")
  (insert "\n")
  (insert "\\end{document}\n"))

; Compile a LaTeX source file into a PDF.
(defun latex-compile-pdf ()
  (interactive)
  (execute "/usr/bin/pdflatex" "-interaction=nonstopmode" ""))

(provide 'latex-wizard)
(provide 'latex-compile-pdf)

edit: I also need to know how to escape the returned filename so it works as a command line argument.
edit 2: Finally, I need to know how to make it output the .pdf, .loc, etc files in the same directory as the .tex file.

Last edited by Barrucadu (2008-11-08 00:26:30)

Offline

#2 2008-11-08 01:06:05

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: Emacs Lisp question

(buffer-file-name) for the first question.

Offline

#3 2008-11-08 17:43:05

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: Emacs Lisp question

I came up with a solution after turning to google and posted it in my blog

Offline

#4 2008-11-09 03:59:50

Jessehk
Member
From: Toronto, Ontario, Canada
Registered: 2007-01-16
Posts: 152

Re: Emacs Lisp question

Ever heard of AucTex? It's the standard LaTeX package for emacs and it's really full featured.

Offline

Board footer

Powered by FluxBB