emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden: diff-default-read-only doesn't]


From: Chong Yidong
Subject: Re: address@hidden: diff-default-read-only doesn't]
Date: Fri, 02 Jun 2006 19:17:12 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

> Would someone please DTRT and ack?
>
> From: Dan Jacobson <address@hidden>
> Subject: diff-default-read-only doesn't
> To: address@hidden
>
> emacs-version "22.0.50.1":
> diff-default-read-only doesn't make the *Diff* buffer read only.
> The only place it is used,
>   (when (and (> (point-max) (point-min)) diff-default-read-only)
> it is never reached, as if it were, there would be no way to put stuff
> in that buffer in the first place, hence the point-max jazz, I guess.

How about this patch?  It makes `diff-mode' set buffer-read-only to t
whenever diff-default-read-only is non-nil.  It also adds
(inhibit-read-only t) to several interactive commands in diff-mode and
the `M-x diff' code in diff.el.

*** emacs/lisp/diff-mode.el.~1.88.~     2006-05-17 13:33:39.000000000 -0400
--- emacs/lisp/diff-mode.el     2006-06-02 19:07:52.000000000 -0400
***************
*** 438,444 ****
         (firsthunk (ignore-errors
                      (goto-char start)
                      (diff-beginning-of-file) (diff-hunk-next) (point)))
!        (nextfile (ignore-errors (diff-file-next) (point))))
      (goto-char start)
      (if (and firsthunk (= firsthunk start)
             (or (null nexthunk)
--- 438,445 ----
         (firsthunk (ignore-errors
                      (goto-char start)
                      (diff-beginning-of-file) (diff-hunk-next) (point)))
!        (nextfile (ignore-errors (diff-file-next) (point)))
!        (inhibit-read-only t))
      (goto-char start)
      (if (and firsthunk (= firsthunk start)
             (or (null nexthunk)
***************
*** 457,463 ****
                     (ignore-errors
                       (diff-hunk-prev) (point))))
         (index (save-excursion
!                 (re-search-backward "^Index: " prevhunk t))))
      (when index (setq start index))
      (diff-end-of-file)
      (if (looking-at "^\n") (forward-char 1)) ;`tla' generates such diffs.
--- 458,465 ----
                     (ignore-errors
                       (diff-hunk-prev) (point))))
         (index (save-excursion
!                 (re-search-backward "^Index: " prevhunk t)))
!        (inhibit-read-only t))
      (when index (setq start index))
      (diff-end-of-file)
      (if (looking-at "^\n") (forward-char 1)) ;`tla' generates such diffs.
***************
*** 490,495 ****
--- 492,498 ----
    (interactive)
    (beginning-of-line)
    (let ((pos (point))
+       (inhibit-read-only t)
        (start (progn (diff-beginning-of-hunk) (point))))
      (unless (looking-at "@@ -\\([0-9]+\\),[0-9]+ \\+\\([0-9]+\\),[0-9]+ @@")
        (error "diff-split-hunk only works on unified context diffs"))
***************
*** 993,1000 ****
    ;; compile support
    (set (make-local-variable 'next-error-function) 'diff-next-error)
  
!   (when (and (> (point-max) (point-min)) diff-default-read-only)
!     (toggle-read-only t))
    ;; setup change hooks
    (if (not diff-update-on-the-fly)
        (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t)
--- 996,1003 ----
    ;; compile support
    (set (make-local-variable 'next-error-function) 'diff-next-error)
  
!   (if diff-default-read-only
!       (setq buffer-read-only t))
    ;; setup change hooks
    (if (not diff-update-on-the-fly)
        (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t)
***************
*** 1355,1360 ****
--- 1358,1364 ----
         (file1 (make-temp-file "diff1"))
         (file2 (make-temp-file "diff2"))
         (coding-system-for-read buffer-file-coding-system)
+        (inhibit-read-only t)
         old new)
      (unwind-protect
        (save-excursion
*** emacs/lisp/diff.el.~1.59.~  2006-02-07 17:37:23.000000000 -0500
--- emacs/lisp/diff.el  2006-06-02 19:12:49.000000000 -0400
***************
*** 67,75 ****
    (if diff-new-temp-file (delete-file diff-new-temp-file))
    (save-excursion
      (goto-char (point-max))
!     (insert (format "\nDiff finished%s.  %s\n"
!                   (if (equal 0 code) " (no differences)" "")
!                   (current-time-string)))))
  
  ;;;###autoload
  (defun diff (old new &optional switches no-async)
--- 67,86 ----
    (if diff-new-temp-file (delete-file diff-new-temp-file))
    (save-excursion
      (goto-char (point-max))
!     (let ((inhibit-read-only t))
!       (insert (format "\nDiff finished%s.  %s\n"
!                     (if (equal 0 code) " (no differences)" "")
!                     (current-time-string))))))
! 
! (defun diff-insertion-filter (proc string)
!   (with-current-buffer (process-buffer proc)
!     (let ((moving (= (point) (process-mark proc)))
!         (inhibit-read-only t))
!       (save-excursion
!       (goto-char (process-mark proc))
!       (insert string)
!       (set-marker (process-mark proc) (point)))
!       (if moving (goto-char (process-mark proc))))))
  
  ;;;###autoload
  (defun diff (old new &optional switches no-async)
***************
*** 113,118 ****
--- 124,130 ----
                     " "))
         (buf (get-buffer-create "*Diff*"))
         (thisdir default-directory)
+        (inhibit-read-only t)
         proc)
      (save-excursion
        (display-buffer buf)
***************
*** 133,138 ****
--- 145,151 ----
          (progn
            (setq proc (start-process "Diff" buf shell-file-name
                                      shell-command-switch command))
+           (set-process-filter proc 'diff-insertion-filter)
            (set-process-sentinel
             proc (lambda (proc msg)
                    (with-current-buffer (process-buffer proc)




reply via email to

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