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

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

Protect against reentering re-builder


From: Juanma Barranquero
Subject: Protect against reentering re-builder
Date: Thu, 15 Nov 2001 16:56:17 +0100

This tiny patch (three lines, not counting reindenting) protects
against accidentally reentering re-builder (which it doesn't like :)



                                                           /L/e/k/t/u




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

        * re-builder.el (re-builder): Protect against reentering
        re-builder.



--- re-builder.el.orig  Mon Oct 22 13:15:52 2001
+++ re-builder.el       Thu Nov 15 16:43:02 2001
@@ -327,21 +327,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-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]