I configured Emacs on one computer and copied ~/.emacs to a different computer. That other computer uses a newly installed operating system.

Both computers run Ubuntu 16.04 with the latest updates installed and both run Ecmacs 24.5.1 from the Ubuntu repositories.

When I opened a LaTeX document, I got this warning:

I created that document on the first computer using Emacs. On that computer, Emacs always puts this in the end of every LaTeX file (after \end{document}):

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

There is is suspicious t.

I didn't go into Emacs package manager and install anything (like AUCTeX) yet, on the computer with the fresh installation. Still, LaTeX files are opened in LaTeX-mode.

When I typed a ! as my response to the warning mentioned above, this was added to ~/.emacs:

 '(safe-local-variable-values (quote ((TeX-master . t))))

Then, that warning went away on subsequent attempts. But there isn't even such a warning in the first place on the first computer, even though the ~/.emacs file was exactly the same.

There are other differences. Like when I press C-c C-c in LaTeX-mode to build the PDF, on the first computer, that's all that happens. On the new one, a buffer frame and a buffer are created, containing the pdflatex command which was used to build the PDF and its console output.

Upon pressing C-c C-c on the first computer, the mini buffer says:

Command: (default LaTeX) 

On the second one, it says:

Command: (default pdflatex) 

I understand that pdflatex is a program with an equally named package (in Ubuntu) and an equally named command to call it. But why is the default on the first computer LaTeX? That is to say: Where is it configured?

Can someone please explain what's going on? If I want the exact same Emacs configuration on both computers, how should I go about it?

This is my ~/.emacs file after the change described above occurred:

(set-face-foreground 'minibuffer-prompt "red")

(require 'package)
(add-to-list 'package-archives
         '("melpa-stable" . "https://stable.melpa.org/packages/"))

(defvar-local is-new-file-buffer nil)

(defun save-new-file-before-kill ()
  (when (and (not (buffer-file-name))
              "New file has not been saved. Would you like to save before closing?"))
    (call-interactively 'save-buffer)))

(add-hook 'kill-buffer-hook 'save-new-file-before-kill)    

(defun new-file (dir)
  (interactive "DCreate New File In: ")
  (let ((buffer (generate-new-buffer "<Unsaved File>")))
    (switch-to-buffer buffer)
    (setq-local default-directory dir)
    (setq-local is-new-file-buffer t)))

(global-set-key [(f12)] 'new-file)

;; Save all tempfiles in $TMPDIR/emacs$UID/                                     
(defconst emacs-tmp-dir (format "%s/%s%s/" "/t" "emacs" (user-uid)))
(setq backup-directory-alist
      `((".*" . ,emacs-tmp-dir)))
(setq auto-save-file-name-transforms
      `((".*" ,emacs-tmp-dir t)))
(setq auto-save-list-file-prefix
 ;; 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.
 '(LaTeX-indent-level 4)
 '(LaTeX-item-indent 0)
 '(TeX-brace-indent-level 4)
 '(indent-tabs-mode t)
    ("~/[I censored this path but it exists on both computers].org" "~/[a different path].org" "~/[and another one].org")))
 '(safe-local-variable-values (quote ((TeX-master . t))))
 '(show-paren-mode t)
 '(tool-bar-mode nil))
 ;; custom-set-faces 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.

;; Bind C-tab to autocompletion in LaTeX-mode.
(add-hook 'LaTeX-mode-hook
        (local-set-key [C-tab] 'TeX-complete-symbol)))

(setq LaTeX-paragraph-commands '("documentclass" "usepackage"))

(setq TeX-auto-save t)
    (setq TeX-parse-self t)
(setq-default TeX-master nil)

(add-hook 'LaTeX-mode-hook 'visual-line-mode)
    (add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
    (setq reftex-plug-into-AUCTeX t)

(setq TeX-PDF-mode t)

(setq org-startup-indented t)

(add-hook 'org-mode-hook 'visual-line-mode)

;; Don't show welcome screen when opening Emacs.
(setq inhibit-startup-screen t)

;; Highlight matching parentheses.
(show-paren-mode 1)

;; Don't clutter the git repo with files by puttem them into a specially named folder.
(defvar org-export-output-directory-prefix "built_files_ignored_by_git_" "prefix of directory used for org-mode export")

(defadvice org-export-output-file-name (before org-add-export-dir activate)
  "Modifies org-export to place exported files in a different directory"
  (when (not pub-dir)
      (setq pub-dir (concat org-export-output-directory-prefix (substring extension 1)))
      (when (not (file-directory-p pub-dir))
       (make-directory pub-dir))))

;; Show line numbers.
(global-linum-mode t)

;; Show column numbers.
(setq column-number-mode t)

;; Agenda view key binding.
(global-set-key [(control ?c) (?a)] 'org-agenda)

/t (mentioned in the code above) exists on both computers and in both cases is a symlink to a folder (which even is in the exact same location on both systems).

  • I stopped reading the remainder of the question when you said you got an error message and then didn't tell us exactly what it was ... Consider setting (setq debug-on-error t) at the outset of your user-configuration and post the error message . . . The error and/or *Backtrace* buffer messages are generally helpful in debugging problems.
    – lawlist
    Commented Apr 22, 2017 at 20:44
  • 1
    @lawlist Sorry. I added it to the question.
    – UTF-8
    Commented Apr 22, 2017 at 21:06
  • Your emacs config is more than just your init file. In general, the ~/.emacs.d directory is your emacs config, with the possible exceptions of (a) the init file itself, which might be ~/.emacs or similar; and (b) any site-lisp files which are on one of the machines but not the other. Note that you can rename ~/.emacs to ~/.emacs.d/init.el to put it into your config directory as well.
    – phils
    Commented Apr 23, 2017 at 10:47

1 Answer 1


On the first computer you have AUCTeX installed, on the second one emacs is using its default mode for editing tex files.

  • That would make sense and I expected this (which is why I pointed out that I didn't install AUXTeX or any other packages using the package manager on the second computer). Can you tell me why LaTeX documents are opened in LaTeX-mode on the second computer, not in latex-mode, text-mode, or fundamental-mode? Isn't LaTeX-mode an AUXTeX thing?
    – UTF-8
    Commented Apr 23, 2017 at 12:52
  • latex-mode is the built in mode for editing tex files in emacs, the AUCTeX one is TeX-latex-mode, but the mode line indication is the same for both.
    – matteol
    Commented Apr 23, 2017 at 16:43
  • Oh, you're right. This is completely unexpected for me. So I should probably go about it like this: Move ~/.emacs to ~/.emacs.d/init.el on the first computer, than copy that folder over / sync it. Then delete that weird stuff in the LaTeX documents which have it. (I noticed that not all of my LaTeX documents do and I can edit and build them just fine.)
    – UTF-8
    Commented Apr 23, 2017 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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