comparison lisp/diff-mode.el @ 31556:74d7a9c42c2a

(diff-hunk-text): Use `with-temp-buffer'. (diff-mode-map): Bind `diff-test-hunk'. (diff-apply-hunk): Use `select-window' instead of `pop-to-buffer'.
author Miles Bader <miles@gnu.org>
date Tue, 12 Sep 2000 11:24:28 +0000
parents 46aca282e6b0
children e05ee0693dda
comparison
equal deleted inserted replaced
31555:a1b90be8f105 31556:74d7a9c42c2a
2 2
3 ;; Copyright (C) 1998, 1999, 2000 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.11 2000/09/07 20:14:27 fx Exp $ 7 ;; Revision: $Id: diff-mode.el,v 1.12 2000/09/11 13:49:38 miles 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
131 (easy-mmode-defmap diff-mode-map 131 (easy-mmode-defmap diff-mode-map
132 `(("\e" . ,diff-mode-shared-map) 132 `(("\e" . ,diff-mode-shared-map)
133 ;; From compilation-minor-mode. 133 ;; From compilation-minor-mode.
134 ("\C-c\C-c" . diff-goto-source) 134 ("\C-c\C-c" . diff-goto-source)
135 ;; Misc operations. 135 ;; Misc operations.
136 ("\C-cda" . diff-apply-hunk)) 136 ("\C-cda" . diff-apply-hunk)
137 ("\C-cdt" . diff-test-hunk))
137 "Keymap for `diff-mode'. See also `diff-mode-shared-map'.") 138 "Keymap for `diff-mode'. See also `diff-mode-shared-map'.")
138 139
139 (easy-menu-define diff-mode-menu diff-mode-map 140 (easy-menu-define diff-mode-menu diff-mode-map
140 "Menu for `diff-mode'." 141 "Menu for `diff-mode'."
141 '("Diff" 142 '("Diff"
881 (equal (match-string 1) (match-string 2))))) 882 (equal (match-string 1) (match-string 2)))))
882 883
883 (defun diff-hunk-text (hunk dest) 884 (defun diff-hunk-text (hunk dest)
884 "Returns the literal source text from HUNK, if DEST is nil, otherwise 885 "Returns the literal source text from HUNK, if DEST is nil, otherwise
885 the destination text." 886 the destination text."
886 (with-current-buffer "foo" 887 (with-temp-buffer
887 (erase-buffer) 888 (erase-buffer)
888 (insert hunk) 889 (insert hunk)
889 (goto-char (point-min)) 890 (goto-char (point-min))
890 (let ((src nil) 891 (let ((src nil)
891 (dst nil) 892 (dst nil)
1066 (message "Hunk %s at offset %d lines" 1067 (message "Hunk %s at offset %d lines"
1067 msg 1068 msg
1068 (- real-line patch-line))))) 1069 (- real-line patch-line)))))
1069 1070
1070 ;; Display BUF in a window, and maybe select it 1071 ;; Display BUF in a window, and maybe select it
1071 (cond ((eq popup 'select) 1072 (let ((win (display-buffer buf)))
1072 (pop-to-buffer buf) 1073 (set-window-point win pos)
1073 (goto-char pos)) 1074 (when (eq popup 'select)
1074 (t 1075 (select-window win))))
1075 (set-window-point (display-buffer buf) pos))))
1076 1076
1077 ;; Return an appropriate indicator of success 1077 ;; Return an appropriate indicator of success
1078 (if reversed 'reversed t))))) 1078 (if reversed 'reversed t)))))
1079 1079
1080 1080