(reb-mode-common): Remove reference to bogus variable `reb-kill-buffer';

don't make hooks buffer-local, use the LOCAL arg of `add-hook'.
(reb-blink-delay, reb-mode-hook, reb-re-syntax, reb-auto-match-limit):
Remove spurious * from defcustom docstrings.
(reb-next-match, reb-prev-match, reb-enter-subexp-mode): Fix typos in messages.
(reb-mode-buffer-p): New function.
(re-builder, reb-kill-buffer): Use `reb-mode-buffer-p'.  Use `when'.
(top, reb-show-subexp, reb-auto-update, reb-auto-update, reb-delete-overlays,
reb-cook-regexp, reb-update-regexp, reb-update-overlays): Use `unless', `when'.
(re-builder-unload-function): New function.
This commit is contained in:
Juanma Barranquero 2008-03-25 16:49:22 +00:00
parent 72d5003de7
commit 4361b6c29e
2 changed files with 105 additions and 79 deletions

View file

@ -1,3 +1,19 @@
2008-03-25 Juanma Barranquero <lekktu@gmail.com>
* emacs-lisp/re-builder.el (reb-mode-common): Remove reference to
bogus variable `reb-kill-buffer'; don't make hooks buffer-local,
use the LOCAL arg of `add-hook'.
(reb-blink-delay, reb-mode-hook, reb-re-syntax, reb-auto-match-limit):
Remove spurious * from defcustom docstrings.
(reb-next-match, reb-prev-match, reb-enter-subexp-mode):
Fix typos in messages.
(reb-mode-buffer-p): New function.
(re-builder, reb-kill-buffer): Use `reb-mode-buffer-p'. Use `when'.
(top, reb-show-subexp, reb-auto-update, reb-auto-update)
(reb-delete-overlays, reb-cook-regexp, reb-update-regexp)
(reb-update-overlays): Use `unless', `when'.
(re-builder-unload-function): New function.
2008-03-25 Dan Nicolaescu <dann@ics.uci.edu> 2008-03-25 Dan Nicolaescu <dann@ics.uci.edu>
* vc-hooks.el (vc-state): Add documentation for 'missing. * vc-hooks.el (vc-state): Add documentation for 'missing.
@ -105,10 +121,6 @@
* simple.el (transient-mark-mode): Turn on by default. * simple.el (transient-mark-mode): Turn on by default.
2008-03-23 Xavier Maillard <xma@gnu.org>
* saveplace.el: fix a typo in the commentary section.
2008-03-23 Dan Nicolaescu <dann@ics.uci.edu> 2008-03-23 Dan Nicolaescu <dann@ics.uci.edu>
* vc-bzr.el (vc-bzr-state): Return 'removed for removed files and * vc-bzr.el (vc-bzr-state): Return 'removed for removed files and
@ -122,10 +134,11 @@
subdirectories. subdirectories.
* vc.el (vc-status-prepare-status-buffer): Fix thinko. * vc.el (vc-status-prepare-status-buffer): Fix thinko.
(vc-status-menu-map): Add binding for (vc-status-menu-map): Add binding for vc-status-kill-dir-status-process.
vc-status-kill-dir-status-process. Add :enable for vc-status-refresh. Add :enable for vc-status-refresh.
(vc-status-menu-map-filter): Remove vc-ignore-menu-filter test. (vc-status-menu-map-filter): Remove vc-ignore-menu-filter test.
(vc-status-tool-bar-map): Add binding for vc-status-kill-dir-status-process. (vc-status-tool-bar-map): Add binding for
vc-status-kill-dir-status-process.
Don't test display-graphic-p and don't bind vc-ignore-menu-filter. Don't test display-graphic-p and don't bind vc-ignore-menu-filter.
(vc-update-vc-status-buffer, vc-status-kill-dir-status-process): (vc-update-vc-status-buffer, vc-status-kill-dir-status-process):
Reset vc-status-process-buffer. Reset vc-status-process-buffer.
@ -133,14 +146,14 @@
(vc-status): If the buffer is already in vc-status-mode only refresh. (vc-status): If the buffer is already in vc-status-mode only refresh.
(vc-status-mark-buffer-changed): Add an optional file parameter. (vc-status-mark-buffer-changed): Add an optional file parameter.
(vc-resynch-buffer): Use it. (vc-resynch-buffer): Use it.
(vc-delete-file): Expand the file name before using it. Be (vc-delete-file): Expand the file name before using it.
careful to not create a new buffer with the old file contents. Be careful to not create a new buffer with the old file contents.
Update the VC state after performing the operation. Update the VC state after performing the operation.
2008-03-23 Andreas Schwab <schwab@suse.de> 2008-03-23 Andreas Schwab <schwab@suse.de>
* menu-bar.el (menu-bar-showhide-fringe-ind-menu) [mixed]: Fix * menu-bar.el (menu-bar-showhide-fringe-ind-menu) [mixed]:
radio button condition. Fix radio button condition.
[box]: Likewise. [box]: Likewise.
[customize]: Add radio button. [customize]: Add radio button.

View file

@ -109,7 +109,7 @@
;;; Code: ;;; Code:
;; On XEmacs, load the overlay compatibility library ;; On XEmacs, load the overlay compatibility library
(if (not (fboundp 'make-overlay)) (unless (fboundp 'make-overlay)
(require 'overlay)) (require 'overlay))
;; User customizable variables ;; User customizable variables
@ -119,17 +119,17 @@
:prefix "reb-") :prefix "reb-")
(defcustom reb-blink-delay 0.5 (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 :group 're-builder
:type 'number) :type 'number)
(defcustom reb-mode-hook nil (defcustom reb-mode-hook nil
"*Hooks to run on entering RE Builder mode." "Hooks to run on entering RE Builder mode."
:group 're-builder :group 're-builder
:type 'hook) :type 'hook)
(defcustom reb-re-syntax 'read (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'." Can either be `read', `string', `sregex', `lisp-re', `rx'."
:group 're-builder :group 're-builder
:type '(choice (const :tag "Read syntax" read) :type '(choice (const :tag "Read syntax" read)
@ -139,7 +139,7 @@ Can either be `read', `string', `sregex', `lisp-re', `rx'."
(const :tag "`rx' syntax" rx))) (const :tag "`rx' syntax" rx)))
(defcustom reb-auto-match-limit 200 (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." Set it to nil if you don't want limits here."
:group 're-builder :group 're-builder
:type '(restricted-sexp :match-alternatives :type '(restricted-sexp :match-alternatives
@ -292,12 +292,9 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
mode-line-buffer-identification mode-line-buffer-identification
'(25 . ("%b" reb-mode-string reb-valid-string))) '(25 . ("%b" reb-mode-string reb-valid-string)))
(reb-update-modestring) (reb-update-modestring)
(make-local-variable 'after-change-functions) (add-hook 'after-change-functions 'reb-auto-update nil t)
(add-hook 'after-change-functions
'reb-auto-update)
;; At least make the overlays go away if the buffer is killed ;; 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 nil t)
(add-hook 'kill-buffer-hook 'reb-kill-buffer)
(reb-auto-update nil nil nil)) (reb-auto-update nil nil nil))
(defun reb-color-display-p () (defun reb-color-display-p ()
@ -326,6 +323,10 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
(reb-lisp-mode)) (reb-lisp-mode))
(t (reb-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. ;;; This is to help people find this in Apropos.
;;;###autoload ;;;###autoload
(defalias 'regexp-builder 're-builder) (defalias 'regexp-builder 're-builder)
@ -336,9 +337,9 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
(interactive) (interactive)
(if (and (string= (buffer-name) reb-buffer) (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") (message "Already in the RE Builder")
(if reb-target-buffer (when reb-target-buffer
(reb-delete-overlays)) (reb-delete-overlays))
(setq reb-target-buffer (current-buffer) (setq reb-target-buffer (current-buffer)
reb-target-window (selected-window) reb-target-window (selected-window)
@ -385,7 +386,7 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
(reb-assert-buffer-in-window) (reb-assert-buffer-in-window)
(with-selected-window reb-target-window (with-selected-window reb-target-window
(if (not (re-search-forward reb-regexp (point-max) t)) (if (not (re-search-forward reb-regexp (point-max) t))
(message "No more matches.") (message "No more matches")
(reb-show-subexp (reb-show-subexp
(or (and reb-subexp-mode reb-subexp-displayed) 0) (or (and reb-subexp-mode reb-subexp-displayed) 0)
t)))) t))))
@ -403,7 +404,7 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
(or (and reb-subexp-mode reb-subexp-displayed) 0) (or (and reb-subexp-mode reb-subexp-displayed) 0)
t) t)
(goto-char p) (goto-char p)
(message "No more matches."))))) (message "No more matches")))))
(defun reb-toggle-case () (defun reb-toggle-case ()
"Toggle case sensitivity of searches for RE Builder target buffer." "Toggle case sensitivity of searches for RE Builder target buffer."
@ -432,7 +433,7 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
(setq reb-subexp-mode t) (setq reb-subexp-mode t)
(reb-update-modestring) (reb-update-modestring)
(use-local-map reb-subexp-mode-map) (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) (defun reb-show-subexp (subexp &optional pause)
"Visually show limit of subexpression SUBEXP of recent search. "Visually show limit of subexpression SUBEXP of recent search.
@ -441,11 +442,11 @@ the match should already be marked by an overlay.
On other displays jump to the beginning and the end of it. 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." If the optional PAUSE is non-nil then pause at the end in any case."
(with-selected-window reb-target-window (with-selected-window reb-target-window
(if (not (reb-color-display-p)) (unless (reb-color-display-p)
(progn (goto-char (match-beginning subexp)) (goto-char (match-beginning subexp))
(sit-for reb-blink-delay))) (sit-for reb-blink-delay))
(goto-char (match-end subexp)) (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)))) (sit-for reb-blink-delay))))
(defun reb-quit-subexp-mode () (defun reb-quit-subexp-mode ()
@ -494,10 +495,9 @@ optional fourth argument FORCE is non-nil."
(new-valid (new-valid
(condition-case nil (condition-case nil
(progn (progn
(if (or (reb-update-regexp) force) (when (or (reb-update-regexp) force)
(progn
(reb-assert-buffer-in-window) (reb-assert-buffer-in-window)
(reb-do-update))) (reb-do-update))
"") "")
(error " *invalid*")))) (error " *invalid*"))))
(setq reb-valid-string new-valid) (setq reb-valid-string new-valid)
@ -506,14 +506,14 @@ optional fourth argument FORCE is non-nil."
;; Through the caching of the re a change invalidating the syntax ;; Through the caching of the re a change invalidating the syntax
;; for symbolic expressions will not delete the overlays so we ;; for symbolic expressions will not delete the overlays so we
;; catch it here ;; catch it here
(if (and (reb-lisp-syntax-p) (when (and (reb-lisp-syntax-p)
(not (string= prev-valid new-valid)) (not (string= prev-valid new-valid))
(string= prev-valid "")) (string= prev-valid ""))
(reb-delete-overlays)))) (reb-delete-overlays))))
(defun reb-delete-overlays () (defun reb-delete-overlays ()
"Delete all RE Builder overlays in the `reb-target-buffer' buffer." "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 (with-current-buffer reb-target-buffer
(mapc 'delete-overlay reb-overlays) (mapc 'delete-overlay reb-overlays)
(setq reb-overlays nil)))) (setq reb-overlays nil))))
@ -548,7 +548,7 @@ optional fourth argument FORCE is non-nil."
(defun reb-kill-buffer () (defun reb-kill-buffer ()
"When the RE Builder buffer is killed make sure no overlays stay around." "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))) (reb-delete-overlays)))
@ -594,7 +594,7 @@ optional fourth argument FORCE is non-nil."
(defun reb-cook-regexp (re) (defun reb-cook-regexp (re)
"Return RE after processing it according to `reb-re-syntax'." "Return RE after processing it according to `reb-re-syntax'."
(cond ((eq reb-re-syntax 'lisp-re) (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)))))) (lre-compile-string (eval (car (read-from-string re))))))
((eq reb-re-syntax 'sregex) ((eq reb-re-syntax 'sregex)
(apply 'sregex (eval (car (read-from-string re))))) (apply 'sregex (eval (car (read-from-string re)))))
@ -613,7 +613,7 @@ Return t if the (cooked) expression changed."
(not (string= oldre re)) (not (string= oldre re))
(setq reb-regexp re) (setq reb-regexp re)
;; Only update the source re for the lisp formats ;; 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))))))) (setq reb-regexp-src re-src)))))))
@ -643,14 +643,14 @@ If SUBEXP is non-nil mark only the corresponding sub-expressions."
(re-search-forward re (point-max) t) (re-search-forward re (point-max) t)
(or (not reb-auto-match-limit) (or (not reb-auto-match-limit)
(< matches reb-auto-match-limit))) (< matches reb-auto-match-limit)))
(if (= 0 (length (match-string 0))) (when (and (= 0 (length (match-string 0)))
(unless (eobp) (not (eobp)))
(forward-char 1))) (forward-char 1))
(let ((i 0) (let ((i 0)
suffix max-suffix) suffix max-suffix)
(setq matches (1+ matches)) (setq matches (1+ matches))
(while (<= i subexps) (while (<= i subexps)
(if (and (or (not subexp) (= subexp i)) (when (and (or (not subexp) (= subexp i))
(match-beginning i)) (match-beginning i))
(let ((overlay (make-overlay (match-beginning i) (let ((overlay (make-overlay (match-beginning i)
(match-end i))) (match-end i)))
@ -684,9 +684,22 @@ If SUBEXP is non-nil mark only the corresponding sub-expressions."
(if (and reb-auto-match-limit (if (and reb-auto-match-limit
(= reb-auto-match-limit count)) (= reb-auto-match-limit count))
" (limit reached)" ""))) " (limit reached)" "")))
(if firstmatch (when firstmatch
(progn (store-match-data firstmatch) (store-match-data firstmatch)
(reb-show-subexp (or subexp 0)))))) (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) (provide 're-builder)