jsinglet / latex-preview-pane

Makes LaTeX editing less painful by providing a updatable preview pane
129 stars 24 forks source link

Code for automatic loading of latex-preview-pane #13

Closed doctorate closed 9 years ago

doctorate commented 10 years ago

this code worked when written in the .emacs file:

(add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)

jsinglet commented 10 years ago

The correct code is actually as documented on the wiki. It is what I use personally. What you have done will work, but it's not optimal. Is it possible that you have a problem elsewhere in your .emacs file?

If you can send me your .emacs file I can have a look and see what might be the issue.

doctorate commented 10 years ago
;;; default.el --- Default configuration for GNU Emacs
;;; Used mainly to load custom extensions.
;;; (Loaded *after* any user and site configuration files)

;; Copyright (C) 2012 Vincent Goulet

;; Author: Vincent Goulet

;; This file is part of Emacs for Windows Modified
;; http://vgoulet.act.ulaval.ca/emacs

;; GNU Emacs for Windows Modified 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 3, or (at your option) any later version.

;; GNU Emacs 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., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;;
;;; Version number of Emacs Modified
;;;
;; Define variable and function 'emacs-modified-version'
(require 'version-modified)

;; Line numbers display
(require 'linum)
(global-linum-mode 1)

;;;
;;; Easier printing
;;;
(require 'w32-winprint)
(require 'htmlize-view)
(htmlize-view-add-to-files-menu)

;;;
;;; ESS
;;;
;; Load ESS and activate the nifty feature showing function arguments
;; in the minibuffer until the call is closed with ')'.
(require 'ess-site)

;;;
;;; org
;;;
;; Load recent version of org-mode.
(require 'org-install)

;;;
;;; AUCTeX
;;;
;; We assume that MiKTeX (http://www.miktek.org) is used for
;; TeX/LaTeX. Otherwise, change the (require ...) line as per the
;; AUCTeX documentation.
;; this from AUCTeX documentation to open multiple files page1
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq-default TeX-PDF-mode t)

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
;; (require 'tex-mik) ; this is not the case, here is TexLive 2013

(require 'package)
(add-to-list 'package-archives
  '("melpa" . "http://melpa.milkbox.net/packages/") t)

;; to get doc-view-mode
(setq doc-view-ghostscript-program "gswin32c")

;;;
;;; SVN
;;;
;; Support for the Subversion version control system
;; (http://http://subversion.tigris.org/) in the VC backend. Use 'M-x
;; svn-status RET' on a directory under version control to update,
;; commit changes, revert files, etc., all within Emacs. Requires an
;; installation of Subversion in the path.
(add-to-list 'vc-handled-backends 'SVN)
(require 'psvn)

;;;
;;; Other site extensions
;;;
;; Emacs will load all ".el" files in "
;; C:/Program Files/GNU Emacs 24.3/site-lisp/site-start.d/"
;; on startup.
(mapc 'load
      (directory-files "C:/GNU Emacs 24.3/site-lisp/site-start.d" t "\\.el\\'"))

;; I added that later
;; set defualt font
(set-default-font "Consolas-14")
;(set-default-font "Simplified Arabic-14")

;; color theme
(load-theme 'cyberpunk t)

;; cursor blink
(blink-cursor-mode -1)

;; to set the current column
(setq column-number-mode t)

;; spell checker Aspell
;(setq-default ispell-program-name "C:/Program Files/Aspell/bin/aspell.exe")
(setq-default ispell-program-name "C:/GNU Emacs 24.3/aspell/bin/aspell.exe")
(setq text-mode-hook '(lambda() (flyspell-mode t) ))
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)
jsinglet commented 10 years ago

Are you placing that code in your .emacs file? Or in default.el?

doctorate commented 10 years ago

In the default.el file, I play only with default.el file. That's what I usually mean when I refer to .emacs file? I don't have .emacs file but .emacs.d folder, I guess. I have another emerging issue of PDF preview - pls see update of : http://tex.stackexchange.com/questions/190882/what-is-the-best-side-by-side-preview-method-for-emacs24-auctex

jsinglet commented 10 years ago

The .emacs file isn't the same as the default.el file.

Take a look at this: https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html

That code needs to be in your .emacs file, which should be located in your home directory (which depends on how you installed emacs, but generally not IN your .emacs.d but in the same directory as it).

In emacs, edit a new file C-x C-f ~/.emacs and place the following in it:

(require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)

(latex-preview-pane-enable)

Then remove the latex-preview-pane code from your default.el (including that hook you wrote). I'd be interested to know if this fixes your problem.

doctorate commented 10 years ago

Side question: how do I know whether this piece of code should go to .emacs file or to the default.el file? I added some code like theme, fonts and many others to the default.el only - or they can go both way? In the meantime, I will do what you suggested and come back to you later

doctorate commented 10 years ago

Ok. I created init.el file in the home directory ~/.emacs.d/ and wrote what you suggested above, deleted the hook in the default.el and It threw the same error that I already encountered first time I tried to follow the wike code:

Warning (initialization): An error occurred while loading `c:/GNU Emacs 24.3/.emacs.d/init.el':

Symbol's function definition is void: latex-preview-pane-enable

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.
jsinglet commented 10 years ago

Hi Doctorate,

Thanks for the feedback, however that's not what I was asking you to do. Before moving forward I would suggest that you take a bit to familiarize yourself with the various emacs configuration files, their location and purpose. I'd love to write it out for you all here, but there are so many other web pages that do a better job than I could.

A good rule of thumb is really that you should do all your customization in .emacs -- I personally never use init.el, defaults.el or others. There are cases where it makes sense, however I have yet to encounter them.

To be clear, what I was asking you to do was to place that code in your .emacs file. It's a file literally named ".emacs" in your home directory. If you take a look at the link I sent you and do some more reading it will start to make sense, I promise!

Best, JLS

doctorate commented 10 years ago

Ok I will create .emacs, but that would be very strange as both init.el and .emacs should be equivalent according to the link you sent, quote:

filenames ~/.emacs, ~/.emacs.el, or ~/.emacs.d/init.el;

Nevertheless, I created the .emacs file in the home dir and added the code. made sure no other code in other files. restart. now without the error message, but also without latex-preview-pane in the menu. So it did not load automatically.

gvol commented 10 years ago

@doctorate, I think you have to run

(package-initialize)

to get packages to autoload.