all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* toggling diff-auto-refine
@ 2007-12-29 14:03 Thien-Thi Nguyen
  2007-12-30 17:03 ` Thien-Thi Nguyen
  2008-01-02  2:37 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2007-12-29 14:03 UTC (permalink / raw)
  To: emacs-devel

how about replacing the `(defcustom diff-auto-refine ...)' with:

(define-minor-mode diff-auto-refine
  "Automatically highlight changes in detail as the user visits hunks."
  :group 'diff-mode :init-value nil :lighter " Auto-Refine"
  (when diff-auto-refine
    (condition-case-no-debug nil (diff-refine-hunk) (error nil))))

i find this useful for cruising around unwieldy diffs where there is a
mix of quickly refined hunks and slowly refined hunks.

thi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: toggling diff-auto-refine
  2007-12-29 14:03 toggling diff-auto-refine Thien-Thi Nguyen
@ 2007-12-30 17:03 ` Thien-Thi Nguyen
  2008-01-02  2:37 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2007-12-30 17:03 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

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


_______________________________________________________

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: .ttn.diff-auto-refine.diff --]
[-- Type: text/x-diff, Size: 3600 bytes --]

*** 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.

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: toggling diff-auto-refine
  2007-12-29 14:03 toggling diff-auto-refine Thien-Thi Nguyen
  2007-12-30 17:03 ` Thien-Thi Nguyen
@ 2008-01-02  2:37 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2008-01-02  2:37 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: emacs-devel

> how about replacing the `(defcustom diff-auto-refine ...)' with:
> (define-minor-mode diff-auto-refine
>   "Automatically highlight changes in detail as the user visits hunks."
>   :group 'diff-mode :init-value nil :lighter " Auto-Refine"
>   (when diff-auto-refine
>     (condition-case-no-debug nil (diff-refine-hunk) (error nil))))

Fine by me, but:
- please call it "-mode" then.
- not sure if the merged mode for smerge+diff should use the
  "diff" prefix.  After all, the actual main code is in the
  smerge-mode.el file, so maybe the "smerge-" prefix would be
  more consistent.  Then again, moving this code out of smerge to some
  shared place might be even better.


        Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-02  2:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-29 14:03 toggling diff-auto-refine Thien-Thi Nguyen
2007-12-30 17:03 ` Thien-Thi Nguyen
2008-01-02  2:37 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.