Mercurial > emacs
annotate lisp/diff-mode.el @ 107006:8cf74d7922ce
Merge from trunk
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Fri, 08 Jan 2010 22:31:37 +0800 |
parents | b1c28ab3d90f |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
42472 | 1 ;;; diff-mode.el --- a mode for viewing/editing context diffs |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2 |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,2005, 2006, |
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
4 ;; 2007, 2008, 2009 Free Software Foundation, Inc. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 |
70292
2b77fa42947f
Update my email address.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69608
diff
changeset
|
6 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca> |
42472 | 7 ;; Keywords: convenience patch diff |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94370
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94370
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94370
diff
changeset
|
14 ;; (at your option) any later version. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94370
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 ;;; Commentary: |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 |
35526
b40a6cecc4d5
(diff-mode): Disable preliminary support for `compile'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33488
diff
changeset
|
26 ;; Provides support for font-lock, outline, navigation |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
27 ;; commands, editing and various conversions as well as jumping |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28 ;; to the corresponding source file. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29 |
53833
32e20bdb34c9
(diff-file-regexp-alist, diff-error-regexp-alist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53782
diff
changeset
|
30 ;; Inspired by Pavel Machek's patch-mode.el (<pavel@@atrey.karlin.mff.cuni.cz>) |
42472 | 31 ;; Some efforts were spent to have it somewhat compatible with XEmacs' |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 ;; diff-mode as well as with compilation-minor-mode |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 ;; Bugs: |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
36 ;; - Reverse doesn't work with normal diffs. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 ;; Todo: |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 |
91528
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
40 ;; - Improve `diff-add-change-log-entries-other-window', |
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
41 ;; it is very simplistic now. |
100171 | 42 ;; |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
43 ;; - Add a `delete-after-apply' so C-c C-a automatically deletes hunks. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
44 ;; Also allow C-c C-a to delete already-applied hunks. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
45 ;; |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
46 ;; - Try `diff <file> <hunk>' to try and fuzzily discover the source location |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
47 ;; of a hunk. Show then the changes between <file> and <hunk> and make it |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
48 ;; possible to apply them to <file>, <hunk-src>, or <hunk-dst>. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
49 ;; Or maybe just make it into a ".rej to diff3-markers converter". |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
50 ;; Maybe just use `wiggle' (by Neil Brown) to do it for us. |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
51 ;; |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
52 ;; - in diff-apply-hunk, strip context in replace-match to better |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
53 ;; preserve markers and spacing. |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
54 ;; - Handle `diff -b' output in context->unified. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 ;;; Code: |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 (eval-when-compile (require 'cl)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 |
65287
0cf1480347a9
(add-log-buffer-file-name-function): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64762
diff
changeset
|
59 (defvar add-log-buffer-file-name-function) |
0cf1480347a9
(add-log-buffer-file-name-function): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64762
diff
changeset
|
60 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 (defgroup diff-mode () |
64004
ea880752de3b
(diff-mode): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63415
diff
changeset
|
63 "Major mode for viewing/editing diffs." |
31269
64bb4634d6d8
(diff-mode) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents:
30873
diff
changeset
|
64 :version "21.1" |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 :group 'tools |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 :group 'diff) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67 |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
68 (defcustom diff-default-read-only nil |
39386
50956864fe56
(diff-default-read-only): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39323
diff
changeset
|
69 "If non-nil, `diff-mode' buffers default to being read-only." |
50956864fe56
(diff-default-read-only): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39323
diff
changeset
|
70 :type 'boolean |
50956864fe56
(diff-default-read-only): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39323
diff
changeset
|
71 :group 'diff-mode) |
50956864fe56
(diff-default-read-only): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39323
diff
changeset
|
72 |
37866
4e2d06e10072
(diff-jump-to-old-file, diff-update-on-the-fly):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37567
diff
changeset
|
73 (defcustom diff-jump-to-old-file nil |
80880
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
74 "Non-nil means `diff-goto-source' jumps to the old file. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 Else, it jumps to the new file." |
62531
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
76 :type 'boolean |
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
77 :group 'diff-mode) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 |
37866
4e2d06e10072
(diff-jump-to-old-file, diff-update-on-the-fly):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37567
diff
changeset
|
79 (defcustom diff-update-on-the-fly t |
100171 | 80 "Non-nil means hunk headers are kept up-to-date on-the-fly. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
81 When editing a diff file, the line numbers in the hunk headers |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
82 need to be kept consistent with the actual diff. This can |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
83 either be done on the fly (but this sometimes interacts poorly with the |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84 undo mechanism) or whenever the file is written (can be slow |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
85 when editing big diffs)." |
62531
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
86 :type 'boolean |
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
87 :group 'diff-mode) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88 |
32061
cdfabbe10a24
(diff-goto-source): Emit a status message.
Miles Bader <miles@gnu.org>
parents:
32012
diff
changeset
|
89 (defcustom diff-advance-after-apply-hunk t |
100171 | 90 "Non-nil means `diff-apply-hunk' will move to the next hunk after applying." |
62531
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
91 :type 'boolean |
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
92 :group 'diff-mode) |
32061
cdfabbe10a24
(diff-goto-source): Emit a status message.
Miles Bader <miles@gnu.org>
parents:
32012
diff
changeset
|
93 |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
94 (defcustom diff-mode-hook nil |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
95 "Run after setting up the `diff-mode' major mode." |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
96 :type 'hook |
62531
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
97 :options '(diff-delete-empty-files diff-make-unified) |
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
98 :group 'diff-mode) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
100 (defvar diff-outline-regexp |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)") |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102 |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
103 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 ;;;; keymap, menu, ... |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
105 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
107 (easy-mmode-defmap diff-mode-shared-map |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
108 '(;; From Pavel Machek's patch-mode. |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
109 ("n" . diff-hunk-next) |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
110 ("N" . diff-file-next) |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
111 ("p" . diff-hunk-prev) |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
112 ("P" . diff-file-prev) |
78882
ccd0441c69e1
* pcvs-defs.el (cvs-mode-map): Bind TAB and backtab.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78756
diff
changeset
|
113 ("\t" . diff-hunk-next) |
ccd0441c69e1
* pcvs-defs.el (cvs-mode-map): Bind TAB and backtab.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78756
diff
changeset
|
114 ([backtab] . diff-hunk-prev) |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
115 ("k" . diff-hunk-kill) |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
116 ("K" . diff-file-kill) |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
117 ;; From compilation-minor-mode. |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
118 ("}" . diff-file-next) |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
119 ("{" . diff-file-prev) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 ("\C-m" . diff-goto-source) |
54869
c491468e3c18
(diff-goto-source): Make it work for mouse bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54693
diff
changeset
|
121 ([mouse-2] . diff-goto-source) |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
122 ;; From XEmacs' diff-mode. |
74269
fa6583f5269e
(diff-mode-map): Add a binding for unified->context.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72813
diff
changeset
|
123 ;; Standard M-w is useful, so don't change M-W. |
fa6583f5269e
(diff-mode-map): Add a binding for unified->context.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72813
diff
changeset
|
124 ;;("W" . widen) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
125 ;;("." . diff-goto-source) ;display-buffer |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126 ;;("f" . diff-goto-source) ;find-file |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 ("o" . diff-goto-source) ;other-window |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 ;;("w" . diff-goto-source) ;other-frame |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129 ;;("N" . diff-narrow) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 ;;("h" . diff-show-header) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 ;;("j" . diff-show-difference) ;jump to Nth diff |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132 ;;("q" . diff-quit) |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
133 ;; Not useful if you have to metafy them. |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
134 ;;(" " . scroll-up) |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
135 ;;("\177" . scroll-down) |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
136 ;; Standard M-a is useful, so don't change M-A. |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
137 ;;("A" . diff-ediff-patch) |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
138 ;; Standard M-r is useful, so don't change M-r or M-R. |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
139 ;;("r" . diff-restrict-view) |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
140 ;;("R" . diff-reverse-direction) |
53782
12d228ede0dd
Bind q to `quit-window'.
Benjamin Rutt <brutt@bloomington.in.us>
parents:
53058
diff
changeset
|
141 ("q" . quit-window)) |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
142 "Basic keymap for `diff-mode', bound to various prefix keys.") |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
144 (easy-mmode-defmap diff-mode-map |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 `(("\e" . ,diff-mode-shared-map) |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
146 ;; From compilation-minor-mode. |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
147 ("\C-c\C-c" . diff-goto-source) |
91528
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
148 ;; By analogy with the global C-x 4 a binding. |
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
149 ("\C-x4A" . diff-add-change-log-entries-other-window) |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
150 ;; Misc operations. |
70333
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
151 ("\C-c\C-a" . diff-apply-hunk) |
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
152 ("\C-c\C-e" . diff-ediff-patch) |
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
153 ("\C-c\C-n" . diff-restrict-view) |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
154 ("\C-c\C-s" . diff-split-hunk) |
56919
34b22fc9d0ed
(diff-mode-map): Bind toggle-next-error-follow-mode.
Eli Zaretskii <eliz@gnu.org>
parents:
56073
diff
changeset
|
155 ("\C-c\C-t" . diff-test-hunk) |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
156 ("\C-c\C-r" . diff-reverse-direction) |
70333
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
157 ("\C-c\C-u" . diff-context->unified) |
74269
fa6583f5269e
(diff-mode-map): Add a binding for unified->context.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72813
diff
changeset
|
158 ;; `d' because it duplicates the context :-( --Stef |
fa6583f5269e
(diff-mode-map): Add a binding for unified->context.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72813
diff
changeset
|
159 ("\C-c\C-d" . diff-unified->context) |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
160 ("\C-c\C-w" . diff-ignore-whitespace-hunk) |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
161 ("\C-c\C-b" . diff-refine-hunk) ;No reason for `b' :-( |
57020
f1329d47fa1a
(diff-mode-map): Rename `next-error-follow-mode' to `next-error-follow-minor-mode'.
Juri Linkov <juri@jurta.org>
parents:
56919
diff
changeset
|
162 ("\C-c\C-f" . next-error-follow-minor-mode)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163 "Keymap for `diff-mode'. See also `diff-mode-shared-map'.") |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
164 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
165 (easy-menu-define diff-mode-menu diff-mode-map |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
166 "Menu for `diff-mode'." |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
167 '("Diff" |
92678
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
168 ["Jump to Source" diff-goto-source |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
169 :help "Jump to the corresponding source line"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
170 ["Apply hunk" diff-apply-hunk |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
171 :help "Apply the current hunk to the source file and go to the next"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
172 ["Test applying hunk" diff-test-hunk |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
173 :help "See whether it's possible to apply the current hunk"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
174 ["Apply diff with Ediff" diff-ediff-patch |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
175 :help "Call `ediff-patch-file' on the current buffer"] |
91528
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
176 ["Create Change Log entries" diff-add-change-log-entries-other-window |
91525 | 177 :help "Create ChangeLog entries for the changes in the diff buffer"] |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
178 "-----" |
92678
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
179 ["Reverse direction" diff-reverse-direction |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
180 :help "Reverse the direction of the diffs"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
181 ["Context -> Unified" diff-context->unified |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
182 :help "Convert context diffs to unified diffs"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
183 ["Unified -> Context" diff-unified->context |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
184 :help "Convert unified diffs to context diffs"] |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 ;;["Fixup Headers" diff-fixup-modifs (not buffer-read-only)] |
101070
3f35938e8ea3
(diff-show-trailing-whitespaces): Remove function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100843
diff
changeset
|
186 ["Show trailing whitespace" whitespace-mode |
101154
7b7c30fbeecd
Fix last change to use bound-and-true-p.
Chong Yidong <cyd@stupidchicken.com>
parents:
101153
diff
changeset
|
187 :style toggle :selected (bound-and-true-p whitespace-mode) |
101070
3f35938e8ea3
(diff-show-trailing-whitespaces): Remove function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100843
diff
changeset
|
188 :help "Show trailing whitespace in modified lines"] |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
189 "-----" |
92678
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
190 ["Split hunk" diff-split-hunk |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
191 :active (diff-splittable-p) |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
192 :help "Split the current (unified diff) hunk at point into two hunks"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
193 ["Ignore whitespace changes" diff-ignore-whitespace-hunk |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
194 :help "Re-diff the current hunk, ignoring whitespace differences"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
195 ["Highlight fine changes" diff-refine-hunk |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
196 :help "Highlight changes of hunk at point at a finer granularity"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
197 ["Kill current hunk" diff-hunk-kill |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
198 :help "Kill current hunk"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
199 ["Kill current file's hunks" diff-file-kill |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
200 :help "Kill all current file's hunks"] |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
201 "-----" |
92678
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
202 ["Previous Hunk" diff-hunk-prev |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
203 :help "Go to the previous count'th hunk"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
204 ["Next Hunk" diff-hunk-next |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
205 :help "Go to the next count'th hunk"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
206 ["Previous File" diff-file-prev |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
207 :help "Go to the previous count'th file"] |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
208 ["Next File" diff-file-next |
a7290e24873c
(diff-mode-menu): Add :help.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92618
diff
changeset
|
209 :help "Go to the next count'th file"] |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 )) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211 |
31973
ad9838a9349c
(diff-mode-map, diff-minor-mode-prefix):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31819
diff
changeset
|
212 (defcustom diff-minor-mode-prefix "\C-c=" |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
213 "Prefix key for `diff-minor-mode' commands." |
62531
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
214 :type '(choice (string "\e") (string "C-c=") string) |
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61269
diff
changeset
|
215 :group 'diff-mode) |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
216 |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
217 (easy-mmode-defmap diff-minor-mode-map |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
218 `((,diff-minor-mode-prefix . ,diff-mode-shared-map)) |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
219 "Keymap for `diff-minor-mode'. See also `diff-mode-shared-map'.") |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
220 |
96854
b9de9e7dceed
Make auto-refining a minor mode, and diff- and smerge- use it.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
96217
diff
changeset
|
221 (define-minor-mode diff-auto-refine-mode |
b9de9e7dceed
Make auto-refining a minor mode, and diff- and smerge- use it.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
96217
diff
changeset
|
222 "Automatically highlight changes in detail as the user visits hunks. |
b9de9e7dceed
Make auto-refining a minor mode, and diff- and smerge- use it.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
96217
diff
changeset
|
223 When transitioning from disabled to enabled, |
b9de9e7dceed
Make auto-refining a minor mode, and diff- and smerge- use it.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
96217
diff
changeset
|
224 try to refine the current hunk, as well." |
96907
c80b0289ddf5
(diff-auto-refine-mode): Remove lighter, since it's
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
96854
diff
changeset
|
225 :group 'diff-mode :init-value t :lighter nil ;; " Auto-Refine" |
96854
b9de9e7dceed
Make auto-refining a minor mode, and diff- and smerge- use it.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
96217
diff
changeset
|
226 (when diff-auto-refine-mode |
b9de9e7dceed
Make auto-refining a minor mode, and diff- and smerge- use it.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
96217
diff
changeset
|
227 (condition-case-no-debug nil (diff-refine-hunk) (error nil)))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
229 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
230 ;;;; font-lock support |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
231 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
233 (defface diff-header |
55322
a02bfe4ba7ab
(diff-header-face, diff-file-header-face): Use min-colors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55088
diff
changeset
|
234 '((((class color) (min-colors 88) (background light)) |
93061
d8532269f863
(diff-header): Make the color louder.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92749
diff
changeset
|
235 :background "grey80") |
55322
a02bfe4ba7ab
(diff-header-face, diff-file-header-face): Use min-colors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55088
diff
changeset
|
236 (((class color) (min-colors 88) (background dark)) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
237 :background "grey45") |
55322
a02bfe4ba7ab
(diff-header-face, diff-file-header-face): Use min-colors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55088
diff
changeset
|
238 (((class color) (background light)) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
239 :foreground "blue1" :weight bold) |
55322
a02bfe4ba7ab
(diff-header-face, diff-file-header-face): Use min-colors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55088
diff
changeset
|
240 (((class color) (background dark)) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
241 :foreground "green" :weight bold) |
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
242 (t :weight bold)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
243 "`diff-mode' face inherited by hunk and index header faces." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
244 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
245 (define-obsolete-face-alias 'diff-header-face 'diff-header "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
246 (defvar diff-header-face 'diff-header) |
31734
6b057ae8165d
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31705
diff
changeset
|
247 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
248 (defface diff-file-header |
55322
a02bfe4ba7ab
(diff-header-face, diff-file-header-face): Use min-colors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55088
diff
changeset
|
249 '((((class color) (min-colors 88) (background light)) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
250 :background "grey70" :weight bold) |
55322
a02bfe4ba7ab
(diff-header-face, diff-file-header-face): Use min-colors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55088
diff
changeset
|
251 (((class color) (min-colors 88) (background dark)) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
252 :background "grey60" :weight bold) |
55322
a02bfe4ba7ab
(diff-header-face, diff-file-header-face): Use min-colors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55088
diff
changeset
|
253 (((class color) (background light)) |
64496
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
254 :foreground "green" :weight bold) |
55322
a02bfe4ba7ab
(diff-header-face, diff-file-header-face): Use min-colors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55088
diff
changeset
|
255 (((class color) (background dark)) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
256 :foreground "cyan" :weight bold) |
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
257 (t :weight bold)) ; :height 1.3 |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
258 "`diff-mode' face used to highlight file header lines." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
259 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
260 (define-obsolete-face-alias 'diff-file-header-face 'diff-file-header "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
261 (defvar diff-file-header-face 'diff-file-header) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
263 (defface diff-index |
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
264 '((t :inherit diff-file-header)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
265 "`diff-mode' face used to highlight index header lines." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
266 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
267 (define-obsolete-face-alias 'diff-index-face 'diff-index "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
268 (defvar diff-index-face 'diff-index) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
270 (defface diff-hunk-header |
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
271 '((t :inherit diff-header)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
272 "`diff-mode' face used to highlight hunk header lines." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
273 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
274 (define-obsolete-face-alias 'diff-hunk-header-face 'diff-hunk-header "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
275 (defvar diff-hunk-header-face 'diff-hunk-header) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
276 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
277 (defface diff-removed |
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
278 '((t :inherit diff-changed)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
279 "`diff-mode' face used to highlight removed lines." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
280 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
281 (define-obsolete-face-alias 'diff-removed-face 'diff-removed "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
282 (defvar diff-removed-face 'diff-removed) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
283 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
284 (defface diff-added |
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
285 '((t :inherit diff-changed)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
286 "`diff-mode' face used to highlight added lines." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
287 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
288 (define-obsolete-face-alias 'diff-added-face 'diff-added "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
289 (defvar diff-added-face 'diff-added) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
291 (defface diff-changed |
32576
c6eb63e9c25c
(diff-header-face, diff-file-header-face)
Eli Zaretskii <eliz@gnu.org>
parents:
32482
diff
changeset
|
292 '((((type tty pc) (class color) (background light)) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
293 :foreground "magenta" :weight bold :slant italic) |
32576
c6eb63e9c25c
(diff-header-face, diff-file-header-face)
Eli Zaretskii <eliz@gnu.org>
parents:
32482
diff
changeset
|
294 (((type tty pc) (class color) (background dark)) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
295 :foreground "yellow" :weight bold :slant italic)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
296 "`diff-mode' face used to highlight changed lines." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
297 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
298 (define-obsolete-face-alias 'diff-changed-face 'diff-changed "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
299 (defvar diff-changed-face 'diff-changed) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
300 |
64496
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
301 (defface diff-indicator-removed |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
302 '((t :inherit diff-removed)) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
303 "`diff-mode' face used to highlight indicator of removed lines (-, <)." |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
304 :group 'diff-mode |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
305 :version "22.1") |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
306 (defvar diff-indicator-removed-face 'diff-indicator-removed) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
307 |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
308 (defface diff-indicator-added |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
309 '((t :inherit diff-added)) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
310 "`diff-mode' face used to highlight indicator of added lines (+, >)." |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
311 :group 'diff-mode |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
312 :version "22.1") |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
313 (defvar diff-indicator-added-face 'diff-indicator-added) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
314 |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
315 (defface diff-indicator-changed |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
316 '((t :inherit diff-changed)) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
317 "`diff-mode' face used to highlight indicator of changed lines." |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
318 :group 'diff-mode |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
319 :version "22.1") |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
320 (defvar diff-indicator-changed-face 'diff-indicator-changed) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
321 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
322 (defface diff-function |
69608
0c54773776e4
(diff-function): Make it inherit from diff-header instead of diff-context.
Nick Roberts <nickrob@snap.net.nz>
parents:
68651
diff
changeset
|
323 '((t :inherit diff-header)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
324 "`diff-mode' face used to highlight function names produced by \"diff -p\"." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
325 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
326 (define-obsolete-face-alias 'diff-function-face 'diff-function "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
327 (defvar diff-function-face 'diff-function) |
32603
87af45b9ad99
(diff-header-face, diff-file-header-face)
Eli Zaretskii <eliz@gnu.org>
parents:
32588
diff
changeset
|
328 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
329 (defface diff-context |
64496
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
330 '((((class color grayscale) (min-colors 88)) :inherit shadow)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
331 "`diff-mode' face used to highlight context and other side-information." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
332 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
333 (define-obsolete-face-alias 'diff-context-face 'diff-context "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
334 (defvar diff-context-face 'diff-context) |
31734
6b057ae8165d
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31705
diff
changeset
|
335 |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
336 (defface diff-nonexistent |
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
337 '((t :inherit diff-file-header)) |
62553
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
338 "`diff-mode' face used to highlight nonexistent files in recursive diffs." |
e7408ff25265
(diff-header-face, diff-file-header-face)
Lute Kamstra <lute@gnu.org>
parents:
62531
diff
changeset
|
339 :group 'diff-mode) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104564
diff
changeset
|
340 (define-obsolete-face-alias 'diff-nonexistent-face 'diff-nonexistent "22.1") |
63197
ce2a9eb0ff8a
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368
Miles Bader <miles@gnu.org>
parents:
63051
diff
changeset
|
341 (defvar diff-nonexistent-face 'diff-nonexistent) |
37531
e71362bfa695
(diff-nonexistant-face): New face.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
35526
diff
changeset
|
342 |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
343 (defconst diff-yank-handler '(diff-yank-function)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
344 (defun diff-yank-function (text) |
54540
2449619c7ccf
(diff-font-lock-keywords): Disable yank-handler.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54528
diff
changeset
|
345 ;; FIXME: the yank-handler is now called separately on each piece of text |
2449619c7ccf
(diff-font-lock-keywords): Disable yank-handler.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54528
diff
changeset
|
346 ;; with a yank-handler property, so the next-single-property-change call |
2449619c7ccf
(diff-font-lock-keywords): Disable yank-handler.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54528
diff
changeset
|
347 ;; below will always return nil :-( --stef |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
348 (let ((mixed (next-single-property-change 0 'yank-handler text)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
349 (start (point))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
350 ;; First insert the text. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
351 (insert text) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
352 ;; If the text does not include any diff markers and if we're not |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
353 ;; yanking back into a diff-mode buffer, get rid of the prefixes. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
354 (unless (or mixed (derived-mode-p 'diff-mode)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
355 (undo-boundary) ; Just in case the user wanted the prefixes. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
356 (let ((re (save-excursion |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
357 (if (re-search-backward "^[><!][ \t]" start t) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
358 (if (eq (char-after) ?!) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
359 "^[!+- ][ \t]" "^[<>][ \t]") |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
360 "^[ <>!+-]")))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
361 (save-excursion |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
362 (while (re-search-backward re start t) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
363 (replace-match "" t t))))))) |
61269
5d2796fc9f80
(diff-minor-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
57418
diff
changeset
|
364 |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
365 (defconst diff-hunk-header-re-unified |
80528
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
366 "^@@ -\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? \\+\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? @@") |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
367 (defconst diff-context-mid-hunk-header-re |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
368 "--- \\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? ----$") |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
369 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
370 (defvar diff-font-lock-keywords |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
371 `((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$") |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
372 (1 diff-hunk-header-face) (6 diff-function-face)) |
64496
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
373 ("^\\(\\*\\{15\\}\\)\\(.*\\)$" ;context |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
374 (1 diff-hunk-header-face) (2 diff-function-face)) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
375 ("^\\*\\*\\* .+ \\*\\*\\*\\*". diff-hunk-header-face) ;context |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
376 (,diff-context-mid-hunk-header-re . diff-hunk-header-face) ;context |
64496
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
377 ("^[0-9,]+[acd][0-9,]+$" . diff-hunk-header-face) ;normal |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
378 ("^---$" . diff-hunk-header-face) ;normal |
82255
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
379 ;; For file headers, accept files with spaces, but be careful to rule |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
380 ;; out false-positives when matching hunk headers. |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
381 ("^\\(---\\|\\+\\+\\+\\|\\*\\*\\*\\) \\([^\t\n]+?\\)\\(?:\t.*\\| \\(\\*\\*\\*\\*\\|----\\)\\)?\n" |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
382 (0 diff-header-face) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
383 (2 (if (not (match-end 3)) diff-file-header-face) prepend)) |
64496
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
384 ("^\\([-<]\\)\\(.*\n\\)" |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
385 (1 diff-indicator-removed-face) (2 diff-removed-face)) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
386 ("^\\([+>]\\)\\(.*\n\\)" |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
387 (1 diff-indicator-added-face) (2 diff-added-face)) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
388 ("^\\(!\\)\\(.*\n\\)" |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
389 (1 diff-indicator-changed-face) (2 diff-changed-face)) |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
390 ("^Index: \\(.+\\).*\n" |
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
391 (0 diff-header-face) (1 diff-index-face prepend)) |
37567
50d77d1b2d58
(diff-nonexistent-face, diff-font-lock-keywords):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37531
diff
changeset
|
392 ("^Only in .*\n" . diff-nonexistent-face) |
64496
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
393 ("^\\(#\\)\\(.*\\)" |
64512
a4d1eb8d55e6
(diff-font-lock-keywords): Simplify comments fontifying rule.
Juri Linkov <juri@jurta.org>
parents:
64496
diff
changeset
|
394 (1 font-lock-comment-delimiter-face) |
a4d1eb8d55e6
(diff-font-lock-keywords): Simplify comments fontifying rule.
Juri Linkov <juri@jurta.org>
parents:
64496
diff
changeset
|
395 (2 font-lock-comment-face)) |
64496
558b187cced1
(diff-file-header): Change foreground color from
Juri Linkov <juri@jurta.org>
parents:
64091
diff
changeset
|
396 ("^[^-=+*!<>#].*\n" (0 diff-context-face)))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
397 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
398 (defconst diff-font-lock-defaults |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
399 '(diff-font-lock-keywords t nil nil nil (font-lock-multiline . nil))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
400 |
31269
64bb4634d6d8
(diff-mode) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents:
30873
diff
changeset
|
401 (defvar diff-imenu-generic-expression |
64bb4634d6d8
(diff-mode) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents:
30873
diff
changeset
|
402 ;; Prefer second name as first is most likely to be a backup or |
33488
352cb95d9f27
(diff-imenu-generic-expression): Modify unidiff
Dave Love <fx@gnu.org>
parents:
33432
diff
changeset
|
403 ;; version-control name. The [\t\n] at the end of the unidiff pattern |
352cb95d9f27
(diff-imenu-generic-expression): Modify unidiff
Dave Love <fx@gnu.org>
parents:
33432
diff
changeset
|
404 ;; catches Debian source diff files (which lack the trailing date). |
352cb95d9f27
(diff-imenu-generic-expression): Modify unidiff
Dave Love <fx@gnu.org>
parents:
33432
diff
changeset
|
405 '((nil "\\+\\+\\+\\ \\([^\t\n]+\\)[\t\n]" 1) ; unidiffs |
31269
64bb4634d6d8
(diff-mode) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents:
30873
diff
changeset
|
406 (nil "^--- \\([^\t\n]+\\)\t.*\n\\*" 1))) ; context diffs |
64bb4634d6d8
(diff-mode) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents:
30873
diff
changeset
|
407 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
408 ;;;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
409 ;;;; Movement |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
410 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
411 |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
412 (defvar diff-valid-unified-empty-line t |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
413 "If non-nil, empty lines are valid in unified diffs. |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
414 Some versions of diff replace all-blank context lines in unified format with |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
415 empty lines. This makes the format less robust, but is tolerated. |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
416 See http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01990.html") |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
417 |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
418 (defconst diff-hunk-header-re |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
419 (concat "^\\(?:" diff-hunk-header-re-unified ".*\\|\\*\\{15\\}.*\n\\*\\*\\* .+ \\*\\*\\*\\*\\|[0-9]+\\(,[0-9]+\\)?[acd][0-9]+\\(,[0-9]+\\)?\\)$")) |
94872
c5a53051fe83
(diff-hunk-header-re): Refine the regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
420 (defconst diff-file-header-re (concat "^\\(--- .+\n\\+\\+\\+ \\|\\*\\*\\* .+\n--- \\|[^-+!<>0-9@* \n]\\).+\n" (substring diff-hunk-header-re 1))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
421 (defvar diff-narrowed-to nil) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
422 |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
423 (defun diff-hunk-style (&optional style) |
54928
28a55e2ec30f
(diff-end-of-hunk): Be more careful with unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54869
diff
changeset
|
424 (when (looking-at diff-hunk-header-re) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
425 (setq style (cdr (assq (char-after) '((?@ . unified) (?* . context))))) |
54928
28a55e2ec30f
(diff-end-of-hunk): Be more careful with unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54869
diff
changeset
|
426 (goto-char (match-end 0))) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
427 style) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
428 |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
429 (defun diff-end-of-hunk (&optional style donttrustheader) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
430 (let (end) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
431 (when (looking-at diff-hunk-header-re) |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
432 ;; Especially important for unified (because headers are ambiguous). |
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
433 (setq style (diff-hunk-style style)) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
434 (goto-char (match-end 0)) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
435 (when (and (not donttrustheader) (match-end 2)) |
80528
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
436 (let* ((nold (string-to-number (or (match-string 2) "1"))) |
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
437 (nnew (string-to-number (or (match-string 4) "1"))) |
80339
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
438 (endold |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
439 (save-excursion |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
440 (re-search-forward (if diff-valid-unified-empty-line |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
441 "^[- \n]" "^[- ]") |
80339
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
442 nil t nold) |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
443 (line-beginning-position 2))) |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
444 (endnew |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
445 ;; The hunk may end with a bunch of "+" lines, so the `end' is |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
446 ;; then further than computed above. |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
447 (save-excursion |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
448 (re-search-forward (if diff-valid-unified-empty-line |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
449 "^[+ \n]" "^[+ ]") |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
450 nil t nnew) |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
451 (line-beginning-position 2)))) |
448b3f1d280a
(diff-end-of-hunk): Be careful not to overlook trailing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80246
diff
changeset
|
452 (setq end (max endold endnew))))) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
453 ;; We may have a first evaluation of `end' thanks to the hunk header. |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
454 (unless end |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
455 (setq end (and (re-search-forward |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
456 (case style |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
457 (unified (concat (if diff-valid-unified-empty-line |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
458 "^[^-+# \\\n]\\|" "^[^-+# \\]\\|") |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
459 ;; A `unified' header is ambiguous. |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
460 diff-file-header-re)) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
461 (context "^[^-+#! \\]") |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
462 (normal "^[^<>#\\]") |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
463 (t "^[^-+#!<> \\]")) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
464 nil t) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
465 (match-beginning 0))) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
466 (when diff-valid-unified-empty-line |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
467 ;; While empty lines may be valid inside hunks, they are also likely |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
468 ;; to be unrelated to the hunk. |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
469 (goto-char (or end (point-max))) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
470 (while (eq ?\n (char-before (1- (point)))) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
471 (forward-char -1) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
472 (setq end (point))))) |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
473 ;; The return value is used by easy-mmode-define-navigation. |
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
474 (goto-char (or end (point-max))))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
475 |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
476 (defun diff-beginning-of-hunk (&optional try-harder) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
477 "Move back to beginning of hunk. |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
478 If TRY-HARDER is non-nil, try to cater to the case where we're not in a hunk |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
479 but in the file header instead, in which case move forward to the first hunk." |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
480 (beginning-of-line) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
481 (unless (looking-at diff-hunk-header-re) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
482 (forward-line 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
483 (condition-case () |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
484 (re-search-backward diff-hunk-header-re) |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
485 (error |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
486 (if (not try-harder) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
487 (error "Can't find the beginning of the hunk") |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
488 (diff-beginning-of-file-and-junk) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
489 (diff-hunk-next)))))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
490 |
82037
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
491 (defun diff-unified-hunk-p () |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
492 (save-excursion |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
493 (ignore-errors |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
494 (diff-beginning-of-hunk) |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
495 (looking-at "^@@")))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
496 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
497 (defun diff-beginning-of-file () |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
498 (beginning-of-line) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
499 (unless (looking-at diff-file-header-re) |
82255
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
500 (let ((start (point)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
501 res) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
502 ;; diff-file-header-re may need to match up to 4 lines, so in case |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
503 ;; we're inside the header, we need to move up to 3 lines forward. |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
504 (forward-line 3) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
505 (if (and (setq res (re-search-backward diff-file-header-re nil t)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
506 ;; Maybe the 3 lines forward were too much and we matched |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
507 ;; a file header after our starting point :-( |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
508 (or (<= (point) start) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
509 (setq res (re-search-backward diff-file-header-re nil t)))) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
510 res |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
511 (goto-char start) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
512 (error "Can't find the beginning of the file"))))) |
100171 | 513 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
514 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
515 (defun diff-end-of-file () |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
516 (re-search-forward "^[-+#!<>0-9@* \\]" nil t) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
517 (re-search-forward (concat "^[^-+#!<>0-9@* \\]\\|" diff-file-header-re) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
518 nil 'move) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
519 (if (match-beginning 1) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
520 (goto-char (match-beginning 1)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
521 (beginning-of-line))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
522 |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
523 ;; Define diff-{hunk,file}-{prev,next} |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
524 (easy-mmode-define-navigation |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
525 diff-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view |
96854
b9de9e7dceed
Make auto-refining a minor mode, and diff- and smerge- use it.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
96217
diff
changeset
|
526 (if diff-auto-refine-mode |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
527 (condition-case-no-debug nil (diff-refine-hunk) (error nil)))) |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
528 |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
529 (easy-mmode-define-navigation |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
530 diff-file diff-file-header-re "file" diff-end-of-hunk) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
531 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
532 (defun diff-restrict-view (&optional arg) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
533 "Restrict the view to the current hunk. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
534 If the prefix ARG is given, restrict the view to the current file instead." |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
535 (interactive "P") |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
536 (save-excursion |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
537 (if arg (diff-beginning-of-file) (diff-beginning-of-hunk 'try-harder)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
538 (narrow-to-region (point) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
539 (progn (if arg (diff-end-of-file) (diff-end-of-hunk)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
540 (point))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
541 (set (make-local-variable 'diff-narrowed-to) (if arg 'file 'hunk)))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
542 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
543 |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
544 (defun diff-hunk-kill () |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
545 "Kill current hunk." |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
546 (interactive) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
547 (diff-beginning-of-hunk) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
548 (let* ((start (point)) |
104893
511c7f2425a4
(diff-hunk-kill): Fix the search of the next hunk (bug#4368).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104778
diff
changeset
|
549 ;; Search the second match, since we're looking at the first. |
511c7f2425a4
(diff-hunk-kill): Fix the search of the next hunk (bug#4368).
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104778
diff
changeset
|
550 (nexthunk (when (re-search-forward diff-hunk-header-re nil t 2) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
551 (match-beginning 0))) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
552 (firsthunk (ignore-errors |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
553 (goto-char start) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
554 (diff-beginning-of-file) (diff-hunk-next) (point))) |
71249
3798a822991e
* diff-mode.el (diff-hunk-kill, diff-file-kill, diff-split-hunk)
Chong Yidong <cyd@stupidchicken.com>
parents:
71248
diff
changeset
|
555 (nextfile (ignore-errors (diff-file-next) (point))) |
3798a822991e
* diff-mode.el (diff-hunk-kill, diff-file-kill, diff-split-hunk)
Chong Yidong <cyd@stupidchicken.com>
parents:
71248
diff
changeset
|
556 (inhibit-read-only t)) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
557 (goto-char start) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
558 (if (and firsthunk (= firsthunk start) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
559 (or (null nexthunk) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
560 (and nextfile (> nexthunk nextfile)))) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
561 ;; It's the only hunk for this file, so kill the file. |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
562 (diff-file-kill) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
563 (diff-end-of-hunk) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
564 (kill-region start (point))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
565 |
93679
3636fd479ab3
* diff-mode.el (diff-file-junk-re): Recognize the git format for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93678
diff
changeset
|
566 ;; "index ", "old mode", "new mode", "new file mode" and |
3636fd479ab3
* diff-mode.el (diff-file-junk-re): Recognize the git format for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93678
diff
changeset
|
567 ;; "deleted file mode" are output by git-diff. |
100171 | 568 (defconst diff-file-junk-re |
93679
3636fd479ab3
* diff-mode.el (diff-file-junk-re): Recognize the git format for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93678
diff
changeset
|
569 "diff \\|index \\|\\(?:deleted file\\|new\\(?: file\\)?\\|old\\) mode") |
80152
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
570 |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
571 (defun diff-beginning-of-file-and-junk () |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
572 "Go to the beginning of file-related diff-info. |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
573 This is like `diff-beginning-of-file' except it tries to skip back over leading |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
574 data such as \"Index: ...\" and such." |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
575 (let* ((orig (point)) |
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
576 ;; Skip forward over what might be "leading junk" so as to get |
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
577 ;; closer to the actual diff. |
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
578 (_ (progn (beginning-of-line) |
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
579 (while (looking-at diff-file-junk-re) |
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
580 (forward-line 1)))) |
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
581 (start (point)) |
82255
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
582 (prevfile (condition-case err |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
583 (save-excursion (diff-beginning-of-file) (point)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
584 (error err))) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
585 (err (if (consp prevfile) prevfile)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
586 (nextfile (ignore-errors |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
587 (save-excursion |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
588 (goto-char start) (diff-file-next) (point)))) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
589 ;; prevhunk is one of the limits. |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
590 (prevhunk (save-excursion |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
591 (ignore-errors |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
592 (if (numberp prevfile) (goto-char prevfile)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
593 (diff-hunk-prev) (point)))) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
594 (previndex (save-excursion |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
595 (forward-line 1) ;In case we're looking at "Index:". |
82255
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
596 (re-search-backward "^Index: " prevhunk t)))) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
597 ;; If we're in the junk, we should use nextfile instead of prevfile. |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
598 (if (and (numberp nextfile) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
599 (or (not (numberp prevfile)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
600 (and previndex (> previndex prevfile)))) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
601 (setq prevfile nextfile)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
602 (if (and previndex (numberp prevfile) (< previndex prevfile)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
603 (setq prevfile previndex)) |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
604 (if (and (numberp prevfile) (<= prevfile start)) |
80152
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
605 (progn |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
606 (goto-char prevfile) |
80152
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
607 ;; Now skip backward over the leading junk we may have before the |
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
608 ;; diff itself. |
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
609 (while (save-excursion |
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
610 (and (zerop (forward-line -1)) |
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
611 (looking-at diff-file-junk-re))) |
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
612 (forward-line -1))) |
82255
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
613 ;; File starts *after* the starting point: we really weren't in |
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
614 ;; a file diff but elsewhere. |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
615 (goto-char orig) |
82255
eea3be43d1de
(diff-font-lock-keywords): Fix up false positives.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
616 (signal (car err) (cdr err))))) |
100171 | 617 |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
618 (defun diff-file-kill () |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
619 "Kill current file's hunks." |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
620 (interactive) |
80152
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
621 (let ((orig (point)) |
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
622 (start (progn (diff-beginning-of-file-and-junk) (point))) |
71249
3798a822991e
* diff-mode.el (diff-hunk-kill, diff-file-kill, diff-split-hunk)
Chong Yidong <cyd@stupidchicken.com>
parents:
71248
diff
changeset
|
623 (inhibit-read-only t)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
624 (diff-end-of-file) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
625 (if (looking-at "^\n") (forward-char 1)) ;`tla' generates such diffs. |
80152
f200e5de5464
(diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80151
diff
changeset
|
626 (if (> orig (point)) (error "Not inside a file diff")) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
627 (kill-region start (point)))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
628 |
27637
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
629 (defun diff-kill-junk () |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
630 "Kill spurious empty diffs." |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
631 (interactive) |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
632 (save-excursion |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
633 (let ((inhibit-read-only t)) |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
634 (goto-char (point-min)) |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
635 (while (re-search-forward (concat "^\\(Index: .*\n\\)" |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
636 "\\([^-+!* <>].*\n\\)*?" |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
637 "\\(\\(Index:\\) \\|" |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
638 diff-file-header-re "\\)") |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
639 nil t) |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
640 (delete-region (if (match-end 4) (match-beginning 0) (match-end 1)) |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
641 (match-beginning 3)) |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
642 (beginning-of-line))))) |
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
643 |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
644 (defun diff-count-matches (re start end) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
645 (save-excursion |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
646 (let ((n 0)) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
647 (goto-char start) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
648 (while (re-search-forward re end t) (incf n)) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
649 n))) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
650 |
82037
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
651 (defun diff-splittable-p () |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
652 (save-excursion |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
653 (beginning-of-line) |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
654 (and (looking-at "^[-+ ]") |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
655 (progn (forward-line -1) (looking-at "^[-+ ]")) |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
656 (diff-unified-hunk-p)))) |
1d7514cb50ef
(diff-refine-ignore-spaces-hunk): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82036
diff
changeset
|
657 |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
658 (defun diff-split-hunk () |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
659 "Split the current (unified diff) hunk at point into two hunks." |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
660 (interactive) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
661 (beginning-of-line) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
662 (let ((pos (point)) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
663 (start (progn (diff-beginning-of-hunk) (point)))) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
664 (unless (looking-at diff-hunk-header-re-unified) |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
665 (error "diff-split-hunk only works on unified context diffs")) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
666 (forward-line 1) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
667 (let* ((start1 (string-to-number (match-string 1))) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
668 (start2 (string-to-number (match-string 3))) |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
669 (newstart1 (+ start1 (diff-count-matches "^[- \t]" (point) pos))) |
71249
3798a822991e
* diff-mode.el (diff-hunk-kill, diff-file-kill, diff-split-hunk)
Chong Yidong <cyd@stupidchicken.com>
parents:
71248
diff
changeset
|
670 (newstart2 (+ start2 (diff-count-matches "^[+ \t]" (point) pos))) |
3798a822991e
* diff-mode.el (diff-hunk-kill, diff-file-kill, diff-split-hunk)
Chong Yidong <cyd@stupidchicken.com>
parents:
71248
diff
changeset
|
671 (inhibit-read-only t)) |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
672 (goto-char pos) |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
673 ;; Hopefully the after-change-function will not screw us over. |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
674 (insert "@@ -" (number-to-string newstart1) ",1 +" |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
675 (number-to-string newstart2) ",1 @@\n") |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
676 ;; Fix the original hunk-header. |
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
677 (diff-fixup-modifs start pos)))) |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47523
diff
changeset
|
678 |
33432
7f6ffdaecedc
(diff-mode-menu): Add entry for applying hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32666
diff
changeset
|
679 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
680 ;;;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
681 ;;;; jump to other buffers |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
682 ;;;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
683 |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
684 (defvar diff-remembered-files-alist nil) |
93190
57ae4f7f7151
(diff-remembered-defdir): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93061
diff
changeset
|
685 (defvar diff-remembered-defdir nil) |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
686 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
687 (defun diff-filename-drop-dir (file) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
688 (when (string-match "/" file) (substring file (match-end 0)))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
689 |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
690 (defun diff-merge-strings (ancestor from to) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
691 "Merge the diff between ANCESTOR and FROM into TO. |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
692 Returns the merged string if successful or nil otherwise. |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
693 The strings are assumed not to contain any \"\\n\" (i.e. end of line). |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
694 If ANCESTOR = FROM, returns TO. |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
695 If ANCESTOR = TO, returns FROM. |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
696 The heuristic is simplistic and only really works for cases |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
697 like \(diff-merge-strings \"b/foo\" \"b/bar\" \"/a/c/foo\")." |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
698 ;; Ideally, we want: |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
699 ;; AMB ANB CMD -> CND |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
700 ;; but that's ambiguous if `foo' or `bar' is empty: |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
701 ;; a/foo a/foo1 b/foo.c -> b/foo1.c but not 1b/foo.c or b/foo.c1 |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
702 (let ((str (concat ancestor "\n" from "\n" to))) |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
703 (when (and (string-match (concat |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
704 "\\`\\(.*?\\)\\(.*\\)\\(.*\\)\n" |
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
705 "\\1\\(.*\\)\\3\n" |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
706 "\\(.*\\(\\2\\).*\\)\\'") str) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
707 (equal to (match-string 5 str))) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
708 (concat (substring str (match-beginning 5) (match-beginning 6)) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
709 (match-string 4 str) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
710 (substring str (match-end 6) (match-end 5)))))) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
711 |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
712 (defun diff-tell-file-name (old name) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
713 "Tell Emacs where the find the source file of the current hunk. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
714 If the OLD prefix arg is passed, tell the file NAME of the old file." |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
715 (interactive |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
716 (let* ((old current-prefix-arg) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
717 (fs (diff-hunk-file-names current-prefix-arg))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
718 (unless fs (error "No file name to look for")) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
719 (list old (read-file-name (format "File for %s: " (car fs)) |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
720 nil (diff-find-file-name old 'noprompt) t)))) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
721 (let ((fs (diff-hunk-file-names old))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
722 (unless fs (error "No file name to look for")) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
723 (push (cons fs name) diff-remembered-files-alist))) |
61269
5d2796fc9f80
(diff-minor-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
57418
diff
changeset
|
724 |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
725 (defun diff-hunk-file-names (&optional old) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
726 "Give the list of file names textually mentioned for the current hunk." |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
727 (save-excursion |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
728 (unless (looking-at diff-file-header-re) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
729 (or (ignore-errors (diff-beginning-of-file)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
730 (re-search-forward diff-file-header-re nil t))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
731 (let ((limit (save-excursion |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
732 (condition-case () |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
733 (progn (diff-hunk-prev) (point)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
734 (error (point-min))))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
735 (header-files |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
736 (if (looking-at "[-*][-*][-*] \\(\\S-+\\)\\(\\s-.*\\)?\n[-+][-+][-+] \\(\\S-+\\)") |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
737 (list (if old (match-string 1) (match-string 3)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
738 (if old (match-string 3) (match-string 1))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
739 (forward-line 1) nil))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
740 (delq nil |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
741 (append |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
742 (when (and (not old) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
743 (save-excursion |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
744 (re-search-backward "^Index: \\(.+\\)" limit t))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
745 (list (match-string 1))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
746 header-files |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
747 (when (re-search-backward |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
748 "^diff \\(-\\S-+ +\\)*\\(\\S-+\\)\\( +\\(\\S-+\\)\\)?" |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
749 nil t) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
750 (list (if old (match-string 2) (match-string 4)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
751 (if old (match-string 4) (match-string 2))))))))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
752 |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
753 (defun diff-find-file-name (&optional old noprompt prefix) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
754 "Return the file corresponding to the current patch. |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
755 Non-nil OLD means that we want the old file. |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
756 Non-nil NOPROMPT means to prefer returning nil than to prompt the user. |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
757 PREFIX is only used internally: don't use it." |
93190
57ae4f7f7151
(diff-remembered-defdir): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93061
diff
changeset
|
758 (unless (equal diff-remembered-defdir default-directory) |
57ae4f7f7151
(diff-remembered-defdir): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93061
diff
changeset
|
759 ;; Flush diff-remembered-files-alist if the default-directory is changed. |
57ae4f7f7151
(diff-remembered-defdir): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93061
diff
changeset
|
760 (set (make-local-variable 'diff-remembered-defdir) default-directory) |
57ae4f7f7151
(diff-remembered-defdir): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93061
diff
changeset
|
761 (set (make-local-variable 'diff-remembered-files-alist) nil)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
762 (save-excursion |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
763 (unless (looking-at diff-file-header-re) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
764 (or (ignore-errors (diff-beginning-of-file)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
765 (re-search-forward diff-file-header-re nil t))) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
766 (let ((fs (diff-hunk-file-names old))) |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
767 (if prefix (setq fs (mapcar (lambda (f) (concat prefix f)) fs))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
768 (or |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
769 ;; use any previously used preference |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
770 (cdr (assoc fs diff-remembered-files-alist)) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
771 ;; try to be clever and use previous choices as an inspiration |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
772 (dolist (rf diff-remembered-files-alist) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
773 (let ((newfile (diff-merge-strings (caar rf) (car fs) (cdr rf)))) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
774 (if (and newfile (file-exists-p newfile)) (return newfile)))) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
775 ;; look for each file in turn. If none found, try again but |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
776 ;; ignoring the first level of directory, ... |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
777 (do* ((files fs (delq nil (mapcar 'diff-filename-drop-dir files))) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
778 (file nil nil)) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
779 ((or (null files) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
780 (setq file (do* ((files files (cdr files)) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
781 (file (car files) (car files))) |
78676
b2023ab19990
(diff-find-file-name): Only accept regular files, to rule out
Glenn Morris <rgm@gnu.org>
parents:
78429
diff
changeset
|
782 ;; Use file-regular-p to avoid |
b2023ab19990
(diff-find-file-name): Only accept regular files, to rule out
Glenn Morris <rgm@gnu.org>
parents:
78429
diff
changeset
|
783 ;; /dev/null, directories, etc. |
b2023ab19990
(diff-find-file-name): Only accept regular files, to rule out
Glenn Morris <rgm@gnu.org>
parents:
78429
diff
changeset
|
784 ((or (null file) (file-regular-p file)) |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
785 file)))) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
786 file)) |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
787 ;; <foo>.rej patches implicitly apply to <foo> |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
788 (and (string-match "\\.rej\\'" (or buffer-file-name "")) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
789 (let ((file (substring buffer-file-name 0 (match-beginning 0)))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
790 (when (file-exists-p file) file))) |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
791 ;; If we haven't found the file, maybe it's because we haven't paid |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
792 ;; attention to the PCL-CVS hint. |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
793 (and (not prefix) |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
794 (boundp 'cvs-pcl-cvs-dirchange-re) |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
795 (save-excursion |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
796 (re-search-backward cvs-pcl-cvs-dirchange-re nil t)) |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
797 (diff-find-file-name old noprompt (match-string 1))) |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
798 ;; if all else fails, ask the user |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
799 (unless noprompt |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
800 (let ((file (read-file-name (format "Use file %s: " |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
801 (or (first fs) "")) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
802 nil (first fs) t (first fs)))) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
803 (set (make-local-variable 'diff-remembered-files-alist) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
804 (cons (cons fs file) diff-remembered-files-alist)) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
805 file)))))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
806 |
32012
b1edfcd919a7
(diff-add-log-file-name): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31973
diff
changeset
|
807 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
808 (defun diff-ediff-patch () |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
809 "Call `ediff-patch-file' on the current buffer." |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
810 (interactive) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
811 (condition-case err |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
812 (ediff-patch-file nil (current-buffer)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
813 (wrong-number-of-arguments (ediff-patch-file)))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
814 |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47523
diff
changeset
|
815 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
816 ;;;; Conversion functions |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47523
diff
changeset
|
817 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
818 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
819 ;;(defvar diff-inhibit-after-change nil |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
820 ;; "Non-nil means inhibit `diff-mode's after-change functions.") |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
821 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
822 (defun diff-unified->context (start end) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
823 "Convert unified diffs to context diffs. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
824 START and END are either taken from the region (if a prefix arg is given) or |
78429
a3a4480349cb
(diff-unified->context, diff-reverse-direction, diff-fixup-modifs):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78359
diff
changeset
|
825 else cover the whole buffer." |
70542
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
826 (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active)) |
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
827 (list (region-beginning) (region-end)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
828 (list (point-min) (point-max)))) |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
829 (unless (markerp end) (setq end (copy-marker end t))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
830 (let (;;(diff-inhibit-after-change t) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
831 (inhibit-read-only t)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
832 (save-excursion |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
833 (goto-char start) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
834 (while (and (re-search-forward |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
835 (concat "^\\(\\(---\\) .+\n\\(\\+\\+\\+\\) .+\\|" |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
836 diff-hunk-header-re-unified ".*\\)$") |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
837 nil t) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
838 (< (point) end)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
839 (combine-after-change-calls |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
840 (if (match-beginning 2) |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
841 ;; we matched a file header |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
842 (progn |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
843 ;; use reverse order to make sure the indices are kept valid |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
844 (replace-match "---" t t nil 3) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
845 (replace-match "***" t t nil 2)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
846 ;; we matched a hunk header |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
847 (let ((line1 (match-string 4)) |
80528
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
848 (lines1 (or (match-string 5) "1")) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
849 (line2 (match-string 6)) |
94370 | 850 (lines2 (or (match-string 7) "1")) |
82035
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
851 ;; Variables to use the special undo function. |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
852 (old-undo buffer-undo-list) |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
853 (old-end (marker-position end)) |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
854 (start (match-beginning 0)) |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
855 (reversible t)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
856 (replace-match |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
857 (concat "***************\n*** " line1 "," |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
858 (number-to-string (+ (string-to-number line1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
859 (string-to-number lines1) |
94370 | 860 -1)) |
861 " ****")) | |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
862 (save-restriction |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
863 (narrow-to-region (line-beginning-position 2) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
864 ;; Call diff-end-of-hunk from just before |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
865 ;; the hunk header so it can use the hunk |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
866 ;; header info. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
867 (progn (diff-end-of-hunk 'unified) (point))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
868 (let ((hunk (buffer-string))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
869 (goto-char (point-min)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
870 (if (not (save-excursion (re-search-forward "^-" nil t))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
871 (delete-region (point) (point-max)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
872 (goto-char (point-max)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
873 (let ((modif nil) last-pt) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
874 (while (progn (setq last-pt (point)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
875 (= (forward-line -1) 0)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
876 (case (char-after) |
64045 | 877 (?\s (insert " ") (setq modif nil) (backward-char 1)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
878 (?+ (delete-region (point) last-pt) (setq modif t)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
879 (?- (if (not modif) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
880 (progn (forward-char 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
881 (insert " ")) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
882 (delete-char 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
883 (insert "! ")) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
884 (backward-char 2)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
885 (?\\ (when (save-excursion (forward-line -1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
886 (= (char-after) ?+)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
887 (delete-region (point) last-pt) (setq modif t))) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
888 ;; diff-valid-unified-empty-line. |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
889 (?\n (insert " ") (setq modif nil) (backward-char 2)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
890 (t (setq modif nil)))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
891 (goto-char (point-max)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
892 (save-excursion |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
893 (insert "--- " line2 "," |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
894 (number-to-string (+ (string-to-number line2) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
895 (string-to-number lines2) |
94370 | 896 -1)) |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
897 " ----\n" hunk)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
898 ;;(goto-char (point-min)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
899 (forward-line 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
900 (if (not (save-excursion (re-search-forward "^+" nil t))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
901 (delete-region (point) (point-max)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
902 (let ((modif nil) (delete nil)) |
82035
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
903 (if (save-excursion (re-search-forward "^\\+.*\n-" nil t)) |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
904 ;; Normally, lines in a substitution come with |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
905 ;; first the removals and then the additions, and |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
906 ;; the context->unified function follows this |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
907 ;; convention, of course. Yet, other alternatives |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
908 ;; are valid as well, but they preclude the use of |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
909 ;; context->unified as an undo command. |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
910 (setq reversible nil)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
911 (while (not (eobp)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
912 (case (char-after) |
64045 | 913 (?\s (insert " ") (setq modif nil) (backward-char 1)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
914 (?- (setq delete t) (setq modif t)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
915 (?+ (if (not modif) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
916 (progn (forward-char 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
917 (insert " ")) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
918 (delete-char 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
919 (insert "! ")) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
920 (backward-char 2)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
921 (?\\ (when (save-excursion (forward-line 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
922 (not (eobp))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
923 (setq delete t) (setq modif t))) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
924 ;; diff-valid-unified-empty-line. |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
925 (?\n (insert " ") (setq modif nil) (backward-char 2) |
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
926 (setq reversible nil)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
927 (t (setq modif nil))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
928 (let ((last-pt (point))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
929 (forward-line 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
930 (when delete |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
931 (delete-region last-pt (point)) |
82035
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
932 (setq delete nil))))))) |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
933 (unless (or (not reversible) (eq buffer-undo-list t)) |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
934 ;; Drop the many undo entries and replace them with |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
935 ;; a single entry that uses diff-context->unified to do |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
936 ;; the work. |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
937 (setq buffer-undo-list |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
938 (cons (list 'apply (- old-end end) start (point-max) |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
939 'diff-context->unified start (point-max)) |
da9840648bbd
(diff-unified->context): Use the new `apply' undo entry kind
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82034
diff
changeset
|
940 old-undo))))))))))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
941 |
70333
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
942 (defun diff-context->unified (start end &optional to-context) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
943 "Convert context diffs to unified diffs. |
70333
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
944 START and END are either taken from the region |
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
945 \(when it is highlighted) or else cover the whole buffer. |
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
946 With a prefix argument, convert unified format to context format." |
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
947 (interactive (if (and transient-mark-mode mark-active) |
70542
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
948 (list (region-beginning) (region-end) current-prefix-arg) |
70333
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
949 (list (point-min) (point-max) current-prefix-arg))) |
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
950 (if to-context |
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
951 (diff-unified->context start end) |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
952 (unless (markerp end) (setq end (copy-marker end t))) |
70333
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
953 (let ( ;;(diff-inhibit-after-change t) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
954 (inhibit-read-only t)) |
70333
64d227e5dd44
(diff-mode-shared-map): Don't bind M-W, M-U, M-C,
Richard M. Stallman <rms@gnu.org>
parents:
70292
diff
changeset
|
955 (save-excursion |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
956 (goto-char start) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
957 (while (and (re-search-forward "^\\(\\(\\*\\*\\*\\) .+\n\\(---\\) .+\\|\\*\\{15\\}.*\n\\*\\*\\* \\([0-9]+\\),\\(-?[0-9]+\\) \\*\\*\\*\\*\\)$" nil t) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
958 (< (point) end)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
959 (combine-after-change-calls |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
960 (if (match-beginning 2) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
961 ;; we matched a file header |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
962 (progn |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
963 ;; use reverse order to make sure the indices are kept valid |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
964 (replace-match "+++" t t nil 3) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
965 (replace-match "---" t t nil 2)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
966 ;; we matched a hunk header |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
967 (let ((line1s (match-string 4)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
968 (line1e (match-string 5)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
969 (pt1 (match-beginning 0)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
970 ;; Variables to use the special undo function. |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
971 (old-undo buffer-undo-list) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
972 (old-end (marker-position end)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
973 (reversible t)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
974 (replace-match "") |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
975 (unless (re-search-forward |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
976 diff-context-mid-hunk-header-re nil t) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
977 (error "Can't find matching `--- n1,n2 ----' line")) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
978 (let ((line2s (match-string 1)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
979 (line2e (match-string 2)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
980 (pt2 (progn |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
981 (delete-region (progn (beginning-of-line) (point)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
982 (progn (forward-line 1) (point))) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
983 (point-marker)))) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
984 (goto-char pt1) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
985 (forward-line 1) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
986 (while (< (point) pt2) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
987 (case (char-after) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
988 (?! (delete-char 2) (insert "-") (forward-line 1)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
989 (?- (forward-char 1) (delete-char 1) (forward-line 1)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
990 (?\s ;merge with the other half of the chunk |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
991 (let* ((endline2 |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
992 (save-excursion |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
993 (goto-char pt2) (forward-line 1) (point)))) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
994 (case (char-after pt2) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
995 ((?! ?+) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
996 (insert "+" |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
997 (prog1 (buffer-substring (+ pt2 2) endline2) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
998 (delete-region pt2 endline2)))) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
999 (?\s |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1000 (unless (= (- endline2 pt2) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1001 (- (line-beginning-position 2) (point))) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1002 ;; If the two lines we're merging don't have the |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1003 ;; same length (can happen with "diff -b"), then |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1004 ;; diff-unified->context will not properly undo |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1005 ;; this operation. |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1006 (setq reversible nil)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1007 (delete-region pt2 endline2) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1008 (delete-char 1) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1009 (forward-line 1)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1010 (?\\ (forward-line 1)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1011 (t (setq reversible nil) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1012 (delete-char 1) (forward-line 1))))) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1013 (t (setq reversible nil) (forward-line 1)))) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1014 (while (looking-at "[+! ] ") |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1015 (if (/= (char-after) ?!) (forward-char 1) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1016 (delete-char 1) (insert "+")) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1017 (delete-char 1) (forward-line 1)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1018 (save-excursion |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1019 (goto-char pt1) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1020 (insert "@@ -" line1s "," |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1021 (number-to-string (- (string-to-number line1e) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1022 (string-to-number line1s) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1023 -1)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1024 " +" line2s "," |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1025 (number-to-string (- (string-to-number line2e) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1026 (string-to-number line2s) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1027 -1)) " @@")) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1028 (set-marker pt2 nil) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1029 ;; The whole procedure succeeded, let's replace the myriad |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1030 ;; of undo elements with just a single special one. |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1031 (unless (or (not reversible) (eq buffer-undo-list t)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1032 (setq buffer-undo-list |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1033 (cons (list 'apply (- old-end end) pt1 (point) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1034 'diff-unified->context pt1 (point)) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1035 old-undo))) |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1036 ))))))))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1037 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1038 (defun diff-reverse-direction (start end) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1039 "Reverse the direction of the diffs. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1040 START and END are either taken from the region (if a prefix arg is given) or |
78429
a3a4480349cb
(diff-unified->context, diff-reverse-direction, diff-fixup-modifs):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78359
diff
changeset
|
1041 else cover the whole buffer." |
70542
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
1042 (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active)) |
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
1043 (list (region-beginning) (region-end)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1044 (list (point-min) (point-max)))) |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
1045 (unless (markerp end) (setq end (copy-marker end t))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1046 (let (;;(diff-inhibit-after-change t) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1047 (inhibit-read-only t)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1048 (save-excursion |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1049 (goto-char start) |
29423
12e89e9b65f6
(diff-font-lock-keywords, diff-hunk-header-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28858
diff
changeset
|
1050 (while (and (re-search-forward "^\\(\\([-*][-*][-*] \\)\\(.+\\)\n\\([-+][-+][-+] \\)\\(.+\\)\\|\\*\\{15\\}.*\n\\*\\*\\* \\(.+\\) \\*\\*\\*\\*\\|@@ -\\([0-9,]+\\) \\+\\([0-9,]+\\) @@.*\\)$" nil t) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1051 (< (point) end)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1052 (combine-after-change-calls |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1053 (cond |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1054 ;; a file header |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1055 ((match-beginning 2) (replace-match "\\2\\5\n\\4\\3" nil)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1056 ;; a context-diff hunk header |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1057 ((match-beginning 6) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1058 (let ((pt-lines1 (match-beginning 6)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1059 (lines1 (match-string 6))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1060 (replace-match "" nil nil nil 6) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1061 (forward-line 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1062 (let ((half1s (point))) |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
1063 (while (looking-at "[-! \\][ \t]\\|#") |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1064 (when (= (char-after) ?-) (delete-char 1) (insert "+")) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1065 (forward-line 1)) |
27637
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
1066 (let ((half1 (delete-and-extract-region half1s (point)))) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1067 (unless (looking-at diff-context-mid-hunk-header-re) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1068 (insert half1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1069 (error "Can't find matching `--- n1,n2 ----' line")) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1070 (let* ((str1end (or (match-end 2) (match-end 1))) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1071 (str1 (buffer-substring (match-beginning 1) str1end))) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1072 (goto-char str1end) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1073 (insert lines1) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1074 (delete-region (match-beginning 1) str1end) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1075 (forward-line 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1076 (let ((half2s (point))) |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
1077 (while (looking-at "[!+ \\][ \t]\\|#") |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1078 (when (= (char-after) ?+) (delete-char 1) (insert "-")) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1079 (forward-line 1)) |
27637
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
1080 (let ((half2 (delete-and-extract-region half2s (point)))) |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
1081 (insert (or half1 "")) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1082 (goto-char half1s) |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
1083 (insert (or half2 "")))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1084 (goto-char pt-lines1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1085 (insert str1)))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1086 ;; a unified-diff hunk header |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1087 ((match-beginning 7) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1088 (replace-match "@@ -\\8 +\\7 @@" nil) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1089 (forward-line 1) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1090 (let ((c (char-after)) first last) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1091 (while (case (setq c (char-after)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1092 (?- (setq first (or first (point))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1093 (delete-char 1) (insert "+") t) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1094 (?+ (setq last (or last (point))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1095 (delete-char 1) (insert "-") t) |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
1096 ((?\\ ?#) t) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1097 (t (when (and first last (< first last)) |
46407
4c4398249108
(diff-reverse-direction): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42472
diff
changeset
|
1098 (insert (delete-and-extract-region first last))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1099 (setq first nil last nil) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1100 (memq c (if diff-valid-unified-empty-line |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1101 '(?\s ?\n) '(?\s))))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1102 (forward-line 1)))))))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1103 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1104 (defun diff-fixup-modifs (start end) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1105 "Fixup the hunk headers (in case the buffer was modified). |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1106 START and END are either taken from the region (if a prefix arg is given) or |
78429
a3a4480349cb
(diff-unified->context, diff-reverse-direction, diff-fixup-modifs):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78359
diff
changeset
|
1107 else cover the whole buffer." |
70542
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
1108 (interactive (if (or current-prefix-arg (and transient-mark-mode mark-active)) |
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
1109 (list (region-beginning) (region-end)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1110 (list (point-min) (point-max)))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1111 (let ((inhibit-read-only t)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1112 (save-excursion |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1113 (goto-char end) (diff-end-of-hunk nil 'donttrustheader) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1114 (let ((plus 0) (minus 0) (space 0) (bang 0)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1115 (while (and (= (forward-line -1) 0) (<= start (point))) |
57279
c8797551b3a0
(diff-file-header-re): Tighten up regexp a tiny bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57020
diff
changeset
|
1116 (if (not (looking-at |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1117 (concat diff-hunk-header-re-unified |
57279
c8797551b3a0
(diff-file-header-re): Tighten up regexp a tiny bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57020
diff
changeset
|
1118 "\\|[-*][-*][-*] [0-9,]+ [-*][-*][-*][-*]$" |
c8797551b3a0
(diff-file-header-re): Tighten up regexp a tiny bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57020
diff
changeset
|
1119 "\\|--- .+\n\\+\\+\\+ "))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1120 (case (char-after) |
57279
c8797551b3a0
(diff-file-header-re): Tighten up regexp a tiny bit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57020
diff
changeset
|
1121 (?\s (incf space)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1122 (?+ (incf plus)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1123 (?- (incf minus)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1124 (?! (incf bang)) |
28858
85d4cc0b8741
(diff-font-lock-keywords): Recognize comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28240
diff
changeset
|
1125 ((?\\ ?#) nil) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1126 (t (setq space 0 plus 0 minus 0 bang 0))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1127 (cond |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1128 ((looking-at diff-hunk-header-re-unified) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1129 (let* ((old1 (match-string 2)) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1130 (old2 (match-string 4)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1131 (new1 (number-to-string (+ space minus))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1132 (new2 (number-to-string (+ space plus)))) |
80528
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
1133 (if old2 |
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
1134 (unless (string= new2 old2) (replace-match new2 t t nil 4)) |
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
1135 (goto-char (match-end 4)) (insert "," new2)) |
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
1136 (if old1 |
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
1137 (unless (string= new1 old1) (replace-match new1 t t nil 2)) |
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
1138 (goto-char (match-end 2)) (insert "," new1)))) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1139 ((looking-at diff-context-mid-hunk-header-re) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1140 (when (> (+ space bang plus) 0) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1141 (let* ((old1 (match-string 1)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1142 (old2 (match-string 2)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1143 (new (number-to-string |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1144 (+ space bang plus -1 (string-to-number old1))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1145 (unless (string= new old2) (replace-match new t t nil 2))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1146 ((looking-at "\\*\\*\\* \\([0-9]+\\),\\(-?[0-9]*\\) \\*\\*\\*\\*$") |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1147 (when (> (+ space bang minus) 0) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1148 (let* ((old (match-string 1)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1149 (new (format |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1150 (concat "%0" (number-to-string (length old)) "d") |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1151 (+ space bang minus -1 (string-to-number old))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1152 (unless (string= new old) (replace-match new t t nil 2)))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1153 (setq space 0 plus 0 minus 0 bang 0))))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1154 |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47523
diff
changeset
|
1155 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1156 ;;;; Hooks |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47523
diff
changeset
|
1157 ;;;; |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1158 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1159 (defun diff-write-contents-hooks () |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1160 "Fixup hunk headers if necessary." |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1161 (if (buffer-modified-p) (diff-fixup-modifs (point-min) (point-max))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1162 nil) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1163 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1164 ;; It turns out that making changes in the buffer from within an |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1165 ;; *-change-function is asking for trouble, whereas making them |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1166 ;; from a post-command-hook doesn't pose much problems |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1167 (defvar diff-unhandled-changes nil) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1168 (defun diff-after-change-function (beg end len) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1169 "Remember to fixup the hunk header. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1170 See `after-change-functions' for the meaning of BEG, END and LEN." |
29423
12e89e9b65f6
(diff-font-lock-keywords, diff-hunk-header-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28858
diff
changeset
|
1171 ;; Ignoring changes when inhibit-read-only is set is strictly speaking |
12e89e9b65f6
(diff-font-lock-keywords, diff-hunk-header-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28858
diff
changeset
|
1172 ;; incorrect, but it turns out that inhibit-read-only is normally not set |
12e89e9b65f6
(diff-font-lock-keywords, diff-hunk-header-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28858
diff
changeset
|
1173 ;; inside editing commands, while it tends to be set when the buffer gets |
12e89e9b65f6
(diff-font-lock-keywords, diff-hunk-header-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28858
diff
changeset
|
1174 ;; updated by an async process or by a conversion function, both of which |
12e89e9b65f6
(diff-font-lock-keywords, diff-hunk-header-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28858
diff
changeset
|
1175 ;; would rather not be uselessly slowed down by this hook. |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1176 (when (and (not undo-in-progress) (not inhibit-read-only)) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1177 (if diff-unhandled-changes |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1178 (setq diff-unhandled-changes |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1179 (cons (min beg (car diff-unhandled-changes)) |
46407
4c4398249108
(diff-reverse-direction): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42472
diff
changeset
|
1180 (max end (cdr diff-unhandled-changes)))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1181 (setq diff-unhandled-changes (cons beg end))))) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1182 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1183 (defun diff-post-command-hook () |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1184 "Fixup hunk headers if necessary." |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1185 (when (consp diff-unhandled-changes) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1186 (ignore-errors |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1187 (save-excursion |
27637
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
1188 (goto-char (car diff-unhandled-changes)) |
46407
4c4398249108
(diff-reverse-direction): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42472
diff
changeset
|
1189 ;; Maybe we've cut the end of the hunk before point. |
4c4398249108
(diff-reverse-direction): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42472
diff
changeset
|
1190 (if (and (bolp) (not (bobp))) (backward-char 1)) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1191 ;; We used to fixup modifs on all the changes, but it turns out that |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1192 ;; it's safer not to do it on big changes, e.g. when yanking a big |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1193 ;; diff, or when the user edits the header, since we might then |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1194 ;; screw up perfectly correct values. --Stef |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1195 (diff-beginning-of-hunk) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1196 (let* ((style (if (looking-at "\\*\\*\\*") 'context)) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1197 (start (line-beginning-position (if (eq style 'context) 3 2))) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1198 (mid (if (eq style 'context) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1199 (save-excursion |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1200 (re-search-forward diff-context-mid-hunk-header-re |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1201 nil t))))) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1202 (when (and ;; Don't try to fixup changes in the hunk header. |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1203 (> (car diff-unhandled-changes) start) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1204 ;; Don't try to fixup changes in the mid-hunk header either. |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1205 (or (not mid) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1206 (< (cdr diff-unhandled-changes) (match-beginning 0)) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1207 (> (car diff-unhandled-changes) (match-end 0))) |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1208 (save-excursion |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1209 (diff-end-of-hunk nil 'donttrustheader) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1210 ;; Don't try to fixup changes past the end of the hunk. |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1211 (>= (point) (cdr diff-unhandled-changes)))) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1212 (diff-fixup-modifs (point) (cdr diff-unhandled-changes))))) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1213 (setq diff-unhandled-changes nil)))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1214 |
55088
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1215 (defun diff-next-error (arg reset) |
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1216 ;; Select a window that displays the current buffer so that point |
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1217 ;; movements are reflected in that window. Otherwise, the user might |
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1218 ;; never see the hunk corresponding to the source she's jumping to. |
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1219 (pop-to-buffer (current-buffer)) |
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1220 (if reset (goto-char (point-min))) |
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1221 (diff-hunk-next arg) |
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1222 (diff-goto-source)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1223 |
101119
ccbca2862f79
(whitespace-style, whitespace-trailing-regexp): Silence compiler.
Glenn Morris <rgm@gnu.org>
parents:
101070
diff
changeset
|
1224 (defvar whitespace-style) |
ccbca2862f79
(whitespace-style, whitespace-trailing-regexp): Silence compiler.
Glenn Morris <rgm@gnu.org>
parents:
101070
diff
changeset
|
1225 (defvar whitespace-trailing-regexp) |
ccbca2862f79
(whitespace-style, whitespace-trailing-regexp): Silence compiler.
Glenn Morris <rgm@gnu.org>
parents:
101070
diff
changeset
|
1226 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1227 ;;;###autoload |
28240
a0b15838fd22
(diff-mode-*-map): use `easy-mmode-defmap'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27637
diff
changeset
|
1228 (define-derived-mode diff-mode fundamental-mode "Diff" |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
1229 "Major mode for viewing/editing context diffs. |
39386
50956864fe56
(diff-default-read-only): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39323
diff
changeset
|
1230 Supports unified and context diffs as well as (to a lesser extent) |
76982
3a37aeee9537
(diff-mode): Revert 2007-03-04 change.
Chong Yidong <cyd@stupidchicken.com>
parents:
76453
diff
changeset
|
1231 normal diffs. |
76323 | 1232 |
47445
d54b5b9a2b77
(diff-mode): Docstring improvement.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46407
diff
changeset
|
1233 When the buffer is read-only, the ESC prefix is not necessary. |
63415
3ed17f92f3c9
(diff-mode): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
63197
diff
changeset
|
1234 If you edit the buffer manually, diff-mode will try to update the hunk |
47445
d54b5b9a2b77
(diff-mode): Docstring improvement.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46407
diff
changeset
|
1235 headers for you on-the-fly. |
d54b5b9a2b77
(diff-mode): Docstring improvement.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46407
diff
changeset
|
1236 |
d54b5b9a2b77
(diff-mode): Docstring improvement.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46407
diff
changeset
|
1237 You can also switch between context diff and unified diff with \\[diff-context->unified], |
66130 | 1238 or vice versa with \\[diff-unified->context] and you can also reverse the direction of |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
1239 a diff with \\[diff-reverse-direction]. |
76323 | 1240 |
1241 \\{diff-mode-map}" | |
1242 | |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1243 (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1244 (set (make-local-variable 'outline-regexp) diff-outline-regexp) |
31269
64bb4634d6d8
(diff-mode) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents:
30873
diff
changeset
|
1245 (set (make-local-variable 'imenu-generic-expression) |
64bb4634d6d8
(diff-mode) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents:
30873
diff
changeset
|
1246 diff-imenu-generic-expression) |
31479
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1247 ;; These are not perfect. They would be better done separately for |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1248 ;; context diffs and unidiffs. |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1249 ;; (set (make-local-variable 'paragraph-start) |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1250 ;; (concat "@@ " ; unidiff hunk |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1251 ;; "\\|\\*\\*\\* " ; context diff hunk or file start |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1252 ;; "\\|--- [^\t]+\t")) ; context or unidiff file |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1253 ;; ; start (first or second line) |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1254 ;; (set (make-local-variable 'paragraph-separate) paragraph-start) |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1255 ;; (set (make-local-variable 'page-delimiter) "--- [^\t]+\t") |
d58461428926
(diff-mouse-goto-source): New function.
Dave Love <fx@gnu.org>
parents:
31269
diff
changeset
|
1256 ;; compile support |
55088
386e33861abd
(diff-next-error): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54928
diff
changeset
|
1257 (set (make-local-variable 'next-error-function) 'diff-next-error) |
35526
b40a6cecc4d5
(diff-mode): Disable preliminary support for `compile'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33488
diff
changeset
|
1258 |
93673
928315b10669
(diff-file-junk-re): Recognize the git format for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93190
diff
changeset
|
1259 (set (make-local-variable 'beginning-of-defun-function) |
928315b10669
(diff-file-junk-re): Recognize the git format for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93190
diff
changeset
|
1260 'diff-beginning-of-file-and-junk) |
928315b10669
(diff-file-junk-re): Recognize the git format for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93190
diff
changeset
|
1261 (set (make-local-variable 'end-of-defun-function) |
928315b10669
(diff-file-junk-re): Recognize the git format for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93190
diff
changeset
|
1262 'diff-end-of-file) |
928315b10669
(diff-file-junk-re): Recognize the git format for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93190
diff
changeset
|
1263 |
101070
3f35938e8ea3
(diff-show-trailing-whitespaces): Remove function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100843
diff
changeset
|
1264 ;; Set up `whitespace-mode' so that turning it on will show trailing |
3f35938e8ea3
(diff-show-trailing-whitespaces): Remove function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100843
diff
changeset
|
1265 ;; whitespace problems on the modified lines of the diff. |
3f35938e8ea3
(diff-show-trailing-whitespaces): Remove function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100843
diff
changeset
|
1266 (set (make-local-variable 'whitespace-style) '(trailing)) |
3f35938e8ea3
(diff-show-trailing-whitespaces): Remove function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100843
diff
changeset
|
1267 (set (make-local-variable 'whitespace-trailing-regexp) |
3f35938e8ea3
(diff-show-trailing-whitespaces): Remove function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100843
diff
changeset
|
1268 "^[-\+!<>].*?\\([\t ]+\\)$") |
3f35938e8ea3
(diff-show-trailing-whitespaces): Remove function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100843
diff
changeset
|
1269 |
71248
3071d2ae4624
* diff-mode.el (diff-mode): Set buffer-read-only to t when
Chong Yidong <cyd@stupidchicken.com>
parents:
70542
diff
changeset
|
1270 (setq buffer-read-only diff-default-read-only) |
27637
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
1271 ;; setup change hooks |
37866
4e2d06e10072
(diff-jump-to-old-file, diff-update-on-the-fly):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37567
diff
changeset
|
1272 (if (not diff-update-on-the-fly) |
53833
32e20bdb34c9
(diff-file-regexp-alist, diff-error-regexp-alist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53782
diff
changeset
|
1273 (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1274 (make-local-variable 'diff-unhandled-changes) |
31973
ad9838a9349c
(diff-mode-map, diff-minor-mode-prefix):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31819
diff
changeset
|
1275 (add-hook 'after-change-functions 'diff-after-change-function nil t) |
ad9838a9349c
(diff-mode-map, diff-minor-mode-prefix):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31819
diff
changeset
|
1276 (add-hook 'post-command-hook 'diff-post-command-hook nil t)) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1277 ;; Neat trick from Dave Love to add more bindings in read-only mode: |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
1278 (lexical-let ((ro-bind (cons 'buffer-read-only diff-mode-shared-map))) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1279 (add-to-list 'minor-mode-overriding-map-alist ro-bind) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1280 ;; Turn off this little trick in case the buffer is put in view-mode. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1281 (add-hook 'view-mode-hook |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
1282 (lambda () |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
1283 (setq minor-mode-overriding-map-alist |
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
1284 (delq ro-bind minor-mode-overriding-map-alist))) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1285 nil t)) |
31795
868648c4a36b
* diff-mode.el (diff-add-log-file-name, diff-current-defun): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31786
diff
changeset
|
1286 ;; add-log support |
868648c4a36b
* diff-mode.el (diff-add-log-file-name, diff-current-defun): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31786
diff
changeset
|
1287 (set (make-local-variable 'add-log-current-defun-function) |
868648c4a36b
* diff-mode.el (diff-add-log-file-name, diff-current-defun): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31786
diff
changeset
|
1288 'diff-current-defun) |
32012
b1edfcd919a7
(diff-add-log-file-name): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31973
diff
changeset
|
1289 (set (make-local-variable 'add-log-buffer-file-name-function) |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1290 (lambda () (diff-find-file-name nil 'noprompt)))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1291 |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1292 ;;;###autoload |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
1293 (define-minor-mode diff-minor-mode |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
1294 "Minor mode for viewing/editing context diffs. |
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
1295 \\{diff-minor-mode-map}" |
61269
5d2796fc9f80
(diff-minor-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
57418
diff
changeset
|
1296 :group 'diff-mode :lighter " Diff" |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
1297 ;; FIXME: setup font-lock |
27637
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
1298 ;; setup change hooks |
37866
4e2d06e10072
(diff-jump-to-old-file, diff-update-on-the-fly):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37567
diff
changeset
|
1299 (if (not diff-update-on-the-fly) |
53833
32e20bdb34c9
(diff-file-regexp-alist, diff-error-regexp-alist)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53782
diff
changeset
|
1300 (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t) |
27637
79014abee3cc
(diff-kill-junk): New interactive function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26748
diff
changeset
|
1301 (make-local-variable 'diff-unhandled-changes) |
31973
ad9838a9349c
(diff-mode-map, diff-minor-mode-prefix):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31819
diff
changeset
|
1302 (add-hook 'after-change-functions 'diff-after-change-function nil t) |
ad9838a9349c
(diff-mode-map, diff-minor-mode-prefix):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31819
diff
changeset
|
1303 (add-hook 'post-command-hook 'diff-post-command-hook nil t))) |
26748
8b8438e9ac12
* diff-mode.el (diff-mode-shared-map): fset'd and doc change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26009
diff
changeset
|
1304 |
71556
31835ba46d29
(diff-find-file-name): Obey cvs-pcl-cvs-dirchange-re.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71249
diff
changeset
|
1305 ;;; Handy hook functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1306 |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1307 (defun diff-delete-if-empty () |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1308 ;; An empty diff file means there's no more diffs to integrate, so we |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1309 ;; can just remove the file altogether. Very handy for .rej files if we |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1310 ;; remove hunks as we apply them. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1311 (when (and buffer-file-name |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1312 (eq 0 (nth 7 (file-attributes buffer-file-name)))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1313 (delete-file buffer-file-name))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1314 |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1315 (defun diff-delete-empty-files () |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1316 "Arrange for empty diff files to be removed." |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1317 (add-hook 'after-save-hook 'diff-delete-if-empty nil t)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1318 |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1319 (defun diff-make-unified () |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1320 "Turn context diffs into unified diffs if applicable." |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1321 (if (save-excursion |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1322 (goto-char (point-min)) |
55392
480f9d542579
(diff-make-unified): Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55322
diff
changeset
|
1323 (and (looking-at diff-hunk-header-re) (eq (char-after) ?*))) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1324 (let ((mod (buffer-modified-p))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1325 (unwind-protect |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1326 (diff-context->unified (point-min) (point-max)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1327 (restore-buffer-modified-p mod))))) |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1328 |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1329 ;;; |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1330 ;;; Misc operations that have proved useful at some point. |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1331 ;;; |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1332 |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1333 (defun diff-next-complex-hunk () |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1334 "Jump to the next \"complex\" hunk. |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1335 \"Complex\" is approximated by \"the hunk changes the number of lines\". |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1336 Only works for unified diffs." |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1337 (interactive) |
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1338 (while |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1339 (and (re-search-forward diff-hunk-header-re-unified nil t) |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1340 (equal (match-string 2) (match-string 4))))) |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1341 |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1342 (defun diff-sanity-check-context-hunk-half (lines) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1343 (let ((count lines)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1344 (while |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1345 (cond |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1346 ((and (memq (char-after) '(?\s ?! ?+ ?-)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1347 (memq (char-after (1+ (point))) '(?\s ?\t))) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1348 (decf count) t) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1349 ((or (zerop count) (= count lines)) nil) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1350 ((memq (char-after) '(?! ?+ ?-)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1351 (if (not (and (eq (char-after (1+ (point))) ?\n) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1352 (y-or-n-p "Try to auto-fix whitespace loss damage? "))) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1353 (error "End of hunk ambiguously marked") |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1354 (forward-char 1) (insert " ") (forward-line -1) t)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1355 ((< lines 0) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1356 (error "End of hunk ambiguously marked")) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1357 ((not (y-or-n-p "Try to auto-fix whitespace loss and word-wrap damage? ")) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1358 (error "Abort!")) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1359 ((eolp) (insert " ") (forward-line -1) t) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1360 (t (insert " ") (delete-region (- (point) 2) (- (point) 1)) t)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1361 (forward-line)))) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1362 |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1363 (defun diff-sanity-check-hunk () |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1364 (let (;; Every modification is protected by a y-or-n-p, so it's probably |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1365 ;; OK to override a read-only setting. |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1366 (inhibit-read-only t)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1367 (save-excursion |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1368 (cond |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1369 ((not (looking-at diff-hunk-header-re)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1370 (error "Not recognizable hunk header")) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1371 |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1372 ;; A context diff. |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1373 ((eq (char-after) ?*) |
84468
f3735c349e01
(diff-sanity-check-hunk): Also accept single-line hunks.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
82910
diff
changeset
|
1374 (if (not (looking-at "\\*\\{15\\}\\(?: .*\\)?\n\\*\\*\\* \\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? \\*\\*\\*\\*")) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1375 (error "Unrecognized context diff first hunk header format") |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1376 (forward-line 2) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1377 (diff-sanity-check-context-hunk-half |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
1378 (if (match-end 2) |
84468
f3735c349e01
(diff-sanity-check-hunk): Also accept single-line hunks.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
82910
diff
changeset
|
1379 (1+ (- (string-to-number (match-string 2)) |
f3735c349e01
(diff-sanity-check-hunk): Also accept single-line hunks.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
82910
diff
changeset
|
1380 (string-to-number (match-string 1)))) |
f3735c349e01
(diff-sanity-check-hunk): Also accept single-line hunks.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
82910
diff
changeset
|
1381 1)) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1382 (if (not (looking-at diff-context-mid-hunk-header-re)) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1383 (error "Unrecognized context diff second hunk header format") |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1384 (forward-line) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1385 (diff-sanity-check-context-hunk-half |
92194
08b13631ff73
* diff-mode.el (diff-file-junk-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91724
diff
changeset
|
1386 (if (match-end 2) |
84468
f3735c349e01
(diff-sanity-check-hunk): Also accept single-line hunks.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
82910
diff
changeset
|
1387 (1+ (- (string-to-number (match-string 2)) |
f3735c349e01
(diff-sanity-check-hunk): Also accept single-line hunks.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
82910
diff
changeset
|
1388 (string-to-number (match-string 1)))) |
f3735c349e01
(diff-sanity-check-hunk): Also accept single-line hunks.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
82910
diff
changeset
|
1389 1))))) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1390 |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1391 ;; A unified diff. |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1392 ((eq (char-after) ?@) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1393 (if (not (looking-at diff-hunk-header-re-unified)) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1394 (error "Unrecognized unified diff hunk header format") |
80528
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
1395 (let ((before (string-to-number (or (match-string 2) "1"))) |
912586de54c9
(diff-hunk-header-re-unified): Allow elided line counts.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80339
diff
changeset
|
1396 (after (string-to-number (or (match-string 4) "1")))) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1397 (forward-line) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1398 (while |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1399 (case (char-after) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1400 (?\s (decf before) (decf after) t) |
78756
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1401 (?- |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1402 (if (and (looking-at diff-file-header-re) |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1403 (zerop before) (zerop after)) |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1404 ;; No need to query: this is a case where two patches |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1405 ;; are concatenated and only counting the lines will |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1406 ;; give the right result. Let's just add an empty |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1407 ;; line so that our code which doesn't count lines |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1408 ;; will not get confused. |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1409 (progn (save-excursion (insert "\n")) nil) |
c41c1aee3d31
(diff-sanity-check-hunk): Fix up the case when unified
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78676
diff
changeset
|
1410 (decf before) t)) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1411 (?+ (decf after) t) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1412 (t |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1413 (cond |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1414 ((and diff-valid-unified-empty-line |
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1415 ;; Not just (eolp) so we don't infloop at eob. |
80246
3629f9a94638
(diff-sanity-check-hunk): Only accept an empty line if
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80152
diff
changeset
|
1416 (eq (char-after) ?\n) |
3629f9a94638
(diff-sanity-check-hunk): Only accept an empty line if
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80152
diff
changeset
|
1417 (> before 0) (> after 0)) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1418 (decf before) (decf after) t) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1419 ((and (zerop before) (zerop after)) nil) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1420 ((or (< before 0) (< after 0)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1421 (error (if (or (zerop before) (zerop after)) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1422 "End of hunk ambiguously marked" |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1423 "Hunk seriously messed up"))) |
80151
533d83b5f687
Make it more robust in the presence of empty context lines in unified hunks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80099
diff
changeset
|
1424 ((not (y-or-n-p (concat "Try to auto-fix " (if (eolp) "whitespace loss" "word-wrap damage") "? "))) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1425 (error "Abort!")) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1426 ((eolp) (insert " ") (forward-line -1) t) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1427 (t (insert " ") |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1428 (delete-region (- (point) 2) (- (point) 1)) t)))) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1429 (forward-line))))) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1430 |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1431 ;; A plain diff. |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1432 (t |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1433 ;; TODO. |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1434 ))))) |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1435 |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1436 (defun diff-hunk-text (hunk destp char-offset) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1437 "Return the literal source text from HUNK as (TEXT . OFFSET). |
70542
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
1438 If DESTP is nil, TEXT is the source, otherwise the destination text. |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1439 CHAR-OFFSET is a char-offset in HUNK, and OFFSET is the corresponding |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1440 char-offset in TEXT." |
31556
74d7a9c42c2a
(diff-hunk-text): Use `with-temp-buffer'.
Miles Bader <miles@gnu.org>
parents:
31538
diff
changeset
|
1441 (with-temp-buffer |
31819
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1442 (insert hunk) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1443 (goto-char (point-min)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1444 (let ((src-pos nil) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1445 (dst-pos nil) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1446 (divider-pos nil) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1447 (num-pfx-chars 2)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1448 ;; Set the following variables: |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1449 ;; SRC-POS buffer pos of the source part of the hunk or nil if none |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1450 ;; DST-POS buffer pos of the destination part of the hunk or nil |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1451 ;; DIVIDER-POS buffer pos of any divider line separating the src & dst |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1452 ;; NUM-PFX-CHARS number of line-prefix characters used by this format" |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1453 (cond ((looking-at "^@@") |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1454 ;; unified diff |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1455 (setq num-pfx-chars 1) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1456 (forward-line 1) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1457 (setq src-pos (point) dst-pos (point))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1458 ((looking-at "^\\*\\*") |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1459 ;; context diff |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1460 (forward-line 2) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1461 (setq src-pos (point)) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1462 (re-search-forward diff-context-mid-hunk-header-re nil t) |
31819
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1463 (forward-line 0) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1464 (setq divider-pos (point)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1465 (forward-line 1) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1466 (setq dst-pos (point))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1467 ((looking-at "^[0-9]+a[0-9,]+$") |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1468 ;; normal diff, insert |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1469 (forward-line 1) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1470 (setq dst-pos (point))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1471 ((looking-at "^[0-9,]+d[0-9]+$") |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1472 ;; normal diff, delete |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1473 (forward-line 1) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1474 (setq src-pos (point))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1475 ((looking-at "^[0-9,]+c[0-9,]+$") |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1476 ;; normal diff, change |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1477 (forward-line 1) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1478 (setq src-pos (point)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1479 (re-search-forward "^---$" nil t) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1480 (forward-line 0) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1481 (setq divider-pos (point)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1482 (forward-line 1) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1483 (setq dst-pos (point))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1484 (t |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1485 (error "Unknown diff hunk type"))) |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1486 |
31819
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1487 (if (if destp (null dst-pos) (null src-pos)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1488 ;; Implied empty text |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1489 (if char-offset '("" . 0) "") |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1490 |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1491 ;; For context diffs, either side can be empty, (if there's only |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1492 ;; added or only removed text). We should then use the other side. |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1493 (cond ((equal src-pos divider-pos) (setq src-pos dst-pos)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1494 ((equal dst-pos (point-max)) (setq dst-pos src-pos))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1495 |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1496 (when char-offset (goto-char (+ (point-min) char-offset))) |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1497 |
31819
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1498 ;; Get rid of anything except the desired text. |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1499 (save-excursion |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1500 ;; Delete unused text region |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1501 (let ((keep (if destp dst-pos src-pos))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1502 (when (and divider-pos (> divider-pos keep)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1503 (delete-region divider-pos (point-max))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1504 (delete-region (point-min) keep)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1505 ;; Remove line-prefix characters, and unneeded lines (unified diffs). |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1506 (let ((kill-char (if destp ?- ?+))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1507 (goto-char (point-min)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1508 (while (not (eobp)) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1509 (if (eq (char-after) kill-char) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1510 (delete-region (point) (progn (forward-line 1) (point))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1511 (delete-char num-pfx-chars) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1512 (forward-line 1))))) |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1513 |
31819
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1514 (let ((text (buffer-substring-no-properties (point-min) (point-max)))) |
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1515 (if char-offset (cons text (- (point) (point-min))) text)))))) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1516 |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1517 |
31734
6b057ae8165d
Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31705
diff
changeset
|
1518 (defun diff-find-text (text) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1519 "Return the buffer position (BEG . END) of the nearest occurrence of TEXT. |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1520 If TEXT isn't found, nil is returned." |
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1521 (let* ((orig (point)) |
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1522 (forw (and (search-forward text nil t) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1523 (cons (match-beginning 0) (match-end 0)))) |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1524 (back (and (goto-char (+ orig (length text))) |
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1525 (search-backward text nil t) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1526 (cons (match-beginning 0) (match-end 0))))) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1527 ;; Choose the closest match. |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1528 (if (and forw back) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1529 (if (> (- (car forw) orig) (- orig (car back))) back forw) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1530 (or back forw)))) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1531 |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1532 (defun diff-find-approx-text (text) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1533 "Return the buffer position (BEG . END) of the nearest occurrence of TEXT. |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1534 Whitespace differences are ignored." |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1535 (let* ((orig (point)) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1536 (re (concat "^[ \t\n]*" |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1537 (mapconcat 'regexp-quote (split-string text) "[ \t\n]+") |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1538 "[ \t\n]*\n")) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1539 (forw (and (re-search-forward re nil t) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1540 (cons (match-beginning 0) (match-end 0)))) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1541 (back (and (goto-char (+ orig (length text))) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1542 (re-search-backward re nil t) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1543 (cons (match-beginning 0) (match-end 0))))) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1544 ;; Choose the closest match. |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1545 (if (and forw back) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1546 (if (> (- (car forw) orig) (- orig (car back))) back forw) |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1547 (or back forw)))) |
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1548 |
80880
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1549 (defsubst diff-xor (a b) (if a (if (not b) a) b)) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1550 |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1551 (defun diff-find-source-location (&optional other-file reverse noprompt) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1552 "Find out (BUF LINE-OFFSET POS SRC DST SWITCHED). |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1553 BUF is the buffer corresponding to the source file. |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1554 LINE-OFFSET is the offset between the expected and actual positions |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1555 of the text of the hunk or nil if the text was not found. |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1556 POS is a pair (BEG . END) indicating the position of the text in the buffer. |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1557 SRC and DST are the two variants of text as returned by `diff-hunk-text'. |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1558 SRC is the variant that was found in the buffer. |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1559 SWITCHED is non-nil if the patch is already applied. |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1560 NOPROMPT, if non-nil, means not to prompt the user." |
31735
9d50fe5df6ce
Moved closer to its users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31734
diff
changeset
|
1561 (save-excursion |
37866
4e2d06e10072
(diff-jump-to-old-file, diff-update-on-the-fly):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37567
diff
changeset
|
1562 (let* ((other (diff-xor other-file diff-jump-to-old-file)) |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
1563 (char-offset (- (point) (progn (diff-beginning-of-hunk 'try-harder) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
1564 (point)))) |
75191
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1565 ;; Check that the hunk is well-formed. Otherwise diff-mode and |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1566 ;; the user may disagree on what constitutes the hunk |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1567 ;; (e.g. because an empty line truncates the hunk mid-course), |
98ad9ce30ba1
(diff-sanity-check-context-hunk-half, diff-sanity-check-hunk): New functions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
74269
diff
changeset
|
1568 ;; leading to potentially nasty surprises for the user. |
103039
5b883aa3f804
(diff-find-source-location): Don't call
Martin Rudalics <rudalics@gmx.at>
parents:
101154
diff
changeset
|
1569 ;; |
103040
10b0e119e49a
Fix bug number in comment.
Martin Rudalics <rudalics@gmx.at>
parents:
103039
diff
changeset
|
1570 ;; Suppress check when NOPROMPT is non-nil (Bug#3033). |
103039
5b883aa3f804
(diff-find-source-location): Don't call
Martin Rudalics <rudalics@gmx.at>
parents:
101154
diff
changeset
|
1571 (_ (unless noprompt (diff-sanity-check-hunk))) |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1572 (hunk (buffer-substring |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1573 (point) (save-excursion (diff-end-of-hunk) (point)))) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1574 (old (diff-hunk-text hunk reverse char-offset)) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1575 (new (diff-hunk-text hunk (not reverse) char-offset)) |
31735
9d50fe5df6ce
Moved closer to its users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31734
diff
changeset
|
1576 ;; Find the location specification. |
31786
181947e98152
(diff-find-source-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31749
diff
changeset
|
1577 (line (if (not (looking-at "\\(?:\\*\\{15\\}.*\n\\)?[-@* ]*\\([0-9,]+\\)\\([ acd+]+\\([0-9,]+\\)\\)?")) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1578 (error "Can't find the hunk header") |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1579 (if other (match-string 1) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1580 (if (match-end 3) (match-string 3) |
95317
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1581 (unless (re-search-forward |
6cd40c65aa90
(diff-context-mid-hunk-header-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94987
diff
changeset
|
1582 diff-context-mid-hunk-header-re nil t) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1583 (error "Can't find the hunk separator")) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1584 (match-string 1))))) |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1585 (file (or (diff-find-file-name other noprompt) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1586 (error "Can't find the file"))) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1587 (buf (find-file-noselect file))) |
31735
9d50fe5df6ce
Moved closer to its users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31734
diff
changeset
|
1588 ;; Update the user preference if he so wished. |
9d50fe5df6ce
Moved closer to its users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31734
diff
changeset
|
1589 (when (> (prefix-numeric-value other-file) 8) |
37866
4e2d06e10072
(diff-jump-to-old-file, diff-update-on-the-fly):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37567
diff
changeset
|
1590 (setq diff-jump-to-old-file other)) |
31786
181947e98152
(diff-find-source-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31749
diff
changeset
|
1591 (with-current-buffer buf |
104564
9d31b5972e9e
(diff-find-source-location): Avoid goto-line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
103040
diff
changeset
|
1592 (goto-char (point-min)) (forward-line (1- (string-to-number line))) |
31786
181947e98152
(diff-find-source-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31749
diff
changeset
|
1593 (let* ((orig-pos (point)) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1594 (switched nil) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1595 ;; FIXME: Check for case where both OLD and NEW are found. |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1596 (pos (or (diff-find-text (car old)) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1597 (progn (setq switched t) (diff-find-text (car new))) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1598 (progn (setq switched nil) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1599 (condition-case nil |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1600 (diff-find-approx-text (car old)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1601 (invalid-regexp nil))) ;Regex too big. |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1602 (progn (setq switched t) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1603 (condition-case nil |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1604 (diff-find-approx-text (car new)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1605 (invalid-regexp nil))) ;Regex too big. |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1606 (progn (setq switched nil) nil)))) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1607 (nconc |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1608 (list buf) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1609 (if pos |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1610 (list (count-lines orig-pos (car pos)) pos) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1611 (list nil (cons orig-pos (+ orig-pos (length (car old)))))) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1612 (if switched (list new old t) (list old new)))))))) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1613 |
31735
9d50fe5df6ce
Moved closer to its users.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31734
diff
changeset
|
1614 |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1615 (defun diff-hunk-status-msg (line-offset reversed dry-run) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1616 (let ((msg (if dry-run |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1617 (if reversed "already applied" "not yet applied") |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1618 (if reversed "undone" "applied")))) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1619 (message (cond ((null line-offset) "Hunk text not found") |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1620 ((= line-offset 0) "Hunk %s") |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1621 ((= line-offset 1) "Hunk %s at offset %d line") |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1622 (t "Hunk %s at offset %d lines")) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1623 msg line-offset))) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1624 |
72813
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1625 (defvar diff-apply-hunk-to-backup-file nil) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1626 |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1627 (defun diff-apply-hunk (&optional reverse) |
31819
e5a0c7120611
(diff-hunk-text): Properly handle one-sided context diffs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31817
diff
changeset
|
1628 "Apply the current hunk to the source file and go to the next. |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1629 By default, the new source file is patched, but if the variable |
37866
4e2d06e10072
(diff-jump-to-old-file, diff-update-on-the-fly):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37567
diff
changeset
|
1630 `diff-jump-to-old-file' is non-nil, then the old source file is |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1631 patched instead (some commands, such as `diff-goto-source' can change |
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1632 the value of this variable when given an appropriate prefix argument). |
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1633 |
32063
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1634 With a prefix argument, REVERSE the hunk." |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1635 (interactive "P") |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1636 (destructuring-bind (buf line-offset pos old new &optional switched) |
80880
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1637 ;; Sometimes we'd like to have the following behavior: if REVERSE go |
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1638 ;; to the new file, otherwise go to the old. But that means that by |
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1639 ;; default we use the old file, which is the opposite of the default |
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1640 ;; for diff-goto-source, and is thus confusing. Also when you don't |
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1641 ;; know about it it's pretty surprising. |
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1642 ;; TODO: make it possible to ask explicitly for this behavior. |
100171 | 1643 ;; |
80880
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1644 ;; This is duplicated in diff-test-hunk. |
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1645 (diff-find-source-location nil reverse) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1646 (cond |
32063
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1647 ((null line-offset) |
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1648 (error "Can't find the text to patch")) |
72813
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1649 ((with-current-buffer buf |
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1650 (and buffer-file-name |
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1651 (backup-file-name-p buffer-file-name) |
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1652 (not diff-apply-hunk-to-backup-file) |
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1653 (not (set (make-local-variable 'diff-apply-hunk-to-backup-file) |
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1654 (yes-or-no-p (format "Really apply this hunk to %s? " |
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1655 (file-name-nondirectory |
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1656 buffer-file-name))))))) |
76453
5e29de959ce6
(diff-apply-hunk): Use proper format string for
Andreas Schwab <schwab@suse.de>
parents:
76323
diff
changeset
|
1657 (error "%s" |
5e29de959ce6
(diff-apply-hunk): Use proper format string for
Andreas Schwab <schwab@suse.de>
parents:
76323
diff
changeset
|
1658 (substitute-command-keys |
72813
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1659 (format "Use %s\\[diff-apply-hunk] to apply it to the other file" |
200db4ae9b54
(diff-apply-hunk-to-backup-file): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
71556
diff
changeset
|
1660 (if (not reverse) "\\[universal-argument] "))))) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1661 ((and switched |
35526
b40a6cecc4d5
(diff-mode): Disable preliminary support for `compile'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33488
diff
changeset
|
1662 ;; A reversed patch was detected, perhaps apply it in reverse. |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1663 (not (save-window-excursion |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1664 (pop-to-buffer buf) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1665 (goto-char (+ (car pos) (cdr old))) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1666 (y-or-n-p |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1667 (if reverse |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1668 "Hunk hasn't been applied yet; apply it now? " |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1669 "Hunk has already been applied; undo it? "))))) |
32063
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1670 (message "(Nothing done)")) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1671 (t |
32063
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1672 ;; Apply the hunk |
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1673 (with-current-buffer buf |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1674 (goto-char (car pos)) |
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1675 (delete-region (car pos) (cdr pos)) |
32063
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1676 (insert (car new))) |
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1677 ;; Display BUF in a window |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1678 (set-window-point (display-buffer buf) (+ (car pos) (cdr new))) |
32063
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1679 (diff-hunk-status-msg line-offset (diff-xor switched reverse) nil) |
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1680 (when diff-advance-after-apply-hunk |
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1681 (diff-hunk-next)))))) |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1682 |
31684 | 1683 |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1684 (defun diff-test-hunk (&optional reverse) |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1685 "See whether it's possible to apply the current hunk. |
32063
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1686 With a prefix argument, try to REVERSE the hunk." |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1687 (interactive "P") |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1688 (destructuring-bind (buf line-offset pos src dst &optional switched) |
80880
dba96e4a8a94
(diff-apply-hunk, diff-test-hunk): Don't do by default
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76982
diff
changeset
|
1689 (diff-find-source-location nil reverse) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1690 (set-window-point (display-buffer buf) (+ (car pos) (cdr src))) |
32063
3fb2a3b13c5e
(diff-test-hunk): Backout previous change. Fix doc string.
Miles Bader <miles@gnu.org>
parents:
32061
diff
changeset
|
1691 (diff-hunk-status-msg line-offset (diff-xor reverse switched) t))) |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1692 |
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1693 |
54869
c491468e3c18
(diff-goto-source): Make it work for mouse bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54693
diff
changeset
|
1694 (defalias 'diff-mouse-goto-source 'diff-goto-source) |
c491468e3c18
(diff-goto-source): Make it work for mouse bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54693
diff
changeset
|
1695 |
c491468e3c18
(diff-goto-source): Make it work for mouse bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54693
diff
changeset
|
1696 (defun diff-goto-source (&optional other-file event) |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1697 "Jump to the corresponding source line. |
37866
4e2d06e10072
(diff-jump-to-old-file, diff-update-on-the-fly):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37567
diff
changeset
|
1698 `diff-jump-to-old-file' (or its opposite if the OTHER-FILE prefix arg |
31795
868648c4a36b
* diff-mode.el (diff-add-log-file-name, diff-current-defun): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31786
diff
changeset
|
1699 is given) determines whether to jump to the old or the new file. |
31538
46aca282e6b0
(diff-apply-hunk): Function basically rewritten. Now understands
Miles Bader <miles@gnu.org>
parents:
31479
diff
changeset
|
1700 If the prefix arg is bigger than 8 (for example with \\[universal-argument] \\[universal-argument]) |
70542
ef7506f44a3a
(diff-context->unified): Use `region-beginning' and `region-end'
Juri Linkov <juri@jurta.org>
parents:
70333
diff
changeset
|
1701 then `diff-jump-to-old-file' is also set, for the next invocations." |
54869
c491468e3c18
(diff-goto-source): Make it work for mouse bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54693
diff
changeset
|
1702 (interactive (list current-prefix-arg last-input-event)) |
32111
161c2ec9f5b2
(diff-font-lock-keywords): Minor regex fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32063
diff
changeset
|
1703 ;; When pointing at a removal line, we probably want to jump to |
161c2ec9f5b2
(diff-font-lock-keywords): Minor regex fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32063
diff
changeset
|
1704 ;; the old location, and else to the new (i.e. as if reverting). |
161c2ec9f5b2
(diff-font-lock-keywords): Minor regex fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32063
diff
changeset
|
1705 ;; This is a convenient detail when using smerge-diff. |
54869
c491468e3c18
(diff-goto-source): Make it work for mouse bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54693
diff
changeset
|
1706 (if event (posn-set-point (event-end event))) |
32111
161c2ec9f5b2
(diff-font-lock-keywords): Minor regex fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32063
diff
changeset
|
1707 (let ((rev (not (save-excursion (beginning-of-line) (looking-at "[-<]"))))) |
161c2ec9f5b2
(diff-font-lock-keywords): Minor regex fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32063
diff
changeset
|
1708 (destructuring-bind (buf line-offset pos src dst &optional switched) |
161c2ec9f5b2
(diff-font-lock-keywords): Minor regex fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32063
diff
changeset
|
1709 (diff-find-source-location other-file rev) |
161c2ec9f5b2
(diff-font-lock-keywords): Minor regex fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32063
diff
changeset
|
1710 (pop-to-buffer buf) |
41526
f0fb05d40941
(diff-end-of-hunk): Watch out for ambiguities.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39386
diff
changeset
|
1711 (goto-char (+ (car pos) (cdr src))) |
32143 | 1712 (diff-hunk-status-msg line-offset (diff-xor rev switched) t)))) |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1713 |
31786
181947e98152
(diff-find-source-location):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31749
diff
changeset
|
1714 |
31795
868648c4a36b
* diff-mode.el (diff-add-log-file-name, diff-current-defun): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31786
diff
changeset
|
1715 (defun diff-current-defun () |
31817
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1716 "Find the name of function at point. |
e23774b771e1
(diff-file-header-face): Reset to its previous value.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31795
diff
changeset
|
1717 For use in `add-log-current-defun-function'." |
85208
8d5ae38b1b47
(diff-current-defun): Force recomputation of change-log-default-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85114
diff
changeset
|
1718 ;; Kill change-log-default-name so it gets recomputed each time, since |
8d5ae38b1b47
(diff-current-defun): Force recomputation of change-log-default-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85114
diff
changeset
|
1719 ;; each hunk may belong to another file which may belong to another |
8d5ae38b1b47
(diff-current-defun): Force recomputation of change-log-default-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85114
diff
changeset
|
1720 ;; directory and hence have a different ChangeLog file. |
8d5ae38b1b47
(diff-current-defun): Force recomputation of change-log-default-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85114
diff
changeset
|
1721 (kill-local-variable 'change-log-default-name) |
56073
dc1d86d80c20
Reindent `diff-current-defun'.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
56072
diff
changeset
|
1722 (save-excursion |
dc1d86d80c20
Reindent `diff-current-defun'.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
56072
diff
changeset
|
1723 (when (looking-at diff-hunk-header-re) |
dc1d86d80c20
Reindent `diff-current-defun'.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
56072
diff
changeset
|
1724 (forward-line 1) |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
1725 (re-search-forward "^[^ ]" nil t)) |
98174
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1726 (destructuring-bind (&optional buf line-offset pos src dst switched) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1727 ;; Use `noprompt' since this is used in which-func-mode and such. |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1728 (ignore-errors ;Signals errors in place of prompting. |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1729 (diff-find-source-location nil nil 'noprompt)) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1730 (when buf |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1731 (beginning-of-line) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1732 (or (when (memq (char-after) '(?< ?-)) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1733 ;; Cursor is pointing at removed text. This could be a removed |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1734 ;; function, in which case, going to the source buffer will |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1735 ;; not help since the function is now removed. Instead, |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1736 ;; try to figure out the function name just from the |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1737 ;; code-fragment. |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1738 (let ((old (if switched dst src))) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1739 (with-temp-buffer |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1740 (insert (car old)) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1741 (funcall (buffer-local-value 'major-mode buf)) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1742 (goto-char (+ (point-min) (cdr old))) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1743 (add-log-current-defun)))) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1744 (with-current-buffer buf |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1745 (goto-char (+ (car pos) (cdr src))) |
841e92880f11
(diff-find-file-name): Rename `batch' to `noprompt' and
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
97316
diff
changeset
|
1746 (add-log-current-defun))))))) |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1747 |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1748 (defun diff-ignore-whitespace-hunk () |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1749 "Re-diff the current hunk, ignoring whitespace differences." |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1750 (interactive) |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
1751 (let* ((char-offset (- (point) (progn (diff-beginning-of-hunk 'try-harder) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
1752 (point)))) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1753 (opts (case (char-after) (?@ "-bu") (?* "-bc") (t "-b"))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1754 (line-nb (and (or (looking-at "[^0-9]+\\([0-9]+\\)") |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1755 (error "Can't find line number")) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1756 (string-to-number (match-string 1)))) |
92618
42c38aef74a3
(diff-ignore-whitespace-hunk): Bind
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92360
diff
changeset
|
1757 (inhibit-read-only t) |
54528
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1758 (hunk (delete-and-extract-region |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1759 (point) (save-excursion (diff-end-of-hunk) (point)))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1760 (lead (make-string (1- line-nb) ?\n)) ;Line nums start at 1. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1761 (file1 (make-temp-file "diff1")) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1762 (file2 (make-temp-file "diff2")) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1763 (coding-system-for-read buffer-file-coding-system) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1764 old new) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1765 (unwind-protect |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1766 (save-excursion |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1767 (setq old (diff-hunk-text hunk nil char-offset)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1768 (setq new (diff-hunk-text hunk t char-offset)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1769 (write-region (concat lead (car old)) nil file1 nil 'nomessage) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1770 (write-region (concat lead (car new)) nil file2 nil 'nomessage) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1771 (with-temp-buffer |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1772 (let ((status |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1773 (call-process diff-command nil t nil |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1774 opts file1 file2))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1775 (case status |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1776 (0 nil) ;Nothing to reformat. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1777 (1 (goto-char (point-min)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1778 ;; Remove the file-header. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1779 (when (re-search-forward diff-hunk-header-re nil t) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1780 (delete-region (point-min) (match-beginning 0)))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1781 (t (goto-char (point-max)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1782 (unless (bolp) (insert "\n")) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1783 (insert hunk))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1784 (setq hunk (buffer-string)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1785 (unless (memq status '(0 1)) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1786 (error "Diff returned: %s" status))))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1787 ;; Whatever happens, put back some equivalent text: either the new |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1788 ;; one or the original one in case some error happened. |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1789 (insert hunk) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1790 (delete-file file1) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1791 (delete-file file2)))) |
67419634950d
(diff-default-read-only): Change default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53833
diff
changeset
|
1792 |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1793 ;;; Fine change highlighting. |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1794 |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1795 (defface diff-refine-change |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1796 '((((class color) (min-colors 88) (background light)) |
93061
d8532269f863
(diff-header): Make the color louder.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92749
diff
changeset
|
1797 :background "grey85") |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1798 (((class color) (min-colors 88) (background dark)) |
92749
4578d4f0f0b2
(diff-refine-change): Adjust colors to be more visible.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92678
diff
changeset
|
1799 :background "grey60") |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1800 (((class color) (background light)) |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1801 :background "yellow") |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1802 (((class color) (background dark)) |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1803 :background "green") |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1804 (t :weight bold)) |
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1805 "Face used for char-based changes shown by `diff-refine-hunk'." |
85210
782f0bc49c07
* diff-mode.el (diff-fine-change): Add :group.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85208
diff
changeset
|
1806 :group 'diff-mode) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1807 |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1808 (defun diff-refine-preproc () |
85445
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1809 (while (re-search-forward "^[+>]" nil t) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1810 ;; Remove spurious changes due to the fact that one side of the hunk is |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1811 ;; marked with leading + or > and the other with leading - or <. |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1812 ;; We used to replace all the prefix chars with " " but this only worked |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1813 ;; when we did char-based refinement (or when using |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1814 ;; smerge-refine-weight-hack) since otherwise, the `forward' motion done |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1815 ;; in chopup do not necessarily do the same as the ones in highlight |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1816 ;; since the "_" is not treated the same as " ". |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1817 (replace-match (cdr (assq (char-before) '((?+ . "-") (?> . "<")))))) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1818 ) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1819 |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1820 (defun diff-refine-hunk () |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1821 "Highlight changes of hunk at point at a finer granularity." |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1822 (interactive) |
85503
59ee4068f60b
* progmodes/gud.el (gud-target-name): Move definition before use.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85478
diff
changeset
|
1823 (eval-and-compile (require 'smerge-mode)) |
85445
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1824 (save-excursion |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1825 (diff-beginning-of-hunk 'try-harder) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1826 (let* ((style (diff-hunk-style)) ;Skips the hunk header as well. |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1827 (beg (point)) |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1828 (props '((diff-mode . fine) (face diff-refine-change))) |
85445
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1829 (end (progn (diff-end-of-hunk) (point)))) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1830 |
85445
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1831 (remove-overlays beg end 'diff-mode 'fine) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1832 |
85445
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1833 (goto-char beg) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1834 (case style |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1835 (unified |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1836 (while (re-search-forward "^\\(?:-.*\n\\)+\\(\\)\\(?:\\+.*\n\\)+" |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1837 end t) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1838 (smerge-refine-subst (match-beginning 0) (match-end 1) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1839 (match-end 1) (match-end 0) |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1840 props 'diff-refine-preproc))) |
85445
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1841 (context |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1842 (let* ((middle (save-excursion (re-search-forward "^---"))) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1843 (other middle)) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1844 (while (re-search-forward "^\\(?:!.*\n\\)+" middle t) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1845 (smerge-refine-subst (match-beginning 0) (match-end 0) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1846 (save-excursion |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1847 (goto-char other) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1848 (re-search-forward "^\\(?:!.*\n\\)+" end) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1849 (setq other (match-end 0)) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1850 (match-beginning 0)) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1851 other |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1852 props 'diff-refine-preproc)))) |
85445
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1853 (t ;; Normal diffs. |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1854 (let ((beg1 (1+ (point)))) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1855 (when (re-search-forward "^---.*\n" end t) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1856 ;; It's a combined add&remove, so there's something to do. |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1857 (smerge-refine-subst beg1 (match-beginning 0) |
3bc55977b5f8
(diff-fine-highlight-preproc): Stick to minimal changes
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85210
diff
changeset
|
1858 (match-end 0) end |
85467
6ae4584fb3f6
(diff-auto-refine): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85445
diff
changeset
|
1859 props 'diff-refine-preproc)))))))) |
85100
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1860 |
c04703192cb6
(diff-hunk-style): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
84468
diff
changeset
|
1861 |
91528
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1862 (defun diff-add-change-log-entries-other-window () |
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1863 "Iterate through the current diff and create ChangeLog entries. |
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1864 I.e. like `add-change-log-entry-other-window' but applied to all hunks." |
91525 | 1865 (interactive) |
1866 ;; XXX: Currently add-change-log-entry-other-window is only called | |
1867 ;; once per hunk. Some hunks have multiple changes, it would be | |
1868 ;; good to call it for each change. | |
1869 (save-excursion | |
1870 (goto-char (point-min)) | |
1871 (let ((orig-buffer (current-buffer))) | |
1872 (condition-case nil | |
1873 ;; Call add-change-log-entry-other-window for each hunk in | |
1874 ;; the diff buffer. | |
91528
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1875 (while (progn |
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1876 (diff-hunk-next) |
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1877 ;; Move to where the changes are, |
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1878 ;; `add-change-log-entry-other-window' works better in |
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1879 ;; that case. |
91666
2229d6434820
(diff-add-change-log-entries-other-window): Avoid the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91528
diff
changeset
|
1880 (re-search-forward |
2229d6434820
(diff-add-change-log-entries-other-window): Avoid the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91528
diff
changeset
|
1881 (concat "\n[!+-<>]" |
2229d6434820
(diff-add-change-log-entries-other-window): Avoid the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91528
diff
changeset
|
1882 ;; If the hunk is a context hunk with an empty first |
2229d6434820
(diff-add-change-log-entries-other-window): Avoid the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91528
diff
changeset
|
1883 ;; half, recognize the "--- NNN,MMM ----" line |
2229d6434820
(diff-add-change-log-entries-other-window): Avoid the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91528
diff
changeset
|
1884 "\\(-- [0-9]+\\(,[0-9]+\\)? ----\n" |
2229d6434820
(diff-add-change-log-entries-other-window): Avoid the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91528
diff
changeset
|
1885 ;; and skip to the next non-context line. |
2229d6434820
(diff-add-change-log-entries-other-window): Avoid the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91528
diff
changeset
|
1886 "\\( .*\n\\)*[+]\\)?") |
2229d6434820
(diff-add-change-log-entries-other-window): Avoid the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91528
diff
changeset
|
1887 nil t)) |
91528
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1888 (save-excursion |
105793
b1c28ab3d90f
(diff-add-change-log-entries-other-window): Document in the code a bug.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104893
diff
changeset
|
1889 ;; FIXME: this pops up windows of all the buffers. |
96217
e5a55b8c9892
* add-log.el (add-change-log-entry): Add new arg to force each new
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95317
diff
changeset
|
1890 (add-change-log-entry nil nil t nil t))) |
91528
bc2ac468b977
(diff-add-change-log-entries-other-window):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91525
diff
changeset
|
1891 ;; When there's no more hunks, diff-hunk-next signals an error. |
91525 | 1892 (error nil))))) |
1893 | |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1894 ;; provide the package |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1895 (provide 'diff-mode) |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1896 |
30873
7f824fa01e10
(diff-mode-map): Bind diff-apply-hunk.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29423
diff
changeset
|
1897 ;;; Old Change Log from when diff-mode wasn't part of Emacs: |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1898 ;; Revision 1.11 1999/10/09 23:38:29 monnier |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1899 ;; (diff-mode-load-hook): dropped. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1900 ;; (auto-mode-alist): also catch *.diffs. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1901 ;; (diff-find-file-name, diff-mode): add smarts to find the right file |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1902 ;; for *.rej files (that lack any file name indication). |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1903 ;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1904 ;; Revision 1.10 1999/09/30 15:32:11 monnier |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1905 ;; added support for "\ No newline at end of file". |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1906 ;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1907 ;; Revision 1.9 1999/09/15 00:01:13 monnier |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1908 ;; - added basic `compile' support. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1909 ;; - have diff-kill-hunk call diff-kill-file if it's the only hunk. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1910 ;; - diff-kill-file now tries to kill the leading garbage as well. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1911 ;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1912 ;; Revision 1.8 1999/09/13 21:10:09 monnier |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1913 ;; - don't use CL in the autoloaded code |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1914 ;; - accept diffs using -T |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1915 ;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1916 ;; Revision 1.7 1999/09/05 20:53:03 monnier |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1917 ;; interface to ediff-patch |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1918 ;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1919 ;; Revision 1.6 1999/09/01 20:55:13 monnier |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1920 ;; (ediff=patch-file): add bindings to call ediff-patch. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1921 ;; (diff-find-file-name): taken out of diff-goto-source. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1922 ;; (diff-unified->context, diff-context->unified, diff-reverse-direction, |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1923 ;; diff-fixup-modifs): only use the region if a prefix arg is given. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1924 ;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1925 ;; Revision 1.5 1999/08/31 19:18:52 monnier |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1926 ;; (diff-beginning-of-file, diff-prev-file): fixed wrong parenthesis. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1927 ;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1928 ;; Revision 1.4 1999/08/31 13:01:44 monnier |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1929 ;; use `combine-after-change-calls' to minimize the slowdown of font-lock. |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1930 ;; |
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1931 |
57418
3a8c458de33d
(diff-current-defun): Fix 2004-06-13's change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57279
diff
changeset
|
1932 ;; arch-tag: 2571d7ff-bc28-4cf9-8585-42e21890be66 |
25959
1c62cbeca833
Initial revision, known outside of Emacs as version 1.8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1933 ;;; diff-mode.el ends here |