# HG changeset patch # User Thien-Thi Nguyen # Date 1216650024 0 # Node ID b9de9e7dceed152c9e9dbae8a0c66cb9fb76c5b5 # Parent 89f46e95065e7b0f5588eaf6abdae214ce08308d Make auto-refining a minor mode, and diff- and smerge- use it. * 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. diff -r 89f46e95065e -r b9de9e7dceed etc/NEWS --- a/etc/NEWS Mon Jul 21 07:27:52 2008 +0000 +++ b/etc/NEWS Mon Jul 21 14:20:24 2008 +0000 @@ -579,7 +579,7 @@ *** 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 @@ *** 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. diff -r 89f46e95065e -r b9de9e7dceed lisp/ChangeLog --- a/lisp/ChangeLog Mon Jul 21 07:27:52 2008 +0000 +++ b/lisp/ChangeLog Mon Jul 21 14:20:24 2008 +0000 @@ -1,3 +1,12 @@ +2008-07-21 Thien-Thi Nguyen + + * 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 * simple.el (visual-line): New custom group. diff -r 89f46e95065e -r b9de9e7dceed lisp/diff-mode.el --- a/lisp/diff-mode.el Mon Jul 21 07:27:52 2008 +0000 +++ b/lisp/diff-mode.el Mon Jul 21 14:20:24 2008 +0000 @@ -91,11 +91,6 @@ :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 @@ `((,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 @@ ;; 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 diff -r 89f46e95065e -r b9de9e7dceed lisp/smerge-mode.el --- a/lisp/smerge-mode.el Mon Jul 21 07:27:52 2008 +0000 +++ b/lisp/smerge-mode.el Mon Jul 21 14:20:24 2008 +0000 @@ -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 @@ :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 @@ ;; 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"])