aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2008-02-04 16:36:48 +0000
committerDan Nicolaescu2008-02-04 16:36:48 +0000
commit7e2a60001ef4611850e77105dac5ec443a023288 (patch)
treea09e5e27243528ddb84411b4ddcabf20857d6af5
parentcb11476b222555583a5afe3f61d08fc8191d0ccc (diff)
downloademacs-7e2a60001ef4611850e77105dac5ec443a023288.tar.gz
emacs-7e2a60001ef4611850e77105dac5ec443a023288.zip
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Add port directions by themselves, with no qualification, as base item of a declaration. (verilog-pretty-declarations): Add new flag that inhibits printing to the message buffer. (verilog-pretty-expr): Add new flag that inhibits printing to the message buffer. Improve handling of the many types of expression line up. (verilog-just-one-space): Don't print an empty message. (verilog-get-lineup-indent): Rework to support the better handling of expression lineup for verilog-pretty-expr. (verilog-auto-wire): Pass the quiet flag to verilog-pretty-expr. (verilog-mode-version, verilog-mode-release-date): Update.
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/progmodes/verilog-mode.el179
2 files changed, 112 insertions, 83 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 93b63a00f55..d7c4a120646 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,19 @@
12008-02-04 Michael McNamara <mac@mail.brushroad.com>
2
3 * progmodes/verilog-mode.el (verilog-declaration-core-re):
4 Add port directions by themselves, with no qualification, as base
5 item of a declaration.
6 (verilog-pretty-declarations): Add new flag that inhibits printing
7 to the message buffer.
8 (verilog-pretty-expr): Add new flag that inhibits printing to the
9 message buffer. Improve handling of the many types of expression
10 line up.
11 (verilog-just-one-space): Don't print an empty message.
12 (verilog-get-lineup-indent): Rework to support the better handling
13 of expression lineup for verilog-pretty-expr.
14 (verilog-auto-wire): Pass the quiet flag to verilog-pretty-expr.
15 (verilog-mode-version, verilog-mode-release-date): Update.
16
12008-02-04 Stefan Monnier <monnier@iro.umontreal.ca> 172008-02-04 Stefan Monnier <monnier@iro.umontreal.ca>
2 18
3 * subr.el (cancel-change-group): Don't move point. 19 * subr.el (cancel-change-group): Don't move point.
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index da91e36ca3d..5a9979e1495 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -115,9 +115,9 @@
115;;; Code: 115;;; Code:
116 116
117;; This variable will always hold the version number of the mode 117;; This variable will always hold the version number of the mode
118(defconst verilog-mode-version "383" 118(defconst verilog-mode-version "389"
119 "Version of this verilog mode.") 119 "Version of this verilog mode.")
120(defconst verilog-mode-release-date "2008-01-07-GNU" 120(defconst verilog-mode-release-date "2008-02-01-GNU"
121 "Release date of this verilog mode.") 121 "Release date of this verilog mode.")
122(defconst verilog-mode-release-emacs t 122(defconst verilog-mode-release-emacs t
123 "If non-nil, this version of verilog mode was released with Emacs itself.") 123 "If non-nil, this version of verilog mode was released with Emacs itself.")
@@ -1526,6 +1526,8 @@ find the errors."
1526 (eval-when-compile 1526 (eval-when-compile
1527 (verilog-regexp-words 1527 (verilog-regexp-words
1528 `( 1528 `(
1529 ;; port direction (by themselves)
1530 "inout" "input" "output"
1529 ;; integer_atom_type 1531 ;; integer_atom_type
1530 "byte" "shortint" "int" "longint" "integer" "time" 1532 "byte" "shortint" "int" "longint" "integer" "time"
1531 ;; integer_vector_type 1533 ;; integer_vector_type
@@ -4681,7 +4683,7 @@ ARG is ignored, for `comment-indent-function' compatibility."
4681 4683
4682;; 4684;;
4683 4685
4684(defun verilog-pretty-declarations () 4686(defun verilog-pretty-declarations (&optional quiet)
4685 "Line up declarations around point." 4687 "Line up declarations around point."
4686 (interactive) 4688 (interactive)
4687 (save-excursion 4689 (save-excursion
@@ -4725,7 +4727,8 @@ ARG is ignored, for `comment-indent-function' compatibility."
4725 (current-column)))) 4727 (current-column))))
4726 (goto-char end) 4728 (goto-char end)
4727 (goto-char start) 4729 (goto-char start)
4728 (if (> (- end start) 100) 4730 (if (and (not quiet)
4731 (> (- end start) 100))
4729 (message "Lining up declarations..(please stand by)")) 4732 (message "Lining up declarations..(please stand by)"))
4730 ;; Get the beginning of line indent first 4733 ;; Get the beginning of line indent first
4731 (while (progn (setq e (marker-position edpos)) 4734 (while (progn (setq e (marker-position edpos))
@@ -4750,7 +4753,7 @@ ARG is ignored, for `comment-indent-function' compatibility."
4750 (setq r (- e (point))) 4753 (setq r (- e (point)))
4751 (> r 0)) 4754 (> r 0))
4752 (setq e (point)) 4755 (setq e (point))
4753 (message "%d" r) 4756 (unless quiet (message "%d" r))
4754 (cond 4757 (cond
4755 ((or (and verilog-indent-declaration-macros 4758 ((or (and verilog-indent-declaration-macros
4756 (looking-at verilog-declaration-re-1-macro)) 4759 (looking-at verilog-declaration-re-1-macro))
@@ -4775,90 +4778,98 @@ ARG is ignored, for `comment-indent-function' compatibility."
4775 (verilog-forward-ws&directives) 4778 (verilog-forward-ws&directives)
4776 (forward-line -1))) 4779 (forward-line -1)))
4777 (forward-line 1)) 4780 (forward-line 1))
4778 (message ""))))) 4781 (unless quiet (message ""))))))
4779 4782
4780(defun verilog-pretty-expr (&optional myre) 4783(defun verilog-pretty-expr (&optional quiet myre)
4781 "Line up expressions around point, or optional regexp MYRE." 4784 "Line up expressions around point, or optional regexp MYRE."
4782 (interactive "sRegular Expression: ((<|:)?=) ") 4785 (interactive "sRegular Expression: ((<|:)?=) ")
4783 (save-excursion 4786 (save-excursion
4784 (if (or (eq myre nil) 4787 (if (or (eq myre nil)
4785 (string-equal myre "")) 4788 (string-equal myre ""))
4786 (setq myre "\\(<\\|:\\)?=")) 4789 (setq myre "\\(<\\|:\\)?="))
4787; (setq myre (concat "\\(^[^;" myre "]*\\)\\([" myre "]\\)")) 4790 (setq myre (concat "\\(^[^;#:<=>]*\\)\\(" myre "\\)"))
4788 (setq myre (concat "\\(^[^;#:?=]*\\)\\([" myre "]\\)")) 4791 (let ((rexp(concat "^\\s-*" verilog-complete-reg)))
4789 (beginning-of-line) 4792 (beginning-of-line)
4790 (if (and (not (looking-at (concat "^\\s-*" verilog-complete-reg))) 4793 (if (and (not (looking-at rexp ))
4791 (looking-at myre)) 4794 (looking-at myre))
4792 (let* ((here (point)) 4795 (let* ((here (point))
4793 (e) (r) 4796 (e) (r)
4794 (start 4797 (start
4795 (progn 4798 (progn
4796 (beginning-of-line) 4799 (beginning-of-line)
4797 (setq e (point))
4798 (verilog-backward-syntactic-ws)
4799 (beginning-of-line)
4800 (while (and (not (looking-at (concat "^\\s-*" verilog-complete-reg)))
4801 (looking-at myre)
4802 (not (bobp)))
4803 (setq e (point)) 4800 (setq e (point))
4804 (verilog-backward-syntactic-ws) 4801 (verilog-backward-syntactic-ws)
4805 (beginning-of-line) 4802 (beginning-of-line)
4806 ) ;Ack, need to grok `define 4803 (while (and (not (looking-at rexp ))
4807 e)) 4804 (looking-at myre)
4808 (end 4805 (not (bobp))
4809 (progn 4806 )
4810 (goto-char here) 4807 (setq e (point))
4811 (end-of-line) 4808 (verilog-backward-syntactic-ws)
4812 (setq e (point)) ;Might be on last line 4809 (beginning-of-line)
4813 (verilog-forward-syntactic-ws) 4810 ) ;Ack, need to grok `define
4814 (beginning-of-line) 4811 e))
4815 (while (and (not (looking-at 4812 (end
4816 (concat "^\\s-*" verilog-complete-reg))) 4813 (progn
4817 (looking-at myre)) 4814 (goto-char here)
4818 (end-of-line) 4815 (end-of-line)
4819 (setq e (point)) 4816 (setq e (point)) ;Might be on last line
4820 (verilog-forward-syntactic-ws) 4817 (verilog-forward-syntactic-ws)
4821 (beginning-of-line)) 4818 (beginning-of-line)
4822 e)) 4819 (while (and (not (looking-at rexp ))
4823 (edpos (set-marker (make-marker) end)) 4820 (looking-at myre))
4824 (ind)) 4821 (end-of-line)
4825 (goto-char start) 4822 (setq e (point))
4826 (verilog-do-indent (verilog-calculate-indent)) 4823 (verilog-forward-syntactic-ws)
4827 (if (> (- end start) 100) 4824 (beginning-of-line)
4828 (message "Lining up expressions..(please stand by)")) 4825 )
4829 4826 e))
4830 ;; Set indent to minimum throughout region 4827 (edpos (set-marker (make-marker) end))
4831 (while (< (point) (marker-position edpos)) 4828 (ind)
4832 (beginning-of-line) 4829 )
4833 (verilog-just-one-space myre) 4830 (goto-char start)
4834 (end-of-line) 4831 (verilog-do-indent (verilog-calculate-indent))
4835 (verilog-forward-syntactic-ws)) 4832 (if (and (not quiet)
4836 4833 (> (- end start) 100))
4837 ;; Now find biggest prefix 4834 (message "Lining up expressions..(please stand by)"))
4838 (setq ind (verilog-get-lineup-indent-2 myre start edpos)) 4835
4839 4836 ;; Set indent to minimum throughout region
4840 ;; Now indent each line. 4837 (while (< (point) (marker-position edpos))
4841 (goto-char start) 4838 (beginning-of-line)
4842 (while (progn (setq e (marker-position edpos)) 4839 (verilog-just-one-space myre)
4843 (setq r (- e (point))) 4840 (end-of-line)
4844 (> r 0)) 4841 (verilog-forward-syntactic-ws)
4845 (setq e (point)) 4842 )
4846 (message "%d" r) 4843
4847 (cond 4844 ;; Now find biggest prefix
4848 ((looking-at myre) 4845 (setq ind (verilog-get-lineup-indent-2 myre start edpos))
4849 (goto-char (match-end 1)) 4846
4850 (if (eq (char-after) ?=) 4847 ;; Now indent each line.
4851 (indent-to (1+ ind)) ; line up the = of the <= with surrounding = 4848 (goto-char start)
4852 (indent-to ind))) 4849 (while (progn (setq e (marker-position edpos))
4853 ((verilog-continued-line-1 start) 4850 (setq r (- e (point)))
4854 (goto-char e) 4851 (> r 0))
4855 (indent-line-to ind)) 4852 (setq e (point))
4856 (t ; Must be comment or white space 4853 (if (not quiet) (message "%d" r))
4857 (goto-char e) 4854 (cond
4858 (verilog-forward-ws&directives) 4855 ((looking-at myre)
4859 (forward-line -1))) 4856 (goto-char (match-end 1))
4860 (forward-line 1)) 4857 (if (not (verilog-parenthesis-depth)) ;; ignore parenthsized exprs
4861 (message ""))))) 4858 (if (eq (char-after) ?=)
4859 (indent-to (1+ ind)) ; line up the = of the <= with surrounding =
4860 (indent-to ind)
4861 )))
4862 ((verilog-continued-line-1 start)
4863 (goto-char e)
4864 (indent-line-to ind))
4865 (t ; Must be comment or white space
4866 (goto-char e)
4867 (verilog-forward-ws&directives)
4868 (forward-line -1))
4869 )
4870 (forward-line 1))
4871 (unless quiet (message ""))
4872 )))))
4862 4873
4863(defun verilog-just-one-space (myre) 4874(defun verilog-just-one-space (myre)
4864 "Remove extra spaces around regular expression MYRE." 4875 "Remove extra spaces around regular expression MYRE."
@@ -4872,8 +4883,8 @@ ARG is ignored, for `comment-indent-function' compatibility."
4872 (if (looking-at "\\s-") (just-one-space)) 4883 (if (looking-at "\\s-") (just-one-space))
4873 (goto-char p1) 4884 (goto-char p1)
4874 (forward-char -1) 4885 (forward-char -1)
4875 (if (looking-at "\\s-") (just-one-space))))) 4886 (if (looking-at "\\s-") (just-one-space))
4876 (message "")) 4887 ))))
4877 4888
4878(defun verilog-indent-declaration (baseind) 4889(defun verilog-indent-declaration (baseind)
4879 "Indent current lines as declaration. 4890 "Indent current lines as declaration.
@@ -4974,13 +4985,15 @@ Region is defined by B and EDPOS."
4974 ;; Get rightmost position 4985 ;; Get rightmost position
4975 (while (progn (setq e (marker-position edpos)) 4986 (while (progn (setq e (marker-position edpos))
4976 (< (point) e)) 4987 (< (point) e))
4977 (if (verilog-re-search-forward myre e 'move) 4988 (if (and (verilog-re-search-forward myre e 'move)
4989 (not (verilog-parenthesis-depth))) ;; skip parenthsized exprs
4978 (progn 4990 (progn
4979 (goto-char (match-end 0)) 4991 (goto-char (match-beginning 2))
4980 (verilog-backward-syntactic-ws) 4992 (verilog-backward-syntactic-ws)
4981 (if (> (current-column) ind) 4993 (if (> (current-column) ind)
4982 (setq ind (current-column))) 4994 (setq ind (current-column)))
4983 (goto-char (match-end 0))))) 4995 (goto-char (match-end 0)))
4996 ))
4984 (if (> ind 0) 4997 (if (> ind 0)
4985 (1+ ind) 4998 (1+ ind)
4986 ;; No lineup-string found 4999 ;; No lineup-string found
@@ -8498,7 +8511,7 @@ Typing \\[verilog-auto] will make this into:
8498 (when nil ;; Too slow on huge modules, plus makes everyone's module change 8511 (when nil ;; Too slow on huge modules, plus makes everyone's module change
8499 (beginning-of-line) 8512 (beginning-of-line)
8500 (setq pnt (point)) 8513 (setq pnt (point))
8501 (verilog-pretty-declarations) 8514 (verilog-pretty-declarations quiet)
8502 (goto-char pnt) 8515 (goto-char pnt)
8503 (verilog-pretty-expr "//")))))) 8516 (verilog-pretty-expr "//"))))))
8504 8517