diff options
| author | Dan Nicolaescu | 2008-01-10 07:05:10 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-01-10 07:05:10 +0000 |
| commit | e1776067924d2a8095dffe6d07733ba04f00b9f6 (patch) | |
| tree | c4a5470453aa1e8ed153a37a6a314e18187198fb | |
| parent | 63dbe8da55f83719acaf0dbd74d6273137334c6f (diff) | |
| download | emacs-e1776067924d2a8095dffe6d07733ba04f00b9f6.tar.gz emacs-e1776067924d2a8095dffe6d07733ba04f00b9f6.zip | |
(verilog-mode-map): Don't bind C-M-a,
C-M-e and C-M-h for emacs, they work by default.
(verilog-emacs-features): Remove.
(verilog-setup-dual-comments, verilog-populate-syntax-table):
Remove. Move syntax table initialization ...
(verilog-mode-syntax-table): ... here.
(verilog-mode): Don't initialize the syntax table here.
(verilog-mark-defun): Only do something useful for XEmacs, emacs
does not need it.
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/progmodes/verilog-mode.el | 208 |
2 files changed, 61 insertions, 159 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b26216ab59d..38b2d418ff3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2008-01-10 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * progmodes/verilog-mode.el (verilog-mode-map): Don't bind C-M-a, | ||
| 4 | C-M-e and C-M-h for emacs, they work by default. | ||
| 5 | (verilog-emacs-features): Remove. | ||
| 6 | (verilog-setup-dual-comments, verilog-populate-syntax-table): | ||
| 7 | Remove. Move syntax table initialization ... | ||
| 8 | (verilog-mode-syntax-table): ... here. | ||
| 9 | (verilog-mode): Don't initialize the syntax table here. | ||
| 10 | (verilog-mark-defun): Only do something useful for XEmacs, emacs | ||
| 11 | does not need it. | ||
| 12 | |||
| 1 | 2008-01-10 Glenn Morris <rgm@gnu.org> | 13 | 2008-01-10 Glenn Morris <rgm@gnu.org> |
| 2 | 14 | ||
| 3 | * shell.el (shell-dirtrack-verbose, shell-mode) | 15 | * shell.el (shell-dirtrack-verbose, shell-mode) |
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index a1611b0eada..c177ca1b184 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el | |||
| @@ -933,7 +933,6 @@ If set will become buffer local.") | |||
| 933 | (define-key map "\M-\r" `electric-verilog-terminate-and-indent) | 933 | (define-key map "\M-\r" `electric-verilog-terminate-and-indent) |
| 934 | (define-key map "\M-\t" 'verilog-complete-word) | 934 | (define-key map "\M-\t" 'verilog-complete-word) |
| 935 | (define-key map "\M-?" 'verilog-show-completions) | 935 | (define-key map "\M-?" 'verilog-show-completions) |
| 936 | (define-key map [(meta control h)] 'verilog-mark-defun) | ||
| 937 | (define-key map "\C-c\`" 'verilog-lint-off) | 936 | (define-key map "\C-c\`" 'verilog-lint-off) |
| 938 | (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) | 937 | (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) |
| 939 | (define-key map "\C-c\C-r" 'verilog-label-be) | 938 | (define-key map "\C-c\C-r" 'verilog-label-be) |
| @@ -943,8 +942,10 @@ If set will become buffer local.") | |||
| 943 | (define-key map "\M-*" 'verilog-star-comment) | 942 | (define-key map "\M-*" 'verilog-star-comment) |
| 944 | (define-key map "\C-c\C-c" 'verilog-comment-region) | 943 | (define-key map "\C-c\C-c" 'verilog-comment-region) |
| 945 | (define-key map "\C-c\C-u" 'verilog-uncomment-region) | 944 | (define-key map "\C-c\C-u" 'verilog-uncomment-region) |
| 946 | (define-key map "\M-\C-a" 'verilog-beg-of-defun) | 945 | (when (featurep 'xemacs) |
| 947 | (define-key map "\M-\C-e" 'verilog-end-of-defun) | 946 | (define-key map [(meta control h)] 'verilog-mark-defun) |
| 947 | (define-key map "\M-\C-a" 'verilog-beg-of-defun) | ||
| 948 | (define-key map "\M-\C-e" 'verilog-end-of-defun)) | ||
| 948 | (define-key map "\C-c\C-d" 'verilog-goto-defun) | 949 | (define-key map "\C-c\C-d" 'verilog-goto-defun) |
| 949 | (define-key map "\C-c\C-k" 'verilog-delete-auto) | 950 | (define-key map "\C-c\C-k" 'verilog-delete-auto) |
| 950 | (define-key map "\C-c\C-a" 'verilog-auto) | 951 | (define-key map "\C-c\C-a" 'verilog-auto) |
| @@ -957,7 +958,7 @@ If set will become buffer local.") | |||
| 957 | 958 | ||
| 958 | ;; menus | 959 | ;; menus |
| 959 | (defvar verilog-xemacs-menu | 960 | (defvar verilog-xemacs-menu |
| 960 | '("Verilog" | 961 | `("Verilog" |
| 961 | ("Choose Compilation Action" | 962 | ("Choose Compilation Action" |
| 962 | ["None" | 963 | ["None" |
| 963 | (progn | 964 | (progn |
| @@ -991,9 +992,15 @@ If set will become buffer local.") | |||
| 991 | :selected (equal verilog-tool `verilog-compiler)] | 992 | :selected (equal verilog-tool `verilog-compiler)] |
| 992 | ) | 993 | ) |
| 993 | ("Move" | 994 | ("Move" |
| 994 | ["Beginning of function" verilog-beg-of-defun t] | 995 | ,(if (featurep 'xemacs) |
| 995 | ["End of function" verilog-end-of-defun t] | 996 | (progn |
| 996 | ["Mark function" verilog-mark-defun t] | 997 | ["Beginning of function" verilog-beg-of-defun t] |
| 998 | ["End of function" verilog-end-of-defun t] | ||
| 999 | ["Mark function" verilog-mark-defun t]) | ||
| 1000 | ["Beginning of function" beginning-of-defun t] | ||
| 1001 | ["End of function" end-of-defun t] | ||
| 1002 | ["Mark function" mark-defun t]) | ||
| 1003 | |||
| 997 | ["Goto function/module" verilog-goto-defun t] | 1004 | ["Goto function/module" verilog-goto-defun t] |
| 998 | ["Move to beginning of block" electric-verilog-backward-sexp t] | 1005 | ["Move to beginning of block" electric-verilog-backward-sexp t] |
| 999 | ["Move to end of block" electric-verilog-forward-sexp t] | 1006 | ["Move to end of block" electric-verilog-forward-sexp t] |
| @@ -1714,151 +1721,37 @@ find the errors." | |||
| 1714 | ) | 1721 | ) |
| 1715 | "List of Verilog keywords.") | 1722 | "List of Verilog keywords.") |
| 1716 | 1723 | ||
| 1717 | |||
| 1718 | (defconst verilog-emacs-features | ||
| 1719 | ;; Documentation at the bottom | ||
| 1720 | (let ((major (and (boundp 'emacs-major-version) | ||
| 1721 | emacs-major-version)) | ||
| 1722 | (minor (and (boundp 'emacs-minor-version) | ||
| 1723 | emacs-minor-version)) | ||
| 1724 | flavor comments flock-syntax) | ||
| 1725 | ;; figure out version numbers if not already discovered | ||
| 1726 | (and (or (not major) (not minor)) | ||
| 1727 | (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version) | ||
| 1728 | (setq major (string-to-number (substring emacs-version | ||
| 1729 | (match-beginning 1) | ||
| 1730 | (match-end 1))) | ||
| 1731 | minor (string-to-number (substring emacs-version | ||
| 1732 | (match-beginning 2) | ||
| 1733 | (match-end 2))))) | ||
| 1734 | (if (not (and major minor)) | ||
| 1735 | (error "Cannot figure out the major and minor version numbers")) | ||
| 1736 | ;; calculate the major version | ||
| 1737 | (cond | ||
| 1738 | ((= major 4) (setq major 'v18)) ;Epoch 4 | ||
| 1739 | ((= major 18) (setq major 'v18)) ;Emacs 18 | ||
| 1740 | ((= major 19) (setq major 'v19 ;Emacs 19 | ||
| 1741 | flavor (if (or (string-match "Lucid" emacs-version) | ||
| 1742 | (string-match "XEmacs" emacs-version)) | ||
| 1743 | 'XEmacs 'FSF))) | ||
| 1744 | ((> major 19) (setq major 'v20 | ||
| 1745 | flavor (if (or (string-match "Lucid" emacs-version) | ||
| 1746 | (string-match "XEmacs" emacs-version)) | ||
| 1747 | 'XEmacs 'FSF))) | ||
| 1748 | ;; I don't know | ||
| 1749 | (t (error "Cannot recognize major version number: %s" major))) | ||
| 1750 | ;; XEmacs 19 uses 8-bit modify-syntax-entry flags, as do all | ||
| 1751 | ;; patched Emacs 19, Emacs 18, Epoch 4's. Only Emacs 19 uses a | ||
| 1752 | ;; 1-bit flag. Let's be as smart as we can about figuring this | ||
| 1753 | ;; out. | ||
| 1754 | (if (or (eq major 'v20) (eq major 'v19)) | ||
| 1755 | (let ((table (copy-syntax-table))) | ||
| 1756 | (modify-syntax-entry ?a ". 12345678" table) | ||
| 1757 | (cond | ||
| 1758 | ;; XEmacs pre 20 and Emacs pre 19.30 use vectors for syntax tables. | ||
| 1759 | ((vectorp table) | ||
| 1760 | (if (= (logand (lsh (aref table ?a) -16) 255) 255) | ||
| 1761 | (setq comments '8-bit) | ||
| 1762 | (setq comments '1-bit))) | ||
| 1763 | ;; XEmacs 20 is known to be 8-bit | ||
| 1764 | ((eq flavor 'XEmacs) (setq comments '8-bit)) | ||
| 1765 | ;; Emacs 19.30 and beyond are known to be 1-bit | ||
| 1766 | ((eq flavor 'FSF) (setq comments '1-bit)) | ||
| 1767 | ;; Don't know what this is | ||
| 1768 | (t (error "Couldn't figure out syntax table format")))) | ||
| 1769 | ;; Emacs 18 has no support for dual comments | ||
| 1770 | (setq comments 'no-dual-comments)) | ||
| 1771 | ;; determine whether to use old or new font lock syntax | ||
| 1772 | ;; We can assume 8-bit syntax table emacsen support new syntax, otherwise | ||
| 1773 | ;; look for version > 19.30 | ||
| 1774 | (setq flock-syntax | ||
| 1775 | (if (or (equal comments '8-bit) | ||
| 1776 | (equal major 'v20) | ||
| 1777 | (and (equal major 'v19) (> minor 30))) | ||
| 1778 | 'flock-syntax-after-1930 | ||
| 1779 | 'flock-syntax-before-1930)) | ||
| 1780 | ;; lets do some minimal sanity checking. | ||
| 1781 | (if (or | ||
| 1782 | ;; Emacs before 19.6 had bugs | ||
| 1783 | (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6)) | ||
| 1784 | ;; Emacs 19 before 19.21 has known bugs | ||
| 1785 | (and (eq major 'v19) (eq flavor 'FSF) (< minor 21))) | ||
| 1786 | (with-output-to-temp-buffer "*verilog-mode warnings*" | ||
| 1787 | (print (format | ||
| 1788 | "The version of Emacs that you are running, %s, | ||
| 1789 | has known bugs in its syntax parsing routines which will affect the | ||
| 1790 | performance of verilog-mode. You should strongly consider upgrading to the | ||
| 1791 | latest available version. verilog-mode may continue to work, after a | ||
| 1792 | fashion, but strange indentation errors could be encountered." | ||
| 1793 | emacs-version)))) | ||
| 1794 | ;; Emacs 18, with no patch is not too good | ||
| 1795 | (if (and (eq major 'v18) (eq comments 'no-dual-comments)) | ||
| 1796 | (with-output-to-temp-buffer "*verilog-mode warnings*" | ||
| 1797 | (print (format | ||
| 1798 | "The version of Emacs 18 you are running, %s, | ||
| 1799 | has known deficiencies in its ability to handle the dual verilog | ||
| 1800 | \(and C++) comments, (e.g. the // and /* */ comments). This will | ||
| 1801 | not be much of a problem for you if you only use the /* */ comments, | ||
| 1802 | but you really should strongly consider upgrading to one of the latest | ||
| 1803 | Emacs 19's. In Emacs 18, you may also experience performance degradations. | ||
| 1804 | Emacs 19 has some new built-in routines which will speed things up for you. | ||
| 1805 | Because of these inherent problems, verilog-mode is not supported | ||
| 1806 | on emacs-18." | ||
| 1807 | emacs-version)))) | ||
| 1808 | ;; Emacs 18 with the syntax patches are no longer supported | ||
| 1809 | (if (and (eq major 'v18) (not (eq comments 'no-dual-comments))) | ||
| 1810 | (with-output-to-temp-buffer "*verilog-mode warnings*" | ||
| 1811 | (print (format | ||
| 1812 | "You are running a syntax patched Emacs 18 variant. While this should | ||
| 1813 | work for you, you may want to consider upgrading to Emacs 19. | ||
| 1814 | The syntax patches are no longer supported either for verilog-mode.")))) | ||
| 1815 | (list major comments flock-syntax)) | ||
| 1816 | "A list of features extant in the Emacs you are using. | ||
| 1817 | There are many flavors of Emacs out there, each with different | ||
| 1818 | features supporting those needed by `verilog-mode'. Here's the current | ||
| 1819 | supported list, along with the values for this variable: | ||
| 1820 | |||
| 1821 | Vanilla Emacs 18/Epoch 4: (v18 no-dual-comments flock-syntax-before-1930) | ||
| 1822 | Emacs 18/Epoch 4 (patch2): (v18 8-bit flock-syntax-after-1930) | ||
| 1823 | XEmacs (formerly Lucid) 19: (v19 8-bit flock-syntax-after-1930) | ||
| 1824 | XEmacs 20: (v20 8-bit flock-syntax-after-1930) | ||
| 1825 | Emacs 19.1-19.30: (v19 8-bit flock-syntax-before-1930) | ||
| 1826 | Emacs 19.31-19.xx: (v19 8-bit flock-syntax-after-1930) | ||
| 1827 | Emacs20 : (v20 1-bit flock-syntax-after-1930).") | ||
| 1828 | |||
| 1829 | (defconst verilog-comment-start-regexp "//\\|/\\*" | 1724 | (defconst verilog-comment-start-regexp "//\\|/\\*" |
| 1830 | "Dual comment value for `comment-start-regexp'.") | 1725 | "Dual comment value for `comment-start-regexp'.") |
| 1831 | 1726 | ||
| 1832 | (defun verilog-populate-syntax-table (table) | 1727 | (defvar verilog-mode-syntax-table |
| 1833 | "Populate the syntax TABLE." | 1728 | (let ((table (make-syntax-table))) |
| 1834 | (modify-syntax-entry ?\\ "\\" table) | 1729 | ;; Populate the syntax TABLE. |
| 1835 | (modify-syntax-entry ?+ "." table) | 1730 | (modify-syntax-entry ?\\ "\\" table) |
| 1836 | (modify-syntax-entry ?- "." table) | 1731 | (modify-syntax-entry ?+ "." table) |
| 1837 | (modify-syntax-entry ?= "." table) | 1732 | (modify-syntax-entry ?- "." table) |
| 1838 | (modify-syntax-entry ?% "." table) | 1733 | (modify-syntax-entry ?= "." table) |
| 1839 | (modify-syntax-entry ?< "." table) | 1734 | (modify-syntax-entry ?% "." table) |
| 1840 | (modify-syntax-entry ?> "." table) | 1735 | (modify-syntax-entry ?< "." table) |
| 1841 | (modify-syntax-entry ?& "." table) | 1736 | (modify-syntax-entry ?> "." table) |
| 1842 | (modify-syntax-entry ?| "." table) | 1737 | (modify-syntax-entry ?& "." table) |
| 1843 | (modify-syntax-entry ?` "w" table) | 1738 | (modify-syntax-entry ?| "." table) |
| 1844 | (modify-syntax-entry ?_ "w" table) | 1739 | (modify-syntax-entry ?` "w" table) |
| 1845 | (modify-syntax-entry ?\' "." table)) | 1740 | (modify-syntax-entry ?_ "w" table) |
| 1846 | 1741 | (modify-syntax-entry ?\' "." table) | |
| 1847 | (defun verilog-setup-dual-comments (table) | 1742 | |
| 1848 | "Set up TABLE to handle block and line style comments." | 1743 | ;; Set up TABLE to handle block and line style comments. |
| 1849 | (cond | 1744 | (if (featurep 'xemacs) |
| 1850 | ((memq '8-bit verilog-emacs-features) | 1745 | (progn |
| 1851 | ;; XEmacs (formerly Lucid) has the best implementation | 1746 | ;; XEmacs (formerly Lucid) has the best implementation |
| 1852 | (modify-syntax-entry ?/ ". 1456" table) | 1747 | (modify-syntax-entry ?/ ". 1456" table) |
| 1853 | (modify-syntax-entry ?* ". 23" table) | 1748 | (modify-syntax-entry ?* ". 23" table) |
| 1854 | (modify-syntax-entry ?\n "> b" table)) | 1749 | (modify-syntax-entry ?\n "> b" table)) |
| 1855 | ((memq '1-bit verilog-emacs-features) | 1750 | ;; Emacs 19 does things differently, but we can work with it |
| 1856 | ;; Emacs 19 does things differently, but we can work with it | 1751 | (modify-syntax-entry ?/ ". 124b" table) |
| 1857 | (modify-syntax-entry ?/ ". 124b" table) | 1752 | (modify-syntax-entry ?* ". 23" table) |
| 1858 | (modify-syntax-entry ?* ". 23" table) | 1753 | (modify-syntax-entry ?\n "> b" table)) |
| 1859 | (modify-syntax-entry ?\n "> b" table)))) | 1754 | table) |
| 1860 | |||
| 1861 | (defvar verilog-mode-syntax-table nil | ||
| 1862 | "Syntax table used in `verilog-mode' buffers.") | 1755 | "Syntax table used in `verilog-mode' buffers.") |
| 1863 | 1756 | ||
| 1864 | (defvar verilog-font-lock-keywords nil | 1757 | (defvar verilog-font-lock-keywords nil |
| @@ -2422,14 +2315,10 @@ Key bindings specific to `verilog-mode-map' are: | |||
| 2422 | (setq major-mode 'verilog-mode) | 2315 | (setq major-mode 'verilog-mode) |
| 2423 | (setq mode-name "Verilog") | 2316 | (setq mode-name "Verilog") |
| 2424 | (setq local-abbrev-table verilog-mode-abbrev-table) | 2317 | (setq local-abbrev-table verilog-mode-abbrev-table) |
| 2425 | (setq verilog-mode-syntax-table (make-syntax-table)) | ||
| 2426 | (verilog-populate-syntax-table verilog-mode-syntax-table) | ||
| 2427 | (set (make-local-variable 'beginning-of-defun-function) | 2318 | (set (make-local-variable 'beginning-of-defun-function) |
| 2428 | 'verilog-beg-of-defun) | 2319 | 'verilog-beg-of-defun) |
| 2429 | (set (make-local-variable 'end-of-defun-function) | 2320 | (set (make-local-variable 'end-of-defun-function) |
| 2430 | 'verilog-end-of-defun) | 2321 | 'verilog-end-of-defun) |
| 2431 | ;; add extra comment syntax | ||
| 2432 | (verilog-setup-dual-comments verilog-mode-syntax-table) | ||
| 2433 | (set-syntax-table verilog-mode-syntax-table) | 2322 | (set-syntax-table verilog-mode-syntax-table) |
| 2434 | (make-local-variable 'indent-line-function) | 2323 | (make-local-variable 'indent-line-function) |
| 2435 | (setq indent-line-function 'verilog-indent-line-relative) | 2324 | (setq indent-line-function 'verilog-indent-line-relative) |
| @@ -2751,12 +2640,13 @@ following code fragment: | |||
| 2751 | "Mark the current verilog function (or procedure). | 2640 | "Mark the current verilog function (or procedure). |
| 2752 | This puts the mark at the end, and point at the beginning." | 2641 | This puts the mark at the end, and point at the beginning." |
| 2753 | (interactive) | 2642 | (interactive) |
| 2754 | (push-mark (point)) | 2643 | (when (featurep 'xemacs) |
| 2755 | (verilog-end-of-defun) | 2644 | (push-mark (point)) |
| 2756 | (push-mark (point)) | 2645 | (verilog-end-of-defun) |
| 2757 | (verilog-beg-of-defun) | 2646 | (push-mark (point)) |
| 2758 | (if (fboundp 'zmacs-activate-region) | 2647 | (verilog-beg-of-defun) |
| 2759 | (zmacs-activate-region))) | 2648 | (if (fboundp 'zmacs-activate-region) |
| 2649 | (zmacs-activate-region)))) | ||
| 2760 | 2650 | ||
| 2761 | (defun verilog-comment-region (start end) | 2651 | (defun verilog-comment-region (start end) |
| 2762 | ; checkdoc-params: (start end) | 2652 | ; checkdoc-params: (start end) |