4
|
1 ;;;
|
|
2 ;;; mu-replace.el --- a replacing utility for GNU Emacs
|
|
3 ;;;
|
|
4 ;;; Copyright (C) 1995,1996 MORIOKA Tomohiko
|
|
5 ;;;
|
|
6 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
|
7 ;;; Version:
|
|
8 ;;; $Id: mu-replace.el,v 1.1.1.1 1996/12/18 03:55:31 steve Exp $
|
|
9 ;;; Keywords: replace
|
|
10 ;;;
|
|
11 ;;; This file is part of tl (Tiny Library).
|
|
12 ;;;
|
|
13 ;;; This program is free software; you can redistribute it and/or
|
|
14 ;;; modify it under the terms of the GNU General Public License as
|
|
15 ;;; published by the Free Software Foundation; either version 2, or
|
|
16 ;;; (at your option) any later version.
|
|
17 ;;;
|
|
18 ;;; This program is distributed in the hope that it will be useful,
|
|
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;;; General Public License for more details.
|
|
22 ;;;
|
|
23 ;;; You should have received a copy of the GNU General Public License
|
|
24 ;;; along with This program. If not, write to the Free Software
|
|
25 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
26 ;;;
|
|
27 ;;; Commentary:
|
|
28 ;;;
|
|
29 ;;; - How to install.
|
|
30 ;;; 1. bytecompile this file and copy it to the apropriate directory.
|
|
31 ;;; 2. put the following lines to your ~/.emacs:
|
|
32 ;;; (autoload 'edit-replace-region "mu-replace" nil t)
|
|
33 ;;; - How to use.
|
|
34 ;;; 1. mark in beginning of region you want to replace.
|
|
35 ;;; 2. go to end of region you want to replace.
|
|
36 ;;; 3. type M-x edit-replace-region [CR]
|
|
37 ;;; then entering to ``edit-replace mode''.
|
|
38 ;;; 4. edit replacement string.
|
|
39 ;;; 5. type C-c C-c then specified region will be replaced.
|
|
40 ;;;
|
|
41 ;;; Code:
|
|
42
|
|
43 (defvar edit-replace-mode-map nil)
|
|
44 (if (null edit-replace-mode-map)
|
|
45 (progn
|
|
46 (setq edit-replace-mode-map (copy-keymap text-mode-map))
|
|
47 (define-key edit-replace-mode-map
|
|
48 "\C-c\C-c" (function edit-replace-query-replace))
|
|
49 ))
|
|
50
|
|
51 (make-variable-buffer-local 'edit-replace-original-buffer)
|
|
52 (make-variable-buffer-local 'edit-replace-start-point)
|
|
53 (make-variable-buffer-local 'edit-replace-end-point)
|
|
54
|
|
55 (defvar edit-replace-original-buffer nil)
|
|
56 (defvar edit-replace-start-point nil)
|
|
57 (defvar edit-replace-end-point nil)
|
|
58
|
|
59 (defun edit-replace-region (beg end &optional str)
|
|
60 (interactive "r")
|
|
61 (let ((the-buf (current-buffer))
|
|
62 (buf (get-buffer-create " *edit-replace*")))
|
|
63 (pop-to-buffer buf)
|
|
64 (setq major-mode 'edit-replace)
|
|
65 (setq mode-name "edit for replace")
|
|
66 (use-local-map edit-replace-mode-map)
|
|
67 (setq edit-replace-original-buffer the-buf)
|
|
68 (setq edit-replace-start-point beg)
|
|
69 (setq edit-replace-end-point end)
|
|
70 ))
|
|
71
|
|
72 (defun edit-replace-query-replace ()
|
|
73 (interactive)
|
|
74 (let ((beg edit-replace-start-point)
|
|
75 (end edit-replace-end-point)
|
|
76 str
|
|
77 (rstr (buffer-string))
|
|
78 )
|
|
79 (switch-to-buffer edit-replace-original-buffer)
|
|
80 (setq str (buffer-substring beg end))
|
|
81 (goto-char beg)
|
|
82 (query-replace str rstr)
|
|
83 ))
|
|
84
|
|
85 ;;; mu-replace.el ends here
|