EasyPG 1.07 Released
[packages] / xemacs-packages / auctex / tex-wizard.el
1 ;;; tex-wizard.el --- Check the TeX configuration
2
3 ;; Copyright (C) 2003, 2006, 2016 Free Software Foundation, Inc.
4
5 ;; Author: David Kastrup <dak@gnu.org>
6 ;; Keywords: tex, wp, convenience
7
8 ;; This file is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
12
13 ;; This file is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
22
23 ;;; Commentary:
24
25 ;; This checks through your TeX configuration.  Call M-x TeX-wizard RET
26
27 ;;; Code:
28
29 (defun TeX-wizard nil
30   (interactive)
31   (switch-to-buffer "*TeX wizard*")
32   (let ((wizwin (selected-window))
33         (wizbuf (current-buffer)))
34     (set-visited-file-name nil)
35     (erase-buffer)
36     (if (featurep 'tex-site)
37         (insert-before-markers "AUCTeX is enabled.  Good.\n")
38       (insert-before-markers "\
39 It appears that AUCTeX is not enabled.  AUCTeX is the main
40 major mode for editing TeX/LaTeX files.\n")
41       (condition-case nil
42           (info-other-window "(AUCTeX)")
43         (error (select-window wizwin)
44                (switch-to-buffer wizbuf)
45                (insert-before-markers "(I am unable to find AUCTeX's info file.)\n")))
46       (if (prog1 (y-or-n-p "Should I try enabling AUCTeX now?")
47             (select-window wizwin)
48             (switch-to-buffer wizbuf))
49           (condition-case nil
50               (require 'tex-site)
51             (error (insert-before-markers "AUCTeX appears not to be installed.\n")))
52         (insert-before-markers "AUCTeX installation imprudently skipped.\n"))
53       (when (featurep 'tex-site)
54         (when (prog1 (yes-or-no-p (format "Also enable AUCTeX in `%s'" user-init-file))
55                 (select-window wizwin)
56                 (switch-to-buffer wizbuf))
57           (write-region "\
58 ;;; Enable AUCTeX
59 \(require 'tex-site)\n" nil user-init-file t))))
60     (if (memq 'turn-on-reftex
61               (if (featurep 'tex-site)
62                   (and (boundp 'LaTeX-mode-hook) LaTeX-mode-hook)
63                 (and (boundp 'latex-mode-hook) latex-mode-hook)))
64         (insert-before-markers "RefTeX is enabled.  Good.\n")
65       (insert-before-markers "\
66 It appears that RefTeX is not enabled.  RefTeX is a mode
67 that will greatly facilitate the management of labels
68 and bibliographics references.\n")
69       (condition-case nil
70           (info-other-window "(RefTeX)")
71         (error (select-window wizwin)
72                (switch-to-buffer wizbuf)
73                (insert-before-markers
74                 "(I am unable to find RefTeX's info file.)\n")))
75       (when (prog1 (yes-or-no-p
76                     (format "Enable RefTeX in `%s'" user-init-file))
77               (select-window wizwin)
78               (switch-to-buffer wizbuf))
79         (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
80         (add-hook 'latex-mode-hook 'turn-on-reftex)
81         (condition-case nil
82             (write-region "\
83 ;;; Enable RefTeX
84 \(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
85 \(add-hook 'latex-mode-hook 'turn-on-reftex)
86 " nil user-init-file t)
87           (error (insert-before-markers
88                   (format "Unable to write to file `%s'\n" user-init-file))))))
89     (when (and (featurep 'tex-site)
90                (boundp 'LaTeX-mode-hook)
91                (memq 'turn-on-reftex LaTeX-mode-hook))
92       (if (and (boundp 'reftex-plug-into-AUCTeX)
93                reftex-plug-into-AUCTeX)
94           (insert-before-markers
95            "RefTeX appears to be configured for use with AUCTeX.\n")
96         (require 'reftex)
97         (insert-before-markers "\
98 It appears that RefTeX is not configured to cooperate with
99 AUCTeX.  Please configure it using the menus, save for future
100 sessions, then press the finish button.")
101         (customize-variable-other-window 'reftex-plug-into-AUCTeX)
102         (set (make-local-variable 'custom-buffer-done-kill) t)
103         (add-hook 'kill-buffer-hook #'exit-recursive-edit nil t)
104         (recursive-edit)
105         (select-window wizwin)
106         (switch-to-buffer wizbuf))))
107   (insert-before-markers "That's all!\n"))
108
109
110 (provide 'tex-wizard)
111 ;;; tex-wizard.el ends here