aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2007-12-08 19:19:43 +0000
committerDan Nicolaescu2007-12-08 19:19:43 +0000
commitb68a96b966c7893316c6135764f6a04eb529d21e (patch)
treee4f66a1ee970d39ca1be5180f7117cc89807d310
parent6edb57162c2967832c85e0f931569715904d7117 (diff)
downloademacs-b68a96b966c7893316c6135764f6a04eb529d21e.tar.gz
emacs-b68a96b966c7893316c6135764f6a04eb529d21e.zip
(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.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/progmodes/verilog-mode.el184
2 files changed, 101 insertions, 92 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4fa2d6de0c6..2295cab3b86 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,14 @@
12007-12-08 Dan Nicolaescu <dann@ics.uci.edu> 12007-12-08 Dan Nicolaescu <dann@ics.uci.edu>
2 2
3 * progmodes/verilog-mode.el (verilog-string-replace-matches)
4 (verilog-string-remove-spaces, verilog-re-search-forward)
5 (verilog-re-search-backward, verilog-re-search-forward-quick)
6 (verilog-re-search-backward-quick, verilog-get-beg-of-line)
7 (verilog-get-end-of-line, verilog-within-string): Move definitions
8 before first use. No code changes.
9
102007-12-08 Dan Nicolaescu <dann@ics.uci.edu>
11
3 * progmodes/verilog-mode.el (verilog-mode-version) 12 * progmodes/verilog-mode.el (verilog-mode-version)
4 (verilog-mode-release-date): Don't use expanding keywords. 13 (verilog-mode-release-date): Don't use expanding keywords.
5 (provide): Move to the end of file. 14 (provide): Move to the end of file.
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index baec1ec3f9f..0fbe238d912 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -1057,6 +1057,98 @@ If set will become buffer local.")
1057 1057
1058(define-abbrev-table 'verilog-mode-abbrev-table ()) 1058(define-abbrev-table 'verilog-mode-abbrev-table ())
1059 1059
1060;;
1061;; Macros
1062;;
1063
1064(defsubst verilog-string-replace-matches (from-string to-string fixedcase literal string)
1065 "Replace occurrences of FROM-STRING with TO-STRING.
1066FIXEDCASE and LITERAL as in `replace-match`. STRING is what to replace.
1067The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\")
1068will break, as the o's continuously replace. xa -> x works ok though."
1069 ;; Hopefully soon to a emacs built-in
1070 (let ((start 0))
1071 (while (string-match from-string string start)
1072 (setq string (replace-match to-string fixedcase literal string)
1073 start (min (length string) (match-end 0))))
1074 string))
1075
1076(defsubst verilog-string-remove-spaces (string)
1077 "Remove spaces surrounding STRING."
1078 (save-match-data
1079 (setq string (verilog-string-replace-matches "^\\s-+" "" nil nil string))
1080 (setq string (verilog-string-replace-matches "\\s-+$" "" nil nil string))
1081 string))
1082
1083(defsubst verilog-re-search-forward (REGEXP BOUND NOERROR)
1084 ; checkdoc-params: (REGEXP BOUND NOERROR)
1085 "Like `re-search-forward', but skips over match in comments or strings."
1086 (store-match-data '(nil nil))
1087 (while (and
1088 (re-search-forward REGEXP BOUND NOERROR)
1089 (and (verilog-skip-forward-comment-or-string)
1090 (progn
1091 (store-match-data '(nil nil))
1092 (if BOUND
1093 (< (point) BOUND)
1094 t)
1095 ))))
1096 (match-end 0))
1097
1098(defsubst verilog-re-search-backward (REGEXP BOUND NOERROR)
1099 ; checkdoc-params: (REGEXP BOUND NOERROR)
1100 "Like `re-search-backward', but skips over match in comments or strings."
1101 (store-match-data '(nil nil))
1102 (while (and
1103 (re-search-backward REGEXP BOUND NOERROR)
1104 (and (verilog-skip-backward-comment-or-string)
1105 (progn
1106 (store-match-data '(nil nil))
1107 (if BOUND
1108 (> (point) BOUND)
1109 t)
1110 ))))
1111 (match-end 0))
1112
1113(defsubst verilog-re-search-forward-quick (regexp bound noerror)
1114 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR,
1115but trashes match data and is faster for REGEXP that doesn't match often.
1116This may at some point use text properties to ignore comments,
1117so there may be a large up front penalty for the first search."
1118 (let (pt)
1119 (while (and (not pt)
1120 (re-search-forward regexp bound noerror))
1121 (if (not (verilog-inside-comment-p))
1122 (setq pt (match-end 0))))
1123 pt))
1124
1125(defsubst verilog-re-search-backward-quick (regexp bound noerror)
1126 ; checkdoc-params: (REGEXP BOUND NOERROR)
1127 "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR,
1128but trashes match data and is faster for REGEXP that doesn't match often.
1129This may at some point use text properties to ignore comments,
1130so there may be a large up front penalty for the first search."
1131 (let (pt)
1132 (while (and (not pt)
1133 (re-search-backward regexp bound noerror))
1134 (if (not (verilog-inside-comment-p))
1135 (setq pt (match-end 0))))
1136 pt))
1137
1138(defsubst verilog-get-beg-of-line (&optional arg)
1139 (save-excursion
1140 (beginning-of-line arg)
1141 (point)))
1142
1143(defsubst verilog-get-end-of-line (&optional arg)
1144 (save-excursion
1145 (end-of-line arg)
1146 (point)))
1147
1148(defsubst verilog-within-string ()
1149 (save-excursion
1150 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point)))))
1151
1060;; compilation program 1152;; compilation program
1061(defun verilog-set-compile-command () 1153(defun verilog-set-compile-command ()
1062 "Function to compute shell command to compile verilog. 1154 "Function to compute shell command to compile verilog.
@@ -2147,98 +2239,6 @@ Use filename, if current buffer being edited shorten to just buffer name."
2147(defun verilog-declaration-beg () 2239(defun verilog-declaration-beg ()
2148 (verilog-re-search-backward verilog-declaration-re (bobp) t)) 2240 (verilog-re-search-backward verilog-declaration-re (bobp) t))
2149 2241
2150;;
2151;; Macros
2152;;
2153
2154(defsubst verilog-string-replace-matches (from-string to-string fixedcase literal string)
2155 "Replace occurrences of FROM-STRING with TO-STRING.
2156FIXEDCASE and LITERAL as in `replace-match`. STRING is what to replace.
2157The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\")
2158will break, as the o's continuously replace. xa -> x works ok though."
2159 ;; Hopefully soon to a emacs built-in
2160 (let ((start 0))
2161 (while (string-match from-string string start)
2162 (setq string (replace-match to-string fixedcase literal string)
2163 start (min (length string) (match-end 0))))
2164 string))
2165
2166(defsubst verilog-string-remove-spaces (string)
2167 "Remove spaces surrounding STRING."
2168 (save-match-data
2169 (setq string (verilog-string-replace-matches "^\\s-+" "" nil nil string))
2170 (setq string (verilog-string-replace-matches "\\s-+$" "" nil nil string))
2171 string))
2172
2173(defsubst verilog-re-search-forward (REGEXP BOUND NOERROR)
2174 ; checkdoc-params: (REGEXP BOUND NOERROR)
2175 "Like `re-search-forward', but skips over match in comments or strings."
2176 (store-match-data '(nil nil))
2177 (while (and
2178 (re-search-forward REGEXP BOUND NOERROR)
2179 (and (verilog-skip-forward-comment-or-string)
2180 (progn
2181 (store-match-data '(nil nil))
2182 (if BOUND
2183 (< (point) BOUND)
2184 t)
2185 ))))
2186 (match-end 0))
2187
2188(defsubst verilog-re-search-backward (REGEXP BOUND NOERROR)
2189 ; checkdoc-params: (REGEXP BOUND NOERROR)
2190 "Like `re-search-backward', but skips over match in comments or strings."
2191 (store-match-data '(nil nil))
2192 (while (and
2193 (re-search-backward REGEXP BOUND NOERROR)
2194 (and (verilog-skip-backward-comment-or-string)
2195 (progn
2196 (store-match-data '(nil nil))
2197 (if BOUND
2198 (> (point) BOUND)
2199 t)
2200 ))))
2201 (match-end 0))
2202
2203(defsubst verilog-re-search-forward-quick (regexp bound noerror)
2204 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR,
2205but trashes match data and is faster for REGEXP that doesn't match often.
2206This may at some point use text properties to ignore comments,
2207so there may be a large up front penalty for the first search."
2208 (let (pt)
2209 (while (and (not pt)
2210 (re-search-forward regexp bound noerror))
2211 (if (not (verilog-inside-comment-p))
2212 (setq pt (match-end 0))))
2213 pt))
2214
2215(defsubst verilog-re-search-backward-quick (regexp bound noerror)
2216 ; checkdoc-params: (REGEXP BOUND NOERROR)
2217 "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR,
2218but trashes match data and is faster for REGEXP that doesn't match often.
2219This may at some point use text properties to ignore comments,
2220so there may be a large up front penalty for the first search."
2221 (let (pt)
2222 (while (and (not pt)
2223 (re-search-backward regexp bound noerror))
2224 (if (not (verilog-inside-comment-p))
2225 (setq pt (match-end 0))))
2226 pt))
2227
2228(defsubst verilog-get-beg-of-line (&optional arg)
2229 (save-excursion
2230 (beginning-of-line arg)
2231 (point)))
2232
2233(defsubst verilog-get-end-of-line (&optional arg)
2234 (save-excursion
2235 (end-of-line arg)
2236 (point)))
2237
2238(defsubst verilog-within-string ()
2239 (save-excursion
2240 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point)))))
2241
2242(require 'font-lock) 2242(require 'font-lock)
2243(defvar verilog-need-fld 1) 2243(defvar verilog-need-fld 1)
2244(defvar font-lock-defaults-alist nil) ;In case we are XEmacs 2244(defvar font-lock-defaults-alist nil) ;In case we are XEmacs