emacs-devel
[Top][All Lists]
Advanced

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

Re: undo in compilation mode


From: Richard Stallman
Subject: Re: undo in compilation mode
Date: Wed, 25 Aug 2004 00:41:31 -0400

        Stefan> I think the OP's problem has more to do with
        Stefan> writability than with the undo facility.  Many people
        Stefan> expect the *compile* buffer to be read-only.

    Yes, read-only would be better (also prevents user from undoing)

Does this change do it?

*** compile.el  11 Aug 2004 16:46:19 -0400      1.323
--- compile.el  25 Aug 2004 00:03:13 -0400      
***************
*** 892,908 ****
                  (error nil))
              (error "Cannot have two processes in `%s' at once"
                     (buffer-name)))))
-       ;; Clear out the compilation buffer and make it writable.
-       ;; Change its default-directory to the directory where the compilation
-       ;; will happen, and insert a `cd' command to indicate this.
-       (setq buffer-read-only nil)
        (buffer-disable-undo (current-buffer))
!       (erase-buffer)
!       (buffer-enable-undo (current-buffer))
!       (setq default-directory thisdir)
!       ;; output a mode setter, for saving and later reloading this buffer
!       (insert "cd " thisdir " # -*-" name-of-mode
!             "-*-\nEntering directory `" thisdir "'\n" command "\n")
        (set-buffer-modified-p nil))
      ;; If we're already in the compilation buffer, go to the end
      ;; of the buffer, so point will track the compilation output.
--- 892,909 ----
                  (error nil))
              (error "Cannot have two processes in `%s' at once"
                     (buffer-name)))))
        (buffer-disable-undo (current-buffer))
!       ;; Make compilation buffer read-only.  The filter can still write it.
!       ;; Clear out the compilation buffer.
!       (let ((inhibit-read-only t))
!       (erase-buffer)
!       ;; Change its default-directory to the directory where the compilation
!       ;; will happen, and insert a `cd' command to indicate this.
!       (setq default-directory thisdir)
!       ;; output a mode setter, for saving and later reloading this buffer
!       (insert "cd " thisdir " # -*-" name-of-mode
!               "-*-\nEntering directory `" thisdir "'\n"
!               command "\n"))
        (set-buffer-modified-p nil))
      ;; If we're already in the compilation buffer, go to the end
      ;; of the buffer, so point will track the compilation output.
***************
*** 913,922 ****
      (with-current-buffer outbuf
        (if (not (eq mode t))
          (funcall mode)
        (with-no-warnings (comint-mode))
        (compilation-shell-minor-mode))
-       ;; In what way is it non-ergonomic ?  -stef
-       ;; (toggle-read-only 1) ;;; Non-ergonomic.
        (if highlight-regexp
          (set (make-local-variable 'compilation-highlight-regexp)
               highlight-regexp))
--- 914,922 ----
      (with-current-buffer outbuf
        (if (not (eq mode t))
          (funcall mode)
+       (setq buffer-read-only nil)
        (with-no-warnings (comint-mode))
        (compilation-shell-minor-mode))
        (if highlight-regexp
          (set (make-local-variable 'compilation-highlight-regexp)
               highlight-regexp))
***************
*** 1174,1179 ****
--- 1174,1180 ----
    "Prepare the buffer for the compilation parsing commands to work.
  Optional argument MINOR indicates this is called from
  `compilation-minor-mode'."
+   (setq buffer-read-only t)
    (make-local-variable 'compilation-current-error)
    (make-local-variable 'compilation-messages-start)
    (make-local-variable 'compilation-error-screen-columns)
***************
*** 1235,1241 ****
  
  (defun compilation-handle-exit (process-status exit-status msg)
    "Write MSG in the current buffer and hack its mode-line-process."
!   (let ((buffer-read-only nil)
        (status (if compilation-exit-message-function
                    (funcall compilation-exit-message-function
                             process-status exit-status msg)
--- 1236,1242 ----
  
  (defun compilation-handle-exit (process-status exit-status msg)
    "Write MSG in the current buffer and hack its mode-line-process."
!   (let ((inhibit-read-only t)
        (status (if compilation-exit-message-function
                    (funcall compilation-exit-message-function
                             process-status exit-status msg)




reply via email to

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