2

On my primary computer, I have the following set up for emacs and everything works like a charm. I use emacs cvs, auctex cvs, and latexmk on a Ubuntu 14.04. However, I just put the same set up on another computer running Ubuntu 14.04 but LaTeX files are opened in fundamental-mode.

enter image description here

In my init I have:

;; Start server and set directory
(setq server-socket-dir (format "/tmp/emacs1000"))
;; Not sure if (useruid) does anything or the difference between
;; (server-start) and '(server-mode t) in custom
;(setq server-socket-dir (format "/tmp/emacs1000" (user-uid)))
;(server-start)

;; Package list M-x package-list-packages
(require 'package)
(add-to-list 'package-archives 
         '("marmelade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives 
         '("melpa" . "http://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives 
         '("elpa" . "http://tromey.com/elpa/"))

;; Package initialize
(package-initialize)

;; AucTex & RefTeX
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/")
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTex t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq TeX-save-query nil)

;; Copy and paste between Emac   instances     
(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)

;; Disablin autosave                                                           
(setq auto-save-default nil)

;; Adjusting tab distance
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)

;; Enable Line Numbering
(setq line-number-mode t)
(setq column-number-mode t)

;; Set the fill column
(setq default-fill-column 80)

;; Turn on Auto Fill mode automatically in all modes
;; Auto-fill-mode the the automatic wrapping of lines and insertion of
;; newlines when the cursor goes over the column limit.
;; This should actually turn on auto-fill-mode by default in all major
;; modes. The other way to do this is to turn on the fill for specific modes
;; via hooks.  
(setq auto-fill-mode 1)

;;  Turn on visual line mode
(global-visual-line-mode t)

;; Prevent Emacs from making backup files
(setq make-backup-files nil)

;; Cleverref setup
(eval-after-load
    "latex"
  '(TeX-add-style-hook
    "cleveref"
    (lambda ()
      (if (boundp 'reftex-ref-style-alist)
      (add-to-list
       'reftex-ref-style-alist
       '("Cleveref" "cleveref"
         (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
      (add-to-list 'reftex-ref-style-default-list "Cleveref")
      (TeX-add-symbols
       '("cref" TeX-arg-ref)
       '("Cref" TeX-arg-ref)
       '("cpageref" TeX-arg-ref)
       '("Cpageref" TeX-arg-ref)))))

;; Latexmk setup
(defun run-latexmk ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (TeX-master-file)))
    (TeX-save-document "")
    (TeX-run-TeX "latexmk"
         (TeX-command-expand "latexmk -pdf %s" 'TeX-master-file)
                 master-file))
  (if (plist-get TeX-error-report-switches (intern master-file))
      (TeX-next-error t)
    (progn
      (demolish-tex-help)
      (minibuffer-message "latexmk: done."))))

(add-hook 'LaTeX-mode-hook 
      (lambda ()
        (push 
         '("Latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
           :help "Run Latexmk on file")
         TeX-command-list)))

;; Set okular to open with C-c C-v view option 
(setq TeX-view-program-list
      '(("Okular" "okular --unique %u")))
(setq TeX-view-program-selection '((output-pdf "Okular")))

;; Paren checking
(load "paren")
(add-to-list 'load-path "~/.emacs.d/elpa/rainbow-delimiters-20150320.17")
(require 'rainbow-delimiters)
(global-rainbow-delimiters-mode)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)

;; Adaptive wrap
(add-to-list 'load-path "~/.emacs.d/elpa/adaptive-wrap-0.5")
(require 'adaptive-wrap)

(when (fboundp 'adaptive-wrap-prefix-mode)
  (defun my-activate-adaptive-wrap-prefix-mode ()
    "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
    (if visual-line-mode
        (adaptive-wrap-prefix-mode 1)
      (adaptive-wrap-prefix-mode -1)))
  (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(TeX-PDF-mode t)
 '(TeX-newline-function (quote newline-and-indent))
 '(TeX-show-compilation t)
 '(TeX-source-correlate-method (quote synctex))
 '(TeX-source-correlate-mode t)
 '(TeX-view-program-list (quote (("Okular" "okular -unique %o#src:%n%b"))) t)
 '(TeX-view-program-selection (quote ((output-pdf "Okular"))) t)
 '(compilation-auto-jump-to-first-error t)
 '(inhibit-startup-screen t)
 '(ispell-lazy-highlight nil)
 '(server-mode t))

In my latexmkrc, I have

$pdflatex = 'pdflatex --shell-escape -interaction=nonstopmode %O %S
-file-line-error -synctex=1';

In my bash_aliases, I have the following

alias emacs='emacsclient -t -s server --alternate-editor='
alias ipython='ipython3'

Considering both set ups are identical running the same software, why wont this work on a different computer? I run into this problem every time I have to set back up emacs on any of my computers.

Messages received from C-h e:

Loading paren...done
Starting Emacs daemon.
File mode specification error: (void-function pushnew)
File local-variables error: (void-function pushnew)
When done with a buffer, type C-x #
  • 1
    You seem to be loading auctex.el in your init file. If the problem is related to the AucTex mode being absent, I'd start by trying to locate auctex.el, which I suspect is absent from another computer. – wvxvw Mar 23 '15 at 8:30
  • 1
    @dustin :) That screenshot clears things up. The string within the parentheses provide 3 sets of information.. it's not a single thing. (1) Fundamental mode is enabled (2) You opened that file using emacsclient and thus Server (3) You have visual-line-mode enabled and thus Wrap. – Kaushal Modi Mar 23 '15 at 15:39
  • @dustin So what is it that's not working? Do the latex files always open in Fundamental mode? – Kaushal Modi Mar 23 '15 at 15:41
  • 1
    @dustin After emacs starts up, the *Messages* log should have some errors. You can jump to that buffer directly using C-h e. Does that buffer list error or warning messages? If so, can you update your question with a list of those errors/warnings? – Kaushal Modi Mar 23 '15 at 15:55
  • @wvxvw The (load "auctex.el" nil t t) has the NOERROR argument as nil. So Dustin should be seeing package loading errors if auctex.el (and preview-latex.el) are not found. – Kaushal Modi Mar 23 '15 at 15:56
5

This might be the issue:

(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/")

The packages in that directory don't necessarily come bundled with emacs, they're system-specific and they depend on how you install Emacs. So these packages might be present on one machine but absent from the other.

You should install AucTeX yourself.

  • Call M-x list-packages.
  • In that list install the Auctex package by hitting i x.
  • I use the cvs version off of github so I don't install it through the package manager. I am going to Georgia now so have to look at this later. – dustin Mar 23 '15 at 15:59
  • Also, this everything done was 100% identical to my other system so it is odd it isn't working. – dustin Mar 23 '15 at 16:04
  • @dustin in that case, I recommend you remove all those lines you have which are configuring the load-path, they're doing more harm than good (and they could be the cause). Also remove the package-update-load-path function. Emacs should take care of all that stuff for you, just add (package-initialize) to the top of your init file. – Malabarba Mar 23 '15 at 16:05
  • Added information requested by kaushal – dustin Mar 23 '15 at 16:13
  • If you add (load "paren") (add-to-list 'load-path "~/.emacs.d/elpa/rainbow-delimiters-20150320.17") (add-hook 'prog-mode-hook 'rainbow-delimiters-mode) this to your answer, I will be able to accept. I had to remove (require 'rainbow-delimiters) (global-rainbow-delimiters-mode) – dustin Mar 29 '15 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.