299 |
(add-hook 'kill-buffer-hook 'reb-kill-buffer) |
(add-hook 'kill-buffer-hook 'reb-kill-buffer) |
300 |
(reb-auto-update nil nil nil)) |
(reb-auto-update nil nil nil)) |
301 |
|
|
|
|
|
|
;; Handy macro for doing things in other windows |
|
|
(defmacro reb-with-current-window (window &rest body) |
|
|
"With WINDOW selected evaluate BODY forms and reselect previous window." |
|
|
|
|
|
(let ((oldwindow (make-symbol "*oldwindow*"))) |
|
|
`(let ((,oldwindow (selected-window))) |
|
|
(select-window ,window) |
|
|
(unwind-protect |
|
|
(progn |
|
|
,@body) |
|
|
(select-window ,oldwindow))))) |
|
|
(put 'reb-with-current-window 'lisp-indent-function 0) |
|
|
|
|
302 |
(defun reb-color-display-p () |
(defun reb-color-display-p () |
303 |
"Return t if display is capable of displaying colors." |
"Return t if display is capable of displaying colors." |
304 |
(eq 'color |
(eq 'color |
316 |
"Return binding for SYMBOL in the RE Builder target buffer." |
"Return binding for SYMBOL in the RE Builder target buffer." |
317 |
`(with-current-buffer reb-target-buffer ,symbol)) |
`(with-current-buffer reb-target-buffer ,symbol)) |
318 |
|
|
319 |
|
(defun reb-initialize-buffer () |
320 |
|
"Initialize the current buffer as a RE Builder buffer." |
321 |
|
(erase-buffer) |
322 |
|
(reb-insert-regexp) |
323 |
|
(goto-char (+ 2 (point-min))) |
324 |
|
(cond ((reb-lisp-syntax-p) |
325 |
|
(reb-lisp-mode)) |
326 |
|
(t (reb-mode)))) |
327 |
|
|
328 |
;;; This is to help people find this in Apropos. |
;;; This is to help people find this in Apropos. |
329 |
;;;###autoload |
;;;###autoload |
330 |
(defalias 'regexp-builder 're-builder) |
(defalias 'regexp-builder 're-builder) |
344 |
reb-window-config (current-window-configuration)) |
reb-window-config (current-window-configuration)) |
345 |
(select-window (split-window (selected-window) (- (window-height) 4))) |
(select-window (split-window (selected-window) (- (window-height) 4))) |
346 |
(switch-to-buffer (get-buffer-create reb-buffer)) |
(switch-to-buffer (get-buffer-create reb-buffer)) |
347 |
(erase-buffer) |
(reb-initialize-buffer))) |
|
(reb-insert-regexp) |
|
|
(goto-char (+ 2 (point-min))) |
|
|
(cond |
|
|
((reb-lisp-syntax-p) |
|
|
(reb-lisp-mode)) |
|
|
(t (reb-mode))))) |
|
348 |
|
|
349 |
(defun reb-change-target-buffer (buf) |
(defun reb-change-target-buffer (buf) |
350 |
"Change the target buffer and display it in the target window." |
"Change the target buffer and display it in the target window." |
382 |
(interactive) |
(interactive) |
383 |
|
|
384 |
(reb-assert-buffer-in-window) |
(reb-assert-buffer-in-window) |
385 |
(reb-with-current-window |
(with-selected-window reb-target-window |
|
reb-target-window |
|
386 |
(if (not (re-search-forward reb-regexp (point-max) t)) |
(if (not (re-search-forward reb-regexp (point-max) t)) |
387 |
(message "No more matches.") |
(message "No more matches.") |
388 |
(reb-show-subexp |
(reb-show-subexp |
394 |
(interactive) |
(interactive) |
395 |
|
|
396 |
(reb-assert-buffer-in-window) |
(reb-assert-buffer-in-window) |
397 |
(reb-with-current-window reb-target-window |
(with-selected-window reb-target-window |
398 |
(goto-char (1- (point))) |
(let ((p (point))) |
399 |
(if (not (re-search-backward reb-regexp (point-min) t)) |
(goto-char (1- p)) |
400 |
(message "No more matches.") |
(if (re-search-backward reb-regexp (point-min) t) |
401 |
(reb-show-subexp |
(reb-show-subexp |
402 |
(or (and reb-subexp-mode reb-subexp-displayed) 0) |
(or (and reb-subexp-mode reb-subexp-displayed) 0) |
403 |
t)))) |
t) |
404 |
|
(goto-char p) |
405 |
|
(message "No more matches."))))) |
406 |
|
|
407 |
(defun reb-toggle-case () |
(defun reb-toggle-case () |
408 |
"Toggle case sensitivity of searches for RE Builder target buffer." |
"Toggle case sensitivity of searches for RE Builder target buffer." |
439 |
the match should already be marked by an overlay. |
the match should already be marked by an overlay. |
440 |
On other displays jump to the beginning and the end of it. |
On other displays jump to the beginning and the end of it. |
441 |
If the optional PAUSE is non-nil then pause at the end in any case." |
If the optional PAUSE is non-nil then pause at the end in any case." |
442 |
(reb-with-current-window reb-target-window |
(with-selected-window reb-target-window |
443 |
(if (not (reb-color-display-p)) |
(if (not (reb-color-display-p)) |
444 |
(progn (goto-char (match-beginning subexp)) |
(progn (goto-char (match-beginning subexp)) |
445 |
(sit-for reb-blink-delay))) |
(sit-for reb-blink-delay))) |
469 |
(if (memq syntax '(read string lisp-re sregex rx)) |
(if (memq syntax '(read string lisp-re sregex rx)) |
470 |
(let ((buffer (get-buffer reb-buffer))) |
(let ((buffer (get-buffer reb-buffer))) |
471 |
(setq reb-re-syntax syntax) |
(setq reb-re-syntax syntax) |
472 |
(if buffer |
(when buffer |
473 |
(with-current-buffer buffer |
(with-current-buffer buffer |
474 |
(erase-buffer) |
(reb-initialize-buffer)))) |
|
(reb-insert-regexp) |
|
|
(goto-char (+ 2 (point-min))) |
|
|
(cond ((reb-lisp-syntax-p) |
|
|
(reb-lisp-mode)) |
|
|
(t (reb-mode)))))) |
|
475 |
(error "Invalid syntax: %s" syntax))) |
(error "Invalid syntax: %s" syntax))) |
476 |
|
|
477 |
|
|