Mercurial > emacs
changeset 79547:46725aa288e8
(verilog-string-replace-matches)
(verilog-string-remove-spaces, verilog-re-search-forward)
(verilog-re-search-backward, verilog-re-search-forward-quick)
(verilog-re-search-backward-quick, verilog-get-beg-of-line)
(verilog-get-end-of-line, verilog-within-string): Move definitions
before first use. No code changes.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sat, 08 Dec 2007 19:19:43 +0000 |
parents | 0413a70bb454 |
children | 41e32a5bc0df |
files | lisp/ChangeLog lisp/progmodes/verilog-mode.el |
diffstat | 2 files changed, 101 insertions(+), 92 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Sat Dec 08 18:43:17 2007 +0000 +++ b/lisp/ChangeLog Sat Dec 08 19:19:43 2007 +0000 @@ -1,3 +1,12 @@ +2007-12-08 Dan Nicolaescu <dann@ics.uci.edu> + + * progmodes/verilog-mode.el (verilog-string-replace-matches) + (verilog-string-remove-spaces, verilog-re-search-forward) + (verilog-re-search-backward, verilog-re-search-forward-quick) + (verilog-re-search-backward-quick, verilog-get-beg-of-line) + (verilog-get-end-of-line, verilog-within-string): Move definitions + before first use. No code changes. + 2007-12-08 Dan Nicolaescu <dann@ics.uci.edu> * progmodes/verilog-mode.el (verilog-mode-version)
--- a/lisp/progmodes/verilog-mode.el Sat Dec 08 18:43:17 2007 +0000 +++ b/lisp/progmodes/verilog-mode.el Sat Dec 08 19:19:43 2007 +0000 @@ -1057,6 +1057,98 @@ (define-abbrev-table 'verilog-mode-abbrev-table ()) +;; +;; Macros +;; + +(defsubst verilog-string-replace-matches (from-string to-string fixedcase literal string) + "Replace occurrences of FROM-STRING with TO-STRING. +FIXEDCASE and LITERAL as in `replace-match`. STRING is what to replace. +The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\") +will break, as the o's continuously replace. xa -> x works ok though." + ;; Hopefully soon to a emacs built-in + (let ((start 0)) + (while (string-match from-string string start) + (setq string (replace-match to-string fixedcase literal string) + start (min (length string) (match-end 0)))) + string)) + +(defsubst verilog-string-remove-spaces (string) + "Remove spaces surrounding STRING." + (save-match-data + (setq string (verilog-string-replace-matches "^\\s-+" "" nil nil string)) + (setq string (verilog-string-replace-matches "\\s-+$" "" nil nil string)) + string)) + +(defsubst verilog-re-search-forward (REGEXP BOUND NOERROR) + ; checkdoc-params: (REGEXP BOUND NOERROR) + "Like `re-search-forward', but skips over match in comments or strings." + (store-match-data '(nil nil)) + (while (and + (re-search-forward REGEXP BOUND NOERROR) + (and (verilog-skip-forward-comment-or-string) + (progn + (store-match-data '(nil nil)) + (if BOUND + (< (point) BOUND) + t) + )))) + (match-end 0)) + +(defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) + ; checkdoc-params: (REGEXP BOUND NOERROR) + "Like `re-search-backward', but skips over match in comments or strings." + (store-match-data '(nil nil)) + (while (and + (re-search-backward REGEXP BOUND NOERROR) + (and (verilog-skip-backward-comment-or-string) + (progn + (store-match-data '(nil nil)) + (if BOUND + (> (point) BOUND) + t) + )))) + (match-end 0)) + +(defsubst verilog-re-search-forward-quick (regexp bound noerror) + "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR, +but trashes match data and is faster for REGEXP that doesn't match often. +This may at some point use text properties to ignore comments, +so there may be a large up front penalty for the first search." + (let (pt) + (while (and (not pt) + (re-search-forward regexp bound noerror)) + (if (not (verilog-inside-comment-p)) + (setq pt (match-end 0)))) + pt)) + +(defsubst verilog-re-search-backward-quick (regexp bound noerror) + ; checkdoc-params: (REGEXP BOUND NOERROR) + "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR, +but trashes match data and is faster for REGEXP that doesn't match often. +This may at some point use text properties to ignore comments, +so there may be a large up front penalty for the first search." + (let (pt) + (while (and (not pt) + (re-search-backward regexp bound noerror)) + (if (not (verilog-inside-comment-p)) + (setq pt (match-end 0)))) + pt)) + +(defsubst verilog-get-beg-of-line (&optional arg) + (save-excursion + (beginning-of-line arg) + (point))) + +(defsubst verilog-get-end-of-line (&optional arg) + (save-excursion + (end-of-line arg) + (point))) + +(defsubst verilog-within-string () + (save-excursion + (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point))))) + ;; compilation program (defun verilog-set-compile-command () "Function to compute shell command to compile verilog. @@ -2147,98 +2239,6 @@ (defun verilog-declaration-beg () (verilog-re-search-backward verilog-declaration-re (bobp) t)) -;; -;; Macros -;; - -(defsubst verilog-string-replace-matches (from-string to-string fixedcase literal string) - "Replace occurrences of FROM-STRING with TO-STRING. -FIXEDCASE and LITERAL as in `replace-match`. STRING is what to replace. -The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\") -will break, as the o's continuously replace. xa -> x works ok though." - ;; Hopefully soon to a emacs built-in - (let ((start 0)) - (while (string-match from-string string start) - (setq string (replace-match to-string fixedcase literal string) - start (min (length string) (match-end 0)))) - string)) - -(defsubst verilog-string-remove-spaces (string) - "Remove spaces surrounding STRING." - (save-match-data - (setq string (verilog-string-replace-matches "^\\s-+" "" nil nil string)) - (setq string (verilog-string-replace-matches "\\s-+$" "" nil nil string)) - string)) - -(defsubst verilog-re-search-forward (REGEXP BOUND NOERROR) - ; checkdoc-params: (REGEXP BOUND NOERROR) - "Like `re-search-forward', but skips over match in comments or strings." - (store-match-data '(nil nil)) - (while (and - (re-search-forward REGEXP BOUND NOERROR) - (and (verilog-skip-forward-comment-or-string) - (progn - (store-match-data '(nil nil)) - (if BOUND - (< (point) BOUND) - t) - )))) - (match-end 0)) - -(defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) - ; checkdoc-params: (REGEXP BOUND NOERROR) - "Like `re-search-backward', but skips over match in comments or strings." - (store-match-data '(nil nil)) - (while (and - (re-search-backward REGEXP BOUND NOERROR) - (and (verilog-skip-backward-comment-or-string) - (progn - (store-match-data '(nil nil)) - (if BOUND - (> (point) BOUND) - t) - )))) - (match-end 0)) - -(defsubst verilog-re-search-forward-quick (regexp bound noerror) - "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR, -but trashes match data and is faster for REGEXP that doesn't match often. -This may at some point use text properties to ignore comments, -so there may be a large up front penalty for the first search." - (let (pt) - (while (and (not pt) - (re-search-forward regexp bound noerror)) - (if (not (verilog-inside-comment-p)) - (setq pt (match-end 0)))) - pt)) - -(defsubst verilog-re-search-backward-quick (regexp bound noerror) - ; checkdoc-params: (REGEXP BOUND NOERROR) - "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR, -but trashes match data and is faster for REGEXP that doesn't match often. -This may at some point use text properties to ignore comments, -so there may be a large up front penalty for the first search." - (let (pt) - (while (and (not pt) - (re-search-backward regexp bound noerror)) - (if (not (verilog-inside-comment-p)) - (setq pt (match-end 0)))) - pt)) - -(defsubst verilog-get-beg-of-line (&optional arg) - (save-excursion - (beginning-of-line arg) - (point))) - -(defsubst verilog-get-end-of-line (&optional arg) - (save-excursion - (end-of-line arg) - (point))) - -(defsubst verilog-within-string () - (save-excursion - (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point))))) - (require 'font-lock) (defvar verilog-need-fld 1) (defvar font-lock-defaults-alist nil) ;In case we are XEmacs