Mercurial > emacs
comparison lisp/diff-mode.el @ 31479:d58461428926
(diff-mouse-goto-source): New function.
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 07 Sep 2000 20:14:27 +0000 |
parents | 64bb4634d6d8 |
children | 46aca282e6b0 |
comparison
equal
deleted
inserted
replaced
31478:cbc394e82b62 | 31479:d58461428926 |
---|---|
204 "diff-mode face used to highlight changed lines." | 204 "diff-mode face used to highlight changed lines." |
205 :group 'diff-mode) | 205 :group 'diff-mode) |
206 (defvar diff-changed-face 'diff-changed-face) | 206 (defvar diff-changed-face 'diff-changed-face) |
207 | 207 |
208 (defvar diff-font-lock-keywords | 208 (defvar diff-font-lock-keywords |
209 '(("^@@ -[0-9,]+ \\+[0-9,]+ @@.*$" . diff-hunk-header-face) ;unified | 209 '(("^@@ \\(-[0-9,]+ \\+[0-9,]+\\) @@\\(.*\\)$" ;unified |
210 ("^--- .+ ----$" . diff-hunk-header-face) ;context | 210 (1 diff-hunk-header-face) |
211 ("^\\*\\*\\*\\(.+\\*\\*\\*\\|\\*\\{12\\}.*\\)\n" . diff-hunk-header-face) ;context | 211 (2 font-lock-comment-face)) |
212 ("^\\(---\\|\\+\\+\\+\\|\\*\\*\\*\\) .*\n" . diff-file-header-face) | 212 ("^--- \\(.+\\) ----$" ;context |
213 (1 diff-hunk-header-face)) | |
214 ("\\(\\*\\{15\\}\\)\\(.*\\)\n" ;context | |
215 (1 diff-hunk-header-face) | |
216 (2 font-lock-comment-face)) | |
217 ("^\\*\\*\\* \\(.+\\) \\*\\*\\*" ;context | |
218 (1 diff-hunk-header-face)) | |
219 ("^\\(---\\|\\+\\+\\+\\|\\*\\*\\*\\) \\(\\S-+\\)" (2 diff-file-header-face)) | |
213 ("^[0-9,]+[acd][0-9,]+$" . diff-hunk-header-face) | 220 ("^[0-9,]+[acd][0-9,]+$" . diff-hunk-header-face) |
214 ("^!.*\n" . diff-changed-face) ;context | 221 ("^!.*\n" . diff-changed-face) ;context |
215 ("^[+>].*\n" . diff-added-face) | 222 ("^[+>].*\n" . diff-added-face) |
216 ("^[-<].*\n" . diff-removed-face) | 223 ("^[-<].*\n" . diff-removed-face) |
217 ("^Index: .*\n" . diff-index-face) | 224 ("^Index: \\(.+\\)$" (1 diff-index-face)) |
218 ("^#.*" . font-lock-string-face) | 225 ("^#.*" . font-lock-string-face) |
219 ("^[^-=+*!<>].*\n" . font-lock-comment-face))) | 226 ("^[^-=+*!<>].*\n" . font-lock-comment-face))) |
220 | 227 |
221 (defconst diff-font-lock-defaults | 228 (defconst diff-font-lock-defaults |
222 '(diff-font-lock-keywords t nil nil nil (font-lock-multiline . nil))) | 229 '(diff-font-lock-keywords t nil nil nil (font-lock-multiline . nil))) |
477 (ignore-errors | 484 (ignore-errors |
478 (goto-line (+ (cadr loc) (caddr loc))) | 485 (goto-line (+ (cadr loc) (caddr loc))) |
479 (push-mark (point) t t) | 486 (push-mark (point) t t) |
480 (goto-line (cadr loc)))))) | 487 (goto-line (cadr loc)))))) |
481 | 488 |
489 (defun diff-mouse-goto-source (event) | |
490 "Run `diff-goto-source' for the diff at a mouse click." | |
491 (interactive "e") | |
492 (save-excursion | |
493 (mouse-set-point event) | |
494 (diff-goto-source))) | |
482 | 495 |
483 (defun diff-ediff-patch () | 496 (defun diff-ediff-patch () |
484 "Call `ediff-patch-file' on the current buffer." | 497 "Call `ediff-patch-file' on the current buffer." |
485 (interactive) | 498 (interactive) |
486 (condition-case err | 499 (condition-case err |
820 \\{diff-mode-map}" | 833 \\{diff-mode-map}" |
821 (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults) | 834 (set (make-local-variable 'font-lock-defaults) diff-font-lock-defaults) |
822 (set (make-local-variable 'outline-regexp) diff-outline-regexp) | 835 (set (make-local-variable 'outline-regexp) diff-outline-regexp) |
823 (set (make-local-variable 'imenu-generic-expression) | 836 (set (make-local-variable 'imenu-generic-expression) |
824 diff-imenu-generic-expression) | 837 diff-imenu-generic-expression) |
825 ;; compile support | 838 ;; These are not perfect. They would be better done separately for |
839 ;; context diffs and unidiffs. | |
840 ;; (set (make-local-variable 'paragraph-start) | |
841 ;; (concat "@@ " ; unidiff hunk | |
842 ;; "\\|\\*\\*\\* " ; context diff hunk or file start | |
843 ;; "\\|--- [^\t]+\t")) ; context or unidiff file | |
844 ;; ; start (first or second line) | |
845 ;; (set (make-local-variable 'paragraph-separate) paragraph-start) | |
846 ;; (set (make-local-variable 'page-delimiter) "--- [^\t]+\t") | |
847 ;; compile support | |
826 (set (make-local-variable 'compilation-file-regexp-alist) | 848 (set (make-local-variable 'compilation-file-regexp-alist) |
827 diff-file-regexp-alist) | 849 diff-file-regexp-alist) |
828 (set (make-local-variable 'compilation-error-regexp-alist) | 850 (set (make-local-variable 'compilation-error-regexp-alist) |
829 diff-error-regexp-alist) | 851 diff-error-regexp-alist) |
830 (when (string-match "\\.rej\\'" (or buffer-file-name "")) | 852 (when (string-match "\\.rej\\'" (or buffer-file-name "")) |