135 |
(const :tag "String syntax" string) |
(const :tag "String syntax" string) |
136 |
(const :tag "`sregex' syntax" sregex) |
(const :tag "`sregex' syntax" sregex) |
137 |
(const :tag "`lisp-re' syntax" lisp-re) |
(const :tag "`lisp-re' syntax" lisp-re) |
138 |
|
(const :tag "`rx' syntax" rx) |
139 |
(value: string))) |
(value: string))) |
140 |
|
|
141 |
(defcustom reb-auto-match-limit 200 |
(defcustom reb-auto-match-limit 200 |
262 |
(cond ((eq reb-re-syntax 'lisp-re) ; Pull in packages |
(cond ((eq reb-re-syntax 'lisp-re) ; Pull in packages |
263 |
(require 'lisp-re)) ; as needed |
(require 'lisp-re)) ; as needed |
264 |
((eq reb-re-syntax 'sregex) ; sregex is not autoloaded |
((eq reb-re-syntax 'sregex) ; sregex is not autoloaded |
265 |
(require 'sregex))) ; right now.. |
(require 'sregex)) ; right now.. |
266 |
|
((eq reb-re-syntax 'rx) ; rx-to-string is autoloaded |
267 |
|
(require 'rx))) ; require rx anyway |
268 |
(reb-mode-common)) |
(reb-mode-common)) |
269 |
|
|
270 |
;; Use the same "\C-c" keymap as `reb-mode' and use font-locking from |
;; Use the same "\C-c" keymap as `reb-mode' and use font-locking from |
323 |
|
|
324 |
(defsubst reb-lisp-syntax-p () |
(defsubst reb-lisp-syntax-p () |
325 |
"Return non-nil if RE Builder uses a Lisp syntax." |
"Return non-nil if RE Builder uses a Lisp syntax." |
326 |
(memq reb-re-syntax '(lisp-re sregex))) |
(memq reb-re-syntax '(lisp-re sregex rx))) |
327 |
|
|
328 |
(defmacro reb-target-binding (symbol) |
(defmacro reb-target-binding (symbol) |
329 |
"Return binding for SYMBOL in the RE Builder target buffer." |
"Return binding for SYMBOL in the RE Builder target buffer." |
469 |
(list (intern |
(list (intern |
470 |
(completing-read "Select syntax: " |
(completing-read "Select syntax: " |
471 |
(mapcar (lambda (el) (cons (symbol-name el) 1)) |
(mapcar (lambda (el) (cons (symbol-name el) 1)) |
472 |
'(read string lisp-re sregex)) |
'(read string lisp-re sregex rx)) |
473 |
nil t (symbol-name reb-re-syntax))))) |
nil t (symbol-name reb-re-syntax))))) |
474 |
|
|
475 |
(if (memq syntax '(read string lisp-re sregex)) |
(if (memq syntax '(read string lisp-re sregex rx)) |
476 |
(let ((buffer (get-buffer reb-buffer))) |
(let ((buffer (get-buffer reb-buffer))) |
477 |
(setq reb-re-syntax syntax) |
(setq reb-re-syntax syntax) |
478 |
(if buffer |
(if buffer |
607 |
(lre-compile-string (eval (car (read-from-string re))))) |
(lre-compile-string (eval (car (read-from-string re))))) |
608 |
((eq reb-re-syntax 'sregex) |
((eq reb-re-syntax 'sregex) |
609 |
(apply 'sregex (eval (car (read-from-string re))))) |
(apply 'sregex (eval (car (read-from-string re))))) |
610 |
|
((eq reb-re-syntax 'rx) |
611 |
|
(rx-to-string (eval (car (read-from-string re))))) |
612 |
(t re))) |
(t re))) |
613 |
|
|
614 |
(defun reb-update-regexp () |
(defun reb-update-regexp () |
675 |
(overlay-put overlay 'priority i))) |
(overlay-put overlay 'priority i))) |
676 |
(setq i (1+ i)))))) |
(setq i (1+ i)))))) |
677 |
(let ((count (if subexp submatches matches))) |
(let ((count (if subexp submatches matches))) |
678 |
(message"%s %smatch%s%s" |
(message "%s %smatch%s%s" |
679 |
(if (= 0 count) "No" (int-to-string count)) |
(if (= 0 count) "No" (int-to-string count)) |
680 |
(if subexp "subexpression " "") |
(if subexp "subexpression " "") |
681 |
(if (= 1 count) "" "es") |
(if (= 1 count) "" "es") |