;;; vhdl-mode.el --- major mode for editing VHDL code
;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-;; 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;; Free Software Foundation, Inc.
;; Authors: Reto Zimmermann <reto@gnu.org>
;; Rodney J. Whitby <software.vhdl-mode@rwhitby.net>
;; Keywords: languages vhdl
;; WWW: http://www.iis.ee.ethz.ch/~zimmi/emacs/vhdl-mode.html
+;; Yoni Rabkin <yoni@rabkins.net> contacted the maintainer of this
+;; file on 18/3/2008, and the maintainer agreed that when a bug is
+;; filed in the Emacs bug reporting system against this file, a copy
+;; of the bug report be sent to the maintainer's email address.
+
(defconst vhdl-version "3.33.6"
"VHDL Mode version number.")
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Commentary:
;;; Code:
-;; XEmacs handling
-(defconst vhdl-xemacs (string-match "XEmacs" emacs-version)
- "Non-nil if XEmacs is used.")
;; Emacs 21+ handling
-(defconst vhdl-emacs-21 (and (<= 21 emacs-major-version) (not vhdl-xemacs))
+(defconst vhdl-emacs-21 (and (<= 21 emacs-major-version) (not (featurep 'xemacs)))
"Non-nil if GNU Emacs 21, 22, ... is used.")
-(defconst vhdl-emacs-22 (and (<= 22 emacs-major-version) (not vhdl-xemacs))
+(defconst vhdl-emacs-22 (and (<= 22 emacs-major-version) (not (featurep 'xemacs)))
"Non-nil if GNU Emacs 22, ... is used.")
(defvar compilation-file-regexp-alist)
;; add related general customizations
(custom-add-to-group 'vhdl-related 'hideshow 'custom-group)
-(if vhdl-xemacs
+(if (featurep 'xemacs)
(custom-add-to-group 'vhdl-related 'paren-mode 'custom-variable)
(custom-add-to-group 'vhdl-related 'paren-showing 'custom-group))
(custom-add-to-group 'vhdl-related 'ps-print 'custom-group)
(custom-add-to-group 'vhdl-related 'speedbar 'custom-group)
(custom-add-to-group 'vhdl-related 'line-number-mode 'custom-variable)
-(unless vhdl-xemacs
+(unless (featurep 'xemacs)
(custom-add-to-group 'vhdl-related 'transient-mark-mode 'custom-variable))
(custom-add-to-group 'vhdl-related 'user-full-name 'custom-variable)
(custom-add-to-group 'vhdl-related 'mail-host-address 'custom-variable)
(defun vhdl-keep-region-active ()
"Do whatever is necessary to keep the region active in XEmacs.
Ignore byte-compiler warnings you might see."
- (and (boundp 'zmacs-region-stays)
+ (and (featurep 'xemacs)
(setq zmacs-region-stays t)))
;; `wildcard-to-regexp' is included only in XEmacs 21
newstr)))
;; `itimer.el': idle timer bug fix in version 1.09 (XEmacs 21.1.9)
-(when (and vhdl-xemacs (string< itimer-version "1.09")
+(when (and (featurep 'xemacs) (string< itimer-version "1.09")
(not noninteractive))
(load "itimer")
(when (string< itimer-version "1.09")
(defun vhdl-show-messages ()
"Get *Messages* buffer to show recent messages."
(interactive)
- (display-buffer (if vhdl-xemacs " *Message-Log*" "*Messages*")))
+ (display-buffer (if (featurep 'xemacs) " *Message-Log*" "*Messages*")))
(defun vhdl-use-direct-instantiation ()
"Return whether direct instantiation is used."
(define-key vhdl-mode-map "\M-\C-u" 'vhdl-backward-up-list)
(define-key vhdl-mode-map "\M-\C-a" 'vhdl-backward-same-indent)
(define-key vhdl-mode-map "\M-\C-e" 'vhdl-forward-same-indent)
- (unless vhdl-xemacs ; would override `M-backspace' in XEmacs
+ (unless (featurep 'xemacs) ; would override `M-backspace' in XEmacs
(define-key vhdl-mode-map "\M-\C-h" 'vhdl-mark-defun))
(define-key vhdl-mode-map "\M-\C-q" 'vhdl-indent-sexp)
(define-key vhdl-mode-map "\M-^" 'vhdl-delete-indentation)
(define-key vhdl-mode-map "\C-c\C-p\C-i" 'vhdl-port-paste-instance)
(define-key vhdl-mode-map "\C-c\C-p\C-s" 'vhdl-port-paste-signals)
(define-key vhdl-mode-map "\C-c\C-p\M-c" 'vhdl-port-paste-constants)
- (if vhdl-xemacs ; `... C-g' not allowed in XEmacs
+ (if (featurep 'xemacs) ; `... C-g' not allowed in XEmacs
(define-key vhdl-mode-map "\C-c\C-p\M-g" 'vhdl-port-paste-generic-map)
(define-key vhdl-mode-map "\C-c\C-p\C-g" 'vhdl-port-paste-generic-map))
(define-key vhdl-mode-map "\C-c\C-p\C-z" 'vhdl-port-paste-initializations)
(define-key vhdl-mode-map "\C-c\C-s\C-b" 'vhdl-subprog-paste-body)
(define-key vhdl-mode-map "\C-c\C-s\C-c" 'vhdl-subprog-paste-call)
(define-key vhdl-mode-map "\C-c\C-s\C-f" 'vhdl-subprog-flatten)
- (define-key vhdl-mode-map "\C-c\C-c\C-n" 'vhdl-compose-new-component)
- (define-key vhdl-mode-map "\C-c\C-c\C-p" 'vhdl-compose-place-component)
- (define-key vhdl-mode-map "\C-c\C-c\C-w" 'vhdl-compose-wire-components)
- (define-key vhdl-mode-map "\C-c\C-c\C-f" 'vhdl-compose-configuration)
- (define-key vhdl-mode-map "\C-c\C-c\C-k" 'vhdl-compose-components-package)
- (define-key vhdl-mode-map "\C-cc" 'vhdl-comment-uncomment-region)
+ (define-key vhdl-mode-map "\C-c\C-m\C-n" 'vhdl-compose-new-component)
+ (define-key vhdl-mode-map "\C-c\C-m\C-p" 'vhdl-compose-place-component)
+ (define-key vhdl-mode-map "\C-c\C-m\C-w" 'vhdl-compose-wire-components)
+ (define-key vhdl-mode-map "\C-c\C-m\C-f" 'vhdl-compose-configuration)
+ (define-key vhdl-mode-map "\C-c\C-m\C-k" 'vhdl-compose-components-package)
+ (define-key vhdl-mode-map "\C-c\C-c" 'vhdl-comment-uncomment-region)
(define-key vhdl-mode-map "\C-c-" 'vhdl-comment-append-inline)
(define-key vhdl-mode-map "\C-c\M--" 'vhdl-comment-display-line)
(define-key vhdl-mode-map "\C-c\C-i\C-l" 'indent-according-to-mode)
(define-key vhdl-mode-map "\C-c\C-b" 'vhdl-beautify-buffer)
(define-key vhdl-mode-map "\C-c\C-u\C-s" 'vhdl-update-sensitivity-list-process)
(define-key vhdl-mode-map "\C-c\C-u\M-s" 'vhdl-update-sensitivity-list-buffer)
- (define-key vhdl-mode-map "\C-cf" 'vhdl-fontify-buffer)
- (define-key vhdl-mode-map "\C-cs" 'vhdl-statistics-buffer)
+ (define-key vhdl-mode-map "\C-c\C-i\C-f" 'vhdl-fontify-buffer)
+ (define-key vhdl-mode-map "\C-c\C-i\C-s" 'vhdl-statistics-buffer)
(define-key vhdl-mode-map "\C-c\M-m" 'vhdl-show-messages)
(define-key vhdl-mode-map "\C-c\C-h" 'vhdl-doc-mode)
(define-key vhdl-mode-map "\C-c\C-v" 'vhdl-version)
;; set up electric character functions to work with
;; `delete-selection-mode' (Emacs) and `pending-delete-mode' (XEmacs)
-(mapcar
+(mapc
(function
(lambda (sym)
(put sym 'delete-selection t) ; for `delete-selection-mode' (Emacs)
(or vars
(error "ERROR: Invalid VHDL indentation style `%s'" style))
;; set all the variables
- (mapcar
+ (mapc
(function
(lambda (varentry)
(let ((var (car varentry))
(skip-chars-forward " \t\n"))))
;; XEmacs hack: work around buggy `forward-comment' in XEmacs 21.4+
-(unless (and vhdl-xemacs (string< "21.2" emacs-version))
+(unless (and (featurep 'xemacs) (string< "21.2" emacs-version))
(defalias 'vhdl-forward-comment 'forward-comment))
;; This is the best we can do in Win-Emacs.
(when (and vhdl-progress-info (not noninteractive)
(< vhdl-progress-interval
(- (nth 1 (current-time)) (aref vhdl-progress-info 2))))
- (message (concat string "... (%2d%s)")
- (/ (* 100 (- pos (aref vhdl-progress-info 0)))
- (- (aref vhdl-progress-info 1)
- (aref vhdl-progress-info 0))) "%")
+ (let ((delta (- (aref vhdl-progress-info 1)
+ (aref vhdl-progress-info 0))))
+ (if (= 0 delta)
+ (message (concat string "... (100%s)") "%")
+ (message (concat string "... (%2d%s)")
+ (/ (* 100 (- pos (aref vhdl-progress-info 0)))
+ delta) "%")))
(aset vhdl-progress-info 2 (nth 1 (current-time)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(actual (vhdl-get-syntactic-context))
(expurgated))
;; remove the library unit symbols
- (mapcar
+ (mapc
(function
(lambda (elt)
(if (memq (car elt) '(entity configuration package
(progn (delete-region (point) (progn (end-of-line) (point)))
(vhdl-template-insert-date))
(unless noerror
- (error (concat "ERROR: Modification date prefix string \""
- vhdl-modify-date-prefix-string "\" not found")))))))
+ (error "ERROR: Modification date prefix string \"%s\" not found"
+ vhdl-modify-date-prefix-string))))))
+
(defun vhdl-template-modify-noerror ()
"Call `vhdl-template-modify' with NOERROR non-nil."
"Query a decision from the user."
(let ((start (point)))
(when string (vhdl-insert-keyword (concat string " ")))
- (message prompt)
+ (message "%s" (or prompt ""))
(let ((char (read-char)))
(delete-region start (point))
(if (and optional (eq char ?\r))
(defun vhdl-ps-print-init ()
"Initialize postscript printing."
- (if vhdl-xemacs
+ (if (featurep 'xemacs)
(when (boundp 'ps-print-color-p)
(vhdl-ps-print-settings))
(make-local-variable 'ps-print-hook)
(save-excursion (beginning-of-line) (looking-at "[0-9]+:"))]
["Rescan Directory" vhdl-speedbar-rescan-hierarchy
:active (save-excursion (beginning-of-line) (looking-at "[0-9]+:"))
- ,(if vhdl-xemacs :active :visible) (not vhdl-speedbar-show-projects)]
+ ,(if (featurep 'xemacs) :active :visible) (not vhdl-speedbar-show-projects)]
["Rescan Project" vhdl-speedbar-rescan-hierarchy
:active (save-excursion (beginning-of-line) (looking-at "[0-9]+:"))
- ,(if vhdl-xemacs :active :visible) vhdl-speedbar-show-projects]
+ ,(if (featurep 'xemacs) :active :visible) vhdl-speedbar-show-projects]
["Save Caches" vhdl-save-caches vhdl-updated-project-list])))
;; hook-ups
(speedbar-add-expansion-list
(goto-line (cdr token))
(recenter))
(vhdl-speedbar-update-current-unit t t)
- (speedbar-set-timer speedbar-update-speed)
+ (speedbar-set-timer dframe-update-speed)
(speedbar-maybee-jump-to-attached-frame))))
(defun vhdl-speedbar-port-copy ()
(assoc (car sublist) regexp-alist))
(setq regexp-alist (cons (list (nth 0 sublist)
(if (= 0 (nth 1 sublist))
- (if vhdl-xemacs 9 nil)
+ (if (featurep 'xemacs) 9 nil)
(nth 1 sublist))
(nth 2 sublist) (nth 3 sublist))
regexp-alist)))
(defun vhdl-doc-variable (variable)
"Display VARIABLE's documentation in *Help* buffer."
(interactive)
- (unless vhdl-xemacs
+ (unless (featurep 'xemacs)
(help-setup-xref (list #'vhdl-doc-variable variable) (interactive-p)))
(with-output-to-temp-buffer
(if (fboundp 'help-buffer) (help-buffer) "*Help*")
(defun vhdl-doc-mode ()
"Display VHDL Mode documentation in *Help* buffer."
(interactive)
- (unless vhdl-xemacs
+ (unless (featurep 'xemacs)
(help-setup-xref (list #'vhdl-doc-mode) (interactive-p)))
(with-output-to-temp-buffer
(if (fboundp 'help-buffer) (help-buffer) "*Help*")