comparison lisp/diff-mode.el @ 31269:64bb4634d6d8

(diff-mode) <defgroup>: Add :version. (diff-mode-shared-map): Bind mouse-2. (diff-imenu-generic-expression): New variable. (diff-mode): Use it.
author Dave Love <fx@gnu.org>
date Tue, 29 Aug 2000 14:38:49 +0000
parents 7f824fa01e10
children d58461428926
comparison
equal deleted inserted replaced
31268:4c6d8d40e71c 31269:64bb4634d6d8
1 ;;; diff-mode.el --- A mode for viewing/editing context diffs 1 ;;; diff-mode.el --- A mode for viewing/editing context diffs
2 2
3 ;; Copyright (C) 1998-1999 Free Software Foundation, Inc. 3 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
4 4
5 ;; Author: Stefan Monnier <monnier@cs.yale.edu> 5 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
6 ;; Keywords: patch diff 6 ;; Keywords: patch diff
7 ;; Revision: $Id: diff-mode.el,v 1.8 2000/06/05 07:30:09 monnier Exp $ 7 ;; Revision: $Id: diff-mode.el,v 1.9 2000/08/16 19:56:10 monnier Exp $
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
10 10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify 11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by 12 ;; it under the terms of the GNU General Public License as published by
55 ;; - Do a fuzzy search in diff-goto-source. 55 ;; - Do a fuzzy search in diff-goto-source.
56 ;; - Allow diff.el to use diff-mode. 56 ;; - Allow diff.el to use diff-mode.
57 ;; This mostly means ability to jump from half-hunk to half-hunk 57 ;; This mostly means ability to jump from half-hunk to half-hunk
58 ;; in context (and normal) diffs and to jump to the corresponding 58 ;; in context (and normal) diffs and to jump to the corresponding
59 ;; (i.e. new or old) file. 59 ;; (i.e. new or old) file.
60 ;; - imenu support.
61 ;; - Handle `diff -b' output in context->unified. 60 ;; - Handle `diff -b' output in context->unified.
62 61
63 ;;; Code: 62 ;;; Code:
64 63
65 (eval-when-compile (require 'cl)) 64 (eval-when-compile (require 'cl))
66 65
67 66
68 (defgroup diff-mode () 67 (defgroup diff-mode ()
69 "Major-mode for viewing/editing diffs" 68 "Major-mode for viewing/editing diffs"
69 :version "21.1"
70 :group 'tools 70 :group 'tools
71 :group 'diff) 71 :group 'diff)
72 72
73 (defcustom diff-jump-to-old-file-flag nil 73 (defcustom diff-jump-to-old-file-flag nil
74 "*Non-nil means `diff-goto-source' jumps to the old file. 74 "*Non-nil means `diff-goto-source' jumps to the old file.
106 ("K" . diff-file-kill) 106 ("K" . diff-file-kill)
107 ;; From compilation-minor-mode. 107 ;; From compilation-minor-mode.
108 ("}" . diff-file-next) 108 ("}" . diff-file-next)
109 ("{" . diff-file-prev) 109 ("{" . diff-file-prev)
110 ("\C-m" . diff-goto-source) 110 ("\C-m" . diff-goto-source)
111 ([mouse-2] . diff-mouse-goto-source)
111 ;; From XEmacs' diff-mode. 112 ;; From XEmacs' diff-mode.
112 ("W" . widen) 113 ("W" . widen)
113 ;;("." . diff-goto-source) ;display-buffer 114 ;;("." . diff-goto-source) ;display-buffer
114 ;;("f" . diff-goto-source) ;find-file 115 ;;("f" . diff-goto-source) ;find-file
115 ("o" . diff-goto-source) ;other-window 116 ("o" . diff-goto-source) ;other-window
217 ("^#.*" . font-lock-string-face) 218 ("^#.*" . font-lock-string-face)
218 ("^[^-=+*!<>].*\n" . font-lock-comment-face))) 219 ("^[^-=+*!<>].*\n" . font-lock-comment-face)))
219 220
220 (defconst diff-font-lock-defaults 221 (defconst diff-font-lock-defaults
221 '(diff-font-lock-keywords t nil nil nil (font-lock-multiline . nil))) 222 '(diff-font-lock-keywords t nil nil nil (font-lock-multiline . nil)))
223
224 (defvar diff-imenu-generic-expression
225 ;; Prefer second name as first is most likely to be a backup or
226 ;; version-control name.
227 '((nil "\\+\\+\\+\\ \\([^\t\n]+\\)\t" 1) ; unidiffs
228 (nil "^--- \\([^\t\n]+\\)\t.*\n\\*" 1))) ; context diffs
222 229
223 ;;;; 230 ;;;;
224 ;;;; Compile support 231 ;;;; Compile support
225 ;;;; 232 ;;;;
226 233
811 When the buffer is read-only, the ESC prefix is not necessary. 818 When the buffer is read-only, the ESC prefix is not necessary.
812 This mode runs `diff-mode-hook'. 819 This mode runs `diff-mode-hook'.
813 \\{diff-mode-map}" 820 \\{diff-mode-map}"
814 (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults) 821 (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults)
815 (set (make-local-variable 'outline-regexp) diff-outline-regexp) 822 (set (make-local-variable 'outline-regexp) diff-outline-regexp)
816 ;; compile support 823 (set (make-local-variable 'imenu-generic-expression)
824 diff-imenu-generic-expression)
825 ;; compile support
817 (set (make-local-variable 'compilation-file-regexp-alist) 826 (set (make-local-variable 'compilation-file-regexp-alist)
818 diff-file-regexp-alist) 827 diff-file-regexp-alist)
819 (set (make-local-variable 'compilation-error-regexp-alist) 828 (set (make-local-variable 'compilation-error-regexp-alist)
820 diff-error-regexp-alist) 829 diff-error-regexp-alist)
821 (when (string-match "\\.rej\\'" (or buffer-file-name "")) 830 (when (string-match "\\.rej\\'" (or buffer-file-name ""))