(Glossary): Treat Transient Mark mode as the default.
[bpt/emacs.git] / lisp / diff-mode.el
index 8a34335..e89aa0e 100644 (file)
@@ -172,28 +172,45 @@ when editing big diffs)."
 (easy-menu-define diff-mode-menu diff-mode-map
   "Menu for `diff-mode'."
   '("Diff"
-    ["Jump to Source"          diff-goto-source        t]
-    ["Apply hunk"              diff-apply-hunk         t]
-    ["Test applying hunk"      diff-test-hunk          t]
-    ["Apply diff with Ediff"   diff-ediff-patch        t]
+    ["Jump to Source"          diff-goto-source
+     :help "Jump to the corresponding source line"]
+    ["Apply hunk"              diff-apply-hunk
+     :help "Apply the current hunk to the source file and go to the next"]
+    ["Test applying hunk"      diff-test-hunk
+     :help "See whether it's possible to apply the current hunk"]
+    ["Apply diff with Ediff"   diff-ediff-patch
+     :help "Call `ediff-patch-file' on the current buffer"]
     ["Create Change Log entries" diff-add-change-log-entries-other-window
      :help "Create ChangeLog entries for the changes in the diff buffer"]
     "-----"
-    ["Reverse direction"       diff-reverse-direction  t]
-    ["Context -> Unified"      diff-context->unified   t]
-    ["Unified -> Context"      diff-unified->context   t]
+    ["Reverse direction"       diff-reverse-direction
+     :help "Reverse the direction of the diffs"]
+    ["Context -> Unified"      diff-context->unified
+     :help "Convert context diffs to unified diffs"]
+    ["Unified -> Context"      diff-unified->context
+     :help "Convert unified diffs to context diffs"]
     ;;["Fixup Headers"         diff-fixup-modifs       (not buffer-read-only)]
     "-----"
-    ["Split hunk"              diff-split-hunk         (diff-splittable-p)]
-    ["Ignore whitespace changes" diff-ignore-whitespace-hunk t]
-    ["Highlight fine changes"  diff-refine-hunk        t]
-    ["Kill current hunk"       diff-hunk-kill          t]
-    ["Kill current file's hunks" diff-file-kill        t]
+    ["Split hunk"              diff-split-hunk
+     :active (diff-splittable-p)
+     :help "Split the current (unified diff) hunk at point into two hunks"]
+    ["Ignore whitespace changes" diff-ignore-whitespace-hunk
+     :help "Re-diff the current hunk, ignoring whitespace differences"]
+    ["Highlight fine changes"  diff-refine-hunk
+     :help "Highlight changes of hunk at point at a finer granularity"]
+    ["Kill current hunk"       diff-hunk-kill
+     :help "Kill current hunk"]
+    ["Kill current file's hunks" diff-file-kill
+     :help "Kill all current file's hunks"]
     "-----"
-    ["Previous Hunk"           diff-hunk-prev          t]
-    ["Next Hunk"               diff-hunk-next          t]
-    ["Previous File"           diff-file-prev          t]
-    ["Next File"               diff-file-next          t]
+    ["Previous Hunk"           diff-hunk-prev
+     :help "Go to the previous count'th hunk"]
+    ["Next Hunk"               diff-hunk-next
+     :help "Go to the next count'th hunk"]
+    ["Previous File"           diff-file-prev
+     :help "Go to the previous count'th file"]
+    ["Next File"               diff-file-next
+     :help "Go to the next count'th file"]
     ))
 
 (defcustom diff-minor-mode-prefix "\C-c="
@@ -212,7 +229,7 @@ when editing big diffs)."
 
 (defface diff-header
   '((((class color) (min-colors 88) (background light))
-     :background "grey85")
+     :background "grey80")
     (((class color) (min-colors 88) (background dark))
      :background "grey45")
     (((class color) (background light))
@@ -655,6 +672,7 @@ data such as \"Index: ...\" and such."
 ;;;;
 
 (defvar diff-remembered-files-alist nil)
+(defvar diff-remembered-defdir nil)
 
 (defun diff-filename-drop-dir (file)
   (when (string-match "/" file) (substring file (match-end 0))))
@@ -728,6 +746,10 @@ Non-nil OLD means that we want the old file.
 Non-nil BATCH means to prefer returning an incorrect answer than to prompt
 the user.
 PREFIX is only used internally: don't use it."
+  (unless (equal diff-remembered-defdir default-directory)
+    ;; Flush diff-remembered-files-alist if the default-directory is changed.
+    (set (make-local-variable 'diff-remembered-defdir) default-directory)
+    (set (make-local-variable 'diff-remembered-files-alist) nil))
   (save-excursion
     (unless (looking-at diff-file-header-re)
       (or (ignore-errors (diff-beginning-of-file))
@@ -1363,7 +1385,8 @@ Only works for unified diffs."
                    (cond
                     ((and diff-valid-unified-empty-line
                           ;; Not just (eolp) so we don't infloop at eob.
-                          (eq (char-after) ?\n))
+                          (eq (char-after) ?\n)
+                          (> before 0) (> after 0))
                      (decf before) (decf after) t)
                     ((and (zerop before) (zerop after)) nil)
                     ((or (< before 0) (< after 0))
@@ -1694,13 +1717,13 @@ For use in `add-log-current-defun-function'."
         (line-nb (and (or (looking-at "[^0-9]+\\([0-9]+\\)")
                           (error "Can't find line number"))
                       (string-to-number (match-string 1))))
+        (inhibit-read-only t)
         (hunk (delete-and-extract-region
                (point) (save-excursion (diff-end-of-hunk) (point))))
         (lead (make-string (1- line-nb) ?\n)) ;Line nums start at 1.
         (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
@@ -1734,9 +1757,9 @@ For use in `add-log-current-defun-function'."
 
 (defface diff-refine-change
   '((((class color) (min-colors 88) (background light))
-     :background "grey90")
+     :background "grey85")
     (((class color) (min-colors 88) (background dark))
-     :background "grey40")
+     :background "grey60")
     (((class color) (background light))
      :background "yellow")
     (((class color) (background dark))