Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
jsinglet committed Oct 20, 2013
0 parents commit f398f4c
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions latex-preview-pane-pkg.el
@@ -0,0 +1 @@
(define-package "latex-preview-pane" "20131020" "Makes LaTeX editing less painfull by providing a updatable preview pane" (quote nil))
121 changes: 121 additions & 0 deletions latex-preview-pane.el
@@ -0,0 +1,121 @@
;;; latex-preview-pane.el --- Makes LaTeX editing less painfull by providing a updatable preview pane

;; Copyright (C) 2013 John L. Singleton <jsinglet@gmail.com>

;; Author: John L. Singleton <jsinglet@gmail.com>
;; Keywords: latex, preview
;; Version: 20131020

;; This file is *NOT* part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;; The latest version of cygwin-mount.el can always be found at
;; https://github.com/jsinglet/latex-preview-pane


;;
;; System specific configuration.
;;

(if (eq window-system 'w32)
(progn
(setq pdf-latex-command "pdflatex")
(setq view-buffer-command "start")

)
)

(if (eq system-type 'darwin)
(progn
(setq pdf-latex-command "pdflatex")
(setq view-buffer-command "open")
)
)

(if (eq system-type 'gnu/linux)
(progn
(setq pdf-latex-command "pdflatex")
(setq view-buffer-command "xdg-open")
)
)

(if (eq system-type 'gnu/kfreebsd)
(progn
(setq pdf-latex-command "pdflatex")
(setq view-buffer-command "xdg-open")
)
)




;;
;; Updates an external preview program of the current latex file
;;
(defun latex-preview-update ()
(interactive)
(if (eq (call-process pdf-latex-command nil "*pdflatex-buffer*" nil buffer-file-name) 1)
(if (y-or-n-p "PDF Generation Failed. View Errors?") (switch-to-buffer "*pdflatex-buffer*"))
(start-process "Preview"
(get-buffer-create "*pdflatex-buffer*")
view-buffer-command
(replace-regexp-in-string ".tex" ".pdf" buffer-file-name)
))
)


;;
;; If a preview pane is open, updates the preview pane on save.
;;
(defun latex-preview-pane-update ()
(interactive)
(when (eq major-mode 'latex-mode)
(progn
(message "Updating LaTeX Preview Pane")
;;(save-buffer)
(latex-preview-pane-update-p))))


(defun latex-preview-pane-update-p ()
(if (eq (call-process pdf-latex-command nil "*pdflatex-buffer*" nil buffer-file-name) 1)
(if (y-or-n-p "PDF Generation Failed. View Errors?") (switch-to-buffer "*pdflatex-buffer*"))
;; if we are currently viewing the document in a pane, we refresh it.
(let ((tex-buff (current-buffer))
(pdf-buff (replace-regexp-in-string ".tex" ".pdf" (buffer-name))))

(if (not (eq (get-buffer-window pdf-buff) nil))
(progn
(switch-to-buffer-other-window pdf-buff)
(doc-view-revert-buffer nil t)
(switch-to-buffer-other-window tex-buff)
)
))))


(add-hook 'after-save-hook 'latex-preview-pane-update)


(eval-after-load 'latex-mode
'(define-key LaTeX-mode-map (kbd "s-p") 'latex-preview-update))

(eval-after-load 'latex-mode
'(define-key LaTeX-mode-map (kbd "M-p") 'latex-preview-update))

(eval-after-load 'latex-mode
'(define-key LaTeX-mode-map (kbd "<f15>") 'latex-preview-update))


0 comments on commit f398f4c

Please sign in to comment.