[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/emacs-lisp/re-builder.el,v
From: |
Juanma Barranquero |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/emacs-lisp/re-builder.el,v |
Date: |
Tue, 25 Mar 2008 16:48:20 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Juanma Barranquero <lektu> 08/03/25 16:48:19
Index: re-builder.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/re-builder.el,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- re-builder.el 8 Jan 2008 20:45:34 -0000 1.37
+++ re-builder.el 25 Mar 2008 16:48:19 -0000 1.38
@@ -109,7 +109,7 @@
;;; Code:
;; On XEmacs, load the overlay compatibility library
-(if (not (fboundp 'make-overlay))
+(unless (fboundp 'make-overlay)
(require 'overlay))
;; User customizable variables
@@ -119,17 +119,17 @@
:prefix "reb-")
(defcustom reb-blink-delay 0.5
- "*Seconds to blink cursor for next/previous match in RE Builder."
+ "Seconds to blink cursor for next/previous match in RE Builder."
:group 're-builder
:type 'number)
(defcustom reb-mode-hook nil
- "*Hooks to run on entering RE Builder mode."
+ "Hooks to run on entering RE Builder mode."
:group 're-builder
:type 'hook)
(defcustom reb-re-syntax 'read
- "*Syntax for the REs in the RE Builder.
+ "Syntax for the REs in the RE Builder.
Can either be `read', `string', `sregex', `lisp-re', `rx'."
:group 're-builder
:type '(choice (const :tag "Read syntax" read)
@@ -139,7 +139,7 @@
(const :tag "`rx' syntax" rx)))
(defcustom reb-auto-match-limit 200
- "*Positive integer limiting the matches for RE Builder auto updates.
+ "Positive integer limiting the matches for RE Builder auto updates.
Set it to nil if you don't want limits here."
:group 're-builder
:type '(restricted-sexp :match-alternatives
@@ -292,12 +292,9 @@
mode-line-buffer-identification
'(25 . ("%b" reb-mode-string reb-valid-string)))
(reb-update-modestring)
- (make-local-variable 'after-change-functions)
- (add-hook 'after-change-functions
- 'reb-auto-update)
+ (add-hook 'after-change-functions 'reb-auto-update nil t)
;; At least make the overlays go away if the buffer is killed
- (make-local-variable 'reb-kill-buffer)
- (add-hook 'kill-buffer-hook 'reb-kill-buffer)
+ (add-hook 'kill-buffer-hook 'reb-kill-buffer nil t)
(reb-auto-update nil nil nil))
(defun reb-color-display-p ()
@@ -326,6 +323,10 @@
(reb-lisp-mode))
(t (reb-mode))))
+(defun reb-mode-buffer-p ()
+ "Return non-nil if the current buffer is a RE Builder buffer."
+ (memq major-mode '(reb-mode reb-lisp-mode)))
+
;;; This is to help people find this in Apropos.
;;;###autoload
(defalias 'regexp-builder 're-builder)
@@ -336,9 +337,9 @@
(interactive)
(if (and (string= (buffer-name) reb-buffer)
- (memq major-mode '(reb-mode reb-lisp-mode)))
+ (reb-mode-buffer-p))
(message "Already in the RE Builder")
- (if reb-target-buffer
+ (when reb-target-buffer
(reb-delete-overlays))
(setq reb-target-buffer (current-buffer)
reb-target-window (selected-window)
@@ -385,7 +386,7 @@
(reb-assert-buffer-in-window)
(with-selected-window reb-target-window
(if (not (re-search-forward reb-regexp (point-max) t))
- (message "No more matches.")
+ (message "No more matches")
(reb-show-subexp
(or (and reb-subexp-mode reb-subexp-displayed) 0)
t))))
@@ -403,7 +404,7 @@
(or (and reb-subexp-mode reb-subexp-displayed) 0)
t)
(goto-char p)
- (message "No more matches.")))))
+ (message "No more matches")))))
(defun reb-toggle-case ()
"Toggle case sensitivity of searches for RE Builder target buffer."
@@ -432,7 +433,7 @@
(setq reb-subexp-mode t)
(reb-update-modestring)
(use-local-map reb-subexp-mode-map)
- (message "`0'-`9' to display subexpressions `q' to quit subexp mode."))
+ (message "`0'-`9' to display subexpressions `q' to quit subexp mode"))
(defun reb-show-subexp (subexp &optional pause)
"Visually show limit of subexpression SUBEXP of recent search.
@@ -441,11 +442,11 @@
On other displays jump to the beginning and the end of it.
If the optional PAUSE is non-nil then pause at the end in any case."
(with-selected-window reb-target-window
- (if (not (reb-color-display-p))
- (progn (goto-char (match-beginning subexp))
- (sit-for reb-blink-delay)))
+ (unless (reb-color-display-p)
+ (goto-char (match-beginning subexp))
+ (sit-for reb-blink-delay))
(goto-char (match-end subexp))
- (if (or (not (reb-color-display-p)) pause)
+ (when (or (not (reb-color-display-p)) pause)
(sit-for reb-blink-delay))))
(defun reb-quit-subexp-mode ()
@@ -494,10 +495,9 @@
(new-valid
(condition-case nil
(progn
- (if (or (reb-update-regexp) force)
- (progn
+ (when (or (reb-update-regexp) force)
(reb-assert-buffer-in-window)
- (reb-do-update)))
+ (reb-do-update))
"")
(error " *invalid*"))))
(setq reb-valid-string new-valid)
@@ -506,14 +506,14 @@
;; Through the caching of the re a change invalidating the syntax
;; for symbolic expressions will not delete the overlays so we
;; catch it here
- (if (and (reb-lisp-syntax-p)
+ (when (and (reb-lisp-syntax-p)
(not (string= prev-valid new-valid))
(string= prev-valid ""))
(reb-delete-overlays))))
(defun reb-delete-overlays ()
"Delete all RE Builder overlays in the `reb-target-buffer' buffer."
- (if (buffer-live-p reb-target-buffer)
+ (when (buffer-live-p reb-target-buffer)
(with-current-buffer reb-target-buffer
(mapc 'delete-overlay reb-overlays)
(setq reb-overlays nil))))
@@ -548,7 +548,7 @@
(defun reb-kill-buffer ()
"When the RE Builder buffer is killed make sure no overlays stay around."
- (if (member major-mode '(reb-mode reb-lisp-mode))
+ (when (reb-mode-buffer-p)
(reb-delete-overlays)))
@@ -594,7 +594,7 @@
(defun reb-cook-regexp (re)
"Return RE after processing it according to `reb-re-syntax'."
(cond ((eq reb-re-syntax 'lisp-re)
- (if (fboundp 'lre-compile-string)
+ (when (fboundp 'lre-compile-string)
(lre-compile-string (eval (car (read-from-string re))))))
((eq reb-re-syntax 'sregex)
(apply 'sregex (eval (car (read-from-string re)))))
@@ -613,7 +613,7 @@
(not (string= oldre re))
(setq reb-regexp re)
;; Only update the source re for the lisp formats
- (if (reb-lisp-syntax-p)
+ (when (reb-lisp-syntax-p)
(setq reb-regexp-src re-src)))))))
@@ -643,14 +643,14 @@
(re-search-forward re (point-max) t)
(or (not reb-auto-match-limit)
(< matches reb-auto-match-limit)))
- (if (= 0 (length (match-string 0)))
- (unless (eobp)
- (forward-char 1)))
+ (when (and (= 0 (length (match-string 0)))
+ (not (eobp)))
+ (forward-char 1))
(let ((i 0)
suffix max-suffix)
(setq matches (1+ matches))
(while (<= i subexps)
- (if (and (or (not subexp) (= subexp i))
+ (when (and (or (not subexp) (= subexp i))
(match-beginning i))
(let ((overlay (make-overlay (match-beginning i)
(match-end i)))
@@ -684,9 +684,22 @@
(if (and reb-auto-match-limit
(= reb-auto-match-limit count))
" (limit reached)" "")))
- (if firstmatch
- (progn (store-match-data firstmatch)
- (reb-show-subexp (or subexp 0))))))
+ (when firstmatch
+ (store-match-data firstmatch)
+ (reb-show-subexp (or subexp 0)))))
+
+;; The End
+(defun re-builder-unload-function ()
+ "Unload the RE Builder library."
+ (when (buffer-live-p (get-buffer reb-buffer))
+ (with-current-buffer reb-buffer
+ (remove-hook 'after-change-functions 'reb-auto-update t)
+ (remove-hook 'kill-buffer-hook 'reb-kill-buffer t)
+ (when (reb-mode-buffer-p)
+ (reb-delete-overlays)
+ (funcall default-major-mode))))
+ ;; continue standard unloading
+ nil)
(provide 're-builder)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/re-builder.el,v,
Juanma Barranquero <=