]> code.delx.au - gnu-emacs/blobdiff - lisp/diff-mode.el
(display_tool_bar_line): Skip glyphs which are too big
[gnu-emacs] / lisp / diff-mode.el
index cc89aad6ca31f5144fbb28a2d97322886e0e1b17..7ea02352b0bc3f3a193d6781842a58c5d27a64b3 100644 (file)
@@ -438,7 +438,8 @@ If the prefix ARG is given, restrict the view to the current file instead."
         (firsthunk (ignore-errors
                      (goto-char start)
                      (diff-beginning-of-file) (diff-hunk-next) (point)))
-        (nextfile (ignore-errors (diff-file-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,7 +458,8 @@ If the prefix ARG is given, restrict the view to the current file instead."
                     (ignore-errors
                       (diff-hunk-prev) (point))))
         (index (save-excursion
-                 (re-search-backward "^Index: " prevhunk t))))
+                 (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.
@@ -497,7 +499,8 @@ If the prefix ARG is given, restrict the view to the current file instead."
     (let* ((start1 (string-to-number (match-string 1)))
           (start2 (string-to-number (match-string 2)))
           (newstart1 (+ start1 (diff-count-matches "^[- \t]" (point) pos)))
-          (newstart2 (+ start2 (diff-count-matches "^[+ \t]" (point) pos))))
+          (newstart2 (+ start2 (diff-count-matches "^[+ \t]" (point) pos)))
+          (inhibit-read-only t))
       (goto-char pos)
       ;; Hopefully the after-change-function will not screw us over.
       (insert "@@ -" (number-to-string newstart1) ",1 +"
@@ -633,8 +636,8 @@ Non-nil OLD means that we want the old file."
   "Convert unified diffs to context diffs.
 START and END are either taken from the region (if a prefix arg is given) or
 else cover the whole bufer."
-  (interactive (if current-prefix-arg
-                  (list (mark) (point))
+  (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active))
+                  (list (region-beginning) (region-end))
                 (list (point-min) (point-max))))
   (unless (markerp end) (setq end (copy-marker end)))
   (let (;;(diff-inhibit-after-change t)
@@ -722,7 +725,7 @@ START and END are either taken from the region
 \(when it is highlighted) or else cover the whole buffer.
 With a prefix argument, convert unified format to context format."
   (interactive (if (and transient-mark-mode mark-active)
-                  (list (mark) (point) current-prefix-arg)
+                  (list (region-beginning) (region-end) current-prefix-arg)
                 (list (point-min) (point-max) current-prefix-arg)))
   (if to-context
       (diff-unified->context start end)
@@ -795,8 +798,8 @@ With a prefix argument, convert unified format to context format."
   "Reverse the direction of the diffs.
 START and END are either taken from the region (if a prefix arg is given) or
 else cover the whole bufer."
-  (interactive (if current-prefix-arg
-                  (list (mark) (point))
+  (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active))
+                  (list (region-beginning) (region-end))
                 (list (point-min) (point-max))))
   (unless (markerp end) (setq end (copy-marker end)))
   (let (;;(diff-inhibit-after-change t)
@@ -857,8 +860,8 @@ else cover the whole bufer."
   "Fixup the hunk headers (in case the buffer was modified).
 START and END are either taken from the region (if a prefix arg is given) or
 else cover the whole bufer."
-  (interactive (if current-prefix-arg
-                  (list (mark) (point))
+  (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active))
+                  (list (region-beginning) (region-end))
                 (list (point-min) (point-max))))
   (let ((inhibit-read-only t))
     (save-excursion
@@ -993,8 +996,7 @@ a diff with \\[diff-reverse-direction]."
   ;; 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))
+  (setq buffer-read-only diff-default-read-only)
   ;; setup change hooks
   (if (not diff-update-on-the-fly)
       (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t)
@@ -1069,7 +1071,7 @@ Only works for unified diffs."
 
 (defun diff-hunk-text (hunk destp char-offset)
   "Return the literal source text from HUNK as (TEXT . OFFSET).
-if DESTP is nil TEXT is the source, otherwise the destination text.
+If DESTP is nil, TEXT is the source, otherwise the destination text.
 CHAR-OFFSET is a char-offset in HUNK, and OFFSET is the corresponding
 char-offset in TEXT."
   (with-temp-buffer
@@ -1302,7 +1304,7 @@ With a prefix argument, try to REVERSE the hunk."
 `diff-jump-to-old-file' (or its opposite if the OTHER-FILE prefix arg
 is given) determines whether to jump to the old or the new file.
 If the prefix arg is bigger than 8 (for example with \\[universal-argument] \\[universal-argument])
-  then `diff-jump-to-old-file' is also set, for the next invocations."
+then `diff-jump-to-old-file' is also set, for the next invocations."
   (interactive (list current-prefix-arg last-input-event))
   ;; When pointing at a removal line, we probably want to jump to
   ;; the old location, and else to the new (i.e. as if reverting).
@@ -1355,6 +1357,7 @@ For use in `add-log-current-defun-function'."
         (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