(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:
parent
72d5003de7
commit
4361b6c29e
2 changed files with 105 additions and 79 deletions
|
@ -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>
|
||||
|
||||
* vc-hooks.el (vc-state): Add documentation for 'missing.
|
||||
|
@ -105,10 +121,6 @@
|
|||
|
||||
* 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>
|
||||
|
||||
* vc-bzr.el (vc-bzr-state): Return 'removed for removed files and
|
||||
|
@ -122,10 +134,11 @@
|
|||
subdirectories.
|
||||
|
||||
* vc.el (vc-status-prepare-status-buffer): Fix thinko.
|
||||
(vc-status-menu-map): Add binding for
|
||||
vc-status-kill-dir-status-process. Add :enable for vc-status-refresh.
|
||||
(vc-status-menu-map): Add binding for vc-status-kill-dir-status-process.
|
||||
Add :enable for vc-status-refresh.
|
||||
(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.
|
||||
(vc-update-vc-status-buffer, vc-status-kill-dir-status-process):
|
||||
Reset vc-status-process-buffer.
|
||||
|
@ -133,14 +146,14 @@
|
|||
(vc-status): If the buffer is already in vc-status-mode only refresh.
|
||||
(vc-status-mark-buffer-changed): Add an optional file parameter.
|
||||
(vc-resynch-buffer): Use it.
|
||||
(vc-delete-file): Expand the file name before using it. Be
|
||||
careful to not create a new buffer with the old file contents.
|
||||
(vc-delete-file): Expand the file name before using it.
|
||||
Be careful to not create a new buffer with the old file contents.
|
||||
Update the VC state after performing the operation.
|
||||
|
||||
2008-03-23 Andreas Schwab <schwab@suse.de>
|
||||
|
||||
* menu-bar.el (menu-bar-showhide-fringe-ind-menu) [mixed]: Fix
|
||||
radio button condition.
|
||||
* menu-bar.el (menu-bar-showhide-fringe-ind-menu) [mixed]:
|
||||
Fix radio button condition.
|
||||
[box]: Likewise.
|
||||
[customize]: Add radio button.
|
||||
|
||||
|
|
|
@ -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 @@ Can either be `read', `string', `sregex', `lisp-re', `rx'."
|
|||
(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 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
|
|||
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 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
|
|||
(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 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
|
|||
(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 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
|
|||
(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 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
|
|||
(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 @@ Except for Lisp syntax this is the same as `reb-regexp'.")
|
|||
(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 @@ the match should already be marked by an overlay.
|
|||
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 @@ optional fourth argument FORCE is non-nil."
|
|||
(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 @@ optional fourth argument FORCE is non-nil."
|
|||
;; 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 @@ optional fourth argument FORCE is non-nil."
|
|||
(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 @@ optional fourth argument FORCE is non-nil."
|
|||
(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 @@ Return t if the (cooked) expression changed."
|
|||
(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 @@ If SUBEXP is non-nil mark only the corresponding sub-expressions."
|
|||
(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 SUBEXP is non-nil mark only the corresponding sub-expressions."
|
|||
(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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue