/[emacs]/emacs/lisp/emacs-lisp/re-builder.el
ViewVC logotype

Diff of /emacs/lisp/emacs-lisp/re-builder.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.26 by lektu, Thu Jul 21 09:10:49 2005 UTC revision 1.27 by lektu, Sun Jul 24 02:29:14 2005 UTC
# Line 299  Except for Lisp syntax this is the same Line 299  Except for Lisp syntax this is the same
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
# Line 330  Except for Lisp syntax this is the same Line 316  Except for Lisp syntax this is the same
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)
# Line 349  Except for Lisp syntax this is the same Line 344  Except for Lisp syntax this is the same
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."
# Line 393  Except for Lisp syntax this is the same Line 382  Except for Lisp syntax this is the same
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
# Line 406  Except for Lisp syntax this is the same Line 394  Except for Lisp syntax this is the same
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."
# Line 449  On color displays this just puts point t Line 439  On color displays this just puts point t
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)))
# Line 479  Optional argument SYNTAX must be specifi Line 469  Optional argument SYNTAX must be specifi
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    

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26