changeset 41314:a2bce9d9c349

(re-builder): Don't re-enter RE Builder Mode.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 20 Nov 2001 18:25:02 +0000
parents 2186cf9476ba
children 0a9e39e97bfa
files lisp/emacs-lisp/re-builder.el
diffstat 1 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/re-builder.el	Tue Nov 20 18:20:56 2001 +0000
+++ b/lisp/emacs-lisp/re-builder.el	Tue Nov 20 18:25:02 2001 +0000
@@ -313,20 +313,23 @@
   "Call up the RE Builder for the current window."
   (interactive)
 
-  (if reb-target-buffer
-      (reb-delete-overlays))
-  (setq reb-target-buffer (current-buffer)
-	reb-target-window (selected-window)
-	reb-window-config (current-window-configuration))
-  (select-window (split-window (selected-window) (- (window-height) 4)))
-  (switch-to-buffer (get-buffer-create reb-buffer))
-  (erase-buffer)
-  (reb-insert-regexp)
-  (goto-char (+ 2 (point-min)))
-  (cond
-   ((reb-lisp-syntax-p)
-    (reb-lisp-mode))
-   (t (reb-mode))))
+  (if (and (string= (buffer-name) reb-buffer)
+           (memq major-mode '(reb-mode reb-lisp-mode)))
+      (message "Already in the RE Builder")
+    (if reb-target-buffer
+        (reb-delete-overlays))
+    (setq reb-target-buffer (current-buffer)
+          reb-target-window (selected-window)
+          reb-window-config (current-window-configuration))
+    (select-window (split-window (selected-window) (- (window-height) 4)))
+    (switch-to-buffer (get-buffer-create reb-buffer))
+    (erase-buffer)
+    (reb-insert-regexp)
+    (goto-char (+ 2 (point-min)))
+    (cond
+     ((reb-lisp-syntax-p)
+      (reb-lisp-mode))
+     (t (reb-mode)))))
 
 (defun reb-change-target-buffer (buf)
   "Change the target buffer and display it in the target window."