User: scop
Date: 05/12/02 10:54:34
Modified: packages/xemacs-packages/prog-modes ChangeLog diff-mode.el
Log:
diff-mode regexp fixes, fix faces for 21.4 <1133436394.7824.24.camel(a)localhost.localdomain>
Revision Changes Path
1.233 +9 -0 XEmacs/packages/xemacs-packages/prog-modes/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/prog-modes/ChangeLog,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -p -r1.232 -r1.233
--- ChangeLog 2005/07/10 10:09:46 1.232
+++ ChangeLog 2005/12/02 09:54:33 1.233
@@ -1,3 +1,12 @@
+2005-12-01 Ville Skyttä <scop(a)xemacs.org>
+
+ * diff-mode.el: Sync hunk and file recognition improvements and
+ some trivial bits from GNU Emacs CVS.
+ (diff-removed-face): Don't use :inherit (not in 21.4).
+ (diff-added-face): Ditto.
+ (diff-function-face): Ditto.
+ (diff-nonexistent-face): Ditto.
+
2005-07-10 Norbert Koch <viteno(a)xemacs.org>
* Makefile (VERSION): XEmacs package 2.05 released.
1.14 +62 -25 XEmacs/packages/xemacs-packages/prog-modes/diff-mode.el
Index: diff-mode.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/prog-modes/diff-mode.el,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- diff-mode.el 2004/08/16 18:49:33 1.13
+++ diff-mode.el 2005/12/02 09:54:34 1.14
@@ -1,6 +1,7 @@
;;; diff-mode.el --- a mode for viewing/editing context diffs
-;; Copyright (C) 1998,1999,2000,01,02,03,2004 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;; 2005 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier(a)cs.yale.edu>
;; Keywords: convenience patch diff
@@ -19,11 +20,12 @@
;; You should have received a copy of the GNU General Public License
;; along with XEmacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Synched up with: GNU Emacs 21.3, except for the easy-mmode-defmap stuff.
;;; Also various trivial bits synced from Emacs CVS 2004-08-13
+;;; and 2005-12-01.
;;; Commentary:
@@ -67,7 +69,7 @@
(defgroup diff-mode ()
- "Major mode for viewing/editing diffs"
+ "Major mode for viewing/editing diffs."
:version "21.1"
:group 'tools
:group 'diff)
@@ -80,8 +82,8 @@
(defcustom diff-jump-to-old-file nil
"*Non-nil means `diff-goto-source' jumps to the old file.
Else, it jumps to the new file."
-:group 'diff-mode
-:type '(boolean))
+:type 'boolean
+:group 'diff-mode)
(defcustom diff-update-on-the-fly t
"*Non-nil means hunk headers are kept up-to-date on-the-fly.
@@ -90,13 +92,13 @@ need to be kept consistent with the actu
either be done on the fly (but this sometimes interacts poorly with the
undo mechanism) or whenever the file is written (can be slow
when editing big diffs)."
-:group 'diff-mode
-:type '(boolean))
+:type 'boolean
+:group 'diff-mode)
(defcustom diff-advance-after-apply-hunk t
"*Non-nil means `diff-apply-hunk' will move to the next hunk after applying."
-:group 'diff-mode
-:type 'boolean)
+:type 'boolean
+:group 'diff-mode)
(defvar diff-mode-hook nil
@@ -186,8 +188,8 @@ when editing big diffs)."
(defcustom diff-minor-mode-prefix "\C-c="
"Prefix key for `diff-minor-mode' commands."
-:group 'diff-mode
-:type '(choice (string "\e") (string "C-c=") string))
+:type '(choice (string "\e") (string "C-c=") string)
+:group 'diff-mode)
(easy-mmode-defmap diff-minor-mode-map
`((,diff-minor-mode-prefix . ,diff-mode-shared-map))
@@ -227,7 +229,7 @@ when editing big diffs)."
(defvar diff-file-header-face 'diff-file-header-face)
(defface diff-index-face
- ;; XEmacs change: no :inherit, this is just a copy of diff-file-header-face.
+ ;; XEmacs change: no :inherit in 21.4, copy/pasted `diff-file-header-face'.
'((((type tty pc) (class color) (background light))
(:foreground "yellow" :bold t))
(((type tty pc) (class color) (background dark))
@@ -242,7 +244,7 @@ when editing big diffs)."
(defvar diff-index-face 'diff-index-face)
(defface diff-hunk-header-face
- ;; XEmacs change: no :inherit, this is just a copy of diff-header-face.
+ ;; XEmacs change: no :inherit in 21.4; copy/pasted `diff-header-face'.
'((((type tty pc) (class color) (background light))
(:foreground "blue1" :bold t))
(((type tty pc) (class color) (background dark))
@@ -257,13 +259,23 @@ when editing big diffs)."
(defvar diff-hunk-header-face 'diff-hunk-header-face)
(defface diff-removed-face
- '((t (:inherit diff-changed-face)))
+ ;; XEmacs change: no :inherit in 21.4; copy/pasted `diff-changed-face'.
+ '((((type tty pc) (class color) (background light))
+ (:foreground "magenta" :bold t :italic t))
+ (((type tty pc) (class color) (background dark))
+ (:foreground "yellow" :bold t :italic t))
+ (t ()))
"`diff-mode' face used to highlight removed lines."
:group 'diff-mode)
(defvar diff-removed-face 'diff-removed-face)
(defface diff-added-face
- '((t (:inherit diff-changed-face)))
+ ;; XEmacs change: no :inherit in 21.4; copy/pasted `diff-changed-face'.
+ '((((type tty pc) (class color) (background light))
+ (:foreground "magenta" :bold t :italic t))
+ (((type tty pc) (class color) (background dark))
+ (:foreground "yellow" :bold t :italic t))
+ (t ()))
"`diff-mode' face used to highlight added lines."
:group 'diff-mode)
(defvar diff-added-face 'diff-added-face)
@@ -279,7 +291,12 @@ when editing big diffs)."
(defvar diff-changed-face 'diff-changed-face)
(defface diff-function-face
- '((t (:inherit diff-context-face)))
+ ;; XEmacs change: no :inherit in 21.4; copy/pasted `diff-context-face'.
+ '((((class color) (background light))
+ (:foreground "grey50"))
+ (((class color) (background dark))
+ (:foreground "grey70"))
+ (t ))
"`diff-mode' face used to highlight function names produced by \"diff -p\"."
:group 'diff-mode)
(defvar diff-function-face 'diff-function-face)
@@ -295,7 +312,16 @@ when editing big diffs)."
(defvar diff-context-face 'diff-context-face)
(defface diff-nonexistent-face
- '((t (:inherit diff-file-header-face)))
+ ;; XEmacs change: no :inherit in 21.4; copy/pasted `diff-file-header-face'.
+ '((((type tty pc) (class color) (background light))
+ (:foreground "yellow" :bold t))
+ (((type tty pc) (class color) (background dark))
+ (:foreground "cyan" :bold t))
+ (((class color) (background light))
+ (:background "grey70" :bold t))
+ (((class color) (background dark))
+ (:background "grey60" :bold t))
+ (t (:bold t))) ; :height 1.3
"`diff-mode' face used to highlight nonexistent files in recursive diffs."
:group 'diff-mode)
(defvar diff-nonexistent-face 'diff-nonexistent-face)
@@ -363,11 +389,15 @@ when editing big diffs)."
;;;;
(defconst diff-hunk-header-re "^\\(@@ -[0-9,]+ \\+[0-9,]+ @@.*\\|\\*\\{15\\}.*\n\\*\\*\\* .+ \\*\\*\\*\\*\\|[0-9]+\\(,[0-9]+\\)?[acd][0-9]+\\(,[0-9]+\\)?\\)$")
-(defconst diff-file-header-re (concat "^\\(--- .+\n\\+\\+\\+\\|\\*\\*\\* .+\n---\\|[^-+!<>0-9@* ]\\).+\n" (substring diff-hunk-header-re 1)))
+(defconst diff-file-header-re (concat "^\\(--- .+\n\\+\\+\\+ \\|\\*\\*\\* .+\n--- \\|[^-+!<>0-9@* ]\\).+\n" (substring diff-hunk-header-re 1)))
(defvar diff-narrowed-to nil)
(defun diff-end-of-hunk (&optional style)
- (if (looking-at diff-hunk-header-re) (goto-char (match-end 0)))
+ (when (looking-at diff-hunk-header-re)
+ (unless style
+ ;; Especially important for unified (because headers are ambiguous).
+ (setq style (cdr (assq (char-after) '((?@ . unified) (?* . context))))))
+ (goto-char (match-end 0)))
(let ((end (and (re-search-forward (case style
;; A `unified' header is ambiguous.
(unified (concat "^[^-+# \\]\\|"
@@ -398,8 +428,11 @@ when editing big diffs)."
(defun diff-end-of-file ()
(re-search-forward "^[-+#!<>0-9@* \\]" nil t)
- (re-search-forward "^[^-+#!<>0-9@* \\]" nil 'move)
- (beginning-of-line))
+ (re-search-forward (concat "^[^-+#!<>0-9@* \\]\\|" diff-file-header-re)
+ nil 'move)
+ (if (match-beginning 1)
+ (goto-char (match-beginning 1))
+ (beginning-of-line)))
;; Define diff-{hunk,file}-{prev,next}
(easy-mmode-define-navigation
@@ -790,7 +823,7 @@ else cover the whole bufer."
;; or
"\\|"
;; I'm not sure
- "\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\n"
+ "\\*\\{15\\}.*\n"
"\\*\\*\\* \\(.+\\) \\*\\*\\*\\*"
;; or
"\\|"
@@ -884,7 +917,7 @@ else cover the whole buffer."
(defun diff-fixup-modifs (start end)
"Fixup the hunk headers (in case the buffer was modified).
START and END are either taken from the region (if a prefix arg is given) or
-else cover the whole bufer."
+else cover the whole buffer."
(interactive (if current-prefix-arg
(list (mark) (point))
(list (point-min) (point-max))))
@@ -893,7 +926,10 @@ else cover the whole bufer."
(goto-char end) (diff-end-of-hunk)
(let ((plus 0) (minus 0) (space 0) (bang 0))
(while (and (= (forward-line -1) 0) (<= start (point)))
- (if (not (looking-at "\\(@@ -[0-9,]+ \\+[0-9,]+ @@.*\\|[-*][-*][-*] .+ [-*][-*][-*][-*]\\)$"))
+ (if (not (looking-at
+ (concat "@@ -[0-9,]+ \\+[0-9,]+ @@"
+ "\\|[-*][-*][-*] [0-9,]+ [-*][-*][-*][-*]$"
+ "\\|--- .+\n\\+\\+\\+ ")))
(case (char-after)
(?\ (incf space))
(?+ (incf plus))
@@ -1353,4 +1389,5 @@ For use in `add-log-current-defun-functi
;; use `combine-after-change-calls' to minimize the slowdown of font-lock.
;;
+;; arch-tag: 2571d7ff-bc28-4cf9-8585-42e21890be66
;;; diff-mode.el ends here