This function may be removed when Emacs 21 is no longer supported."
(or (equal value t) (equal value nil)))
+(defalias 'verilog-syntax-ppss
+ (if (fboundp 'syntax-ppss) 'syntax-ppss
+ (lambda (&optional pos) (parse-partial-sexp (point-min) (or pos (point))))))
+
(defgroup verilog-mode nil
"Facilitates easy editing of Verilog source text."
:version "22.2"
(modify-syntax-entry ?/ ". 1456" table)
(modify-syntax-entry ?* ". 23" table)
(modify-syntax-entry ?\n "> b" table))
- ;; Emacs 19 does things differently, but we can work with it
+ ;; Emacs does things differently, but we can work with it
(modify-syntax-entry ?/ ". 124b" table)
(modify-syntax-entry ?* ". 23" table)
(modify-syntax-entry ?\n "> b" table))
(easy-menu-add verilog-menu)
(setq mode-popup-menu (cons "Verilog Mode" verilog-stmt-menu)))
- ;; Stuff for GNU emacs
+ ;; Stuff for GNU Emacs
(set (make-local-variable 'font-lock-defaults)
'((verilog-font-lock-keywords verilog-font-lock-keywords-1
verilog-font-lock-keywords-2
;; all buffer local:
(when (featurep 'xemacs)
(make-local-hook 'font-lock-mode-hook)
- (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20
+ (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in Emacs
(make-local-hook 'after-change-functions))
(add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t)
- (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20
+ (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in Emacs
(add-hook 'after-change-functions 'verilog-colorize-include-files t t)
;; Tell imenu how to handle Verilog.
With optional ARG, remove existing end of line comments."
(interactive)
;; before that see if we are in a comment
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(cond
((nth 7 state) ; Inside // comment
(if (eolp)
More specifically, in a list after a struct|union keyword."
(interactive)
(save-excursion
- (let* ((state (parse-partial-sexp (point-min) (point)))
+ (let* ((state (verilog-syntax-ppss))
(depth (nth 0 state)))
(if depth
(progn (backward-up-list depth)
(progn ,@body)
(error
(error "%%Error: %s%s" (error-message-string err)
- (if (featurep 'xemacs) "\n" ""))))) ;; xemacs forgets to add a newline
+ (if (featurep 'xemacs) "\n" ""))))) ;; XEmacs forgets to add a newline
(defun verilog-batch-execute-func (funref)
"Internal processing of a batch command, running FUNREF on all command arguments."
(p nil) )
(if (< bound (point))
(progn
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(cond
((nth 7 state) ;; in // comment
(verilog-re-search-backward "//" nil 'move)
jump)
(if (> bound (point))
(progn
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(cond
((nth 7 state) ;; in // comment
(verilog-re-search-forward "//" nil 'move))
(defun verilog-in-comment-p ()
"Return true if in a star or // comment."
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(or (nth 4 state) (nth 7 state))))
(defun verilog-in-star-comment-p ()
"Return true if in a star comment."
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(and
(nth 4 state) ; t if in a comment of style a // or b /**/
(not
(defun verilog-in-slash-comment-p ()
"Return true if in a slash comment."
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(nth 7 state)))
(defun verilog-in-comment-or-string-p ()
"Return true if in a string or comment."
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment)
(defun verilog-in-escaped-name-p ()
(defun verilog-in-paren ()
"Return true if in a parenthetical expression."
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(> (nth 0 state) 0 )))
(defun verilog-in-coverage ()
(defun verilog-parenthesis-depth ()
"Return non zero if in parenthetical-expression."
- (save-excursion
- (nth 1 (parse-partial-sexp (point-min) (point)))))
+ (save-excursion (nth 1 (verilog-syntax-ppss))))
(defun verilog-skip-forward-comment-or-string ()
"Return true if in a string or comment."
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(cond
((nth 3 state) ;Inside string
(goto-char (nth 3 state))
(defun verilog-skip-backward-comment-or-string ()
"Return true if in a string or comment."
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(cond
((nth 3 state) ;Inside string
(search-backward "\"")
(let ((more t))
(while more
(setq more
- (let ((state
- (save-excursion
- (parse-partial-sexp (point-min) (point)))))
+ (let ((state (save-excursion (verilog-syntax-ppss))))
(cond
((nth 7 state) ;Inside // comment
(search-backward "//")
"If in comment, move to end and return true."
(let (state)
(progn
- (setq state
- (save-excursion
- (parse-partial-sexp (point-min) (point))))
+ (setq state (save-excursion (verilog-syntax-ppss)))
(cond
((nth 3 state)
t)
(verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil))
(skip-chars-backward "a-zA-Z0-9'_$")
(looking-at "[a-zA-Z0-9`_\$]+")
- ;; Important: don't use match string, this must work with emacs 19 font-lock on
+ ;; Important: don't use match string, this must work with Emacs 19 font-lock on
(buffer-substring-no-properties (match-beginning 0) (match-end 0))))
(defun verilog-read-inst-name ()
(save-excursion
(verilog-read-inst-backward-name)
(looking-at "[a-zA-Z0-9`_\$]+")
- ;; Important: don't use match string, this must work with emacs 19 font-lock on
+ ;; Important: don't use match string, this must work with Emacs 19 font-lock on
(buffer-substring-no-properties (match-beginning 0) (match-end 0))))
(defun verilog-read-module-name ()
(verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)
(skip-chars-backward "a-zA-Z0-9`_$")
(looking-at "[a-zA-Z0-9`_\$]+")
- ;; Important: don't use match string, this must work with emacs 19 font-lock on
+ ;; Important: don't use match string, this must work with Emacs 19 font-lock on
(buffer-substring-no-properties (match-beginning 0) (match-end 0))))
(defun verilog-read-auto-params (num-param &optional max-param)
(goto-char (match-end 0)))
;; Regexp form??
((looking-at
- ;; Regexp bug in xemacs disallows ][ inside [], and wants + last
+ ;; Regexp bug in XEmacs disallows ][ inside [], and wants + last
"\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
(setq rep (match-string-no-properties 3))
(goto-char (match-end 0))
(setq func-returns (nth 3 fass)))
(t
;; Read from file
- ;; Clear then restore any hilighting to make emacs19 happy
+ ;; Clear then restore any hilighting to make Emacs 19 happy
(let ((fontlocked (when (and (boundp 'font-lock-mode)
font-lock-mode)
(font-lock-mode nil)