emacs-devel
[Top][All Lists]
Advanced

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

Re: toggling diff-auto-refine


From: Thien-Thi Nguyen
Subject: Re: toggling diff-auto-refine
Date: Sun, 30 Dec 2007 18:03:22 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

i see that smerge-mode.el has a similar feature,
so now have expanded the initial proposal slightly.

patch description:

  Merge `smerge-auto-refine' and `diff-auto-refine'
  variables into `diff-auto-refine' minor mode.

motivation:

  for convenience.  w/o the minor mode, you have to do

   M-: (setq diff-auto-refine (not diff-auto-refine)) RET

  followed by `C-c C-b' (diff-refine-hunk) when you want it.
  w/ the minor mode, you can do

   M-x diff-auto-refine RET

entry for lisp/ChangeLog:

  * smerge-mode.el: Require diff-mode when compiling.
  (smerge-auto-refine): Delete defcustom var.
  (smerge-next, smerge-prev): Use diff-auto-refine.
  * diff-mode.el (diff-auto-refine): Delete defcustom var.
  (diff-auto-refine): New minor mode (command + var).

diff below.  any objections?

thi


_______________________________________________________
*** lisp/smerge-mode.el.~1.58.~ Fri Nov 23 08:59:10 2007
--- lisp/smerge-mode.el Sun Dec 30 17:23:09 2007
***************
*** 46,52 ****
  
  ;;; Code:
  
! (eval-when-compile (require 'cl))
  
  
  ;;; The real definition comes later.
--- 46,52 ----
  
  ;;; Code:
  
! (eval-when-compile (require 'cl) (require 'diff-mode))
  
  
  ;;; The real definition comes later.
***************
*** 79,89 ****
    :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"))
--- 79,84 ----
***************
*** 258,264 ****
  
  ;; Define smerge-next and smerge-prev
  (easy-mmode-define-navigation smerge smerge-begin-re "conflict" nil nil
!   (if smerge-auto-refine
        (condition-case nil (smerge-refine) (error nil))))
  
  (defconst smerge-match-names ["conflict" "mine" "base" "other"])
--- 253,259 ----
  
  ;; Define smerge-next and smerge-prev
  (easy-mmode-define-navigation smerge smerge-begin-re "conflict" nil nil
!   (if diff-auto-refine
        (condition-case nil (smerge-refine) (error nil))))
  
  (defconst smerge-match-names ["conflict" "mine" "base" "other"])
*** lisp/diff-mode.el.~1.122.~  Tue Oct 30 11:53:38 2007
--- lisp/diff-mode.el   Sun Dec 30 17:18:58 2007
***************
*** 90,100 ****
    :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
--- 90,95 ----
***************
*** 198,203 ****
--- 193,209 ----
    `((,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
+   "Automatically highlight changes in detail as the user visits hunks.
+ Additionally, when in Diff mode, refine the current hunk.
+ When not in Diff mode, clear variable `diff-auto-refine' unconditionally."
+   :group 'diff-mode :init-value nil :lighter " Auto-Refine"
+   ;; If the "auto refinement" concept becomes useful in
+   ;; other contexts, we can remove this sanity check.  --ttn
+   (setq diff-auto-refine (when (eq 'diff-mode major-mode)
+                            diff-auto-refine))
+   (when diff-auto-refine
+     (condition-case-no-debug nil (diff-refine-hunk) (error nil))))
  
  ;;;;
  ;;;; font-lock support
*** etc/NEWS.~1.1632.~  Sat Dec 29 01:19:53 2007
--- etc/NEWS    Sun Dec 30 17:24:36 2007
***************
*** 258,267 ****
  This is enabled if isearch-buffers-multi is non-nil.
  
  ** smerge-refine highlights word-level details of changes in conflict.
- It's used automatically as you move through conflicts, see smerge-auto-refine.
- 
  ** 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.
  
  ** archive-mode has basic support to browse Rar archives.
  
--- 258,266 ----
  This is enabled if isearch-buffers-multi is non-nil.
  
  ** smerge-refine highlights word-level details of changes in conflict.
  ** diff-refine-hunk highlights word-level details of changes in a diff hunk.
! Both of these can be done automatically as you move through hunks.
! See diff-auto-refine.
  
  ** archive-mode has basic support to browse Rar archives.
  


Diffs between working revision and workfile end here.

reply via email to

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