aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-03-19 14:29:35 +0000
committerStefan Monnier2008-03-19 14:29:35 +0000
commitd63b01e1498ccc02149f4102f0888f454d75f43e (patch)
treed72e17d1f79b597b62be6c7439d06a11cc15017f
parentd6baaf335142c0b724e6c5872ccdb9f72df869fe (diff)
downloademacs-d63b01e1498ccc02149f4102f0888f454d75f43e.tar.gz
emacs-d63b01e1498ccc02149f4102f0888f454d75f43e.zip
(verilog-syntax-ppss): New function.
(electric-verilog-terminate-line, verilog-in-struct-region-p) (verilog-backward-ws&directives, verilog-forward-ws&directives) (verilog-in-comment-p, verilog-in-star-comment-p) (verilog-in-slash-comment-p, verilog-skip-backward-comments) (verilog-parenthesis-depth, verilog-skip-backward-comment-or-string) (verilog-skip-forward-comment-or-string, verilog-in-paren) (verilog-skip-forward-comment-p): Use it,
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/progmodes/verilog-mode.el77
2 files changed, 39 insertions, 49 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1efebbfe48d..23b173de55d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12008-03-19 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/verilog-mode.el (verilog-syntax-ppss): New function.
4 (electric-verilog-terminate-line, verilog-in-struct-region-p)
5 (verilog-backward-ws&directives, verilog-forward-ws&directives)
6 (verilog-in-comment-p, verilog-in-star-comment-p)
7 (verilog-in-slash-comment-p, verilog-skip-backward-comments)
8 (verilog-parenthesis-depth, verilog-skip-backward-comment-or-string)
9 (verilog-skip-forward-comment-or-string, verilog-in-paren)
10 (verilog-skip-forward-comment-p): Use it,
11
12008-03-19 Juanma Barranquero <lekktu@gmail.com> 122008-03-19 Juanma Barranquero <lekktu@gmail.com>
2 13
3 * textmodes/org.el (org-link-store, org-link-follow, org-latex) 14 * textmodes/org.el (org-link-store, org-link-follow, org-latex)
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index b24ccdc5bad..9394c80c6b9 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -274,6 +274,10 @@ STRING should be given if the last search was by `string-match' on STRING."
274 This function may be removed when Emacs 21 is no longer supported." 274 This function may be removed when Emacs 21 is no longer supported."
275 (or (equal value t) (equal value nil))) 275 (or (equal value t) (equal value nil)))
276 276
277(defalias 'verilog-syntax-ppss
278 (if (fboundp 'syntax-ppss) 'syntax-ppss
279 (lambda (&optional pos) (parse-partial-sexp (point-min) (or pos (point))))))
280
277(defgroup verilog-mode nil 281(defgroup verilog-mode nil
278 "Facilitates easy editing of Verilog source text." 282 "Facilitates easy editing of Verilog source text."
279 :version "22.2" 283 :version "22.2"
@@ -1742,7 +1746,7 @@ find the errors."
1742 (modify-syntax-entry ?/ ". 1456" table) 1746 (modify-syntax-entry ?/ ". 1456" table)
1743 (modify-syntax-entry ?* ". 23" table) 1747 (modify-syntax-entry ?* ". 23" table)
1744 (modify-syntax-entry ?\n "> b" table)) 1748 (modify-syntax-entry ?\n "> b" table))
1745 ;; Emacs 19 does things differently, but we can work with it 1749 ;; Emacs does things differently, but we can work with it
1746 (modify-syntax-entry ?/ ". 124b" table) 1750 (modify-syntax-entry ?/ ". 124b" table)
1747 (modify-syntax-entry ?* ". 23" table) 1751 (modify-syntax-entry ?* ". 23" table)
1748 (modify-syntax-entry ?\n "> b" table)) 1752 (modify-syntax-entry ?\n "> b" table))
@@ -2381,7 +2385,7 @@ Key bindings specific to `verilog-mode-map' are:
2381 (easy-menu-add verilog-menu) 2385 (easy-menu-add verilog-menu)
2382 (setq mode-popup-menu (cons "Verilog Mode" verilog-stmt-menu))) 2386 (setq mode-popup-menu (cons "Verilog Mode" verilog-stmt-menu)))
2383 2387
2384 ;; Stuff for GNU emacs 2388 ;; Stuff for GNU Emacs
2385 (set (make-local-variable 'font-lock-defaults) 2389 (set (make-local-variable 'font-lock-defaults)
2386 '((verilog-font-lock-keywords verilog-font-lock-keywords-1 2390 '((verilog-font-lock-keywords verilog-font-lock-keywords-1
2387 verilog-font-lock-keywords-2 2391 verilog-font-lock-keywords-2
@@ -2392,10 +2396,10 @@ Key bindings specific to `verilog-mode-map' are:
2392 ;; all buffer local: 2396 ;; all buffer local:
2393 (when (featurep 'xemacs) 2397 (when (featurep 'xemacs)
2394 (make-local-hook 'font-lock-mode-hook) 2398 (make-local-hook 'font-lock-mode-hook)
2395 (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20 2399 (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in Emacs
2396 (make-local-hook 'after-change-functions)) 2400 (make-local-hook 'after-change-functions))
2397 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t) 2401 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t)
2398 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20 2402 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in Emacs
2399 (add-hook 'after-change-functions 'verilog-colorize-include-files t t) 2403 (add-hook 'after-change-functions 'verilog-colorize-include-files t t)
2400 2404
2401 ;; Tell imenu how to handle Verilog. 2405 ;; Tell imenu how to handle Verilog.
@@ -2423,9 +2427,7 @@ Key bindings specific to `verilog-mode-map' are:
2423With optional ARG, remove existing end of line comments." 2427With optional ARG, remove existing end of line comments."
2424 (interactive) 2428 (interactive)
2425 ;; before that see if we are in a comment 2429 ;; before that see if we are in a comment
2426 (let ((state 2430 (let ((state (save-excursion (verilog-syntax-ppss))))
2427 (save-excursion
2428 (parse-partial-sexp (point-min) (point)))))
2429 (cond 2431 (cond
2430 ((nth 7 state) ; Inside // comment 2432 ((nth 7 state) ; Inside // comment
2431 (if (eolp) 2433 (if (eolp)
@@ -2936,7 +2938,7 @@ More specifically, point @ in the line foo : @ begin"
2936More specifically, in a list after a struct|union keyword." 2938More specifically, in a list after a struct|union keyword."
2937 (interactive) 2939 (interactive)
2938 (save-excursion 2940 (save-excursion
2939 (let* ((state (parse-partial-sexp (point-min) (point))) 2941 (let* ((state (verilog-syntax-ppss))
2940 (depth (nth 0 state))) 2942 (depth (nth 0 state)))
2941 (if depth 2943 (if depth
2942 (progn (backward-up-list depth) 2944 (progn (backward-up-list depth)
@@ -3692,7 +3694,7 @@ This lets programs calling batch mode to easily extract error messages."
3692 (progn ,@body) 3694 (progn ,@body)
3693 (error 3695 (error
3694 (error "%%Error: %s%s" (error-message-string err) 3696 (error "%%Error: %s%s" (error-message-string err)
3695 (if (featurep 'xemacs) "\n" ""))))) ;; xemacs forgets to add a newline 3697 (if (featurep 'xemacs) "\n" ""))))) ;; XEmacs forgets to add a newline
3696 3698
3697(defun verilog-batch-execute-func (funref) 3699(defun verilog-batch-execute-func (funref)
3698 "Internal processing of a batch command, running FUNREF on all command arguments." 3700 "Internal processing of a batch command, running FUNREF on all command arguments."
@@ -4273,9 +4275,7 @@ Optional BOUND limits search."
4273 (p nil) ) 4275 (p nil) )
4274 (if (< bound (point)) 4276 (if (< bound (point))
4275 (progn 4277 (progn
4276 (let ((state 4278 (let ((state (save-excursion (verilog-syntax-ppss))))
4277 (save-excursion
4278 (parse-partial-sexp (point-min) (point)))))
4279 (cond 4279 (cond
4280 ((nth 7 state) ;; in // comment 4280 ((nth 7 state) ;; in // comment
4281 (verilog-re-search-backward "//" nil 'move) 4281 (verilog-re-search-backward "//" nil 'move)
@@ -4307,9 +4307,7 @@ Optional BOUND limits search."
4307 jump) 4307 jump)
4308 (if (> bound (point)) 4308 (if (> bound (point))
4309 (progn 4309 (progn
4310 (let ((state 4310 (let ((state (save-excursion (verilog-syntax-ppss))))
4311 (save-excursion
4312 (parse-partial-sexp (point-min) (point)))))
4313 (cond 4311 (cond
4314 ((nth 7 state) ;; in // comment 4312 ((nth 7 state) ;; in // comment
4315 (verilog-re-search-forward "//" nil 'move)) 4313 (verilog-re-search-forward "//" nil 'move))
@@ -4329,16 +4327,12 @@ Optional BOUND limits search."
4329 4327
4330(defun verilog-in-comment-p () 4328(defun verilog-in-comment-p ()
4331 "Return true if in a star or // comment." 4329 "Return true if in a star or // comment."
4332 (let ((state 4330 (let ((state (save-excursion (verilog-syntax-ppss))))
4333 (save-excursion
4334 (parse-partial-sexp (point-min) (point)))))
4335 (or (nth 4 state) (nth 7 state)))) 4331 (or (nth 4 state) (nth 7 state))))
4336 4332
4337(defun verilog-in-star-comment-p () 4333(defun verilog-in-star-comment-p ()
4338 "Return true if in a star comment." 4334 "Return true if in a star comment."
4339 (let ((state 4335 (let ((state (save-excursion (verilog-syntax-ppss))))
4340 (save-excursion
4341 (parse-partial-sexp (point-min) (point)))))
4342 (and 4336 (and
4343 (nth 4 state) ; t if in a comment of style a // or b /**/ 4337 (nth 4 state) ; t if in a comment of style a // or b /**/
4344 (not 4338 (not
@@ -4347,16 +4341,12 @@ Optional BOUND limits search."
4347 4341
4348(defun verilog-in-slash-comment-p () 4342(defun verilog-in-slash-comment-p ()
4349 "Return true if in a slash comment." 4343 "Return true if in a slash comment."
4350 (let ((state 4344 (let ((state (save-excursion (verilog-syntax-ppss))))
4351 (save-excursion
4352 (parse-partial-sexp (point-min) (point)))))
4353 (nth 7 state))) 4345 (nth 7 state)))
4354 4346
4355(defun verilog-in-comment-or-string-p () 4347(defun verilog-in-comment-or-string-p ()
4356 "Return true if in a string or comment." 4348 "Return true if in a string or comment."
4357 (let ((state 4349 (let ((state (save-excursion (verilog-syntax-ppss))))
4358 (save-excursion
4359 (parse-partial-sexp (point-min) (point)))))
4360 (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment) 4350 (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment)
4361 4351
4362(defun verilog-in-escaped-name-p () 4352(defun verilog-in-escaped-name-p ()
@@ -4370,9 +4360,7 @@ Optional BOUND limits search."
4370 4360
4371(defun verilog-in-paren () 4361(defun verilog-in-paren ()
4372 "Return true if in a parenthetical expression." 4362 "Return true if in a parenthetical expression."
4373 (let ((state 4363 (let ((state (save-excursion (verilog-syntax-ppss))))
4374 (save-excursion
4375 (parse-partial-sexp (point-min) (point)))))
4376 (> (nth 0 state) 0 ))) 4364 (> (nth 0 state) 0 )))
4377 4365
4378(defun verilog-in-coverage () 4366(defun verilog-in-coverage ()
@@ -4413,15 +4401,12 @@ Optional BOUND limits search."
4413 4401
4414(defun verilog-parenthesis-depth () 4402(defun verilog-parenthesis-depth ()
4415 "Return non zero if in parenthetical-expression." 4403 "Return non zero if in parenthetical-expression."
4416 (save-excursion 4404 (save-excursion (nth 1 (verilog-syntax-ppss))))
4417 (nth 1 (parse-partial-sexp (point-min) (point)))))
4418 4405
4419 4406
4420(defun verilog-skip-forward-comment-or-string () 4407(defun verilog-skip-forward-comment-or-string ()
4421 "Return true if in a string or comment." 4408 "Return true if in a string or comment."
4422 (let ((state 4409 (let ((state (save-excursion (verilog-syntax-ppss))))
4423 (save-excursion
4424 (parse-partial-sexp (point-min) (point)))))
4425 (cond 4410 (cond
4426 ((nth 3 state) ;Inside string 4411 ((nth 3 state) ;Inside string
4427 (goto-char (nth 3 state)) 4412 (goto-char (nth 3 state))
@@ -4436,9 +4421,7 @@ Optional BOUND limits search."
4436 4421
4437(defun verilog-skip-backward-comment-or-string () 4422(defun verilog-skip-backward-comment-or-string ()
4438 "Return true if in a string or comment." 4423 "Return true if in a string or comment."
4439 (let ((state 4424 (let ((state (save-excursion (verilog-syntax-ppss))))
4440 (save-excursion
4441 (parse-partial-sexp (point-min) (point)))))
4442 (cond 4425 (cond
4443 ((nth 3 state) ;Inside string 4426 ((nth 3 state) ;Inside string
4444 (search-backward "\"") 4427 (search-backward "\"")
@@ -4458,9 +4441,7 @@ Optional BOUND limits search."
4458 (let ((more t)) 4441 (let ((more t))
4459 (while more 4442 (while more
4460 (setq more 4443 (setq more
4461 (let ((state 4444 (let ((state (save-excursion (verilog-syntax-ppss))))
4462 (save-excursion
4463 (parse-partial-sexp (point-min) (point)))))
4464 (cond 4445 (cond
4465 ((nth 7 state) ;Inside // comment 4446 ((nth 7 state) ;Inside // comment
4466 (search-backward "//") 4447 (search-backward "//")
@@ -4484,9 +4465,7 @@ Optional BOUND limits search."
4484 "If in comment, move to end and return true." 4465 "If in comment, move to end and return true."
4485 (let (state) 4466 (let (state)
4486 (progn 4467 (progn
4487 (setq state 4468 (setq state (save-excursion (verilog-syntax-ppss)))
4488 (save-excursion
4489 (parse-partial-sexp (point-min) (point))))
4490 (cond 4469 (cond
4491 ((nth 3 state) 4470 ((nth 3 state)
4492 t) 4471 t)
@@ -5935,7 +5914,7 @@ Ignore width if optional NO-WIDTH is set."
5935 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)) 5914 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil))
5936 (skip-chars-backward "a-zA-Z0-9'_$") 5915 (skip-chars-backward "a-zA-Z0-9'_$")
5937 (looking-at "[a-zA-Z0-9`_\$]+") 5916 (looking-at "[a-zA-Z0-9`_\$]+")
5938 ;; Important: don't use match string, this must work with emacs 19 font-lock on 5917 ;; Important: don't use match string, this must work with Emacs 19 font-lock on
5939 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) 5918 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
5940 5919
5941(defun verilog-read-inst-name () 5920(defun verilog-read-inst-name ()
@@ -5943,7 +5922,7 @@ Ignore width if optional NO-WIDTH is set."
5943 (save-excursion 5922 (save-excursion
5944 (verilog-read-inst-backward-name) 5923 (verilog-read-inst-backward-name)
5945 (looking-at "[a-zA-Z0-9`_\$]+") 5924 (looking-at "[a-zA-Z0-9`_\$]+")
5946 ;; Important: don't use match string, this must work with emacs 19 font-lock on 5925 ;; Important: don't use match string, this must work with Emacs 19 font-lock on
5947 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) 5926 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
5948 5927
5949(defun verilog-read-module-name () 5928(defun verilog-read-module-name ()
@@ -5953,7 +5932,7 @@ Ignore width if optional NO-WIDTH is set."
5953 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil) 5932 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)
5954 (skip-chars-backward "a-zA-Z0-9`_$") 5933 (skip-chars-backward "a-zA-Z0-9`_$")
5955 (looking-at "[a-zA-Z0-9`_\$]+") 5934 (looking-at "[a-zA-Z0-9`_\$]+")
5956 ;; Important: don't use match string, this must work with emacs 19 font-lock on 5935 ;; Important: don't use match string, this must work with Emacs 19 font-lock on
5957 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) 5936 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
5958 5937
5959(defun verilog-read-auto-params (num-param &optional max-param) 5938(defun verilog-read-auto-params (num-param &optional max-param)
@@ -6594,7 +6573,7 @@ list of ( (signal_name connection_name)... )."
6594 (goto-char (match-end 0))) 6573 (goto-char (match-end 0)))
6595 ;; Regexp form?? 6574 ;; Regexp form??
6596 ((looking-at 6575 ((looking-at
6597 ;; Regexp bug in xemacs disallows ][ inside [], and wants + last 6576 ;; Regexp bug in XEmacs disallows ][ inside [], and wants + last
6598 "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") 6577 "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
6599 (setq rep (match-string-no-properties 3)) 6578 (setq rep (match-string-no-properties 3))
6600 (goto-char (match-end 0)) 6579 (goto-char (match-end 0))
@@ -7190,7 +7169,7 @@ Cache the output of function so next call may have faster access."
7190 (setq func-returns (nth 3 fass))) 7169 (setq func-returns (nth 3 fass)))
7191 (t 7170 (t
7192 ;; Read from file 7171 ;; Read from file
7193 ;; Clear then restore any hilighting to make emacs19 happy 7172 ;; Clear then restore any hilighting to make Emacs 19 happy
7194 (let ((fontlocked (when (and (boundp 'font-lock-mode) 7173 (let ((fontlocked (when (and (boundp 'font-lock-mode)
7195 font-lock-mode) 7174 font-lock-mode)
7196 (font-lock-mode nil) 7175 (font-lock-mode nil)