From f30e0cd847f3935ec8ac3176b99721c5db106351 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 18 Jun 2003 21:49:55 +0000 Subject: [PATCH] (looking-back): Handle the case of non-trivial regexps. Add an optional `limit' argument. (push, pop, with-temp-file, with-temp-message, delay-mode-hooks) (with-syntax-table): Add edebug info. --- lisp/ChangeLog | 16 ++++++++++++++++ lisp/subr.el | 23 ++++++++++++----------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 19f7d061ce9..7539addffe5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,19 @@ +2003-06-18 Stefan Monnier + + * subr.el (looking-back): Handle the case of non-trivial regexps. + Add an optional `limit' argument. + (push, pop, with-temp-file, with-temp-message, delay-mode-hooks) + (with-syntax-table): Add edebug info. + +2003-06-17 Stefan Monnier + + * simple.el (kill-new): Leave yank-handler property alone if no + explicit yank-handler is specified. + (vis-mode-saved-buffer-invisibility-spec): Rename from + saved-buffer-invisibility-spec. + (vis-mode): Correctly handle the case where the mode is turned on + or off several times in a row. + 2003-06-17 Luc Teirlinck * info.el (Info-fontify-node): Give only the last whitespace diff --git a/lisp/subr.el b/lisp/subr.el index 2ca79e54b76..4f8003f4d01 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -85,6 +85,7 @@ BODY should be a list of Lisp expressions." "Add NEWELT to the list stored in the symbol LISTNAME. This is equivalent to (setq LISTNAME (cons NEWELT LISTNAME)). LISTNAME must be a symbol." + (declare (debug (form sexp))) (list 'setq listname (list 'cons newelt listname))) @@ -93,6 +94,7 @@ LISTNAME must be a symbol." LISTNAME must be a symbol whose value is a list. If the value is nil, `pop' returns nil but does not actually change the list." + (declare (debug (sexp))) (list 'car (list 'prog1 listname (list 'setq listname (list 'cdr listname))))) @@ -1630,6 +1632,7 @@ See also `with-temp-buffer'." "Create a new buffer, evaluate BODY there, and write the buffer to FILE. The value returned is the value of the last form in BODY. See also `with-temp-buffer'." + (declare (debug t)) (let ((temp-file (make-symbol "temp-file")) (temp-buffer (make-symbol "temp-buffer"))) `(let ((,temp-file ,file) @@ -1652,6 +1655,7 @@ The value returned is the value of the last form in BODY. MESSAGE is written to the message log buffer if `message-log-max' is non-nil. If MESSAGE is nil, the echo area and message log buffer are unchanged. Use a MESSAGE of \"\" to temporarily clear the echo area." + (declare (debug t)) (let ((current-message (make-symbol "current-message")) (temp-message (make-symbol "with-temp-message"))) `(let ((,temp-message ,message) @@ -1741,6 +1745,7 @@ Major mode functions should use this." (defmacro delay-mode-hooks (&rest body) "Execute BODY, but delay any `run-mode-hooks'. Only affects hooks run in the current buffer." + (declare (debug t)) `(progn (make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks t)) @@ -1761,6 +1766,7 @@ Uses the `derived-mode-parent' property of the symbol to trace backwards." The syntax table of the current buffer is saved, BODY is evaluated, and the saved table is restored, even in case of an abnormal exit. Value is what BODY returns." + (declare (debug t)) (let ((old-table (make-symbol "table")) (old-buffer (make-symbol "buffer"))) `(let ((,old-table (syntax-table)) @@ -1820,18 +1826,13 @@ STRING should be given if the last search was by `string-match' on STRING." (buffer-substring-no-properties (match-beginning num) (match-end num))))) -(defun looking-back (regexp) - "Return t if text before point matches regular expression REGEXP. -This function modifies the match data that `match-beginning', -`match-end' and `match-data' access; save and restore the match -data if you want to preserve them." +(defun looking-back (regexp &optional limit) + "Return non-nil if text before point matches regular expression REGEXP. +Like `looking-at' except backwards and slower. +LIMIT if non-nil speeds up the search by specifying how far back the +match can start." (save-excursion - (let ((beg (point))) - (if (re-search-backward regexp nil t) - (if (= (match-end 0) beg) - t - nil) - nil)))) + (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t))) (defconst split-string-default-separators "[ \f\t\n\r\v]+" "The default value of separators for `split-string'. -- 2.39.2