1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-10 08:10:21 -08:00

(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.
This commit is contained in:
Dan Nicolaescu 2008-01-10 07:05:10 +00:00
parent 63dbe8da55
commit e177606792
2 changed files with 60 additions and 158 deletions

View file

@ -1,3 +1,15 @@
2008-01-10 Dan Nicolaescu <dann@ics.uci.edu>
* progmodes/verilog-mode.el (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.
2008-01-10 Glenn Morris <rgm@gnu.org> 2008-01-10 Glenn Morris <rgm@gnu.org>
* shell.el (shell-dirtrack-verbose, shell-mode) * shell.el (shell-dirtrack-verbose, shell-mode)

View file

@ -933,7 +933,6 @@ If set will become buffer local.")
(define-key map "\M-\r" `electric-verilog-terminate-and-indent) (define-key map "\M-\r" `electric-verilog-terminate-and-indent)
(define-key map "\M-\t" 'verilog-complete-word) (define-key map "\M-\t" 'verilog-complete-word)
(define-key map "\M-?" 'verilog-show-completions) (define-key map "\M-?" 'verilog-show-completions)
(define-key map [(meta control h)] 'verilog-mark-defun)
(define-key map "\C-c\`" 'verilog-lint-off) (define-key map "\C-c\`" 'verilog-lint-off)
(define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit)
(define-key map "\C-c\C-r" 'verilog-label-be) (define-key map "\C-c\C-r" 'verilog-label-be)
@ -943,8 +942,10 @@ If set will become buffer local.")
(define-key map "\M-*" 'verilog-star-comment) (define-key map "\M-*" 'verilog-star-comment)
(define-key map "\C-c\C-c" 'verilog-comment-region) (define-key map "\C-c\C-c" 'verilog-comment-region)
(define-key map "\C-c\C-u" 'verilog-uncomment-region) (define-key map "\C-c\C-u" 'verilog-uncomment-region)
(define-key map "\M-\C-a" 'verilog-beg-of-defun) (when (featurep 'xemacs)
(define-key map "\M-\C-e" 'verilog-end-of-defun) (define-key map [(meta control h)] 'verilog-mark-defun)
(define-key map "\M-\C-a" 'verilog-beg-of-defun)
(define-key map "\M-\C-e" 'verilog-end-of-defun))
(define-key map "\C-c\C-d" 'verilog-goto-defun) (define-key map "\C-c\C-d" 'verilog-goto-defun)
(define-key map "\C-c\C-k" 'verilog-delete-auto) (define-key map "\C-c\C-k" 'verilog-delete-auto)
(define-key map "\C-c\C-a" 'verilog-auto) (define-key map "\C-c\C-a" 'verilog-auto)
@ -957,7 +958,7 @@ If set will become buffer local.")
;; menus ;; menus
(defvar verilog-xemacs-menu (defvar verilog-xemacs-menu
'("Verilog" `("Verilog"
("Choose Compilation Action" ("Choose Compilation Action"
["None" ["None"
(progn (progn
@ -991,9 +992,15 @@ If set will become buffer local.")
:selected (equal verilog-tool `verilog-compiler)] :selected (equal verilog-tool `verilog-compiler)]
) )
("Move" ("Move"
["Beginning of function" verilog-beg-of-defun t] ,(if (featurep 'xemacs)
["End of function" verilog-end-of-defun t] (progn
["Mark function" verilog-mark-defun t] ["Beginning of function" verilog-beg-of-defun t]
["End of function" verilog-end-of-defun t]
["Mark function" verilog-mark-defun t])
["Beginning of function" beginning-of-defun t]
["End of function" end-of-defun t]
["Mark function" mark-defun t])
["Goto function/module" verilog-goto-defun t] ["Goto function/module" verilog-goto-defun t]
["Move to beginning of block" electric-verilog-backward-sexp t] ["Move to beginning of block" electric-verilog-backward-sexp t]
["Move to end of block" electric-verilog-forward-sexp t] ["Move to end of block" electric-verilog-forward-sexp t]
@ -1714,151 +1721,37 @@ find the errors."
) )
"List of Verilog keywords.") "List of Verilog keywords.")
(defconst verilog-emacs-features
;; Documentation at the bottom
(let ((major (and (boundp 'emacs-major-version)
emacs-major-version))
(minor (and (boundp 'emacs-minor-version)
emacs-minor-version))
flavor comments flock-syntax)
;; figure out version numbers if not already discovered
(and (or (not major) (not minor))
(string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
(setq major (string-to-number (substring emacs-version
(match-beginning 1)
(match-end 1)))
minor (string-to-number (substring emacs-version
(match-beginning 2)
(match-end 2)))))
(if (not (and major minor))
(error "Cannot figure out the major and minor version numbers"))
;; calculate the major version
(cond
((= major 4) (setq major 'v18)) ;Epoch 4
((= major 18) (setq major 'v18)) ;Emacs 18
((= major 19) (setq major 'v19 ;Emacs 19
flavor (if (or (string-match "Lucid" emacs-version)
(string-match "XEmacs" emacs-version))
'XEmacs 'FSF)))
((> major 19) (setq major 'v20
flavor (if (or (string-match "Lucid" emacs-version)
(string-match "XEmacs" emacs-version))
'XEmacs 'FSF)))
;; I don't know
(t (error "Cannot recognize major version number: %s" major)))
;; XEmacs 19 uses 8-bit modify-syntax-entry flags, as do all
;; patched Emacs 19, Emacs 18, Epoch 4's. Only Emacs 19 uses a
;; 1-bit flag. Let's be as smart as we can about figuring this
;; out.
(if (or (eq major 'v20) (eq major 'v19))
(let ((table (copy-syntax-table)))
(modify-syntax-entry ?a ". 12345678" table)
(cond
;; XEmacs pre 20 and Emacs pre 19.30 use vectors for syntax tables.
((vectorp table)
(if (= (logand (lsh (aref table ?a) -16) 255) 255)
(setq comments '8-bit)
(setq comments '1-bit)))
;; XEmacs 20 is known to be 8-bit
((eq flavor 'XEmacs) (setq comments '8-bit))
;; Emacs 19.30 and beyond are known to be 1-bit
((eq flavor 'FSF) (setq comments '1-bit))
;; Don't know what this is
(t (error "Couldn't figure out syntax table format"))))
;; Emacs 18 has no support for dual comments
(setq comments 'no-dual-comments))
;; determine whether to use old or new font lock syntax
;; We can assume 8-bit syntax table emacsen support new syntax, otherwise
;; look for version > 19.30
(setq flock-syntax
(if (or (equal comments '8-bit)
(equal major 'v20)
(and (equal major 'v19) (> minor 30)))
'flock-syntax-after-1930
'flock-syntax-before-1930))
;; lets do some minimal sanity checking.
(if (or
;; Emacs before 19.6 had bugs
(and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6))
;; Emacs 19 before 19.21 has known bugs
(and (eq major 'v19) (eq flavor 'FSF) (< minor 21)))
(with-output-to-temp-buffer "*verilog-mode warnings*"
(print (format
"The version of Emacs that you are running, %s,
has known bugs in its syntax parsing routines which will affect the
performance of verilog-mode. You should strongly consider upgrading to the
latest available version. verilog-mode may continue to work, after a
fashion, but strange indentation errors could be encountered."
emacs-version))))
;; Emacs 18, with no patch is not too good
(if (and (eq major 'v18) (eq comments 'no-dual-comments))
(with-output-to-temp-buffer "*verilog-mode warnings*"
(print (format
"The version of Emacs 18 you are running, %s,
has known deficiencies in its ability to handle the dual verilog
\(and C++) comments, (e.g. the // and /* */ comments). This will
not be much of a problem for you if you only use the /* */ comments,
but you really should strongly consider upgrading to one of the latest
Emacs 19's. In Emacs 18, you may also experience performance degradations.
Emacs 19 has some new built-in routines which will speed things up for you.
Because of these inherent problems, verilog-mode is not supported
on emacs-18."
emacs-version))))
;; Emacs 18 with the syntax patches are no longer supported
(if (and (eq major 'v18) (not (eq comments 'no-dual-comments)))
(with-output-to-temp-buffer "*verilog-mode warnings*"
(print (format
"You are running a syntax patched Emacs 18 variant. While this should
work for you, you may want to consider upgrading to Emacs 19.
The syntax patches are no longer supported either for verilog-mode."))))
(list major comments flock-syntax))
"A list of features extant in the Emacs you are using.
There are many flavors of Emacs out there, each with different
features supporting those needed by `verilog-mode'. Here's the current
supported list, along with the values for this variable:
Vanilla Emacs 18/Epoch 4: (v18 no-dual-comments flock-syntax-before-1930)
Emacs 18/Epoch 4 (patch2): (v18 8-bit flock-syntax-after-1930)
XEmacs (formerly Lucid) 19: (v19 8-bit flock-syntax-after-1930)
XEmacs 20: (v20 8-bit flock-syntax-after-1930)
Emacs 19.1-19.30: (v19 8-bit flock-syntax-before-1930)
Emacs 19.31-19.xx: (v19 8-bit flock-syntax-after-1930)
Emacs20 : (v20 1-bit flock-syntax-after-1930).")
(defconst verilog-comment-start-regexp "//\\|/\\*" (defconst verilog-comment-start-regexp "//\\|/\\*"
"Dual comment value for `comment-start-regexp'.") "Dual comment value for `comment-start-regexp'.")
(defun verilog-populate-syntax-table (table) (defvar verilog-mode-syntax-table
"Populate the syntax TABLE." (let ((table (make-syntax-table)))
(modify-syntax-entry ?\\ "\\" table) ;; Populate the syntax TABLE.
(modify-syntax-entry ?+ "." table) (modify-syntax-entry ?\\ "\\" table)
(modify-syntax-entry ?- "." table) (modify-syntax-entry ?+ "." table)
(modify-syntax-entry ?= "." table) (modify-syntax-entry ?- "." table)
(modify-syntax-entry ?% "." table) (modify-syntax-entry ?= "." table)
(modify-syntax-entry ?< "." table) (modify-syntax-entry ?% "." table)
(modify-syntax-entry ?> "." table) (modify-syntax-entry ?< "." table)
(modify-syntax-entry ?& "." table) (modify-syntax-entry ?> "." table)
(modify-syntax-entry ?| "." table) (modify-syntax-entry ?& "." table)
(modify-syntax-entry ?` "w" table) (modify-syntax-entry ?| "." table)
(modify-syntax-entry ?_ "w" table) (modify-syntax-entry ?` "w" table)
(modify-syntax-entry ?\' "." table)) (modify-syntax-entry ?_ "w" table)
(modify-syntax-entry ?\' "." table)
(defun verilog-setup-dual-comments (table) ;; Set up TABLE to handle block and line style comments.
"Set up TABLE to handle block and line style comments." (if (featurep 'xemacs)
(cond (progn
((memq '8-bit verilog-emacs-features) ;; XEmacs (formerly Lucid) has the best implementation
;; XEmacs (formerly Lucid) has the best implementation (modify-syntax-entry ?/ ". 1456" table)
(modify-syntax-entry ?/ ". 1456" table) (modify-syntax-entry ?* ". 23" table)
(modify-syntax-entry ?* ". 23" table) (modify-syntax-entry ?\n "> b" table))
(modify-syntax-entry ?\n "> b" table)) ;; Emacs 19 does things differently, but we can work with it
((memq '1-bit verilog-emacs-features) (modify-syntax-entry ?/ ". 124b" table)
;; Emacs 19 does things differently, but we can work with it (modify-syntax-entry ?* ". 23" table)
(modify-syntax-entry ?/ ". 124b" table) (modify-syntax-entry ?\n "> b" table))
(modify-syntax-entry ?* ". 23" table) table)
(modify-syntax-entry ?\n "> b" table))))
(defvar verilog-mode-syntax-table nil
"Syntax table used in `verilog-mode' buffers.") "Syntax table used in `verilog-mode' buffers.")
(defvar verilog-font-lock-keywords nil (defvar verilog-font-lock-keywords nil
@ -2422,14 +2315,10 @@ Key bindings specific to `verilog-mode-map' are:
(setq major-mode 'verilog-mode) (setq major-mode 'verilog-mode)
(setq mode-name "Verilog") (setq mode-name "Verilog")
(setq local-abbrev-table verilog-mode-abbrev-table) (setq local-abbrev-table verilog-mode-abbrev-table)
(setq verilog-mode-syntax-table (make-syntax-table))
(verilog-populate-syntax-table verilog-mode-syntax-table)
(set (make-local-variable 'beginning-of-defun-function) (set (make-local-variable 'beginning-of-defun-function)
'verilog-beg-of-defun) 'verilog-beg-of-defun)
(set (make-local-variable 'end-of-defun-function) (set (make-local-variable 'end-of-defun-function)
'verilog-end-of-defun) 'verilog-end-of-defun)
;; add extra comment syntax
(verilog-setup-dual-comments verilog-mode-syntax-table)
(set-syntax-table verilog-mode-syntax-table) (set-syntax-table verilog-mode-syntax-table)
(make-local-variable 'indent-line-function) (make-local-variable 'indent-line-function)
(setq indent-line-function 'verilog-indent-line-relative) (setq indent-line-function 'verilog-indent-line-relative)
@ -2751,12 +2640,13 @@ following code fragment:
"Mark the current verilog function (or procedure). "Mark the current verilog function (or procedure).
This puts the mark at the end, and point at the beginning." This puts the mark at the end, and point at the beginning."
(interactive) (interactive)
(push-mark (point)) (when (featurep 'xemacs)
(verilog-end-of-defun) (push-mark (point))
(push-mark (point)) (verilog-end-of-defun)
(verilog-beg-of-defun) (push-mark (point))
(if (fboundp 'zmacs-activate-region) (verilog-beg-of-defun)
(zmacs-activate-region))) (if (fboundp 'zmacs-activate-region)
(zmacs-activate-region))))
(defun verilog-comment-region (start end) (defun verilog-comment-region (start end)
; checkdoc-params: (start end) ; checkdoc-params: (start end)