bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch to add new function to re-builder


From: Juanma Barranquero
Subject: Patch to add new function to re-builder
Date: Thu, 15 Nov 2001 16:46:25 +0100

This patch, sent during the pretest, was delayed to be reconsidered
after the release.

It adds a new function to re-builder that allows switching the target
buffer.


                                                           /L/e/k/t/u


2001-11-15  Juanma Barranquero  <address@hidden>

        * re-builder.el (reb-change-target-buffer): New function.



--- re-builder.el.orig  Mon Oct 22 13:15:52 2001
+++ re-builder.el       Thu Nov 15 16:03:14 2001
@@ -1,6 +1,6 @@
 ;;; re-builder.el --- building Regexps with visual feedback
 
-;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
 
 ;; Author: Detlev Zundel <address@hidden>
 ;; Keywords: matching, lisp, tools
@@ -44,6 +44,11 @@
 ;; you want to know the reason why RE Builder considers it as invalid
 ;; call `reb-force-update' ("\C-c\C-u") which should reveal the error.
 
+;; The target buffer can be changed with `reb-change-target-buffer'
+;; ("\C-c\C-b"). Changing the target buffer automatically removes
+;; the overlays from the old buffer and displays the new one in the
+;; target window.
+
 ;; The `re-builder' keeps the focus while updating the matches in the
 ;; target buffer so corrections are easy to incorporate.  If you are
 ;; satisfied with the result you can paste the RE to the kill-ring
@@ -224,6 +229,7 @@
       (define-key reb-mode-map "\C-c\C-r" 'reb-prev-match)
       (define-key reb-mode-map "\C-c\C-i" 'reb-change-syntax)
       (define-key reb-mode-map "\C-c\C-e" 'reb-enter-subexp-mode)
+      (define-key reb-mode-map "\C-c\C-b" 'reb-change-target-buffer)
       (define-key reb-mode-map "\C-c\C-u" 'reb-force-update)))
 
 (defun reb-mode ()
@@ -342,6 +348,18 @@
     (reb-lisp-mode))
    (t (reb-mode))))
 
+(defun reb-change-target-buffer (buf)
+  "Change the target buffer and display it in the target window."
+  (interactive "bSet target buffer to: ")
+
+  (let ((buffer (get-buffer buf)))
+    (if (not buffer)
+        (error "No such buffer")
+      (reb-delete-overlays)
+      (setq reb-target-buffer buffer)
+      (reb-do-update
+       (if reb-subexp-mode reb-subexp-displayed nil))
+      (reb-update-modestring))))
 
 (defun reb-force-update ()
   "Forces an update in the RE Builder target window without a match limit."





reply via email to

[Prev in Thread] Current Thread [Next in Thread]