[Top][All Lists]

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

[AUCTeX-devel] Make TeX output buffer inherit from special-mode

From: Ivan Andrus
Subject: [AUCTeX-devel] Make TeX output buffer inherit from special-mode
Date: Mon, 21 Jan 2013 11:00:30 +0100

I'm often annoyed that the TeX output buffer (i.e. *file output*) doesn't 
inherit from special-mode.  In particular, I want to use q to quit and g to 
refresh (i.e. run LaTeX again).  Also, since editing it doesn't make much 
sense, using space and backspace for navigation can be nice.  Below I include a 
very rough first attempt at this.  My intent here is to ask whether something 
like this has a hope of being added to AUCTeX.  If so I can work on making it 
more robust and prepare it for submission.  



(define-derived-mode TeX-output-mode special-mode "TeX Output"
  "Mode for viewing TeX output."
  (setq revert-buffer-function #'TeX-revert-buffer)
  (setq buffer-read-only nil))

(defun TeX-revert-buffer (ignore-auto noconfirm)
  (goto-char (point-min))
  (when (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-run-TeX name command file)))))

(defun TeX-run-command (name command file)
  "Create a process for NAME using COMMAND to process FILE.
Return the new process."
  (let ((default TeX-command-default)
        (buffer (TeX-process-buffer-name file))
        (dir (TeX-master-directory))
        (command-buff (current-buffer)))
    (TeX-process-check file)            ; Check that no process is running
    (setq-default TeX-command-buffer command-buff)
    (get-buffer-create buffer)
    (set-buffer buffer)
    (set (make-local-variable 'line-number-display-limit) 0)
    (setq TeX-output-extension nil)
    (set (make-local-variable 'TeX-command-buffer) command-buff)
    (if dir (cd dir))
    (insert "Running `" name "' on `" file "' with ``" command "''\n")

    ;; Change this line.  Probably other things could be moved into
    ;; TeX-output-mode, like disabling undo.
    ;; (setq mode-name name)

    (if TeX-show-compilation
        (display-buffer buffer)
      (message "Type `%s' to display results of compilation."
    (setq TeX-parse-function 'TeX-parse-command)
    (setq TeX-command-default default)
    (setq TeX-sentinel-function
          (lambda (process name)
            (message (concat name ": done."))))
    (if TeX-process-asynchronous
        (let ((process (start-process name buffer TeX-shell
                                      TeX-shell-command-option command)))
          (if TeX-after-start-process-function
              (funcall TeX-after-start-process-function process))
          (TeX-command-mode-line process)
          (set-process-filter process 'TeX-command-filter)
          (set-process-sentinel process 'TeX-command-sentinel)
          (set-marker (process-mark process) (point-max))
          (setq compilation-in-progress (cons process compilation-in-progress))
      (setq mode-line-process ": run")
      (set-buffer-modified-p (buffer-modified-p))
      (sit-for 0)                               ; redisplay
      (call-process TeX-shell nil buffer nil
                    TeX-shell-command-option command))))

reply via email to

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