]> git.eshelyaron.com Git - emacs.git/commitdiff
Make auto-refining a minor mode, and diff- and smerge- use it.
authorThien-Thi Nguyen <ttn@gnuvola.org>
Mon, 21 Jul 2008 14:20:24 +0000 (14:20 +0000)
committerThien-Thi Nguyen <ttn@gnuvola.org>
Mon, 21 Jul 2008 14:20:24 +0000 (14:20 +0000)
* diff-mode.el (diff-auto-refine): Delete defcustom.
(diff-auto-refine-mode): New func/var via define-minor-mode.
Update var ref to use diff-auto-refine-mode.
* smerge-mode.el (diff-mode): Require when compiling.
(smerge-auto-refine): Delete defcustom.
Update smerge-auto-refine ref to use diff-auto-refine-mode.

etc/NEWS
lisp/ChangeLog
lisp/diff-mode.el
lisp/smerge-mode.el

index 859a37b0c8fc0e95ede0a818c2aa9cb6a352c7ac..a507af057778dcdb3d069f599851b3589b347bec 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -579,7 +579,7 @@ set a variable's `safe-local-variable' and `risky-local-variable' property.
 
 *** diff-refine-hunk highlights word-level details of changes in a diff hunk.
 It's used automatically as you move through hunks, see
-diff-auto-refine.  It is bound to `C-c C-b'.
+diff-auto-refine-mode.  It is bound to `C-c C-b'.
 
 *** diff-add-change-log-entries-other-window iterates through the diff
 buffer and tries to create ChangeLog entries for each change.
@@ -784,7 +784,8 @@ It is used to configure wireless interfaces.
 *** sgml-electric-tag-pair-mode lets you simultaneously edit matched tag pairs.
 
 *** smerge-refine highlights word-level details of changes in conflict.
-It's used automatically as you move through conflicts, see smerge-auto-refine.
+It's used automatically as you move through conflicts, see
+smerge-auto-refine-mode.
 
 *** talk.el has been extended for multiple tty support.
 
index f3f2bb12e5d54ea60304048dc46bc85a652e6bd9..59760e276c3df6e3c30500e3d546724cc1e02bb3 100644 (file)
@@ -1,3 +1,12 @@
+2008-07-21  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+       * diff-mode.el (diff-auto-refine): Delete defcustom.
+       (diff-auto-refine-mode): New func/var via define-minor-mode.
+       Update var ref to use diff-auto-refine-mode.
+       * smerge-mode.el (diff-mode): Require when compiling.
+       (smerge-auto-refine): Delete defcustom.
+       Update smerge-auto-refine ref to use diff-auto-refine-mode.
+
 2008-07-21  Chong Yidong  <cyd@stupidchicken.com>
 
        * simple.el (visual-line): New custom group.
index 864d74b4e3012526e34bfb3729a0485b83e5603f..da1cd30198f25c0b8bb2fc107a8d4325e7a94479 100644 (file)
@@ -91,11 +91,6 @@ when editing big diffs)."
   :type 'boolean
   :group 'diff-mode)
 
-(defcustom diff-auto-refine t
-  "Automatically highlight changes in detail as the user visits hunks."
-  :type 'boolean
-  :group 'diff-mode)
-
 (defcustom diff-mode-hook nil
   "Run after setting up the `diff-mode' major mode."
   :type 'hook
@@ -220,6 +215,13 @@ when editing big diffs)."
   `((,diff-minor-mode-prefix . ,diff-mode-shared-map))
   "Keymap for `diff-minor-mode'.  See also `diff-mode-shared-map'.")
 
+(define-minor-mode diff-auto-refine-mode
+  "Automatically highlight changes in detail as the user visits hunks.
+When transitioning from disabled to enabled,
+try to refine the current hunk, as well."
+  :group 'diff-mode :init-value t :lighter " Auto-Refine"
+  (when diff-auto-refine-mode
+    (condition-case-no-debug nil (diff-refine-hunk) (error nil))))
 
 ;;;;
 ;;;; font-lock support
@@ -528,7 +530,7 @@ but in the file header instead, in which case move forward to the first hunk."
 ;; Define diff-{hunk,file}-{prev,next}
 (easy-mmode-define-navigation
  diff-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view
- (if diff-auto-refine
+ (if diff-auto-refine-mode
      (condition-case-no-debug nil (diff-refine-hunk) (error nil))))
 
 (easy-mmode-define-navigation
index 6489133e12732ef67e47e2582d56824fe60cf39a..169f50082690439a0a57d49261446a842e210462 100644 (file)
@@ -44,7 +44,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl) (require 'diff-mode))
 
 
 ;;; The real definition comes later.
@@ -77,11 +77,6 @@ Used in `smerge-diff-base-mine' and related functions."
   :group 'smerge
   :type 'boolean)
 
-(defcustom smerge-auto-refine t
-  "Automatically highlight changes in detail as the user visits conflicts."
-  :group 'smerge
-  :type 'boolean)
-
 (defface smerge-mine
   '((((min-colors 88) (background light))
      (:foreground "blue1"))
@@ -259,7 +254,7 @@ Can be nil if the style is undecided, or else:
 
 ;; Define smerge-next and smerge-prev
 (easy-mmode-define-navigation smerge smerge-begin-re "conflict" nil nil
-  (if smerge-auto-refine
+  (if diff-auto-refine-mode
       (condition-case nil (smerge-refine) (error nil))))
 
 (defconst smerge-match-names ["conflict" "mine" "base" "other"])