emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 41/299: * tex-buf.el (TeX-output-revert-buffer): New function. (T


From: Stefan Monnier
Subject: [elpa] 41/299: * tex-buf.el (TeX-output-revert-buffer): New function. (TeX-special-mode, TeX-output-mode): New major modes. (TeX-special-mode-map, TeX-output-mode-map): New variables.
Date: Sun, 02 Nov 2014 03:10:08 +0000

monnier pushed a commit to branch externals/auctex
in repository elpa.

commit 271951d94b096650a2f84cf6f3f444d6b6ac993c
Author: Tassilo Horn <address@hidden>
Date:   Fri Jan 25 08:05:03 2013 +0000

    * tex-buf.el (TeX-output-revert-buffer): New function.
    (TeX-special-mode, TeX-output-mode): New major modes.
    (TeX-special-mode-map, TeX-output-mode-map): New variables.
---
 ChangeLog  |    6 +++++
 tex-buf.el |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 79 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 46184ae..b74c7ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-01-24  Ivan Andrus  <address@hidden>
+
+       * tex-buf.el (TeX-output-revert-buffer): New function.
+       (TeX-special-mode, TeX-output-mode): New major modes.
+       (TeX-special-mode-map, TeX-output-mode-map): New variables.
+
 2013-01-21  Tassilo Horn  <address@hidden>
 
        * Makefile.in (STYLESRC): Activate new style placeins.el.
diff --git a/tex-buf.el b/tex-buf.el
index 07f0502..0afcd26 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -571,7 +571,7 @@ Return the new process."
     (set (make-local-variable 'TeX-command-buffer) command-buff)
     (if dir (cd dir))
     (insert "Running `" name "' on `" file "' with ``" command "''\n")
-    (setq mode-name name)
+    (TeX-output-mode)
     (if TeX-show-compilation
        (display-buffer buffer)
       (message "Type `%s' to display results of compilation."
@@ -1780,6 +1780,7 @@ You might want to examine and modify the free variables 
`file',
                              (buffer-substring start (point))))
                  help))))
     (goto-char (point-min))
+    (TeX-special-mode)
     (TeX-pop-to-buffer old-buffer nil t)))
 
 ;;; Error Messages
@@ -2202,6 +2203,77 @@ error."
                       (regexp :tag "Match")
                       (string :format "Description:\n%v"))))
 
+;;; Output mode
+
+(if (fboundp 'special-mode)
+    (progn
+      (defalias 'TeX-special-mode 'special-mode)
+      (defvaralias 'TeX-special-mode-map 'special-mode-map))
+  (defun TeX-special-mode ()
+    "Placeholder mode for Emacsen which don't have `special-mode'.")
+  (defvar TeX-special-mode-map
+    (let ((map (make-sparse-keymap)))
+      (suppress-keymap map)
+      (define-key map "q" (if (fboundp 'quit-window)
+                              'quit-window
+                            'bury-buffer))
+      (define-key map " " (if (fboundp 'scroll-up-command)
+                              'scroll-up-command
+                            'scroll-up))
+      (define-key map [backspace] (if (fboundp 'scroll-down-command)
+                                      'scroll-down-command
+                                    'scroll-down))
+      (define-key map "\C-?" (if (fboundp 'scroll-down-command)
+                                 'scroll-down-command
+                               'scroll-down))
+      (define-key map "?" 'describe-mode)
+      (define-key map "h" 'describe-mode)
+      (define-key map ">" 'end-of-buffer)
+      (define-key map "<" 'beginning-of-buffer)
+      (define-key map "g" 'revert-buffer)
+      map)
+    "Keymap for `TeX-special-mode-map'."))
+
+(defvar TeX-output-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map TeX-special-mode-map)
+    (define-key map "n" 'TeX-next-error)
+    ;; TODO: Implement TeX-previous-error
+    ;; (define-key map "p" 'TeX-previous-error)
+    (define-key map "b" 'TeX-toggle-debug-bad-boxes)
+    (define-key map "w" 'TeX-toggle-debug-warnings)
+    (define-key map "i" (lambda ()
+                          (interactive)
+                          (with-current-buffer TeX-command-buffer
+                            (TeX-interactive-mode (if TeX-interactive-mode -1 
1)))))
+    (define-key map "s" (lambda ()
+                          (interactive)
+                          (with-current-buffer TeX-command-buffer
+                            (TeX-source-correlate-mode (if 
TeX-source-correlate-mode -1 1)))))
+    map)
+  "Keymap for `TeX-output-mode'.")
+
+(define-derived-mode TeX-output-mode TeX-special-mode "TeX Output"
+    "Major mode for viewing TeX output.
+\\{TeX-output-mode-map} "
+    :syntax-table nil
+    (setq revert-buffer-function #'TeX-output-revert-buffer)
+    ;; special-mode makes it read-only which prevents input from TeX.
+    (setq buffer-read-only nil))
+
+(defun TeX-output-revert-buffer (ignore-auto noconfirm)
+  "Rerun the TeX command which of which this buffer was the output."
+  (goto-char (point-min))
+  (if (looking-at "Running `\\(.*\\)' on `\\(.*\\)' with ``\\(.*\\)''$")
+      (let ((name (match-string 1))
+            (file (match-string 2))
+            (command (match-string 3)))
+        (with-current-buffer TeX-command-buffer
+          (TeX-command name (if (string-match "_region_" file)
+                                'TeX-region-file
+                              'TeX-master-file))))
+    (error "Unable to find what command to run.")))
+
 (provide 'tex-buf)
 
 ;;; tex-buf.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]