merge trunk
[bpt/emacs.git] / lisp / progmodes / vhdl-mode.el
index deac855..b422cf6 100644 (file)
@@ -1,6 +1,6 @@
 ;;; vhdl-mode.el --- major mode for editing VHDL code
 
-;; Copyright (C) 1992-201 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2014 Free Software Foundation, Inc.
 
 ;; Authors:     Reto Zimmermann <reto@gnu.org>
 ;;              Rodney J. Whitby <software.vhdl-mode@rwhitby.net>
 ;; 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"
+(defconst vhdl-version "3.34.2"
   "VHDL Mode version number.")
 
-(defconst vhdl-time-stamp "2005-08-30"
+(defconst vhdl-time-stamp "2012-11-21"
   "VHDL Mode time stamp for last update.")
 
 ;; This file is part of GNU Emacs.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Emacs Versions
 
-;; supported: GNU Emacs 20.X/21.X/22.X, XEmacs 20.X/21.X
-;; tested on: GNU Emacs 20.4, XEmacs 21.1 (marginally)
+;; this updated version was only tested on: GNU Emacs 20.4
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Installation
 
-;; Prerequisites:  GNU Emacs 20.X/21.X/22.X, XEmacs 20.X/21.X.
+;; Prerequisites:  GNU Emacs 20.X/21.X/22.X/23.X, XEmacs 20.X/21.X.
 
 ;; Put `vhdl-mode.el' into the `site-lisp' directory of your Emacs installation
 ;; or into an arbitrary directory that is added to the load path by the
 ;; following line in your Emacs start-up file `.emacs':
 
-;;   (setq load-path (cons (expand-file-name "<directory-name>") load-path))
+;;   (push (expand-file-name "<directory-name>") load-path)
 
 ;; If you already have the compiled `vhdl-mode.elc' file, put it in the same
 ;; directory.  Otherwise, byte-compile the source file:
 
 ;; Add the following lines to the `site-start.el' file in the `site-lisp'
 ;; directory of your Emacs installation or to your Emacs start-up file `.emacs'
-;; (not required in Emacs 20.X):
+;; (not required in Emacs 20 and higher):
 
 ;;   (autoload 'vhdl-mode "vhdl-mode" "VHDL Mode" t)
-;;   (setq auto-mode-alist (cons '("\\.vhdl?\\'" . vhdl-mode) auto-mode-alist))
+;;   (push '("\\.vhdl?\\'" . vhdl-mode) auto-mode-alist)
 
 ;; More detailed installation instructions are included in the official
 ;; VHDL Mode distribution.
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Acknowledgements
+;; Acknowledgments
 
 ;; Electrification ideas by Bob Pack <rlpst@cislabs.pitt.edu>
 ;; and Steve Grout.
 ;; Emacs 21+ handling
 (defconst vhdl-emacs-21 (and (<= 21 emacs-major-version) (not (featurep 'xemacs)))
   "Non-nil if GNU Emacs 21, 22, ... is used.")
+;; Emacs 22+ handling
 (defconst vhdl-emacs-22 (and (<= 22 emacs-major-version) (not (featurep 'xemacs)))
   "Non-nil if GNU Emacs 22, ... is used.")
 
@@ -184,7 +184,7 @@ Examples:
   \".*\"           \"\"      inserts empty string")
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; User variables
+;; User variables (customization options)
 
 (defgroup vhdl nil
   "Customizations for VHDL Mode."
@@ -198,7 +198,7 @@ Examples:
   :group 'vhdl)
 
 (defcustom vhdl-indent-tabs-mode nil
-  "*Non-nil means indentation can insert tabs.
+  "Non-nil means indentation can insert tabs.
 Overrides local variable `indent-tabs-mode'."
   :type 'boolean
   :group 'vhdl-mode)
@@ -210,11 +210,25 @@ Overrides local variable `indent-tabs-mode'."
 
 (defcustom vhdl-compiler-alist
   '(
+    ;;     60:       docal  <= false;
+    ;;               ^^^^^
+    ;; [Error] Assignment error: variable is illegal target of signal assignment
+    ("ADVance MS" "vacom" "-work \\1" "make" "-f \\1"
+     nil "valib \\1; vamap \\2 \\1" "./" "work/" "Makefile" "adms"
+     ("^\\s-+\\([0-9]+\\):\\s-+" nil 1 nil) ("Compiling file \\(.+\\)" 1)
+     ("ENTI/\\1.vif" "ARCH/\\1-\\2.vif" "CONF/\\1.vif"
+      "PACK/\\1.vif" "BODY/\\1.vif" upcase))
+    ;; Aldec
+    ;; COMP96 ERROR COMP96_0018: "Identifier expected." "test.vhd" 66 3
+    ("Aldec" "vcom" "-work \\1" "make" "-f \\1"
+     nil "vlib \\1; vmap \\2 \\1" "./" "work/" "Makefile" "aldec"
+     (".* ERROR [^:]+: \".*\" \"\\([^ \\t\\n]+\\)\" \\([0-9]+\\) \\([0-9]+\\)" 1 2 3) ("" 0)
+     nil)
     ;; Cadence Leapfrog: cv -file test.vhd
     ;; duluth: *E,430 (test.vhd,13): identifier (POSITIV) is not declared
     ("Cadence Leapfrog" "cv" "-work \\1 -file" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "leapfrog"
-     ("duluth: \\*E,[0-9]+ (\\(.+\\),\\([0-9]+\\)):" 1 2 0) ("" 0)
+     ("duluth: \\*E,[0-9]+ (\\([^ \\t\\n]+\\),\\([0-9]+\\)):" 1 2 nil) ("" 0)
      ("\\1/entity" "\\2/\\1" "\\1/configuration"
       "\\1/package" "\\1/body" downcase))
     ;; Cadence Affirma NC vhdl: ncvhdl test.vhd
@@ -222,46 +236,69 @@ Overrides local variable `indent-tabs-mode'."
     ;; (PLL_400X_TOP) is not declared [10.3].
     ("Cadence NC" "ncvhdl" "-work \\1" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "ncvhdl"
-     ("ncvhdl_p: \\*E,\\w+ (\\(.+\\),\\([0-9]+\\)|\\([0-9]+\\)):" 1 2 3) ("" 0)
+     ("ncvhdl_p: \\*E,\\w+ (\\([^ \\t\\n]+\\),\\([0-9]+\\)|\\([0-9]+\\)):" 1 2 3) ("" 0)
      ("\\1/entity/pc.db" "\\2/\\1/pc.db" "\\1/configuration/pc.db"
       "\\1/package/pc.db" "\\1/body/pc.db" downcase))
+    ;; ghdl vhdl: ghdl test.vhd
+    ("GHDL" "ghdl" "-i --workdir=\\1 --ieee=synopsys -fexplicit " "make" "-f \\1"
+     nil "mkdir \\1" "./" "work/" "Makefile" "ghdl"
+     ("ghdl_p: \\*E,\\w+ (\\([^ \\t\\n]+\\),\\([0-9]+\\)|\\([0-9]+\\)):" 1 2 3) ("" 0)
+     ("\\1/entity" "\\2/\\1" "\\1/configuration"
+      "\\1/package" "\\1/body" downcase))
+    ;; IBM Compiler
+    ;; 00 COACHDL* | [CCHDL-1]: File: adder.vhd, line.column: 120.6
+    ("IBM Compiler" "g2tvc" "-src" "precomp" "\\1"
+     nil "mkdir \\1" "./" "work/" "Makefile" "ibm"
+     ("[0-9]+ COACHDL.*: File: \\([^ \\t\\n]+\\), line.column: \\([0-9]+\\).\\([0-9]+\\)" 1 2 3) (" " 0)
+     nil)
     ;; Ikos Voyager: analyze test.vhd
     ;; analyze test.vhd
     ;; E L4/C5:        this library unit is inaccessible
     ("Ikos" "analyze" "-l \\1" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "ikos"
-     ("E L\\([0-9]+\\)/C\\([0-9]+\\):" 0 1 2)
+     ("E L\\([0-9]+\\)/C\\([0-9]+\\):" nil 1 2)
      ("^analyze +\\(.+ +\\)*\\(.+\\)$" 2)
      nil)
     ;; ModelSim, Model Technology: vcom test.vhd
     ;; ERROR: test.vhd(14): Unknown identifier: positiv
     ;; WARNING[2]: test.vhd(85): Possible infinite loop
+    ;; ** Warning: [4] ../src/emacsvsim.vhd(43): An abstract ...
     ;; ** Error: adder.vhd(190): Unknown identifier: ctl_numb
     ("ModelSim" "vcom" "-93 -work \\1" "make" "-f \\1"
      nil "vlib \\1; vmap \\2 \\1" "./" "work/" "Makefile" "modelsim"
-     ("\\(ERROR\\|WARNING\\|\\*\\* Error\\|\\*\\* Warning\\)[^:]*: \\(.+\\)(\\([0-9]+\\)):" 2 3 0) ("" 0)
+     ("\\(ERROR\\|WARNING\\|\\*\\* Error\\|\\*\\* Warning\\)[^:]*:\\( *\[[0-9]+\]\\)? \\([^ \\t\\n]+\\)(\\([0-9]+\\)):" 3 4 nil) ("" 0)
      ("\\1/_primary.dat" "\\2/\\1.dat" "\\1/_primary.dat"
       "\\1/_primary.dat" "\\1/body.dat" downcase))
     ;; ProVHDL, Synopsys LEDA: provhdl -w work -f test.vhd
     ;; test.vhd:34: error message
     ("LEDA ProVHDL" "provhdl" "-w \\1 -f" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "provhdl"
-     ("\\([^ \t\n]+\\):\\([0-9]+\\): " 1 2 0) ("" 0)
+     ("\\([^ \\t\\n]+\\):\\([0-9]+\\): " 1 2 nil) ("" 0)
      ("ENTI/\\1.vif" "ARCH/\\1-\\2.vif" "CONF/\\1.vif"
       "PACK/\\1.vif" "BODY/BODY-\\1.vif" upcase))
+    ;; Quartus compiler
+    ;; Error: VHDL error at dvi2sdi.vhd(473): object k2_alto_out_lvl is used
+    ;; Error: Verilog HDL syntax error at otsuif_v1_top.vhd(147) near text
+    ;; Error: VHDL syntax error at otsuif_v1_top.vhd(147): clk_ is an illegal
+    ;; Error: VHDL Use Clause error at otsuif_v1_top.vhd(455): design library
+    ;; Warning: VHDL Process Statement warning at dvi2sdi_tst.vhd(172): ...
+    ("Quartus" "make" "-work \\1" "make" "-f \\1"
+     nil "mkdir \\1" "./" "work/" "Makefile" "quartus"
+     ("\\(Error\\|Warning\\): .* \\([^ \\t\\n]+\\)(\\([0-9]+\\))" 2 3 nil) ("" 0)
+     nil)
     ;; QuickHDL, Mentor Graphics: qvhcom test.vhd
     ;; ERROR: test.vhd(24): near "dnd": expecting: END
     ;; WARNING[4]: test.vhd(30): A space is required between ...
     ("QuickHDL" "qvhcom" "-work \\1" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "quickhdl"
-     ("\\(ERROR\\|WARNING\\)[^:]*: \\(.+\\)(\\([0-9]+\\)):" 2 3 0) ("" 0)
+     ("\\(ERROR\\|WARNING\\)[^:]*: \\([^ \\t\\n]+\\)(\\([0-9]+\\)):" 2 3 nil) ("" 0)
      ("\\1/_primary.dat" "\\2/\\1.dat" "\\1/_primary.dat"
       "\\1/_primary.dat" "\\1/body.dat" downcase))
     ;; Savant: scram -publish-cc test.vhd
     ;; test.vhd:87: _set_passed_through_out_port(IIR_Boolean) not defined for
     ("Savant" "scram" "-publish-cc -design-library-name \\1" "make" "-f \\1"
      nil "mkdir \\1" "./" "work._savant_lib/" "Makefile" "savant"
-     ("\\([^ \t\n]+\\):\\([0-9]+\\): " 1 2 0) ("" 0)
+     ("\\([^ \\t\\n]+\\):\\([0-9]+\\): " 1 2 nil) ("" 0)
      ("\\1_entity.vhdl" "\\2_secondary_units._savant_lib/\\2_\\1.vhdl"
       "\\1_config.vhdl" "\\1_package.vhdl"
       "\\1_secondary_units._savant_lib/\\1_package_body.vhdl" downcase))
@@ -269,39 +306,39 @@ Overrides local variable `indent-tabs-mode'."
     ;; Error: CSVHDL0002: test.vhd: (line 97): Invalid prefix
     ("Simili" "vhdlp" "-work \\1" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "simili"
-     ("\\(Error\\|Warning\\): \\w+: \\(.+\\): (line \\([0-9]+\\)): " 2 3 0) ("" 0)
+     ("\\(Error\\|Warning\\): \\w+: \\([^ \\t\\n]+\\): (line \\([0-9]+\\)): " 2 3 nil) ("" 0)
      ("\\1/prim.var" "\\2/_\\1.var" "\\1/prim.var"
       "\\1/prim.var" "\\1/_body.var" downcase))
     ;; Speedwave (Innoveda): analyze -libfile vsslib.ini -src test.vhd
     ;;     ERROR[11]::File test.vhd Line 100: Use of undeclared identifier
     ("Speedwave" "analyze" "-libfile vsslib.ini -src" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "speedwave"
-     ("^ *ERROR\[[0-9]+\]::File \\(.+\\) Line \\([0-9]+\\):" 1 2 0) ("" 0)
+     ("^ *ERROR\[[0-9]+\]::File \\([^ \\t\\n]+\\) Line \\([0-9]+\\):" 1 2 nil) ("" 0)
      nil)
     ;; Synopsys, VHDL Analyzer (sim): vhdlan -nc test.vhd
     ;; **Error: vhdlan,703 test.vhd(22): OTHERS is not legal in this context.
     ("Synopsys" "vhdlan" "-nc -work \\1" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "synopsys"
-     ("\\*\\*Error: vhdlan,[0-9]+ \\(.+\\)(\\([0-9]+\\)):" 1 2 0) ("" 0)
+     ("\\*\\*Error: vhdlan,[0-9]+ \\([^ \\t\\n]+\\)(\\([0-9]+\\)):" 1 2 nil) ("" 0)
      ("\\1.sim" "\\2__\\1.sim" "\\1.sim" "\\1.sim" "\\1__.sim" upcase))
     ;; Synopsys, VHDL Analyzer (syn): vhdlan -nc -spc test.vhd
     ;; **Error: vhdlan,703 test.vhd(22): OTHERS is not legal in this context.
     ("Synopsys Design Compiler" "vhdlan" "-nc -spc -work \\1" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "synopsys_dc"
-     ("\\*\\*Error: vhdlan,[0-9]+ \\(.+\\)(\\([0-9]+\\)):" 1 2 0) ("" 0)
+     ("\\*\\*Error: vhdlan,[0-9]+ \\([^ \\t\\n]+\\)(\\([0-9]+\\)):" 1 2 nil) ("" 0)
      ("\\1.syn" "\\2__\\1.syn" "\\1.syn" "\\1.syn" "\\1__.syn" upcase))
     ;; Synplify:
     ;; @W:"test.vhd":57:8:57:9|Optimizing register bit count_x(5) to a constant 0
     ("Synplify" "n/a" "n/a" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "synplify"
-     ("@[EWN]:\"\\(.+\\)\":\\([0-9]+\\):\\([0-9]+\\):" 1 2 3) ("" 0)
+     ("@[EWN]:\"\\([^ \\t\\n]+\\)\":\\([0-9]+\\):\\([0-9]+\\):" 1 2 3) ("" 0)
      nil)
     ;; Vantage: analyze -libfile vsslib.ini -src test.vhd
     ;;     Compiling "test.vhd" line 1...
     ;; **Error: LINE 49 *** No aggregate value is valid in this context.
     ("Vantage" "analyze" "-libfile vsslib.ini -src" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "vantage"
-     ("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" 0 1 0)
+     ("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" nil 1 nil)
      ("^ *Compiling \"\\(.+\\)\" " 1)
      nil)
     ;; VeriBest: vc vhdl test.vhd
@@ -311,18 +348,24 @@ Overrides local variable `indent-tabs-mode'."
     ;; [Error] Name BITA is unknown
     ("VeriBest" "vc" "vhdl" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "veribest"
-     ("^ +\\([0-9]+\\): +[^ ]" 0 1 0) ("" 0)
+     ("^ +\\([0-9]+\\): +[^ ]" nil 1 nil) ("" 0)
      nil)
     ;; Viewlogic: analyze -libfile vsslib.ini -src test.vhd
     ;;     Compiling "test.vhd" line 1...
     ;; **Error: LINE 49 *** No aggregate value is valid in this context.
     ("Viewlogic" "analyze" "-libfile vsslib.ini -src" "make" "-f \\1"
      nil "mkdir \\1" "./" "work/" "Makefile" "viewlogic"
-     ("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" 0 1 0)
+     ("\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" nil 1 nil)
      ("^ *Compiling \"\\(.+\\)\" " 1)
      nil)
+    ;; Xilinx XST:
+    ;; ERROR:HDLParsers:164 - "test.vhd" Line 3. parse error
+    ("Xilinx XST" "xflow" "" "make" "-f \\1"
+     nil "mkdir \\1" "./" "work/" "Makefile" "xilinx"
+     ("^ERROR:HDLParsers:[0-9]+ - \"\\([^ \\t\\n]+\\)\" Line \\([0-9]+\\)\." 1 2 nil) ("" 0)
+     nil)
     )
-  "*List of available VHDL compilers and their properties.
+  "List of available VHDL compilers and their properties.
 Each list entry specifies the following items for a compiler:
 Compiler:
   Compiler name    : name used in option `vhdl-compiler' to choose compiler
@@ -405,9 +448,13 @@ NOTE: Activate new error and file message regexps and reflect the new setting
                (string :tag "ID string          ")
                (list :tag "Error message" :indent 4
                      (regexp  :tag "Regexp           ")
-                     (integer :tag "File subexp index")
+                     (choice  :tag "File subexp      "
+                             (integer :tag "Index")
+                             (const :tag "No file name" nil))
                      (integer :tag "Line subexp index")
-                     (integer :tag "Column subexp idx"))
+                     (choice  :tag "Column subexp    "
+                             (integer :tag "Index")
+                             (const :tag "No column number" nil)))
                (list :tag "File message" :indent 4
                      (regexp  :tag "Regexp           ")
                      (integer :tag "File subexp index"))
@@ -426,20 +473,21 @@ NOTE: Activate new error and file message regexps and reflect the new setting
                                      (const :tag "Downcase" downcase))))))
   :set (lambda (variable value)
         (vhdl-custom-set variable value 'vhdl-update-mode-menu))
+  :version "24.4"
   :group 'vhdl-compile)
 
-(defcustom vhdl-compiler "ModelSim"
-  "*Specifies the VHDL compiler to be used for syntax analysis.
+(defcustom vhdl-compiler "GHDL"
+  "Specifies the VHDL compiler to be used for syntax analysis.
 Select a compiler name from the ones defined in option `vhdl-compiler-alist'."
   :type (let ((alist vhdl-compiler-alist) list)
          (while alist
-           (setq list (cons (list 'const (caar alist)) list))
+           (push (list 'const (caar alist)) list)
            (setq alist (cdr alist)))
          (append '(choice) (nreverse list)))
   :group 'vhdl-compile)
 
 (defcustom vhdl-compile-use-local-error-regexp t
-  "*Non-nil means use buffer-local `compilation-error-regexp-alist'.
+  "Non-nil means use buffer-local `compilation-error-regexp-alist'.
 In this case, only error message regexps for VHDL compilers are active if
 compilation is started from a VHDL buffer.  Otherwise, the error message
 regexps are appended to the predefined global regexps, and all regexps are
@@ -450,8 +498,20 @@ NOTE: Activate the new setting by restarting Emacs."
   :type 'boolean
   :group 'vhdl-compile)
 
+(defcustom vhdl-makefile-default-targets '("all" "clean" "library")
+  "List of default target names in Makefiles.
+Automatically generated Makefiles include three default targets to compile
+the entire design, clean the entire design and to create the design library.
+This option allows to change the names of these targets to avoid conflicts
+with other user Makefiles."
+  :type '(list (string :tag "Compile entire design")
+              (string :tag "Clean entire design  ")
+              (string :tag "Create design library"))
+  :version "24.3"
+  :group 'vhdl-compile)
+
 (defcustom vhdl-makefile-generation-hook nil
-  "*Functions to run at the end of Makefile generation.
+  "Functions to run at the end of Makefile generation.
 Allows to insert user specific parts into a Makefile.
 
 Example:
@@ -462,7 +522,7 @@ Example:
   :group 'vhdl-compile)
 
 (defcustom vhdl-default-library "work"
-  "*Name of default library.
+  "Name of default library.
 Is overwritten by project settings if a project is active."
   :type 'string
   :group 'vhdl-compile)
@@ -488,7 +548,7 @@ Is overwritten by project settings if a project is active."
 -- This is a multi-line project description
 -- that can be used as a project dependent part of the file header.
 "))
-  "*List of projects and their properties.
+  "List of projects and their properties.
   Name             : name used in option `vhdl-project' to choose project
   Title            : title of project (single-line string)
   Default directory: default project directory (absolute path)
@@ -566,7 +626,7 @@ NOTE: Reflect the new setting in the choice list of option `vhdl-project'
                 (list :tag "Compiler" :indent 6
                       ,(let ((alist vhdl-compiler-alist) list)
                          (while alist
-                           (setq list (cons (list 'const (caar alist)) list))
+                           (push (list 'const (caar alist)) list)
                            (setq alist (cdr alist)))
                          (append '(choice :tag "Compiler name")
                                  (nreverse list)))
@@ -594,21 +654,21 @@ NOTE: Reflect the new setting in the choice list of option `vhdl-project'
   :group 'vhdl-project)
 
 (defcustom vhdl-project nil
-  "*Specifies the default for the current project.
+  "Specifies the default for the current project.
 Select a project name from the ones defined in option `vhdl-project-alist'.
 Is used to determine the project title and description to be inserted in file
 headers and the source files/directories to be scanned in the hierarchy
 browser.  The current project can also be changed temporarily in the menu."
   :type (let ((alist vhdl-project-alist) list)
          (while alist
-           (setq list (cons (list 'const (caar alist)) list))
+           (push (list 'const (caar alist)) list)
            (setq alist (cdr alist)))
          (append '(choice (const :tag "None" nil) (const :tag "--"))
                  (nreverse list)))
   :group 'vhdl-project)
 
 (defcustom vhdl-project-file-name '("\\1.prj")
-  "*List of file names/paths for importing/exporting project setups.
+  "List of file names/paths for importing/exporting project setups.
 \"\\1\" is replaced by the project name (SPC is replaced by `_'), \"\\2\" is
 replaced by the user name (allows to have user-specific project setups).
 The first entry is used as file name to import/export individual project
@@ -624,7 +684,7 @@ in global directories)."
   :group 'vhdl-project)
 
 (defcustom vhdl-project-auto-load '(startup)
-  "*Automatically load project setups from files.
+  "Automatically load project setups from files.
 All project setup files that match the file names specified in option
 `vhdl-project-file-name' are automatically loaded.  The project of the
 \(alphabetically) last loaded setup of the first `vhdl-project-file-name'
@@ -635,7 +695,7 @@ A project setup file can be obtained by exporting a project (see menu).
   :group 'vhdl-project)
 
 (defcustom vhdl-project-sort t
-  "*Non-nil means projects are displayed in alphabetical order."
+  "Non-nil means projects are displayed in alphabetical order."
   :type 'boolean
   :group 'vhdl-project)
 
@@ -647,11 +707,11 @@ A project setup file can be obtained by exporting a project (see menu).
   :group 'vhdl-port
   :group 'vhdl-compose)
 
-(defcustom vhdl-standard '(87 nil)
-  "*VHDL standards used.
+(defcustom vhdl-standard '(93 nil)
+  "VHDL standards used.
 Basic standard:
   VHDL'87      : IEEE Std 1076-1987
-  VHDL'93      : IEEE Std 1076-1993
+  VHDL'93/02   : IEEE Std 1076-1993/2002
 Additional standards:
   VHDL-AMS     : IEEE Std 1076.1 (analog-mixed-signal)
   Math packages: IEEE Std 1076.2 (`math_real', `math_complex')
@@ -660,7 +720,7 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
       \"Activate Options\"."
   :type '(list (choice :tag "Basic standard"
                       (const :tag "VHDL'87" 87)
-                      (const :tag "VHDL'93" 93))
+                      (const :tag "VHDL'93/02" 93))
               (set :tag "Additional standards" :indent 2
                    (const :tag "VHDL-AMS" ams)
                    (const :tag "Math packages" math)))
@@ -675,13 +735,13 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
   :group 'vhdl-style)
 
 (defcustom vhdl-basic-offset 2
-  "*Amount of basic offset used for indentation.
+  "Amount of basic offset used for indentation.
 This value is used by + and - symbols in `vhdl-offsets-alist'."
   :type 'integer
   :group 'vhdl-style)
 
 (defcustom vhdl-upper-case-keywords nil
-  "*Non-nil means convert keywords to upper case.
+  "Non-nil means convert keywords to upper case.
 This is done when typed or expanded or by the fix case functions."
   :type 'boolean
   :set (lambda (variable value)
@@ -689,7 +749,7 @@ This is done when typed or expanded or by the fix case functions."
   :group 'vhdl-style)
 
 (defcustom vhdl-upper-case-types nil
-  "*Non-nil means convert standardized types to upper case.
+  "Non-nil means convert standardized types to upper case.
 This is done when expanded or by the fix case functions."
   :type 'boolean
   :set (lambda (variable value)
@@ -697,7 +757,7 @@ This is done when expanded or by the fix case functions."
   :group 'vhdl-style)
 
 (defcustom vhdl-upper-case-attributes nil
-  "*Non-nil means convert standardized attributes to upper case.
+  "Non-nil means convert standardized attributes to upper case.
 This is done when expanded or by the fix case functions."
   :type 'boolean
   :set (lambda (variable value)
@@ -705,7 +765,7 @@ This is done when expanded or by the fix case functions."
   :group 'vhdl-style)
 
 (defcustom vhdl-upper-case-enum-values nil
-  "*Non-nil means convert standardized enumeration values to upper case.
+  "Non-nil means convert standardized enumeration values to upper case.
 This is done when expanded or by the fix case functions."
   :type 'boolean
   :set (lambda (variable value)
@@ -713,7 +773,7 @@ This is done when expanded or by the fix case functions."
   :group 'vhdl-style)
 
 (defcustom vhdl-upper-case-constants t
-  "*Non-nil means convert standardized constants to upper case.
+  "Non-nil means convert standardized constants to upper case.
 This is done when expanded."
   :type 'boolean
   :set (lambda (variable value)
@@ -721,7 +781,7 @@ This is done when expanded."
   :group 'vhdl-style)
 
 (defcustom vhdl-use-direct-instantiation 'standard
-  "*Non-nil means use VHDL'93 direct component instantiation.
+  "Non-nil means use VHDL'93 direct component instantiation.
   Never   : never
   Standard: only in VHDL standards that allow it (VHDL'93 and higher)
   Always  : always"
@@ -730,6 +790,15 @@ This is done when expanded."
                 (const :tag "Always" always))
   :group 'vhdl-style)
 
+(defcustom vhdl-array-index-record-field-in-sensitivity-list t
+  "Non-nil means include array indices / record fields in sensitivity list.
+If a signal read in a process is a record field or pointed to by an array
+index, the record field or array index is included with the record name in
+the sensitivity list (e.g. \"in1(0)\", \"in2.f0\").
+Otherwise, only the record name is included (e.g. \"in1\", \"in2\")."
+  :type 'boolean
+  :version "24.3"
+  :group 'vhdl-style)
 
 (defgroup vhdl-naming nil
   "Customizations for naming conventions."
@@ -737,7 +806,7 @@ This is done when expanded."
 
 (defcustom vhdl-entity-file-name '(".*" . "\\&")
   (concat
-   "*Specifies how the entity file name is obtained.
+   "Specifies how the entity file name is obtained.
 The entity file name can be obtained by modifying the entity name (e.g.
 attaching or stripping off a substring).  The file extension is automatically
 taken from the file name of the current buffer."
@@ -749,7 +818,7 @@ taken from the file name of the current buffer."
 
 (defcustom vhdl-architecture-file-name '("\\(.*\\) \\(.*\\)" . "\\1_\\2")
   (concat
-   "*Specifies how the architecture file name is obtained.
+   "Specifies how the architecture file name is obtained.
 The architecture file name can be obtained by modifying the entity
 and/or architecture name (e.g. attaching or stripping off a substring).  The
 file extension is automatically taken from the file name of the current
@@ -764,7 +833,7 @@ access to both names (see default setting as example)."
 
 (defcustom vhdl-configuration-file-name '(".*" . "\\&")
   (concat
-   "*Specifies how the configuration file name is obtained.
+   "Specifies how the configuration file name is obtained.
 The configuration file name can be obtained by modifying the configuration
 name (e.g. attaching or stripping off a substring).  The file extension is
 automatically taken from the file name of the current buffer."
@@ -776,7 +845,7 @@ automatically taken from the file name of the current buffer."
 
 (defcustom vhdl-package-file-name '(".*" . "\\&")
   (concat
-   "*Specifies how the package file name is obtained.
+   "Specifies how the package file name is obtained.
 The package file name can be obtained by modifying the package name (e.g.
 attaching or stripping off a substring).  The file extension is automatically
 taken from the file name of the current buffer.  Package files can be created
@@ -789,7 +858,7 @@ file name."
   :group 'vhdl-compose)
 
 (defcustom vhdl-file-name-case 'identity
-  "*Specifies how to change case for obtaining file names.
+  "Specifies how to change case for obtaining file names.
 When deriving a file name from a VHDL unit name, case can be changed as
 follows:
   As Is:      case is not changed (taken as is)
@@ -809,7 +878,7 @@ follows:
   :group 'vhdl)
 
 (defcustom vhdl-electric-keywords '(vhdl user)
-  "*Type of keywords for which electrification is enabled.
+  "Type of keywords for which electrification is enabled.
   VHDL keywords: invoke built-in templates
   User keywords: invoke user models (see option `vhdl-model-alist')"
   :type '(set (const :tag "VHDL keywords" vhdl)
@@ -819,7 +888,7 @@ follows:
   :group 'vhdl-template)
 
 (defcustom vhdl-optional-labels 'process
-  "*Constructs for which labels are to be queried.
+  "Constructs for which labels are to be queried.
 Template generators prompt for optional labels for:
   None          : no constructs
   Processes only: processes only (also procedurals in VHDL-AMS)
@@ -830,7 +899,7 @@ Template generators prompt for optional labels for:
   :group 'vhdl-template)
 
 (defcustom vhdl-insert-empty-lines 'unit
-  "*Specifies whether to insert empty lines in some templates.
+  "Specifies whether to insert empty lines in some templates.
 This improves readability of code.  Empty lines are inserted in:
   None             : no constructs
   Design units only: entities, architectures, configurations, packages only
@@ -845,7 +914,7 @@ Replaces option `vhdl-additional-empty-lines'."
   :group 'vhdl-compose)
 
 (defcustom vhdl-argument-list-indent nil
-  "*Non-nil means indent argument lists relative to opening parenthesis.
+  "Non-nil means indent argument lists relative to opening parenthesis.
 That is, argument, association, and port lists start on the same line as the
 opening parenthesis and subsequent lines are indented accordingly.
 Otherwise, lists start on a new line and are indented as normal code."
@@ -855,7 +924,7 @@ Otherwise, lists start on a new line and are indented as normal code."
   :group 'vhdl-compose)
 
 (defcustom vhdl-association-list-with-formals t
-  "*Non-nil means write association lists with formal parameters.
+  "Non-nil means write association lists with formal parameters.
 Templates prompt for formal and actual parameters (ports/generics).
 When pasting component instantiations, formals are included.
 If nil, only a list of actual parameters is entered."
@@ -865,17 +934,17 @@ If nil, only a list of actual parameters is entered."
   :group 'vhdl-compose)
 
 (defcustom vhdl-conditions-in-parenthesis nil
-  "*Non-nil means place parenthesis around condition expressions."
+  "Non-nil means place parenthesis around condition expressions."
   :type 'boolean
   :group 'vhdl-template)
 
 (defcustom vhdl-zero-string "'0'"
-  "*String to use for a logic zero."
+  "String to use for a logic zero."
   :type 'string
   :group 'vhdl-template)
 
 (defcustom vhdl-one-string "'1'"
-  "*String to use for a logic one."
+  "String to use for a logic one."
   :type 'string
   :group 'vhdl-template)
 
@@ -906,7 +975,7 @@ If nil, only a list of actual parameters is entered."
 -------------------------------------------------------------------------------
 
 "
-  "*String or file to insert as file header.
+  "String or file to insert as file header.
 If the string specifies an existing file name, the contents of the file is
 inserted, otherwise the string itself is inserted as file header.
 Type `C-j' for newlines.
@@ -916,7 +985,8 @@ if the header needs to be version controlled.
 The following keywords for template generation are supported:
   <filename>    : replaced by the name of the buffer
   <author>      : replaced by the user name and email address
-                  \(`user-full-name', `mail-host-address', `user-mail-address')
+                  \(`user-full-name',`mail-host-address', `user-mail-address')
+  <authorfull>  : replaced by the user full name (`user-full-name')
   <login>       : replaced by user login name (`user-login-name')
   <company>     : replaced by contents of option `vhdl-company-name'
   <date>        : replaced by the current date
@@ -936,7 +1006,7 @@ dependent part of the file header and can also contain the above keywords."
   :group 'vhdl-header)
 
 (defcustom vhdl-file-footer ""
-  "*String or file to insert as file footer.
+  "String or file to insert as file footer.
 If the string specifies an existing file name, the contents of the file is
 inserted, otherwise the string itself is inserted as file footer (i.e. at
 the end of the file).
@@ -946,7 +1016,7 @@ The same keywords as in option `vhdl-file-header' can be used."
   :group 'vhdl-header)
 
 (defcustom vhdl-company-name ""
-  "*Name of company to insert in file header.
+  "Name of company to insert in file header.
 See option `vhdl-file-header'."
   :type 'string
   :group 'vhdl-header)
@@ -955,14 +1025,14 @@ See option `vhdl-file-header'."
 -------------------------------------------------------------------------------
 -- Copyright (c) <year> <company>
 "
-  "*Copyright string to insert in file header.
+  "Copyright string to insert in file header.
 Can be multi-line string (type `C-j' for newline) and contain other file
 header keywords (see option `vhdl-file-header')."
   :type 'string
   :group 'vhdl-header)
 
 (defcustom vhdl-platform-spec ""
-  "*Specification of VHDL platform to insert in file header.
+  "Specification of VHDL platform to insert in file header.
 The platform specification should contain names and versions of the
 simulation and synthesis tools used.
 See option `vhdl-file-header'."
@@ -970,7 +1040,7 @@ See option `vhdl-file-header'."
   :group 'vhdl-header)
 
 (defcustom vhdl-date-format "%Y-%m-%d"
-  "*Specifies the date format to use in the header.
+  "Specifies the date format to use in the header.
 This string is passed as argument to the command `format-time-string'.
 For more information on format strings, see the documentation for the
 `format-time-string' command (C-h f `format-time-string')."
@@ -978,7 +1048,7 @@ For more information on format strings, see the documentation for the
   :group 'vhdl-header)
 
 (defcustom vhdl-modify-date-prefix-string "-- Last update: "
-  "*Prefix string of modification date in VHDL file header.
+  "Prefix string of modification date in VHDL file header.
 If actualization of the modification date is called (menu,
 `\\[vhdl-template-modify]'), this string is searched and the rest
 of the line replaced by the current date."
@@ -986,7 +1056,7 @@ of the line replaced by the current date."
   :group 'vhdl-header)
 
 (defcustom vhdl-modify-date-on-saving t
-  "*Non-nil means update the modification date when the buffer is saved.
+  "Non-nil means update the modification date when the buffer is saved.
 Calls function `\\[vhdl-template-modify]').
 
 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
@@ -999,27 +1069,28 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
   "Customizations for sequential processes."
   :group 'vhdl-template)
 
-(defcustom vhdl-reset-kind 'async
-  "*Specifies which kind of reset to use in sequential processes."
+(defcustom  vhdl-reset-kind 'async
+  "Specifies which kind of reset to use in sequential processes."
   :type '(choice (const :tag "None" none)
                 (const :tag "Synchronous" sync)
-                (const :tag "Asynchronous" async))
+                (const :tag "Asynchronous" async)
+                (const :tag "Query" query))
   :group 'vhdl-sequential-process)
 
 (defcustom vhdl-reset-active-high nil
-  "*Non-nil means reset in sequential processes is active high.
+  "Non-nil means reset in sequential processes is active high.
 Otherwise, reset is active low."
   :type 'boolean
   :group 'vhdl-sequential-process)
 
 (defcustom vhdl-clock-rising-edge t
-  "*Non-nil means rising edge of clock triggers sequential processes.
+  "Non-nil means rising edge of clock triggers sequential processes.
 Otherwise, falling edge triggers."
   :type 'boolean
   :group 'vhdl-sequential-process)
 
 (defcustom vhdl-clock-edge-condition 'standard
-  "*Syntax of the clock edge condition.
+  "Syntax of the clock edge condition.
   Standard: \"clk'event and clk = '1'\"
   Function: \"rising_edge(clk)\""
   :type '(choice (const :tag "Standard" standard)
@@ -1027,12 +1098,12 @@ Otherwise, falling edge triggers."
   :group 'vhdl-sequential-process)
 
 (defcustom vhdl-clock-name ""
-  "*Name of clock signal to use in templates."
+  "Name of clock signal to use in templates."
   :type 'string
   :group 'vhdl-sequential-process)
 
 (defcustom vhdl-reset-name ""
-  "*Name of reset signal to use in templates."
+  "Name of reset signal to use in templates."
   :type 'string
   :group 'vhdl-sequential-process)
 
@@ -1054,7 +1125,7 @@ begin  -- process <label>
   end if;
 end process <label>;"
      "e" ""))
-  "*List of user models.
+  "List of user models.
 VHDL models (templates) can be specified by the user in this list.  They can be
 invoked from the menu, through key bindings (`C-c C-m ...'), or by keyword
 electrification (i.e. overriding existing or creating new keywords, see
@@ -1103,7 +1174,7 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
 
 (defcustom vhdl-compose-architecture-name '(".*" . "str")
   (concat
-   "*Specifies how the component architecture name is obtained.
+   "Specifies how the component architecture name is obtained.
 The component architecture name can be obtained by modifying the entity name
 \(e.g. attaching or stripping off a substring).
 If TO STRING is empty, the architecture name is queried."
@@ -1115,7 +1186,7 @@ If TO STRING is empty, the architecture name is queried."
 (defcustom vhdl-compose-configuration-name
   '("\\(.*\\) \\(.*\\)" . "\\1_\\2_cfg")
   (concat
-   "*Specifies how the configuration name is obtained.
+   "Specifies how the configuration name is obtained.
 The configuration name can be obtained by modifying the entity and/or
 architecture name (e.g. attaching or stripping off a substring).  The string
 that is matched against the regexp is the concatenation of the entity and the
@@ -1129,7 +1200,7 @@ default setting as example)."
 (defcustom vhdl-components-package-name
   '((".*" . "\\&_components") . "components")
   (concat
-   "*Specifies how the name for the components package is obtained.
+   "Specifies how the name for the components package is obtained.
 The components package is a package containing all component declarations for
 the current design.  Its name can be obtained by modifying the project name
 \(e.g. attaching or stripping off a substring).  If no project is defined, the
@@ -1142,19 +1213,19 @@ DIRECTORY entry is chosen."
   :group 'vhdl-compose)
 
 (defcustom vhdl-use-components-package nil
-  "*Non-nil means use a separate components package for component declarations.
+  "Non-nil means use a separate components package for component declarations.
 Otherwise, component declarations are inserted and searched for in the
 architecture declarative parts."
   :type 'boolean
   :group 'vhdl-compose)
 
 (defcustom vhdl-compose-include-header t
-  "*Non-nil means include a header in automatically generated files."
+  "Non-nil means include a header in automatically generated files."
   :type 'boolean
   :group 'vhdl-compose)
 
 (defcustom vhdl-compose-create-files 'single
-  "*Specifies whether new files should be created for the new component.
+  "Specifies whether new files should be created for the new component.
 The component's entity and architecture are inserted:
   None          : in current buffer
   Single file   : in new single file
@@ -1167,14 +1238,14 @@ The file names are obtained from variables `vhdl-entity-file-name' and
   :group 'vhdl-compose)
 
 (defcustom vhdl-compose-configuration-create-file nil
-  "*Specifies whether a new file should be created for the configuration.
+  "Specifies whether a new file should be created for the configuration.
 If non-nil, a new file is created for the configuration.
 The file name is obtained from variable `vhdl-configuration-file-name'."
   :type 'boolean
   :group 'vhdl-compose)
 
 (defcustom vhdl-compose-configuration-hierarchical t
-  "*Specifies whether hierarchical configurations should be created.
+  "Specifies whether hierarchical configurations should be created.
 If non-nil, automatically created configurations are hierarchical and include
 the whole hierarchy of subcomponents.  Otherwise the configuration only
 includes one level of subcomponents."
@@ -1182,7 +1253,7 @@ includes one level of subcomponents."
   :group 'vhdl-compose)
 
 (defcustom vhdl-compose-configuration-use-subconfiguration t
-  "*Specifies whether subconfigurations should be used inside configurations.
+  "Specifies whether subconfigurations should be used inside configurations.
 If non-nil, automatically created configurations use configurations in binding
 indications for subcomponents, if such configurations exist.  Otherwise,
 entities are used in binding indications for subcomponents."
@@ -1196,22 +1267,22 @@ entities are used in binding indications for subcomponents."
   :group 'vhdl-compose)
 
 (defcustom vhdl-include-port-comments nil
-  "*Non-nil means include port comments when a port is pasted."
+  "Non-nil means include port comments when a port is pasted."
   :type 'boolean
   :group 'vhdl-port)
 
 (defcustom vhdl-include-direction-comments nil
-  "*Non-nil means include port direction in instantiations as comments."
+  "Non-nil means include port direction in instantiations as comments."
   :type 'boolean
   :group 'vhdl-port)
 
 (defcustom vhdl-include-type-comments nil
-  "*Non-nil means include generic/port type in instantiations as comments."
+  "Non-nil means include generic/port type in instantiations as comments."
   :type 'boolean
   :group 'vhdl-port)
 
 (defcustom vhdl-include-group-comments 'never
-  "*Specifies whether to include group comments and spacings.
+  "Specifies whether to include group comments and spacings.
 The comments and empty lines between groups of ports are pasted:
   Never       : never
   Declarations: in entity/component/constant/signal declarations only
@@ -1221,9 +1292,21 @@ The comments and empty lines between groups of ports are pasted:
                 (const :tag "Always" always))
   :group 'vhdl-port)
 
+(defcustom vhdl-actual-generic-name '(".*" . "\\&")
+  (concat
+   "Specifies how actual generic names are obtained from formal generic names.
+In a component instantiation, an actual generic name can be
+obtained by modifying the formal generic name (e.g. attaching or stripping
+off a substring)."
+   vhdl-name-doc-string)
+  :type '(cons (regexp :tag "From regexp")
+              (string :tag "To string  "))
+  :group 'vhdl-port
+  :version "24.4")
+
 (defcustom vhdl-actual-port-name '(".*" . "\\&")
   (concat
-   "*Specifies how actual port names are obtained from formal port names.
+   "Specifies how actual port names are obtained from formal port names.
 In a component instantiation, an actual port name can be obtained by
 modifying the formal port name (e.g. attaching or stripping off a substring)."
    vhdl-name-doc-string)
@@ -1233,7 +1316,7 @@ modifying the formal port name (e.g. attaching or stripping off a substring)."
 
 (defcustom vhdl-instance-name '(".*" . "\\&_%d")
   (concat
-   "*Specifies how an instance name is obtained.
+   "Specifies how an instance name is obtained.
 The instance name can be obtained by modifying the name of the component to be
 instantiated (e.g. attaching or stripping off a substring).  \"%d\" is replaced
 by a unique number (starting with 1).
@@ -1250,7 +1333,7 @@ If TO STRING is empty, the instance name is queried."
 
 (defcustom vhdl-testbench-entity-name '(".*" . "\\&_tb")
   (concat
-   "*Specifies how the testbench entity name is obtained.
+   "Specifies how the testbench entity name is obtained.
 The entity name of a testbench can be obtained by modifying the name of
 the component to be tested (e.g. attaching or stripping off a substring)."
    vhdl-name-doc-string)
@@ -1260,7 +1343,7 @@ the component to be tested (e.g. attaching or stripping off a substring)."
 
 (defcustom vhdl-testbench-architecture-name '(".*" . "")
   (concat
-   "*Specifies how the testbench architecture name is obtained.
+   "Specifies how the testbench architecture name is obtained.
 The testbench architecture name can be obtained by modifying the name of
 the component to be tested (e.g. attaching or stripping off a substring).
 If TO STRING is empty, the architecture name is queried."
@@ -1271,7 +1354,7 @@ If TO STRING is empty, the architecture name is queried."
 
 (defcustom vhdl-testbench-configuration-name vhdl-compose-configuration-name
   (concat
-   "*Specifies how the testbench configuration name is obtained.
+   "Specifies how the testbench configuration name is obtained.
 The configuration name of a testbench can be obtained by modifying the entity
 and/or architecture name (e.g. attaching or stripping off a substring).  The
 string that is matched against the regexp is the concatenation of the entity
@@ -1284,7 +1367,7 @@ names (see default setting as example)."
 
 (defcustom vhdl-testbench-dut-name '(".*" . "DUT")
   (concat
-   "*Specifies how a DUT instance name is obtained.
+   "Specifies how a DUT instance name is obtained.
 The design-under-test instance name (i.e. the component instantiated in the
 testbench) can be obtained by modifying the component name (e.g. attaching
 or stripping off a substring)."
@@ -1294,7 +1377,7 @@ or stripping off a substring)."
   :group 'vhdl-testbench)
 
 (defcustom vhdl-testbench-include-header t
-  "*Non-nil means include a header in automatically generated files."
+  "Non-nil means include a header in automatically generated files."
   :type 'boolean
   :group 'vhdl-testbench)
 
@@ -1302,7 +1385,7 @@ or stripping off a substring)."
   -- clock
   signal Clk : std_logic := '1';
 "
-  "*String or file to be inserted in the testbench declarative part.
+  "String or file to be inserted in the testbench declarative part.
 If the string specifies an existing file name, the contents of the file is
 inserted, otherwise the string itself is inserted in the testbench
 architecture before the BEGIN keyword.
@@ -1322,7 +1405,7 @@ Type `C-j' for newlines."
     wait until Clk = '1';
   end process WaveGen_Proc;
 "
-  "*String or file to be inserted in the testbench statement part.
+  "String or file to be inserted in the testbench statement part.
 If the string specifies an existing file name, the contents of the file is
 inserted, otherwise the string itself is inserted in the testbench
 architecture before the END keyword.
@@ -1331,22 +1414,22 @@ Type `C-j' for newlines."
   :group 'vhdl-testbench)
 
 (defcustom vhdl-testbench-initialize-signals nil
-  "*Non-nil means initialize signals with `0' when declared in testbench."
+  "Non-nil means initialize signals with `0' when declared in testbench."
   :type 'boolean
   :group 'vhdl-testbench)
 
 (defcustom vhdl-testbench-include-library t
-  "*Non-nil means a library/use clause for std_logic_1164 is included."
+  "Non-nil means a library/use clause for std_logic_1164 is included."
   :type 'boolean
   :group 'vhdl-testbench)
 
 (defcustom vhdl-testbench-include-configuration t
-  "*Non-nil means a testbench configuration is attached at the end."
+  "Non-nil means a testbench configuration is attached at the end."
   :type 'boolean
   :group 'vhdl-testbench)
 
 (defcustom vhdl-testbench-create-files 'single
-  "*Specifies whether new files should be created for the testbench.
+  "Specifies whether new files should be created for the testbench.
 testbench entity and architecture are inserted:
   None          : in current buffer
   Single file   : in new single file
@@ -1360,7 +1443,7 @@ and `vhdl-testbench-architecture-file-name'."
 
 (defcustom vhdl-testbench-entity-file-name vhdl-entity-file-name
   (concat
-   "*Specifies how the testbench entity file name is obtained.
+   "Specifies how the testbench entity file name is obtained.
 The entity file name can be obtained by modifying the testbench entity name
 \(e.g. attaching or stripping off a substring).  The file extension is
 automatically taken from the file name of the current buffer.  Testbench
@@ -1373,7 +1456,7 @@ absolute path to the file name."
 
 (defcustom vhdl-testbench-architecture-file-name vhdl-architecture-file-name
   (concat
-   "*Specifies how the testbench architecture file name is obtained.
+   "Specifies how the testbench architecture file name is obtained.
 The architecture file name can be obtained by modifying the testbench entity
 and/or architecture name (e.g. attaching or stripping off a substring).  The
 string that is matched against the regexp is the concatenation of the entity
@@ -1392,17 +1475,17 @@ name."
   :group 'vhdl)
 
 (defcustom vhdl-self-insert-comments t
-  "*Non-nil means various templates automatically insert help comments."
+  "Non-nil means various templates automatically insert help comments."
   :type 'boolean
   :group 'vhdl-comment)
 
 (defcustom vhdl-prompt-for-comments t
-  "*Non-nil means various templates prompt for user definable comments."
+  "Non-nil means various templates prompt for user definable comments."
   :type 'boolean
   :group 'vhdl-comment)
 
 (defcustom vhdl-inline-comment-column 40
-  "*Column to indent and align inline comments to.
+  "Column to indent and align inline comments to.
 Overrides local option `comment-column'.
 
 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
@@ -1411,7 +1494,7 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
   :group 'vhdl-comment)
 
 (defcustom vhdl-end-comment-column 79
-  "*End of comment column.
+  "End of comment column.
 Comments that exceed this column number are wrapped.
 
 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
@@ -1422,38 +1505,49 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
 (defvar end-comment-column)
 
 
-(defgroup vhdl-align nil
-  "Customizations for alignment."
+(defgroup vhdl-beautify nil
+  "Customizations for beautification."
   :group 'vhdl)
 
 (defcustom vhdl-auto-align t
-  "*Non-nil means align some templates automatically after generation."
+  "Non-nil means align some templates automatically after generation."
   :type 'boolean
-  :group 'vhdl-align)
+  :group 'vhdl-beautify)
 
 (defcustom vhdl-align-groups t
-  "*Non-nil means align groups of code lines separately.
+  "Non-nil means align groups of code lines separately.
 A group of code lines is a region of consecutive lines between two lines that
 match the regexp in option `vhdl-align-group-separate'."
   :type 'boolean
-  :group 'vhdl-align)
+  :group 'vhdl-beautify)
 
 (defcustom vhdl-align-group-separate "^\\s-*$"
-  "*Regexp for matching a line that separates groups of lines for alignment.
+  "Regexp for matching a line that separates groups of lines for alignment.
 Examples:
   \"^\\s-*$\":          matches an empty line
   \"^\\s-*\\(--.*\\)?$\": matches an empty line or a comment-only line"
   :type 'regexp
-  :group 'vhdl-align)
+  :group 'vhdl-beautify)
 
 (defcustom vhdl-align-same-indent t
-  "*Non-nil means align blocks with same indent separately.
+  "Non-nil means align blocks with same indent separately.
 When a region or the entire buffer is aligned, the code is divided into
 blocks of same indent which are aligned separately (except for argument/port
 lists).  This gives nicer alignment in most cases.
 Option `vhdl-align-groups' still applies within these blocks."
   :type 'boolean
-  :group 'vhdl-align)
+  :group 'vhdl-beautify)
+
+(defcustom vhdl-beautify-options '(t t t t t)
+  "List of options for beautifying code.  Allows to disable individual
+features of code beautification."
+  :type '(list (boolean :tag "Whitespace cleanup       ")
+              (boolean :tag "Single statement per line")
+              (boolean :tag "Indentation              ")
+              (boolean :tag "Alignment                ")
+              (boolean :tag "Case fixing              "))
+  :group 'vhdl-beautify
+  :version "24.4")
 
 
 (defgroup vhdl-highlight nil
@@ -1461,7 +1555,7 @@ Option `vhdl-align-groups' still applies within these blocks."
   :group 'vhdl)
 
 (defcustom vhdl-highlight-keywords t
-  "*Non-nil means highlight VHDL keywords and other standardized words.
+  "Non-nil means highlight VHDL keywords and other standardized words.
 The following faces are used:
   `font-lock-keyword-face'       : keywords
   `font-lock-type-face'          : standardized types
@@ -1477,7 +1571,7 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-highlight-names t
-  "*Non-nil means highlight declaration names and construct labels.
+  "Non-nil means highlight declaration names and construct labels.
 The following faces are used:
   `font-lock-function-name-face' : names in declarations of units,
      subprograms, components, as well as labels of VHDL constructs
@@ -1494,7 +1588,7 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-highlight-special-words nil
-  "*Non-nil means highlight words with special syntax.
+  "Non-nil means highlight words with special syntax.
 The words with syntax and color specified in option `vhdl-special-syntax-alist'
 are highlighted accordingly.
 Can be used for visual support of naming conventions.
@@ -1507,7 +1601,7 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-highlight-forbidden-words nil
-  "*Non-nil means highlight forbidden words.
+  "Non-nil means highlight forbidden words.
 The reserved words specified in option `vhdl-forbidden-words' or having the
 syntax specified in option `vhdl-forbidden-syntax' are highlighted in a
 warning color (face `vhdl-font-lock-reserved-words-face') to indicate not to
@@ -1522,7 +1616,7 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-highlight-verilog-keywords nil
-  "*Non-nil means highlight Verilog keywords as reserved words.
+  "Non-nil means highlight Verilog keywords as reserved words.
 Verilog keywords are highlighted in a warning color (face
 `vhdl-font-lock-reserved-words-face') to indicate not to use them.
 
@@ -1535,7 +1629,7 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-highlight-translate-off nil
-  "*Non-nil means background-highlight code excluded from translation.
+  "Non-nil means background-highlight code excluded from translation.
 That is, all code between \"-- pragma translate_off\" and
 \"-- pragma translate_on\" is highlighted using a different background color
 \(face `vhdl-font-lock-translate-off-face').
@@ -1549,7 +1643,7 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-highlight-case-sensitive nil
-  "*Non-nil means consider case for highlighting.
+  "Non-nil means consider case for highlighting.
 Possible trade-off:
   non-nil  also upper-case VHDL words are highlighted, but case of words with
            special syntax is not considered
@@ -1563,22 +1657,25 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-special-syntax-alist
-  '(("generic/constant" "\\w+_[cg]" "Gold3" "BurlyWood1")
-    ("type" "\\w+_t" "ForestGreen" "PaleGreen")
-    ("variable" "\\w+_v" "Grey50" "Grey80"))
-  "*List of special syntax to be highlighted.
+  '(("generic/constant" "\\<\\w+_[cg]\\>" "Gold3" "BurlyWood1" nil)
+    ("type" "\\<\\w+_t\\>" "ForestGreen" "PaleGreen" nil)
+    ("variable" "\\<\\w+_v\\>" "Grey50" "Grey80" nil))
+  "List of special syntax to be highlighted.
 If option `vhdl-highlight-special-words' is non-nil, words with the specified
 syntax (as regular expression) are highlighted in the corresponding color.
 
   Name         : string of words and spaces
   Regexp       : regular expression describing word syntax
-                  (e.g. \"\\\w+_c\" matches word with suffix \"_c\")
+                 (e.g. \"\\\\=\<\\\w+_c\\\\=\>\" matches word with suffix \"_c\")
+                 expression must start with \"\\\\=\<\" and end with \"\\\\=\>\"
+                 if only whole words should be matched (no substrings)
   Color (light): foreground color for light background
                  (matching color examples: Gold3, Grey50, LimeGreen, Tomato,
                  LightSeaGreen, DodgerBlue, Gold, PaleVioletRed)
   Color (dark) : foreground color for dark background
                  (matching color examples: BurlyWood1, Grey80, Green, Coral,
                  AquaMarine2, LightSkyBlue1, Yellow, PaleVioletRed1)
+  In comments  : If non-nil, words are also highlighted inside comments
 
 Can be used for visual support of naming conventions, such as highlighting
 different kinds of signals (e.g. \"Clk50\", \"Rst_n\") or objects (e.g.
@@ -1593,13 +1690,14 @@ NOTE: Activate a changed regexp in a VHDL buffer by re-fontifying it (menu
                       (string :tag "Name         ")
                       (regexp :tag "Regexp       " "\\w+_")
                       (string :tag "Color (light)")
-                      (string :tag "Color (dark) ")))
+                      (string :tag "Color (dark) ")
+                      (boolean :tag "In comments  ")))
   :set (lambda (variable value)
         (vhdl-custom-set variable value 'vhdl-font-lock-init))
   :group 'vhdl-highlight)
 
 (defcustom vhdl-forbidden-words '()
-  "*List of forbidden words to be highlighted.
+  "List of forbidden words to be highlighted.
 If option `vhdl-highlight-forbidden-words' is non-nil, these reserved
 words are highlighted in a warning color to indicate not to use them.
 
@@ -1612,7 +1710,7 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-forbidden-syntax ""
-  "*Syntax of forbidden words to be highlighted.
+  "Syntax of forbidden words to be highlighted.
 If option `vhdl-highlight-forbidden-words' is non-nil, words with this
 syntax are highlighted in a warning color to indicate not to use them.
 Can be used to highlight too long identifiers (e.g. \"\\w\\w\\w\\w\\w\\w\\w\\w\\w\\w+\"
@@ -1627,7 +1725,7 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl-highlight)
 
 (defcustom vhdl-directive-keywords '("pragma" "synopsys")
-  "*List of compiler directive keywords recognized for highlighting.
+  "List of compiler directive keywords recognized for highlighting.
 
 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
       entry \"Fontify Buffer\")."
@@ -1643,13 +1741,13 @@ NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
   :group 'vhdl)
 
 (defcustom vhdl-speedbar-auto-open nil
-  "*Non-nil means automatically open speedbar at startup.
+  "Non-nil means automatically open speedbar at startup.
 Alternatively, the speedbar can be opened from the VHDL menu."
   :type 'boolean
   :group 'vhdl-speedbar)
 
 (defcustom vhdl-speedbar-display-mode 'files
-  "*Specifies the default displaying mode when opening speedbar.
+  "Specifies the default displaying mode when opening speedbar.
 Alternatively, the displaying mode can be selected from the speedbar menu or
 by typing `f' (files), `h' (directory hierarchy) or `H' (project hierarchy)."
   :type '(choice (const :tag "Files" files)
@@ -1658,7 +1756,7 @@ by typing `f' (files), `h' (directory hierarchy) or `H' (project hierarchy)."
   :group 'vhdl-speedbar)
 
 (defcustom vhdl-speedbar-scan-limit '(10000000 (1000000 50))
-  "*Limits scanning of large files and netlists.
+  "Limits scanning of large files and netlists.
 Design units: maximum file size to scan for design units
 Hierarchy (instances of subcomponents):
   File size: maximum file size to scan for instances (in bytes)
@@ -1685,18 +1783,18 @@ prevent the scanning of large netlists."
   :group 'vhdl-speedbar)
 
 (defcustom vhdl-speedbar-jump-to-unit t
-  "*Non-nil means jump to the design unit code when opened in a buffer.
+  "Non-nil means jump to the design unit code when opened in a buffer.
 The buffer cursor position is left unchanged otherwise."
   :type 'boolean
   :group 'vhdl-speedbar)
 
 (defcustom vhdl-speedbar-update-on-saving t
-  "*Automatically update design hierarchy when buffer is saved."
+  "Automatically update design hierarchy when buffer is saved."
   :type 'boolean
   :group 'vhdl-speedbar)
 
 (defcustom vhdl-speedbar-save-cache '(hierarchy display)
-  "*Automatically save modified hierarchy caches when exiting Emacs.
+  "Automatically save modified hierarchy caches when exiting Emacs.
   Hierarchy: design hierarchy information
   Display:   displaying information (which design units to expand)"
   :type '(set (const :tag "Hierarchy" hierarchy)
@@ -1704,7 +1802,7 @@ The buffer cursor position is left unchanged otherwise."
   :group 'vhdl-speedbar)
 
 (defcustom vhdl-speedbar-cache-file-name ".emacs-vhdl-cache-\\1-\\2"
-  "*Name of file for saving hierarchy cache.
+  "Name of file for saving hierarchy cache.
 \"\\1\" is replaced by the project name if a project is specified,
 \"directory\" otherwise.  \"\\2\" is replaced by the user name (allows for
 different users to have cache files in the same directory). Can also have
@@ -1718,20 +1816,20 @@ an absolute path (i.e. all caches can be stored in one global directory)."
   :group 'vhdl)
 
 (defcustom vhdl-index-menu nil
-  "*Non-nil means add an index menu for a source file when loading.
+  "Non-nil means add an index menu for a source file when loading.
 Alternatively, the speedbar can be used.  Note that the index menu scans a file
 when it is opened, while speedbar only scans the file upon request."
   :type 'boolean
   :group 'vhdl-menu)
 
 (defcustom vhdl-source-file-menu nil
-  "*Non-nil means add a menu of all source files in current directory.
+  "Non-nil means add a menu of all source files in current directory.
 Alternatively, the speedbar can be used."
   :type 'boolean
   :group 'vhdl-menu)
 
 (defcustom vhdl-hideshow-menu nil
-  "*Non-nil means add hideshow menu and functionality at startup.
+  "Non-nil means add hideshow menu and functionality at startup.
 Hideshow can also be enabled from the VHDL Mode menu.
 Hideshow allows hiding code of various VHDL constructs.
 
@@ -1741,7 +1839,7 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
   :group 'vhdl-menu)
 
 (defcustom vhdl-hide-all-init nil
-  "*Non-nil means hide all design units initially after a file is loaded."
+  "Non-nil means hide all design units initially after a file is loaded."
   :type 'boolean
   :group 'vhdl-menu)
 
@@ -1751,7 +1849,7 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
   :group 'vhdl)
 
 (defcustom vhdl-print-two-column t
-  "*Non-nil means print code in two columns and landscape format.
+  "Non-nil means print code in two columns and landscape format.
 Adjusts settings in a way that PostScript printing (\"File\" menu, `ps-print')
 prints VHDL files in a nice two-column landscape style.
 
@@ -1761,7 +1859,7 @@ NOTE: Activate the new setting by restarting Emacs.
   :group 'vhdl-print)
 
 (defcustom vhdl-print-customize-faces t
-  "*Non-nil means use an optimized set of faces for PostScript printing.
+  "Non-nil means use an optimized set of faces for PostScript printing.
 
 NOTE: Activate the new setting by restarting Emacs.
       Overrides `ps-print' settings locally."
@@ -1774,7 +1872,7 @@ NOTE: Activate the new setting by restarting Emacs.
   :group 'vhdl)
 
 (defcustom vhdl-intelligent-tab t
-  "*Non-nil means `TAB' does indentation, word completion and tab insertion.
+  "Non-nil means `TAB' does indentation, word completion and tab insertion.
 That is, if preceding character is part of a word then complete word,
 else if not at beginning of line then insert tab,
 else if last command was a `TAB' or `RET' then dedent one step,
@@ -1788,38 +1886,44 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
   :group 'vhdl-misc)
 
 (defcustom vhdl-indent-syntax-based t
-  "*Non-nil means indent lines of code based on their syntactic context.
+  "Non-nil means indent lines of code based on their syntactic context.
 Otherwise, a line is indented like the previous nonblank line.  This can be
 useful in large files where syntax-based indentation gets very slow."
   :type 'boolean
   :group 'vhdl-misc)
 
+(defcustom vhdl-indent-comment-like-next-code-line t
+  "Non-nil means comment lines are indented like the following code line.
+Otherwise, comment lines are indented like the preceding code line.
+Indenting comment lines like the following code line gives nicer indentation
+when comments precede the code that they refer to."
+  :type 'boolean
+  :version "24.3"
+  :group 'vhdl-misc)
+
 (defcustom vhdl-word-completion-case-sensitive nil
-  "*Non-nil means word completion using `TAB' is case sensitive.
+  "Non-nil means word completion using `TAB' is case sensitive.
 That is, `TAB' completes words that start with the same letters and case.
 Otherwise, case is ignored."
   :type 'boolean
   :group 'vhdl-misc)
 
 (defcustom vhdl-word-completion-in-minibuffer t
-  "*Non-nil enables word completion in minibuffer (for template prompts).
+  "Non-nil enables word completion in minibuffer (for template prompts).
 
 NOTE: Activate the new setting by restarting Emacs."
   :type 'boolean
   :group 'vhdl-misc)
 
 (defcustom vhdl-underscore-is-part-of-word nil
-  "*Non-nil means consider the underscore character `_' as part of word.
+  "Non-nil means consider the underscore character `_' as part of word.
 An identifier containing underscores is then treated as a single word in
 select and move operations.  All parts of an identifier separated by underscore
-are treated as single words otherwise.
-
-NOTE: Activate the new setting in a VHDL buffer by using the menu entry
-      \"Activate Options\"."
+are treated as single words otherwise."
   :type 'boolean
-  :set (lambda (variable value)
-        (vhdl-custom-set variable value 'vhdl-mode-syntax-table-init))
   :group 'vhdl-misc)
+(make-obsolete-variable 'vhdl-underscore-is-part-of-word
+                        'superword-mode "24.4")
 
 
 (defgroup vhdl-related nil
@@ -1833,6 +1937,7 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
   (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 'comment-style 'custom-variable)
 (custom-add-to-group 'vhdl-related 'line-number-mode 'custom-variable)
 (unless (featurep 'xemacs)
   (custom-add-to-group 'vhdl-related 'transient-mark-mode 'custom-variable))
@@ -1840,28 +1945,37 @@ NOTE: Activate the new setting in a VHDL buffer by using the menu entry
 (custom-add-to-group 'vhdl-related 'mail-host-address 'custom-variable)
 (custom-add-to-group 'vhdl-related 'user-mail-address 'custom-variable)
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Hidden user variables
+
+(defvar vhdl-compile-absolute-path nil
+  "If non-nil, use absolute instead of relative path for compiled files.")
+
+(defvar vhdl-comment-display-line-char ?-
+  "Character to use in comment display line.")
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Internal variables
 
 (defvar vhdl-menu-max-size 20
-  "*Specifies the maximum size of a menu before splitting it into submenus.")
+  "Specifies the maximum size of a menu before splitting it into submenus.")
 
 (defvar vhdl-progress-interval 1
-  "*Interval used to update progress status during long operations.
+  "Interval used to update progress status during long operations.
 If a number, percentage complete gets updated after each interval of
 that many seconds.  To inhibit all messages, set this option to nil.")
 
 (defvar vhdl-inhibit-startup-warnings-p nil
-  "*If non-nil, inhibits start up compatibility warnings.")
+  "If non-nil, inhibits start up compatibility warnings.")
 
 (defvar vhdl-strict-syntax-p nil
-  "*If non-nil, all syntactic symbols must be found in `vhdl-offsets-alist'.
+  "If non-nil, all syntactic symbols must be found in `vhdl-offsets-alist'.
 If the syntactic symbol for a particular line does not match a symbol
 in the offsets alist, an error is generated, otherwise no error is
 reported and the syntactic symbol is ignored.")
 
 (defvar vhdl-echo-syntactic-information-p nil
-  "*If non-nil, syntactic info is echoed when the line is indented.")
+  "If non-nil, syntactic info is echoed when the line is indented.")
 
 (defconst vhdl-offsets-alist-default
   '((string               . -1000)
@@ -1889,7 +2003,7 @@ Do not change this constant!  See the variable `vhdl-offsets-alist' for
 more information.")
 
 (defvar vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default)
-  "*Association list of syntactic element symbols and indentation offsets.
+  "Association list of syntactic element symbols and indentation offsets.
 As described below, each cons cell in this list has the form:
 
     (SYNTACTIC-SYMBOL . OFFSET)
@@ -1950,7 +2064,7 @@ Here is the current list of valid syntactic element symbols:
  package-body           -- inside a package body")
 
 (defvar vhdl-comment-only-line-offset 0
-  "*Extra offset for line which contains only the start of a comment.
+  "Extra offset for line which contains only the start of a comment.
 Can contain an integer or a cons cell of the form:
 
  (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
@@ -1961,7 +2075,7 @@ the amount of offset to give column-zero anchored comment-only lines.
 Just an integer as value is equivalent to (<val> . 0)")
 
 (defvar vhdl-special-indent-hook nil
-  "*Hook for user defined special indentation adjustments.
+  "Hook for user defined special indentation adjustments.
 This hook gets called after a line is indented by the mode.")
 
 (defvar vhdl-style-alist
@@ -2000,10 +2114,10 @@ your style, only those that are different from the default.")
                            (lambda (var)
                              (cons var (symbol-value var))))
                           varlist))))
-      (setq vhdl-style-alist (cons default vhdl-style-alist))))
+      (push default vhdl-style-alist)))
 
 (defvar vhdl-mode-hook nil
-  "*Hook called by `vhdl-mode'.")
+  "Hook called by `vhdl-mode'.")
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2017,10 +2131,11 @@ your style, only those that are different from the default.")
 (require 'hippie-exp)
 
 ;; optional (minimize warning messages during compile)
+(unless (featurep 'xemacs)
 (eval-when-compile
   (require 'font-lock)
   (require 'ps-print)
-  (require 'speedbar))
+    (require 'speedbar)))              ; for speedbar-with-writable
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2040,7 +2155,7 @@ Ignore byte-compiler warnings you might see."
 ;; `wildcard-to-regexp' is included only in XEmacs 21
 (unless (fboundp 'wildcard-to-regexp)
   (defun wildcard-to-regexp (wildcard)
-    "Simplified version of `wildcard-to-regexp' from Emacs' `files.el'."
+    "Simplified version of `wildcard-to-regexp' from Emacs's `files.el'."
     (let* ((i (string-match "[*?]" wildcard))
           (result (substring wildcard 0 i))
           (len (length wildcard)))
@@ -2087,7 +2202,7 @@ Ignore byte-compiler warnings you might see."
 ;; `file-expand-wildcards' undefined (XEmacs)
 (unless (fboundp 'file-expand-wildcards)
   (defun file-expand-wildcards (pattern &optional full)
-    "Taken from Emacs' `files.el'."
+    "Taken from Emacs's `files.el'."
     (let* ((nondir (file-name-nondirectory pattern))
           (dirpart (file-name-directory pattern))
           (dirs (if (and dirpart (string-match "[[*?]" dirpart))
@@ -2120,6 +2235,17 @@ Ignore byte-compiler warnings you might see."
 (unless (fboundp 'member-ignore-case)
   (defalias 'member-ignore-case 'member))
 
+;; `last-input-char' obsolete in Emacs 24, `last-input-event' different
+;; behavior in XEmacs
+(defvar vhdl-last-input-event)
+(if (featurep 'xemacs)
+    (defvaralias 'vhdl-last-input-event 'last-input-char)
+  (defvaralias 'vhdl-last-input-event 'last-input-event))
+
+;; `help-print-return-message' changed to `print-help-return-message' in Emacs
+;;;(unless (fboundp 'help-print-return-message)
+;;;  (defalias 'help-print-return-message 'print-help-return-message))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Compatibility with older VHDL Mode versions
 
@@ -2140,7 +2266,7 @@ Ignore byte-compiler warnings you might see."
       (vhdl-warning (apply 'format args) t)
     (unless vhdl-warnings
       (vhdl-run-when-idle .1 nil 'vhdl-print-warnings))
-    (setq vhdl-warnings (cons (apply 'format args) vhdl-warnings))))
+    (push (apply 'format args) vhdl-warnings)))
 
 (defun vhdl-warning (string &optional nobeep)
   "Print out warning STRING and beep."
@@ -2174,7 +2300,7 @@ Ignore byte-compiler warnings you might see."
   (let ((old-alist vhdl-model-alist)
        new-alist)
     (while old-alist
-      (setq new-alist (cons (append (car old-alist) '("")) new-alist))
+      (push (append (car old-alist) '("")) new-alist)
       (setq old-alist (cdr old-alist)))
     (setq vhdl-model-alist (nreverse new-alist)))
   (customize-save-variable 'vhdl-model-alist vhdl-model-alist))
@@ -2184,7 +2310,7 @@ Ignore byte-compiler warnings you might see."
   (let ((old-alist vhdl-project-alist)
        new-alist)
     (while old-alist
-      (setq new-alist (cons (append (car old-alist) '("")) new-alist))
+      (push (append (car old-alist) '("")) new-alist)
       (setq old-alist (cdr old-alist)))
     (setq vhdl-project-alist (nreverse new-alist)))
   (customize-save-variable 'vhdl-project-alist vhdl-project-alist))
@@ -2272,7 +2398,6 @@ Ignore byte-compiler warnings you might see."
   (unless (get 'speedbar-indentation-width 'saved-value)
     (setq speedbar-indentation-width 2)))
 
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Help functions / inline substitutions / macros
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2363,6 +2488,7 @@ old environment.  Used for consistent searching."
                       (progn (set-buffer (create-file-buffer ,file-name))
                              (setq file-opened t)
                              (vhdl-insert-file-contents ,file-name)
+                              ;; FIXME: This modifies a global syntax-table!
                              (modify-syntax-entry ?\- ". 12" (syntax-table))
                              (modify-syntax-entry ?\n ">" (syntax-table))
                              (modify-syntax-entry ?\^M ">" (syntax-table))
@@ -2419,7 +2545,7 @@ conversion."
 
 (defun vhdl-delete (elt list)
   "Delete by side effect the first occurrence of ELT as a member of LIST."
-  (setq list (cons nil list))
+  (push nil list)
   (let ((list1 list))
     (while (and (cdr list1) (not (equal elt (cadr list1))))
       (setq list1 (cdr list1)))
@@ -2427,6 +2553,9 @@ conversion."
       (setcdr list1 (cddr list1))))
   (cdr list))
 
+(declare-function speedbar-refresh "speedbar" (&optional arg))
+(declare-function speedbar-do-function-pointer "speedbar" ())
+
 (defun vhdl-speedbar-refresh (&optional key)
   "Refresh directory or project with name KEY."
   (when (and (boundp 'speedbar-frame)
@@ -2467,6 +2596,11 @@ conversion."
     (set-buffer (marker-buffer marker)))
   (goto-char marker))
 
+(defun vhdl-goto-line (line)
+  "Use this instead of calling user level function `goto-line'."
+  (goto-char (point-min))
+  (forward-line (1- line)))
+
 (defun vhdl-menu-split (list title)
   "Split menu LIST into several submenus, if number of
 elements > `vhdl-menu-max-size'."
@@ -2477,19 +2611,19 @@ elements > `vhdl-menu-max-size'."
            (menuno 1)
            (i 0))
        (while remain
-         (setq sublist (cons (car remain) sublist))
+         (push (car remain) sublist)
          (setq remain (cdr remain))
          (setq i (+ i 1))
          (if (= i vhdl-menu-max-size)
              (progn
-               (setq result (cons (cons (format "%s %s" title menuno)
-                                        (nreverse sublist)) result))
+               (push (cons (format "%s %s" title menuno)
+                           (nreverse sublist)) result)
                (setq i 0)
                (setq menuno (+ menuno 1))
                (setq sublist '()))))
        (and sublist
-            (setq result (cons (cons (format "%s %s" title menuno)
-                                     (nreverse sublist)) result)))
+            (push (cons (format "%s %s" title menuno)
+                        (nreverse sublist)) result))
        (nreverse result))
     list))
 
@@ -2653,11 +2787,6 @@ STRING are replaced by `-' and substrings are converted to lower case."
     (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)
-  ;; backspace/delete key bindings
-  (define-key vhdl-mode-map [backspace]           'backward-delete-char-untabify)
-  (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable
-    (define-key vhdl-mode-map [delete]      'delete-char)
-    (define-key vhdl-mode-map [(meta delete)] 'kill-word))
   ;; mode specific key bindings
   (define-key vhdl-mode-map "\C-c\C-m\C-e" 'vhdl-electric-mode)
   (define-key vhdl-mode-map "\C-c\C-m\C-s" 'vhdl-stutter-mode)
@@ -2724,6 +2853,8 @@ STRING are replaced by `-' and substrings are converted to lower case."
   (define-key vhdl-mode-map "\C-c\C-l\C-o" 'vhdl-line-open)
   (define-key vhdl-mode-map "\C-c\C-l\C-g" 'goto-line)
   (define-key vhdl-mode-map "\C-c\C-l\C-c" 'vhdl-comment-uncomment-line)
+  (define-key vhdl-mode-map "\C-c\C-x\C-s" 'vhdl-fix-statement-region)
+  (define-key vhdl-mode-map "\C-c\C-x\M-s" 'vhdl-fix-statement-buffer)
   (define-key vhdl-mode-map "\C-c\C-x\C-p" 'vhdl-fix-clause)
   (define-key vhdl-mode-map "\C-c\C-x\M-c" 'vhdl-fix-case-region)
   (define-key vhdl-mode-map "\C-c\C-x\C-c" 'vhdl-fix-case-buffer)
@@ -2794,56 +2925,51 @@ STRING are replaced by `-' and substrings are converted to lower case."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Syntax table
 
-(defvar vhdl-mode-syntax-table nil
+(defvar vhdl-mode-syntax-table
+  (let ((st (make-syntax-table)))
+    ;; define punctuation
+    (modify-syntax-entry ?\# "."    st)
+    (modify-syntax-entry ?\$ "."    st)
+    (modify-syntax-entry ?\% "."    st)
+    (modify-syntax-entry ?\& "."    st)
+    (modify-syntax-entry ?\' "."    st)
+    (modify-syntax-entry ?\* "."    st)
+    (modify-syntax-entry ?\+ "."    st)
+    (modify-syntax-entry ?\. "."    st)
+    (modify-syntax-entry ?\/ "."    st)
+    (modify-syntax-entry ?\: "."    st)
+    (modify-syntax-entry ?\; "."    st)
+    (modify-syntax-entry ?\< "."    st)
+    (modify-syntax-entry ?\= "."    st)
+    (modify-syntax-entry ?\> "."    st)
+    (modify-syntax-entry ?\\ "."    st)
+    (modify-syntax-entry ?\| "."    st)
+    ;; define string
+    (modify-syntax-entry ?\" "\""   st)
+    ;; define underscore
+    (modify-syntax-entry ?\_ (if vhdl-underscore-is-part-of-word "w" "_") st)
+    ;; a single hyphen is punctuation, but a double hyphen starts a comment
+    (modify-syntax-entry ?\- ". 12" st)
+    ;; and \n and \^M end a comment
+    (modify-syntax-entry ?\n ">"    st)
+    (modify-syntax-entry ?\^M ">"   st)
+    ;; define parentheses to match
+    (modify-syntax-entry ?\( "()"   st)
+    (modify-syntax-entry ?\) ")("   st)
+    (modify-syntax-entry ?\[ "(]"   st)
+    (modify-syntax-entry ?\] ")["   st)
+    (modify-syntax-entry ?\{ "(}"   st)
+    (modify-syntax-entry ?\} "){"   st)
+    st)
   "Syntax table used in `vhdl-mode' buffers.")
 
-(defvar vhdl-mode-ext-syntax-table nil
+(defvar vhdl-mode-ext-syntax-table
+  ;; Extended syntax table including '_' (for simpler search regexps).
+  (let ((st (copy-syntax-table vhdl-mode-syntax-table)))
+    (modify-syntax-entry ?_ "w" st)
+    st)
   "Syntax table extended by `_' used in `vhdl-mode' buffers.")
 
-(defun vhdl-mode-syntax-table-init ()
-  "Initialize `vhdl-mode-syntax-table'."
-  (setq vhdl-mode-syntax-table (make-syntax-table))
-  ;; define punctuation
-  (modify-syntax-entry ?\# "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\$ "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\% "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\& "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\' "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\* "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\+ "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\. "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\/ "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\: "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\; "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\< "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\= "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\> "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\\ "."    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\| "."    vhdl-mode-syntax-table)
-  ;; define string
-  (modify-syntax-entry ?\" "\""   vhdl-mode-syntax-table)
-  ;; define underscore
-  (when vhdl-underscore-is-part-of-word
-    (modify-syntax-entry ?\_ "w"   vhdl-mode-syntax-table))
-  ;; a single hyphen is punctuation, but a double hyphen starts a comment
-  (modify-syntax-entry ?\- ". 12" vhdl-mode-syntax-table)
-  ;; and \n and \^M end a comment
-  (modify-syntax-entry ?\n ">"    vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\^M ">"   vhdl-mode-syntax-table)
-  ;; define parentheses to match
-  (modify-syntax-entry ?\( "()"   vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\) ")("   vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\[ "(]"   vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\] ")["   vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\{ "(}"   vhdl-mode-syntax-table)
-  (modify-syntax-entry ?\} "){"   vhdl-mode-syntax-table)
-  ;; extended syntax table including '_' (for simpler search regexps)
-  (setq vhdl-mode-ext-syntax-table (copy-syntax-table vhdl-mode-syntax-table))
-  (modify-syntax-entry ?_ "w" vhdl-mode-ext-syntax-table))
-
-;; initialize syntax table for VHDL Mode
-(vhdl-mode-syntax-table-init)
-
 (defvar vhdl-syntactic-context nil
   "Buffer local variable containing syntactic analysis list.")
 (make-variable-buffer-local 'vhdl-syntactic-context)
@@ -3270,9 +3396,6 @@ STRING are replaced by `-' and substrings are converted to lower case."
       (list
        (append
        '("Package")
-       (when (vhdl-standard-p 'math)
-         '(["math_complex"     vhdl-template-package-math-complex t]
-           ["math_real"        vhdl-template-package-math-real t]))
        '(["numeric_bit"        vhdl-template-package-numeric-bit t]
          ["numeric_std"        vhdl-template-package-numeric-std t]
          ["std_logic_1164"     vhdl-template-package-std-logic-1164 t]
@@ -3283,8 +3406,22 @@ STRING are replaced by `-' and substrings are converted to lower case."
          ["std_logic_unsigned" vhdl-template-package-std-logic-unsigned t]
          ["std_logic_misc"     vhdl-template-package-std-logic-misc t]
          ["std_logic_textio"   vhdl-template-package-std-logic-textio t]
-         "--"
-         ["Insert Package..."  vhdl-template-insert-package
+         "--")
+       (when (vhdl-standard-p 'ams)
+         '(["fundamental_constants" vhdl-template-package-fundamental-constants t]
+           ["material_constants" vhdl-template-package-material-constants t]
+           ["energy_systems"   vhdl-template-package-energy-systems t]
+           ["electrical_systems" vhdl-template-package-electrical-systems t]
+           ["mechanical_systems" vhdl-template-package-mechanical-systems t]
+           ["radiant_systems"  vhdl-template-package-radiant-systems t]
+           ["thermal_systems"  vhdl-template-package-thermal-systems t]
+           ["fluidic_systems"  vhdl-template-package-fluidic-systems t]
+           "--"))
+       (when (vhdl-standard-p 'math)
+         '(["math_complex"     vhdl-template-package-math-complex t]
+           ["math_real"        vhdl-template-package-math-real t]
+           "--"))
+       '(["Insert Package..."  vhdl-template-insert-package
                                :keys "C-c C-i C-p"])))
       '(("Directive"
         ["translate_on"        vhdl-template-directive-translate-on t]
@@ -3417,6 +3554,7 @@ STRING are replaced by `-' and substrings are converted to lower case."
      ["Buffer"                 vhdl-beautify-buffer t])
     ("Fix"
      ["Generic/Port Clause"    vhdl-fix-clause t]
+     ["Generic/Port Clause Buffer" vhdl-fix-clause t]
      "--"
      ["Case Region"            vhdl-fix-case-region (mark)]
      ["Case Buffer"            vhdl-fix-case-buffer t]
@@ -3424,6 +3562,9 @@ STRING are replaced by `-' and substrings are converted to lower case."
      ["Whitespace Region"      vhdl-fixup-whitespace-region (mark)]
      ["Whitespace Buffer"      vhdl-fixup-whitespace-buffer t]
      "--"
+     ["Statement Region"       vhdl-fix-statement-region (mark)]
+     ["Statement Buffer"       vhdl-fix-statement-buffer t]
+     "--"
      ["Trailing Spaces Buffer" vhdl-remove-trailing-spaces t])
     ("Update"
      ["Sensitivity List"       vhdl-update-sensitivity-list-process t]
@@ -3449,11 +3590,13 @@ STRING are replaced by `-' and substrings are converted to lower case."
      ("Mode"
       ["Electric Mode"
        (progn (customize-set-variable 'vhdl-electric-mode
-                                     (not vhdl-electric-mode)))
+                                     (not vhdl-electric-mode))
+             (vhdl-mode-line-update))
        :style toggle :selected vhdl-electric-mode :keys "C-c C-m C-e"]
       ["Stutter Mode"
        (progn (customize-set-variable 'vhdl-stutter-mode
-                                     (not vhdl-stutter-mode)))
+                                     (not vhdl-stutter-mode))
+             (vhdl-mode-line-update))
        :style toggle :selected vhdl-stutter-mode :keys "C-c C-m C-s"]
       ["Indent Tabs Mode"
        (progn (customize-set-variable 'vhdl-indent-tabs-mode
@@ -3515,6 +3658,8 @@ STRING are replaced by `-' and substrings are converted to lower case."
        (customize-set-variable 'vhdl-compile-use-local-error-regexp
                               (not vhdl-compile-use-local-error-regexp))
        :style toggle :selected vhdl-compile-use-local-error-regexp]
+      ["Makefile Default Targets..."
+       (customize-option 'vhdl-makefile-default-targets) t]
       ["Makefile Generation Hook..."
        (customize-option 'vhdl-makefile-generation-hook) t]
       ["Default Library Name" (customize-option 'vhdl-default-library) t]
@@ -3527,7 +3672,7 @@ STRING are replaced by `-' and substrings are converted to lower case."
                                       (list '87 (cadr vhdl-standard)))
               (vhdl-activate-customizations))
        :style radio :selected (eq '87 (car vhdl-standard))]
-       ["VHDL'93"
+       ["VHDL'93/02"
        (progn (customize-set-variable 'vhdl-standard
                                       (list '93 (cadr vhdl-standard)))
               (vhdl-activate-customizations))
@@ -3580,6 +3725,10 @@ STRING are replaced by `-' and substrings are converted to lower case."
        ["Always"
        (customize-set-variable 'vhdl-use-direct-instantiation 'always)
        :style radio :selected (eq 'always vhdl-use-direct-instantiation)])
+      ["Include Array Index and Record Field in Sensitivity List"
+       (customize-set-variable 'vhdl-array-index-record-field-in-sensitivity-list
+                              (not vhdl-array-index-record-field-in-sensitivity-list))
+       :style toggle :selected vhdl-array-index-record-field-in-sensitivity-list]
       "--"
       ["Customize Group..." (customize-group 'vhdl-style) t])
      ("Naming"
@@ -3676,7 +3825,10 @@ STRING are replaced by `-' and substrings are converted to lower case."
         :style radio :selected (eq 'sync vhdl-reset-kind)]
        ["Asynchronous"
         (customize-set-variable 'vhdl-reset-kind 'async)
-        :style radio :selected (eq 'async vhdl-reset-kind)])
+        :style radio :selected (eq 'async vhdl-reset-kind)]
+       ["Query"
+        (customize-set-variable 'vhdl-reset-kind 'query)
+        :style radio :selected (eq 'query vhdl-reset-kind)])
        ["Reset is Active High"
        (customize-set-variable 'vhdl-reset-active-high
                                (not vhdl-reset-active-high))
@@ -3721,6 +3873,7 @@ STRING are replaced by `-' and substrings are converted to lower case."
        ["Always"
        (customize-set-variable 'vhdl-include-group-comments 'always)
        :style radio :selected (eq 'always vhdl-include-group-comments)])
+      ["Actual Generic Name..." (customize-option 'vhdl-actual-generic-name) t]
       ["Actual Port Name..." (customize-option 'vhdl-actual-port-name) t]
       ["Instance Name..." (customize-option 'vhdl-instance-name) t]
       ("Testbench"
@@ -3817,7 +3970,7 @@ STRING are replaced by `-' and substrings are converted to lower case."
       ["End Comment Column..." (customize-option 'vhdl-end-comment-column) t]
       "--"
       ["Customize Group..." (customize-group 'vhdl-comment) t])
-     ("Align"
+     ("Beautify"
       ["Auto Align Templates"
        (customize-set-variable 'vhdl-auto-align (not vhdl-auto-align))
        :style toggle :selected vhdl-auto-align]
@@ -3825,13 +3978,14 @@ STRING are replaced by `-' and substrings are converted to lower case."
        (customize-set-variable 'vhdl-align-groups (not vhdl-align-groups))
        :style toggle :selected vhdl-align-groups]
       ["Group Separation String..."
-       (customize-set-variable 'vhdl-align-group-separate) t]
+       (customize-option 'vhdl-align-group-separate) t]
       ["Align Lines with Same Indent"
        (customize-set-variable 'vhdl-align-same-indent
                               (not vhdl-align-same-indent))
        :style toggle :selected vhdl-align-same-indent]
+      ["Beautify Options..." (customize-option 'vhdl-beautify-options) t]
       "--"
-      ["Customize Group..." (customize-group 'vhdl-align) t])
+      ["Customize Group..." (customize-group 'vhdl-beautify) t])
      ("Highlight"
       ["Highlighting On/Off..."
        (customize-option
@@ -3966,6 +4120,10 @@ STRING are replaced by `-' and substrings are converted to lower case."
        (customize-set-variable 'vhdl-indent-syntax-based
                               (not vhdl-indent-syntax-based))
        :style toggle :selected vhdl-indent-syntax-based]
+      ["Indent Comments Like Next Code Line"
+       (customize-set-variable 'vhdl-indent-comment-like-next-code-line
+                              (not vhdl-indent-comment-like-next-code-line))
+       :style toggle :selected vhdl-indent-comment-like-next-code-line]
       ["Word Completion is Case Sensitive"
        (customize-set-variable 'vhdl-word-completion-case-sensitive
                               (not vhdl-word-completion-case-sensitive))
@@ -4009,7 +4167,7 @@ STRING are replaced by `-' and substrings are converted to lower case."
      "^\\s-*\\(\\(\\(impure\\|pure\\)\\s-+\\|\\)function\\|procedure\\)\\s-+\\(\"?\\(\\w\\|\\s_\\)+\"?\\)"
      4)
     ("Instance"
-     "^\\s-*\\(\\(\\w\\|\\s_\\)+\\s-*:\\(\\s-\\|\n\\)*\\(\\w\\|\\s_\\)+\\)\\(\\s-\\|\n\\)+\\(generic\\|port\\)\\s-+map\\>"
+     "^\\s-*\\(\\(\\w\\|\\s_\\)+\\s-*:\\(\\s-\\|\n\\)*\\(entity\\s-+\\(\\w\\|\\s_\\)+\\.\\)?\\(\\w\\|\\s_\\)+\\)\\(\\s-\\|\n\\)+\\(generic\\|port\\)\\s-+map\\>"
      1)
     ("Component"
      "^\\s-*\\(component\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
@@ -4044,10 +4202,7 @@ STRING are replaced by `-' and substrings are converted to lower case."
   (set (make-local-variable 'imenu-generic-expression)
        vhdl-imenu-generic-expression)
   (when (and vhdl-index-menu (fboundp 'imenu))
-    (if (or (not (boundp 'font-lock-maximum-size))
-           (> font-lock-maximum-size (buffer-size)))
-       (imenu-add-to-menubar "Index")
-      (message "Scanning buffer for index...buffer too big"))))
+    (imenu-add-to-menubar "Index")))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Source file menu (using `easy-menu.el')
@@ -4094,14 +4249,13 @@ The directory of the current source file is scanned."
     (setq found nil)
     (while file-list
       (setq found t)
-      (setq menu-list (cons (vector (car file-list)
-                                  (list 'find-file (car file-list)) t)
-                          menu-list))
+      (push (vector (car file-list) (list 'find-file (car file-list)) t)
+           menu-list)
       (setq file-list (cdr file-list)))
     (setq menu-list (vhdl-menu-split menu-list "Sources"))
-    (when found (setq menu-list (cons "--" menu-list)))
-    (setq menu-list (cons ["*Rescan*" vhdl-add-source-files-menu t] menu-list))
-    (setq menu-list (cons "Sources" menu-list))
+    (when found (push "--" menu-list))
+    (push ["*Rescan*" vhdl-add-source-files-menu t] menu-list)
+    (push "Sources" menu-list)
     ;; Create menu
     (easy-menu-add menu-list)
     (easy-menu-define vhdl-sources-menu newmap
@@ -4132,7 +4286,7 @@ Usage:
     brackets and removed if the queried string is left empty.  Prompts for
     mandatory arguments remain in the code if the queried string is left
     empty.  They can be queried again by `C-c C-t C-q'.  Enabled
-    electrification is indicated by `/e' in the modeline.
+    electrification is indicated by `/e' in the mode line.
 
       Typing `M-SPC' after a keyword inserts a space without calling the
     template generator.  Automatic template generation (i.e.
@@ -4159,7 +4313,7 @@ Usage:
     Double striking of some keys inserts cumbersome VHDL syntax elements.
     Stuttering can be disabled (enabled) by typing `C-c C-m C-s' or by
     option `vhdl-stutter-mode'.  Enabled stuttering is indicated by `/s' in
-    the modeline.  The stuttering keys and their effects are:
+    the mode line.  The stuttering keys and their effects are:
 
       ;;   -->  \" : \"       [   -->  (        --    -->  comment
       ;;;  -->  \" := \"      [[  -->  [        --CR  -->  comment-out code
@@ -4193,8 +4347,10 @@ Usage:
                    with a comment in between.
         `--CR'     comments out code on that line.  Re-hitting CR comments
                    out following lines.
-        `C-c c'    comments out a region if not commented out,
-                   uncomments a region if already commented out.
+        `C-c C-c'  comments out a region if not commented out,
+                   uncomments a region if already commented out.  Option
+                   `comment-style' defines where the comment characters
+                   should be placed (beginning of line, indent, etc.).
 
       You are prompted for comments after object definitions (i.e. signals,
     variables, constants, ports) and after subprogram and process
@@ -4215,7 +4371,8 @@ Usage:
     `TAB' indents a line if at the beginning of the line.  The amount of
     indentation is specified by option `vhdl-basic-offset'.  `C-c C-i C-l'
     always indents the current line (is bound to `TAB' if option
-    `vhdl-intelligent-tab' is nil).
+    `vhdl-intelligent-tab' is nil).  If a region is active, `TAB' indents
+    the entire region.
 
       Indentation can be done for a group of lines (`C-c C-i C-g'), a region
     \(`M-C-\\') or the entire buffer (menu).  Argument and port lists are
@@ -4229,6 +4386,10 @@ Usage:
       Syntax-based indentation can be very slow in large files.  Option
     `vhdl-indent-syntax-based' allows to use faster but simpler indentation.
 
+      Option `vhdl-indent-comment-like-next-code-line' controls whether
+    comment lines are indented like the preceding or like the following code
+    line.
+
 
   ALIGNMENT:
     The alignment functions align operators, keywords, and inline comments
@@ -4357,12 +4518,12 @@ Usage:
 
 
   STRUCTURAL COMPOSITION:
-    Enables simple structural composition.  `C-c C-c C-n' creates a skeleton
+    Enables simple structural composition.  `C-c C-m C-n' creates a skeleton
     for a new component.  Subcomponents (i.e. component declaration and
     instantiation) can be automatically placed from a previously read port
-    \(`C-c C-c C-p') or directly from the hierarchy browser (`P').  Finally,
+    \(`C-c C-m C-p') or directly from the hierarchy browser (`P').  Finally,
     all subcomponents can be automatically connected using internal signals
-    and ports (`C-c C-c C-w') following these rules:
+    and ports (`C-c C-m C-w') following these rules:
       - subcomponent actual ports with same name are considered to be
         connected by a signal (internal signal or port)
       - signals that are only inputs to subcomponents are considered as
@@ -4383,25 +4544,25 @@ Usage:
 
       Component declarations can be placed in a components package (option
     `vhdl-use-components-package') which can be automatically generated for
-    an entire directory or project (`C-c C-c M-p').  The VHDL'93 direct
+    an entire directory or project (`C-c C-m M-p').  The VHDL'93 direct
     component instantiation is also supported (option
     `vhdl-use-direct-instantiation').
 
-|     Configuration declarations can automatically be generated either from
-|   the menu (`C-c C-c C-f') (for the architecture the cursor is in) or from
-|   the speedbar menu (for the architecture under the cursor).  The
-|   configurations can optionally be hierarchical (i.e. include all
-|   component levels of a hierarchical design, option
-|   `vhdl-compose-configuration-hierarchical') or include subconfigurations
-|   (option `vhdl-compose-configuration-use-subconfiguration').  For
-|   subcomponents in hierarchical configurations, the most-recently-analyzed
-|   (mra) architecture is selected.  If another architecture is desired, it
-|   can be marked as most-recently-analyzed (speedbar menu) before
-|   generating the configuration.
-|
-|     Note: Configurations of subcomponents (i.e. hierarchical configuration
-|   declarations) are currently not considered when displaying
-|   configurations in speedbar.
+      Configuration declarations can automatically be generated either from
+    the menu (`C-c C-m C-f') (for the architecture the cursor is in) or from
+    the speedbar menu (for the architecture under the cursor).  The
+    configurations can optionally be hierarchical (i.e. include all
+    component levels of a hierarchical design, option
+    `vhdl-compose-configuration-hierarchical') or include subconfigurations
+    (option `vhdl-compose-configuration-use-subconfiguration').  For
+    subcomponents in hierarchical configurations, the most-recently-analyzed
+    (mra) architecture is selected.  If another architecture is desired, it
+    can be marked as most-recently-analyzed (speedbar menu) before
+    generating the configuration.
+
+      Note: Configurations of subcomponents (i.e. hierarchical configuration
+    declarations) are currently not considered when displaying
+    configurations in speedbar.
 
       See the options group `vhdl-compose' for all relevant user options.
 
@@ -4433,11 +4594,13 @@ Usage:
 
       The Makefile's default target \"all\" compiles the entire design, the
     target \"clean\" removes it and the target \"library\" creates the
-    library directory if not existent.  The Makefile also includes a target
-    for each primary library unit which allows selective compilation of this
-    unit, its secondary units and its subhierarchy (example: compilation of
-    a design specified by a configuration).  User specific parts can be
-    inserted into a Makefile with option `vhdl-makefile-generation-hook'.
+    library directory if not existent.  These target names can be customized
+    by option `vhdl-makefile-default-targets'.  The Makefile also includes a
+    target for each primary library unit which allows selective compilation
+    of this unit, its secondary units and its subhierarchy (example:
+    compilation of a design specified by a configuration).  User specific
+    parts can be inserted into a Makefile with option
+    `vhdl-makefile-generation-hook'.
 
     Limitations:
       - Only library units and dependencies within the current library are
@@ -4476,14 +4639,14 @@ Usage:
     option `vhdl-index-menu' to non-nil) or made accessible as a mouse menu
     (e.g. add \"(global-set-key '[S-down-mouse-3] 'imenu)\" to your start-up
     file) for browsing the file contents (is not populated if buffer is
-    larger than `font-lock-maximum-size').  Also, a source file menu can be
+    larger than 256000).  Also, a source file menu can be
     added (set option `vhdl-source-file-menu' to non-nil) for browsing the
     current directory for VHDL source files.
 
 
   VHDL STANDARDS:
     The VHDL standards to be used are specified in option `vhdl-standard'.
-    Available standards are: VHDL'87/'93, VHDL-AMS, and Math Packages.
+    Available standards are: VHDL'87/'93(02), VHDL-AMS, and Math Packages.
 
 
   KEYWORD CASE:
@@ -4559,6 +4722,9 @@ Usage:
         - Out parameters of procedures are considered to be read.
       Use option `vhdl-entity-file-name' to specify the entity file name
       \(used to obtain the port names).
+      Use option `vhdl-array-index-record-field-in-sensitivity-list' to
+      specify whether to include array indices and record fields in
+      sensitivity lists.
 
 
   CODE FIXING:
@@ -4600,7 +4766,7 @@ Usage:
     automatically recognized as VHDL source files.  To add an extension
     \".xxx\", add the following line to your Emacs start-up file (`.emacs'):
 
-      \(setq auto-mode-alist (cons '(\"\\\\.xxx\\\\'\" . vhdl-mode) auto-mode-alist))
+      \(push '(\"\\\\.xxx\\\\'\" . vhdl-mode) auto-mode-alist)
 
 
   HINTS:
@@ -4632,16 +4798,17 @@ releases.  You are kindly invited to participate in beta testing.  Subscribe
 to above mailing lists by sending an email to <reto@gnu.org>.
 
 VHDL Mode is officially distributed at
-URL `http://opensource.ethz.ch/emacs/vhdl-mode.html'
+http://www.iis.ee.ethz.ch/~zimmi/emacs/vhdl-mode.html
 where the latest version can be found.
 
 
 Known problems:
 ---------------
 
-- Indentation bug in simultaneous if- and case-statements (VHDL-AMS).
 - XEmacs: Incorrect start-up when automatically opening speedbar.
 - XEmacs: Indentation in XEmacs 21.4 (and higher).
+- Indentation incorrect for new 'postponed' VHDL keyword.
+- Indentation incorrect for 'protected body' construct.
 
 
                                                 The VHDL Mode Authors
@@ -4764,7 +4931,7 @@ Key bindings:
 ;;; Keywords and standardized words
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defconst vhdl-93-keywords
+(defconst vhdl-02-keywords
   '(
     "abs" "access" "after" "alias" "all" "and" "architecture" "array"
     "assert" "attribute"
@@ -4779,7 +4946,7 @@ Key bindings:
     "map" "mod"
     "nand" "new" "next" "nor" "not" "null"
     "of" "on" "open" "or" "others" "out"
-    "package" "port" "postponed" "procedure" "process" "pure"
+    "package" "port" "postponed" "procedure" "process" "protected" "pure"
     "range" "record" "register" "reject" "rem" "report" "return"
     "rol" "ror"
     "select" "severity" "shared" "signal" "sla" "sll" "sra" "srl" "subtype"
@@ -4789,7 +4956,7 @@ Key bindings:
     "wait" "when" "while" "with"
     "xnor" "xor"
     )
-  "List of VHDL'93 keywords.")
+  "List of VHDL'02 keywords.")
 
 (defconst vhdl-ams-keywords
   '(
@@ -4822,7 +4989,7 @@ Key bindings:
     )
   "List of Verilog keywords as candidate for additional reserved words.")
 
-(defconst vhdl-93-types
+(defconst vhdl-02-types
   '(
     "boolean" "bit" "bit_vector" "character" "severity_level" "integer"
     "real" "time" "natural" "positive" "string" "line" "text" "side"
@@ -4830,25 +4997,72 @@ Key bindings:
     "std_logic" "std_logic_vector"
     "std_ulogic" "std_ulogic_vector"
     )
-  "List of VHDL'93 standardized types.")
+  "List of VHDL'02 standardized types.")
 
 (defconst vhdl-ams-types
+  ;; standards: IEEE Std 1076.1-2007, IEEE Std 1076.1.1-2004
   '(
+    ;; package `standard'
     "domain_type" "real_vector"
-    ;; from `nature_pkg' package
-    "voltage" "current" "electrical" "position" "velocity" "force"
-    "mechanical_vf" "mechanical_pf" "rotvel" "torque" "rotational"
-    "pressure" "flowrate" "fluid"
-  )
+    ;; package `energy_systems'
+    "energy" "power" "periodicity" "real_across" "real_through" "unspecified"
+    "unspecified_vector" "energy_vector" "power_vector" "periodicity_vector"
+    "real_across_vector" "real_through_vector"
+    ;; package `electrical_systems'
+    "voltage" "current" "charge" "resistance" "conductance" "capacitance"
+    "mmf" "electric_flux" "electric_flux_density" "electric_field_strength"
+    "magnetic_flux" "magnetic_flux_density" "magnetic_field_strength"
+    "inductance" "reluctance" "electrical" "electrical_vector" "magnetic"
+    "magnetic_vector" "voltage_vector" "current_vector" "mmf_vector"
+    "magnetic_flux_vector" "charge_vector" "resistance_vector"
+    "conductance_vector" "capacitance_vector" "electric_flux_vector"
+    "electric_flux_density_vector" "electric_field_strength_vector"
+    "magnetic_flux_density_vector" "magnetic_field_strength_vector"
+    "inductance_vector" "reluctance_vector" "ground"
+    ;; package `mechanical_systems'
+    "displacement" "force" "velocity" "acceleration" "mass" "stiffness"
+    "damping" "momentum" "angle" "torque" "angular_velocity"
+    "angular_acceleration" "moment_inertia" "angular_momentum"
+    "angular_stiffness" "angular_damping" "translational"
+    "translational_vector" "translational_velocity"
+    "translational_velocity_vector" "rotational" "rotational_vector"
+    "rotational_velocity" "rotational_velocity_vector" "displacement_vector"
+    "force_vector" "velocity_vector" "force_velocity_vector" "angle_vector"
+    "torque_vector" "angular_velocity_vector" "torque_velocity_vector"
+    "acceleration_vector" "mass_vector" "stiffness_vector" "damping_vector"
+    "momentum_vector" "angular_acceleration_vector" "moment_inertia_vector"
+    "angular_momentum_vector" "angular_stiffness_vector"
+    "angular_damping_vector" "anchor" "translational_v_ref"
+    "rotational_v_ref" "translational_v" "rotational_v"
+    ;; package `radiant_systems'
+    "illuminance" "luminous_flux" "luminous_intensity" "irradiance" "radiant"
+    "radiant_vector" "luminous_intensity_vector" "luminous_flux_vector"
+    "illuminance_vector" "irradiance_vector"
+    ;; package `thermal_systems'
+    "temperature" "heat_flow" "thermal_capacitance" "thermal_resistance"
+    "thermal_conductance" "thermal" "thermal_vector" "temperature_vector"
+    "heat_flow_vector" "thermal_capacitance_vector"
+    "thermal_resistance_vector" "thermal_conductance_vector"
+    ;; package `fluidic_systems'
+    "pressure" "vflow_rate" "mass_flow_rate" "volume" "density" "viscosity"
+    "fresistance" "fconductance" "fcapacitance" "inertance" "cfresistance"
+    "cfcapacitance" "cfinertance" "cfconductance" "fluidic" "fluidic_vector"
+    "compressible_fluidic" "compressible_fluidic_vector" "pressure_vector"
+    "vflow_rate_vector" "mass_flow_rate_vector" "volume_vector"
+    "density_vector" "viscosity_vector" "fresistance_vector"
+    "fconductance_vector" "fcapacitance_vector" "inertance_vector"
+    "cfresistance_vector" "cfconductance_vector" "cfcapacitance_vector"
+    "cfinertance_vector"
+    )
   "List of VHDL-AMS standardized types.")
 
 (defconst vhdl-math-types
   '(
-    "complex" "complex_polar"
+    "complex" "complex_polar" "positive_real" "principal_value"
     )
   "List of Math Packages standardized types.")
 
-(defconst vhdl-93-attributes
+(defconst vhdl-02-attributes
   '(
     "base" "left" "right" "high" "low" "pos" "val" "succ"
     "pred" "leftof" "rightof" "range" "reverse_range"
@@ -4858,7 +5072,7 @@ Key bindings:
     "simple_name" "instance_name" "path_name"
     "foreign"
     )
-  "List of VHDL'93 standardized attributes.")
+  "List of VHDL'02 standardized attributes.")
 
 (defconst vhdl-ams-attributes
   '(
@@ -4869,7 +5083,7 @@ Key bindings:
     )
   "List of VHDL-AMS standardized attributes.")
 
-(defconst vhdl-93-enum-values
+(defconst vhdl-02-enum-values
   '(
     "true" "false"
     "note" "warning" "error" "failure"
@@ -4878,7 +5092,7 @@ Key bindings:
     "fs" "ps" "ns" "us" "ms" "sec" "min" "hr"
     "right" "left"
     )
-  "List of VHDL'93 standardized enumeration values.")
+  "List of VHDL'02 standardized enumeration values.")
 
 (defconst vhdl-ams-enum-values
   '(
@@ -4888,22 +5102,38 @@ Key bindings:
     )
   "List of VHDL-AMS standardized enumeration values.")
 
+(defconst vhdl-ams-constants
+  ;; standard: IEEE Std 1076.1.1-2004
+  '(
+    ;; package `fundamental_constants'
+    "phys_q" "phys_eps0" "phys_mu0" "phys_k" "phys_gravity" "phys_ctok"
+    "phys_c" "phys_h" "phys_h_over_2_pi" "yocto" "zepto" "atto" "femto"
+    "pico" "nano" "micro" "milli" "centi" "deci" "deka" "hecto" "kilo" "mega"
+    "giga" "tera" "peta" "exa" "zetta" "yotta" "deca"
+    ;; package `material_constants'
+    "phys_eps_si" "phys_eps_sio2" "phys_e_si" "phys_e_sio2" "phys_e_poly"
+    "phys_nu_si" "phys_nu_poly" "phys_rho_poly" "phys_rho_sio2"
+    "ambient_temperature" "ambient_pressure" "ambient_illuminance"
+    )
+  "List of VHDL-AMS standardized constants.")
+
 (defconst vhdl-math-constants
+  ;; standard: IEEE Std 1076.2-1996
   '(
-    "math_e" "math_1_over_e"
-    "math_pi" "math_two_pi" "math_1_over_pi"
-    "math_half_pi" "math_q_pi" "math_3_half_pi"
-    "math_log_of_2" "math_log_of_10" "math_log2_of_e" "math_log10_of_e"
-    "math_sqrt2" "math_sqrt1_2" "math_sqrt_pi"
-    "math_deg_to_rad" "math_rad_to_deg"
-    "cbase_1" "cbase_j" "czero"
+    "math_1_over_e" "math_1_over_pi" "math_1_over_sqrt_2" "math_2_pi"
+    "math_3_pi_over_2" "math_cbase_1" "math_cbase_j" "math_czero"
+    "math_deg_to_rad" "math_e" "math_log10_of_e" "math_log2_of_e"
+    "math_log_of_10" "math_log_of_2" "math_pi" "math_pi_over_2"
+    "math_pi_over_3" "math_pi_over_4" "math_rad_to_deg" "math_sqrt_2"
+    "math_sqrt_pi"
     )
   "List of Math Packages standardized constants.")
 
-(defconst vhdl-93-functions
+(defconst vhdl-02-functions
   '(
     "now" "resolved" "rising_edge" "falling_edge"
-    "read" "readline" "write" "writeline" "endfile"
+    "read" "readline" "hread" "oread" "write" "writeline" "hwrite" "owrite"
+    "endfile"
     "resize" "is_X" "std_match"
     "shift_left" "shift_right" "rotate_left" "rotate_right"
     "to_unsigned" "to_signed" "to_integer"
@@ -4913,25 +5143,27 @@ Key bindings:
     "shl" "shr" "ext" "sxt"
     "deallocate"
     )
-  "List of VHDL'93 standardized functions.")
+  "List of VHDL'02 standardized functions.")
 
 (defconst vhdl-ams-functions
   '(
+    ;; package `standard'
     "frequency"
     )
   "List of VHDL-AMS standardized functions.")
 
 (defconst vhdl-math-functions
+  ;; standard: IEEE Std 1076.2-1996
   '(
-    "sign" "ceil" "floor" "round" "trunc" "fmax" "fmin" "uniform"
-    "sqrt" "cbrt" "exp" "log"
-    "sin" "cos" "tan" "arcsin" "arccos" "arctan"
-    "sinh" "cosh" "tanh" "arcsinh" "arccosh" "arctanh"
-    "cmplx" "complex_to_polar" "polar_to_complex" "arg" "conj"
+    "arccos" "arccosh" "arcsin" "arcsinh" "arctan" "arctanh" "arg"
+    "cbrt" "ceil" "cmplx" "complex_to_polar" "conj" "cos" "cosh" "exp"
+    "floor" "get_principal_value" "log" "log10" "log2" "polar_to_complex"
+    "realmax" "realmin" "round" "sign" "sin" "sinh" "sqrt"
+    "tan" "tanh" "trunc" "uniform"
     )
   "List of Math Packages standardized functions.")
 
-(defconst vhdl-93-packages
+(defconst vhdl-02-packages
   '(
     "std_logic_1164" "numeric_std" "numeric_bit"
     "standard" "textio"
@@ -4939,12 +5171,13 @@ Key bindings:
     "std_logic_misc" "std_logic_textio"
     "ieee" "std" "work"
     )
-  "List of VHDL'93 standardized packages and libraries.")
+  "List of VHDL'02 standardized packages and libraries.")
 
 (defconst vhdl-ams-packages
   '(
-    ;; from `nature_pkg' package
-    "nature_pkg"
+    "fundamental_constants" "material_constants" "energy_systems"
+    "electrical_systems" "mechanical_systems" "radiant_systems"
+    "thermal_systems" "fluidic_systems"
     )
   "List of VHDL-AMS standardized packages and libraries.")
 
@@ -4990,6 +5223,9 @@ Key bindings:
 (defvar vhdl-enum-values-regexp nil
   "Regexp for VHDL standardized enumeration values.")
 
+(defvar vhdl-constants-regexp nil
+  "Regexp for VHDL standardized constants.")
+
 (defvar vhdl-functions-regexp nil
   "Regexp for VHDL standardized functions.")
 
@@ -5002,29 +5238,50 @@ Key bindings:
 (defvar vhdl-directive-keywords-regexp nil
   "Regexp for compiler directive keywords.")
 
+(defun vhdl-upcase-list (condition list)
+  "Upcase all elements in LIST based on CONDITION."
+  (when condition
+    (let ((tmp-list list))
+      (while tmp-list
+       (setcar tmp-list (upcase (car tmp-list)))
+       (setq tmp-list (cdr tmp-list)))))
+  list)
+
 (defun vhdl-words-init ()
   "Initialize reserved words."
   (setq vhdl-keywords
-       (append vhdl-93-keywords
-               (when (vhdl-standard-p 'ams) vhdl-ams-keywords)))
+       (vhdl-upcase-list
+        (and vhdl-highlight-case-sensitive vhdl-upper-case-keywords)
+        (append vhdl-02-keywords
+                (when (vhdl-standard-p 'ams) vhdl-ams-keywords))))
   (setq vhdl-types
-       (append vhdl-93-types
-               (when (vhdl-standard-p 'ams) vhdl-ams-types)
-               (when (vhdl-standard-p 'math) vhdl-math-types)))
+       (vhdl-upcase-list
+        (and vhdl-highlight-case-sensitive vhdl-upper-case-types)
+        (append vhdl-02-types
+                (when (vhdl-standard-p 'ams) vhdl-ams-types)
+                (when (vhdl-standard-p 'math) vhdl-math-types))))
   (setq vhdl-attributes
-       (append vhdl-93-attributes
-               (when (vhdl-standard-p 'ams) vhdl-ams-attributes)))
+       (vhdl-upcase-list
+        (and vhdl-highlight-case-sensitive vhdl-upper-case-attributes)
+        (append vhdl-02-attributes
+                (when (vhdl-standard-p 'ams) vhdl-ams-attributes))))
   (setq vhdl-enum-values
-       (append vhdl-93-enum-values
-               (when (vhdl-standard-p 'ams) vhdl-ams-enum-values)))
+       (vhdl-upcase-list
+        (and vhdl-highlight-case-sensitive vhdl-upper-case-enum-values)
+        (append vhdl-02-enum-values
+                (when (vhdl-standard-p 'ams) vhdl-ams-enum-values))))
   (setq vhdl-constants
-       (append (when (vhdl-standard-p 'math) vhdl-math-constants)))
+       (vhdl-upcase-list
+        (and vhdl-highlight-case-sensitive vhdl-upper-case-constants)
+        (append (when (vhdl-standard-p 'ams) vhdl-ams-constants)
+                (when (vhdl-standard-p 'math) vhdl-math-constants)
+                '(""))))
   (setq vhdl-functions
-       (append vhdl-93-functions
+       (append vhdl-02-functions
                (when (vhdl-standard-p 'ams) vhdl-ams-functions)
                (when (vhdl-standard-p 'math) vhdl-math-functions)))
   (setq vhdl-packages
-       (append vhdl-93-packages
+       (append vhdl-02-packages
                (when (vhdl-standard-p 'ams) vhdl-ams-packages)
                (when (vhdl-standard-p 'math) vhdl-math-packages)))
   (setq vhdl-reserved-words
@@ -5039,6 +5296,8 @@ Key bindings:
        (concat "\\<\\(" (regexp-opt vhdl-attributes) "\\)\\>"))
   (setq vhdl-enum-values-regexp
        (concat "\\<\\(" (regexp-opt vhdl-enum-values) "\\)\\>"))
+  (setq vhdl-constants-regexp
+       (concat "\\<\\(" (regexp-opt vhdl-constants) "\\)\\>"))
   (setq vhdl-functions-regexp
        (concat "\\<\\(" (regexp-opt vhdl-functions) "\\)\\>"))
   (setq vhdl-packages-regexp
@@ -5090,7 +5349,7 @@ We cannot use just `word' syntax class since `_' cannot be in word
 class.  Putting underscore in word class breaks forward word movement
 behavior that users are familiar with.")
 
-(defconst vhdl-case-header-key "case[( \t\n][^;=>]+[) \t\n]is"
+(defconst vhdl-case-header-key "case[( \t\n\r\f][^;=>]+[) \t\n\r\f]is"
   "Regexp describing a case statement header key.")
 
 (defconst vhdl-label-key
@@ -5318,6 +5577,17 @@ the offset is simply returned."
   "Check if point is in a string."
   (eq (vhdl-in-literal) 'string))
 
+(defun vhdl-in-quote-p ()
+  "Check if point is in a quote ('x')."
+  (or (and (> (point) (point-min))
+          (< (1+ (point)) (point-max))
+          (= (char-before (point)) ?\')
+          (= (char-after (1+ (point))) ?\'))
+      (and (> (1- (point)) (point-min))
+          (< (point) (point-max))
+          (= (char-before (1- (point))) ?\')
+          (= (char-after (point)) ?\'))))
+
 (defun vhdl-in-literal ()
   "Determine if point is in a VHDL literal."
   (save-excursion
@@ -5328,6 +5598,12 @@ the offset is simply returned."
        ((vhdl-beginning-of-macro) 'pound)
        (t nil)))))
 
+(defun vhdl-in-extended-identifier-p ()
+  "Determine if point is inside extended identifier (delimited by '\')."
+  (save-match-data
+    (and (save-excursion (re-search-backward "\\\\" (vhdl-point 'bol) t))
+        (save-excursion (re-search-forward "\\\\" (vhdl-point 'eol) t)))))
+
 (defun vhdl-forward-comment (&optional direction)
   "Skip all comments (including whitespace).  Skip backwards if DIRECTION is
 negative, skip forward otherwise."
@@ -5335,20 +5611,30 @@ negative, skip forward otherwise."
   (if (and direction (< direction 0))
       ;; skip backwards
       (progn
-       (skip-chars-backward " \t\n")
+       (skip-chars-backward " \t\n\r\f")
        (while (re-search-backward "^[^\"-]*\\(\\(-?\"[^\"]*\"\\|-[^\"-]\\)[^\"-]*\\)*\\(--\\)" (vhdl-point 'bol) t)
          (goto-char (match-beginning 3))
-         (skip-chars-backward " \t\n")))
+         (skip-chars-backward " \t\n\r\f")))
     ;; skip forwards
-    (skip-chars-forward " \t\n")
+    (skip-chars-forward " \t\n\r\f")
     (while (looking-at "--.*")
       (goto-char (match-end 0))
-      (skip-chars-forward " \t\n"))))
+      (skip-chars-forward " \t\n\r\f"))))
 
 ;; XEmacs hack: work around buggy `forward-comment' in XEmacs 21.4+
 (unless (and (featurep 'xemacs) (string< "21.2" emacs-version))
   (defalias 'vhdl-forward-comment 'forward-comment))
 
+(defun vhdl-back-to-indentation ()
+  "Move point to the first non-whitespace character on this line."
+  (interactive)
+  (beginning-of-line 1)
+  (skip-syntax-forward " " (vhdl-point 'eol)))
+
+;; XEmacs hack: work around old `back-to-indentation' in XEmacs
+(when (featurep 'xemacs)
+  (defalias 'back-to-indentation 'vhdl-back-to-indentation))
+
 ;; This is the best we can do in Win-Emacs.
 (defun vhdl-win-il (&optional lim)
   "Determine if point is in a VHDL literal."
@@ -5513,7 +5799,7 @@ that point, else nil."
   (and
    (save-excursion
      (forward-sexp)
-     (skip-chars-forward " \t\n")
+     (skip-chars-forward " \t\n\r\f")
      (not (looking-at "is\\b[^_]")))
    (save-excursion
      (backward-sexp)
@@ -5553,12 +5839,12 @@ corresponding \"begin\" keyword, else return nil."
           "is"))))
 
 (defconst vhdl-begin-fwd-re
-  "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|procedural\\|units\\|record\\|for\\)\\b\\([^_]\\|\\'\\)"
+  "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|procedural\\(\\s-+body\\)?\\|units\\|use\\|record\\|protected\\(\\s-+body\\)?\\|for\\)\\b\\([^_]\\|\\'\\)"
   "A regular expression for searching forward that matches all known
 \"begin\" keywords.")
 
 (defconst vhdl-begin-bwd-re
-  "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|procedural\\|units\\|record\\|for\\)\\b[^_]"
+  "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|procedural\\(\\s-+body\\)?\\|units\\|use\\|record\\|protected\\(\\s-+body\\)?\\|for\\)\\b[^_]"
   "A regular expression for searching backward that matches all known
 \"begin\" keywords.")
 
@@ -5591,21 +5877,21 @@ keyword."
           (and (/= (following-char) ?\;)
                (not (looking-at "is\\|begin\\|process\\|procedural\\|block")))))
     t)
-   ;; "begin", "then":
-   ((looking-at "be\\|t")
+   ;; "begin", "then", "use":
+   ((looking-at "be\\|t\\|use")
     t)
    ;; "else":
    ((and (looking-at "e")
         ;; make sure that the "else" isn't inside a
         ;; conditional signal assignment.
         (save-excursion
-          (re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
+          (vhdl-re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
           (or (eq (following-char) ?\;)
               (eq (point) lim))))
     t)
    ;; "block", "generate", "loop", "process", "procedural",
-   ;; "units", "record":
-   ((and (looking-at "bl\\|[glpur]")
+   ;; "units", "record", "protected body":
+   ((and (looking-at "block\\|generate\\|loop\\|process\\|procedural\\|protected\\(\\s-+body\\)?\\|units\\|record")
         (save-excursion
           (backward-sexp)
           (not (looking-at "end\\s-+\\w"))))
@@ -5633,7 +5919,7 @@ keyword."
   (cond
    ((looking-at "is\\|block\\|generate\\|process\\|procedural")
     "begin")
-   ((looking-at "then")
+   ((looking-at "then\\|use")
     "<else>")
    (t
     "end")))
@@ -5648,6 +5934,9 @@ Assumes that the caller will make sure that we are not in the middle
 of an identifier that just happens to contain a \"begin\" keyword."
   (save-excursion
     (and (looking-at vhdl-begin-fwd-re)
+        (or (not (looking-at "\\<use\\>"))
+            (save-excursion (back-to-indentation)
+                            (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
         (/= (preceding-char) ?_)
         (not (vhdl-in-literal))
         (vhdl-begin-p lim)
@@ -5670,8 +5959,8 @@ of an identifier that just happens to contain a \"begin\" keyword."
                              (vhdl-beginning-of-statement-1 lim)
                              (vhdl-backward-skip-label lim)
                              (vhdl-first-word (point)))))))
-         ;; "component", "units", "record":
-         ((looking-at "[cur]")
+         ;; "component", "units", "record", "protected body":
+         ((looking-at "component\\|units\\|protected\\(\\s-+body\\)?\\|record")
           ;; The first end found will close the block
           (vector "end" nil))
          ;; "block", "process", "procedural":
@@ -5683,8 +5972,8 @@ of an identifier that just happens to contain a \"begin\" keyword."
                         (vhdl-backward-skip-label lim)
                         (vhdl-first-word (point))))))
          ;; "then":
-         ((looking-at "t")
-          (vector "elsif\\|else\\|end\\s-+if"
+         ((looking-at "t\\|use")
+          (vector "elsif\\|else\\|end\\s-+\\(if\\|use\\)"
                   (and (vhdl-last-word (point))
                        (or (vhdl-first-word (point))
                            (save-excursion
@@ -5730,25 +6019,25 @@ of an identifier that just happens to contain an \"end\" keyword."
               (vhdl-end-p lim))
          (if (looking-at "el")
              ;; "else", "elsif":
-             (vector "if\\|elsif" (vhdl-first-word (point)) "then" nil)
+             (vector "if\\|elsif" (vhdl-first-word (point)) "then\\|use" nil)
            ;; "end ...":
            (setq pos (point))
            (forward-sexp)
-           (skip-chars-forward " \t\n")
+           (skip-chars-forward " \t\n\r\f")
            (cond
             ;; "end if":
             ((looking-at "if\\b[^_]")
              (vector "else\\|elsif\\|if"
                      (vhdl-first-word pos)
-                     "else\\|then" nil))
+                     "else\\|then\\|use" nil))
             ;; "end component":
             ((looking-at "component\\b[^_]")
              (vector (buffer-substring (match-beginning 1)
                                        (match-end 1))
                      (vhdl-first-word pos)
                      nil nil))
-            ;; "end units", "end record":
-            ((looking-at "\\(units\\|record\\)\\b[^_]")
+            ;; "end units", "end record", "end protected":
+            ((looking-at "\\(units\\|record\\|protected\\(\\s-+body\\)?\\)\\b[^_]")
              (vector (buffer-substring (match-beginning 1)
                                        (match-end 1))
                      (vhdl-first-word pos)
@@ -5805,38 +6094,38 @@ of an identifier that just happens to contain an \"end\" keyword."
     (cond ((looking-at "block\\|process\\|procedural")
           (if (save-excursion
                 (forward-sexp)
-                (skip-chars-forward " \t\n")
+                (skip-chars-forward " \t\n\r\f")
                 (= (following-char) ?\())
               (forward-sexp 2)
             (forward-sexp))
-          (when (looking-at "[ \t\n]*is")
+          (when (looking-at "[ \t\n\r\f]*is")
             (goto-char (match-end 0)))
           (point))
          ((looking-at "component")
           (forward-sexp 2)
-          (when (looking-at "[ \t\n]*is")
+          (when (looking-at "[ \t\n\r\f]*is")
             (goto-char (match-end 0)))
           (point))
          ((looking-at "for")
           (forward-sexp 2)
-          (skip-chars-forward " \t\n")
+          (skip-chars-forward " \t\n\r\f")
           (while (looking-at "[,:(]")
             (forward-sexp)
-            (skip-chars-forward " \t\n"))
+            (skip-chars-forward " \t\n\r\f"))
           (point))
          (t nil)
          )))
 
 (defconst vhdl-trailer-re
-  "\\b\\(is\\|then\\|generate\\|loop\\|record\\)\\b[^_]")
+  "\\b\\(is\\|then\\|generate\\|loop\\|record\\|protected\\(\\s-+body\\)?\\|use\\)\\b[^_]")
 
 (defconst vhdl-statement-fwd-re
-  "\\b\\(if\\|for\\|while\\)\\b\\([^_]\\|\\'\\)"
+  "\\b\\(if\\|for\\|while\\|loop\\)\\b\\([^_]\\|\\'\\)"
   "A regular expression for searching forward that matches all known
 \"statement\" keywords.")
 
 (defconst vhdl-statement-bwd-re
-  "\\b\\(if\\|for\\|while\\)\\b[^_]"
+  "\\b\\(if\\|for\\|while\\|loop\\)\\b[^_]"
   "A regular expression for searching backward that matches all known
 \"statement\" keywords.")
 
@@ -5852,7 +6141,7 @@ in the middle of an identifier that just happens to contain a
         ;; Make sure it's the start of a parameter specification.
         (save-excursion
           (forward-sexp 2)
-          (skip-chars-forward " \t\n")
+          (skip-chars-forward " \t\n\r\f")
           (looking-at "in\\b[^_]"))
         ;; Make sure it's not an "end for".
         (save-excursion
@@ -5871,7 +6160,7 @@ in the middle of an identifier that just happens to contain a
     t)
    ))
 
-(defconst vhdl-case-alternative-re "when[( \t\n][^;=>]+=>"
+(defconst vhdl-case-alternative-re "when[( \t\n\r\f][^;=>]+=>"
   "Regexp describing a case statement alternative key.")
 
 (defun vhdl-case-alternative-p (&optional lim)
@@ -5908,6 +6197,9 @@ contain a \"when\" keyword."
        (cond
         ;; "begin" keyword:
         ((and (looking-at vhdl-begin-fwd-re)
+              (or (not (looking-at "\\<use\\>"))
+                  (save-excursion (back-to-indentation)
+                                  (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
               (/= (preceding-char) ?_)
               (vhdl-begin-p lim))
          (setq foundp 'begin))
@@ -5931,7 +6223,7 @@ With COUNT, do it that many times."
     (save-excursion
       (while (> count 0)
        ;; skip whitespace
-       (skip-chars-forward " \t\n")
+       (skip-chars-forward " \t\n\r\f")
        ;; Check for an unbalanced "end" keyword
        (if (and (looking-at vhdl-end-fwd-re)
                 (/= (preceding-char) ?_)
@@ -6007,6 +6299,10 @@ searches."
            nil
          (backward-sexp)
          (if (and (looking-at vhdl-begin-fwd-re)
+                  (or (not (looking-at "\\<use\\>"))
+                      (save-excursion
+                        (back-to-indentation)
+                        (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
                   (/= (preceding-char) ?_)
                   (not (vhdl-in-literal))
                   (vhdl-begin-p lim))
@@ -6278,7 +6574,7 @@ search, and an argument indicating an interactive call."
   (re-search-forward vhdl-e-o-s-re))
 
 (defconst vhdl-b-o-s-re
-  (concat ";\\|\(\\|\)\\|\\bwhen\\b[^_]\\|"
+  (concat ";[^_]\\|\([^_]\\|\)[^_]\\|\\bwhen\\b[^_]\\|"
          vhdl-begin-bwd-re "\\|" vhdl-statement-bwd-re))
 
 (defun vhdl-beginning-of-statement-1 (&optional lim)
@@ -6299,7 +6595,7 @@ statement if already at the beginning of one."
     (while (and (not donep)
                (not (bobp))
                ;; look backwards for a statement boundary
-               (re-search-backward vhdl-b-o-s-re lim 'move))
+               (progn (forward-char) (re-search-backward vhdl-b-o-s-re lim 'move)))
       (if (or (= (preceding-char) ?_)
              (vhdl-in-literal))
          (backward-char)
@@ -6319,13 +6615,17 @@ statement if already at the beginning of one."
                     (vhdl-forward-syntactic-ws here)
                     (setq donep t))))
         ;; If we are looking at a semicolon, then stop
-        ((eq (following-char) ?\;)
+        ((and (eq (following-char) ?\;) (not (vhdl-in-quote-p)))
          (progn
            (forward-char)
            (vhdl-forward-syntactic-ws here)
            (setq donep t)))
         ;; If we are looking at a "begin", then stop
         ((and (looking-at vhdl-begin-fwd-re)
+              (or (not (looking-at "\\<use\\>"))
+                  (save-excursion
+                    (back-to-indentation)
+                    (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
               (/= (preceding-char) ?_)
               (vhdl-begin-p nil))
          ;; If it's a leader "begin", then find the
@@ -6576,6 +6876,10 @@ is not moved."
        (setq begin-after-ip (and
                              (not literal)
                              (looking-at vhdl-begin-fwd-re)
+                             (or (not (looking-at "\\<use\\>"))
+                                 (save-excursion
+                                   (back-to-indentation)
+                                   (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
                              (vhdl-begin-p)))
        (setq end-after-ip (and
                            (not literal)
@@ -6624,7 +6928,8 @@ is not moved."
           ((progn
              (vhdl-backward-syntactic-ws lim)
              (or (bobp)
-                 (= (preceding-char) ?\;)))
+                 (and (= (preceding-char) ?\;)
+                      (not (vhdl-in-quote-p)))))
            (vhdl-add-syntax 'statement placeholder))
           ;; CASE 2D: we are looking at a top-level statement-cont
           (t
@@ -6662,6 +6967,10 @@ is not moved."
                 (save-excursion
                   (vhdl-beginning-of-statement-1 containing-sexp)
                   (skip-chars-backward " \t(")
+                  (while (and (= (preceding-char) ?\;)
+                              (not (vhdl-in-quote-p)))
+                    (vhdl-beginning-of-statement-1 containing-sexp)
+                    (skip-chars-backward " \t("))
                   (<= (point) containing-sexp)))
            (goto-char containing-sexp)
            (vhdl-add-syntax 'arglist-cont-nonempty (vhdl-point 'boi)))
@@ -6891,7 +7200,7 @@ only-lines."
     (let* ((relpos (cdr langelem))
           (assignp (save-excursion
                     (goto-char (vhdl-point 'boi))
-                    (and (re-search-forward "\\(<\\|:\\)="
+                    (and (re-search-forward "\\(<\\|:\\|=\\)="
                                             (vhdl-point 'eol) t)
                          (- (point) (vhdl-point 'boi)))))
           (curcol (progn
@@ -6900,7 +7209,7 @@ only-lines."
           foundp)
       (while (and (not foundp)
                  (< (point) (vhdl-point 'eol)))
-       (re-search-forward "\\(<\\|:\\)=\\|(" (vhdl-point 'eol) 'move)
+       (re-search-forward "\\(<\\|:\\|=\\)=\\|(" (vhdl-point 'eol) 'move)
        (if (vhdl-in-literal)
            (forward-char)
          (if (= (preceding-char) ?\()
@@ -7001,7 +7310,8 @@ character is a space."
   (interactive)
   (if (and (= (preceding-char) ? ) (vhdl-in-comment-p))
       (indent-new-comment-line)
-    (when (and (>= (preceding-char) ?a) (<= (preceding-char) ?z))
+    (when (and (>= (preceding-char) ?a) (<= (preceding-char) ?z)
+              (not (vhdl-in-comment-p)))
       (vhdl-fix-case-word -1))
     (newline-and-indent)))
 
@@ -7011,6 +7321,7 @@ indentation change."
   (interactive)
   (let* ((syntax (and vhdl-indent-syntax-based (vhdl-get-syntactic-context)))
         (pos (- (point-max) (point)))
+        (is-comment nil)
         (indent
          (if syntax
              ;; indent syntax-based
@@ -7018,6 +7329,15 @@ indentation change."
                       (>= (vhdl-get-offset (car syntax)) comment-column))
                  ;; special case: comments at or right of comment-column
                  (vhdl-get-offset (car syntax))
+               ;; align comments like following code line
+               (when vhdl-indent-comment-like-next-code-line
+                 (save-excursion
+                   (while (eq (caar syntax) 'comment)
+                     (setq is-comment t)
+                     (beginning-of-line 2)
+                     (setq syntax (vhdl-get-syntactic-context)))))
+               (when is-comment
+                 (push (cons 'comment nil) syntax))
                (apply '+ (mapcar 'vhdl-get-offset syntax)))
            ;; indent like previous nonblank line
            (save-excursion (beginning-of-line)
@@ -7026,10 +7346,13 @@ indentation change."
         (shift-amt  (- indent (current-indentation))))
     (and vhdl-echo-syntactic-information-p
         (message "syntax: %s, indent= %d" syntax indent))
-    (unless (zerop shift-amt)
-      (delete-region (vhdl-point 'bol) (vhdl-point 'boi))
-      (beginning-of-line)
-      (indent-to indent))
+    (let ((has-formfeed
+          (save-excursion (beginning-of-line) (looking-at "\\s-*\f"))))
+      (when (or (not (zerop shift-amt)) has-formfeed)
+       (delete-region (vhdl-point 'bol) (vhdl-point 'boi))
+       (beginning-of-line)
+       (when has-formfeed (insert "\f"))
+       (indent-to indent)))
     (if (< (point) (vhdl-point 'boi))
        (back-to-indentation)
       ;; If initial point was within line's indentation, position after
@@ -7040,7 +7363,7 @@ indentation change."
     (vhdl-update-progress-info "Indenting" (vhdl-current-line))
     shift-amt))
 
-(defun vhdl-indent-region (beg end column)
+(defun vhdl-indent-region (beg end &optional column)
   "Indent region as VHDL code.
 Adds progress reporting to `indent-region'."
   (interactive "r\nP")
@@ -7055,7 +7378,7 @@ Adds progress reporting to `indent-region'."
   "Indent whole buffer as VHDL code.
 Calls `indent-region' for whole buffer and adds progress reporting."
   (interactive)
-  (vhdl-indent-region (point-min) (point-max) nil))
+  (vhdl-indent-region (point-min) (point-max)))
 
 (defun vhdl-indent-group ()
   "Indent group of lines between empty lines."
@@ -7068,7 +7391,7 @@ Calls `indent-region' for whole buffer and adds progress reporting."
               (if (re-search-forward vhdl-align-group-separate nil t)
                   (point-marker)
                 (point-max-marker)))))
-    (vhdl-indent-region beg end nil)))
+    (vhdl-indent-region beg end)))
 
 (defun vhdl-indent-sexp (&optional endpos)
   "Indent each line of the list starting just after point.
@@ -7125,27 +7448,29 @@ ENDPOS is encountered."
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Alignment, whitespace fixup, beautifying
+;;; Alignment, beautifying
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defconst vhdl-align-alist
   '(
     ;; after some keywords
-    (vhdl-mode "^\\s-*\\(constant\\|quantity\\|signal\\|subtype\\|terminal\\|type\\|variable\\)[ \t]"
-              "^\\s-*\\(constant\\|quantity\\|signal\\|subtype\\|terminal\\|type\\|variable\\)\\([ \t]+\\)" 2)
+    (vhdl-mode "^\\s-*\\(across\\|constant\\|quantity\\|signal\\|subtype\\|terminal\\|through\\|type\\|variable\\)[ \t]"
+              "^\\s-*\\(across\\|constant\\|quantity\\|signal\\|subtype\\|terminal\\|through\\|type\\|variable\\)\\([ \t]+\\)" 2)
     ;; before ':'
     (vhdl-mode ":[^=]" "\\([ \t]*\\):[^=]")
     ;; after direction specifications
     (vhdl-mode ":[ \t]*\\(in\\|out\\|inout\\|buffer\\|\\)\\>"
               ":[ \t]*\\(in\\|out\\|inout\\|buffer\\|\\)\\([ \t]+\\)" 2)
     ;; before "==", ":=", "=>", and "<="
-    (vhdl-mode "[<:=]=" "\\([ \t]*\\)[<:=]=" 1) ; since "<= ... =>" can occur
+    (vhdl-mode "[<:=]=" "\\([ \t]*\\)\\??[<:=]=" 1) ; since "<= ... =>" can occur
     (vhdl-mode "=>" "\\([ \t]*\\)=>" 1)
-    (vhdl-mode "[<:=]=" "\\([ \t]*\\)[<:=]=" 1) ; since "=> ... <=" can occur
+    (vhdl-mode "[<:=]=" "\\([ \t]*\\)\\??[<:=]=" 1) ; since "=> ... <=" can occur
     ;; before some keywords
     (vhdl-mode "[ \t]after\\>" "[^ \t]\\([ \t]+\\)after\\>" 1)
     (vhdl-mode "[ \t]when\\>" "[^ \t]\\([ \t]+\\)when\\>" 1)
     (vhdl-mode "[ \t]else\\>" "[^ \t]\\([ \t]+\\)else\\>" 1)
+    (vhdl-mode "[ \t]across\\>" "[^ \t]\\([ \t]+\\)across\\>" 1)
+    (vhdl-mode "[ \t]through\\>" "[^ \t]\\([ \t]+\\)through\\>" 1)
     ;; before "=>" since "when/else ... =>" can occur
     (vhdl-mode "=>" "\\([ \t]*\\)=>" 1)
     )
@@ -7195,7 +7520,7 @@ parentheses."
        (forward-list)
        (setq end (point))
        (goto-char (1+ beg))
-       (skip-chars-forward " \t\n")
+       (skip-chars-forward " \t\n\r\f")
        (setq beg (point))))
     ;; run FUNCTION
     (if beg
@@ -7280,8 +7605,14 @@ the token in MATCH."
            bol (setq begin (progn (beginning-of-line) (point))))
       (while (< bol end)
        (save-excursion
-         (when (and (re-search-forward match eol t)
-                    (not (vhdl-in-literal)))
+         (when (and (vhdl-re-search-forward match eol t)
+                    (save-excursion
+                      (goto-char (match-beginning 0))
+                      (forward-char)
+                      (and (not (vhdl-in-literal))
+                           (not (vhdl-in-quote-p))
+                           (not (vhdl-in-extended-identifier-p))))
+                    (not (looking-at "\\s-*$")))
            (setq distance (- (match-beginning substr) bol))
            (when (> distance max)
              (setq max distance))))
@@ -7295,8 +7626,16 @@ the token in MATCH."
       (goto-char (setq bol begin))
       (setq eol (point-at-eol))
       (while (> lines 0)
-       (when (and (re-search-forward match eol t)
-                  (not (vhdl-in-literal)))
+       (when (and (vhdl-re-search-forward match eol t)
+                  (save-excursion
+                    (goto-char (match-beginning 0))
+                    (forward-char)
+                    (and (not (vhdl-in-literal))
+                         (not (vhdl-in-quote-p))
+                         (not (vhdl-in-extended-identifier-p))))
+                  (not (looking-at "\\s-*$"))
+                  (> (match-beginning 0)  ; not if at boi
+                     (save-excursion (back-to-indentation) (point))))
          (setq width (- (match-end substr) (match-beginning substr)))
          (setq distance (- (match-beginning substr) bol))
          (goto-char (match-beginning substr))
@@ -7325,7 +7664,8 @@ the token in MATCH."
        (when vhdl-progress-interval
          (setq vhdl-progress-info (vector (count-lines (point-min) beg)
                                           (count-lines (point-min) end) 0))))
-      (vhdl-fixup-whitespace-region beg end t)
+      (when (nth 0 vhdl-beautify-options)
+       (vhdl-fixup-whitespace-region beg end t))
       (goto-char beg)
       (if (not vhdl-align-groups)
          ;; align entire region
@@ -7449,14 +7789,14 @@ the token in MATCH."
        ;; search for comment start positions and lengths
        (while (< (point) end)
         (when (and (not (looking-at "^\\s-*\\(begin\\|end\\)\\>"))
-                   (looking-at "^\\(.*[^ \t\n-]+\\)\\s-*\\(--.*\\)$")
+                   (looking-at "^\\(.*?[^ \t\n\r\f-]+\\)\\s-*\\(--.*\\)$")
                    (not (save-excursion (goto-char (match-beginning 2))
                                         (vhdl-in-literal))))
           (setq start (+ (- (match-end 1) (match-beginning 1)) spacing))
           (setq length (- (match-end 2) (match-beginning 2)))
           (setq start-max (max start start-max))
           (setq length-max (max length length-max))
-          (setq comment-list (cons (cons start length) comment-list)))
+          (push (cons start length) comment-list))
         (beginning-of-line 2))
        (setq comment-list
             (sort comment-list (function (lambda (a b) (> (car a) (car b))))))
@@ -7467,14 +7807,14 @@ the token in MATCH."
         (unless (or (= (caar comment-list) (car start-list))
                     (<= (+ (car start-list) (cdar comment-list))
                            end-comment-column))
-          (setq start-list (cons (caar comment-list) start-list)))
+          (push (caar comment-list) start-list))
         (setq comment-list (cdr comment-list)))
        ;; align lines as nicely as possible
        (goto-char beg)
        (while (< (point) end)
         (setq cur-start nil)
         (when (and (not (looking-at "^\\s-*\\(begin\\|end\\)\\>"))
-                   (or (and (looking-at "^\\(.*[^ \t\n-]+\\)\\(\\s-*\\)\\(--.*\\)$")
+                   (or (and (looking-at "^\\(.*?[^ \t\n\r\f-]+\\)\\(\\s-*\\)\\(--.*\\)$")
                             (not (save-excursion
                                    (goto-char (match-beginning 3))
                                    (vhdl-in-literal))))
@@ -7582,32 +7922,35 @@ end of line, do nothing in comments and strings."
     (setq end (point-marker))
     ;; have no space before and one space after `,' and ';'
     (goto-char beg)
-    (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|\'.\'\\)\\|\\(\\s-*\\([,;]\\)\\)" end t)
+    (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|\'.\'\\|\\\\[^\\\n]*[\\\n]\\)\\|\\(\\s-*\\([,;]\\)\\)" end t)
       (if (match-string 1)
          (goto-char (match-end 1))
-       (replace-match "\\3 " nil nil nil 3)))
+       (replace-match "\\3 " nil nil nil 2)))
     ;; have no space after `('
     (goto-char beg)
-    (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|\'.\'\\)\\|\\((\\)\\s-+" end t)
+    (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|\'.\'\\|\\\\[^\\\n]*[\\\n]\\)\\|\\((\\)\\s-+" end t)
       (if (match-string 1)
          (goto-char (match-end 1))
        (replace-match "\\2")))
     ;; have no space before `)'
     (goto-char beg)
-    (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|\'.\'\\|^\\s-+\\)\\|\\s-+\\()\\)" end t)
+    (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|\'.\'\\|\\\\[^\\\n]*[\\\n]\\|^\\s-+\\)\\|\\s-+\\()\\)" end t)
       (if (match-string 1)
          (goto-char (match-end 1))
        (replace-match "\\2")))
     ;; surround operator symbols by one space
     (goto-char beg)
-    (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|\'.\'\\)\\|\\(\\([^/:<>=]\\)\\(:\\|=\\|<\\|>\\|:=\\|<=\\|>=\\|=>\\|/=\\)\\([^=>]\\|$\\)\\)" end t)
-      (if (match-string 1)
-         (goto-char (match-end 1))
+    (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|\'.\'\\|\\\\[^\\\n]*[\\\n]\\)\\|\\(\\([^/:<>=\n]\\)\\(:\\|\\??=\\|\\??<<\\|\\??>>\\|\\??<\\|\\??>\\|:=\\|\\??<=\\|\\??>=\\|=>\\|\\??/=\\|\\?\\?\\)\\([^=>\n]\\|$\\)\\)" end t)
+      (if (or (match-string 1)
+             (<= (match-beginning 0)  ; not if at boi
+                (save-excursion (back-to-indentation) (point))))
+         (goto-char (match-end 0))
        (replace-match "\\3 \\4 \\5")
        (goto-char (match-end 2))))
     ;; eliminate multiple spaces and spaces at end of line
     (goto-char beg)
     (while (or (and (looking-at "--.*\n") (re-search-forward "--.*\n" end t))
+              (and (looking-at "--.*") (re-search-forward "--.*" end t))
               (and (looking-at "\"") (re-search-forward "\"[^\"\n]*[\"\n]" end t))
               (and (looking-at "\\s-+$") (re-search-forward "\\s-+$" end t)
                    (progn (replace-match "" nil nil) t))
@@ -7618,6 +7961,7 @@ end of line, do nothing in comments and strings."
                    (progn (replace-match "  " nil nil) t))
               (and (looking-at "\\s-+") (re-search-forward "\\s-+" end t)
                    (progn (replace-match " " nil nil) t))
+              (and (looking-at "-") (re-search-forward "-" end t))
 ;             (re-search-forward "[^ \t-]+" end t))))
               (re-search-forward "[^ \t\"-]+" end t))))
   (unless no-message (message "Fixing up whitespace...done")))
@@ -7629,6 +7973,154 @@ end of line, do nothing in comments."
   (interactive)
   (vhdl-fixup-whitespace-region (point-min) (point-max)))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Case fixing
+
+(defun vhdl-fix-case-region-1 (beg end upper-case word-regexp &optional count)
+  "Convert all words matching WORD-REGEXP in region to lower or upper case,
+depending on parameter UPPER-CASE."
+  (let ((case-replace nil)
+       (last-update 0))
+    (vhdl-prepare-search-2
+     (save-excursion
+       (goto-char end)
+       (setq end (point-marker))
+       (goto-char beg)
+       (while (re-search-forward word-regexp end t)
+        (or (vhdl-in-literal)
+            (if upper-case
+                (upcase-word -1)
+              (downcase-word -1)))
+        (when (and count vhdl-progress-interval (not noninteractive)
+                   (< vhdl-progress-interval
+                      (- (nth 1 (current-time)) last-update)))
+          (message "Fixing case... (%2d%s)"
+                   (+ (* count 20) (/ (* 20 (- (point) beg)) (- end beg)))
+                   "%")
+          (setq last-update (nth 1 (current-time)))))
+       (goto-char end)))))
+
+(defun vhdl-fix-case-region (beg end &optional arg)
+  "Convert all VHDL words in region to lower or upper case, depending on
+options vhdl-upper-case-{keywords,types,attributes,enum-values}."
+  (interactive "r\nP")
+  (vhdl-fix-case-region-1
+   beg end vhdl-upper-case-keywords vhdl-keywords-regexp 0)
+  (vhdl-fix-case-region-1
+   beg end vhdl-upper-case-types vhdl-types-regexp 1)
+  (vhdl-fix-case-region-1
+   beg end vhdl-upper-case-attributes (concat "'" vhdl-attributes-regexp) 2)
+  (vhdl-fix-case-region-1
+   beg end vhdl-upper-case-enum-values vhdl-enum-values-regexp 3)
+  (vhdl-fix-case-region-1
+   beg end vhdl-upper-case-constants vhdl-constants-regexp 4)
+  (when vhdl-progress-interval (message "Fixing case...done")))
+
+(defun vhdl-fix-case-buffer ()
+  "Convert all VHDL words in buffer to lower or upper case, depending on
+options vhdl-upper-case-{keywords,types,attributes,enum-values}."
+  (interactive)
+  (vhdl-fix-case-region (point-min) (point-max)))
+
+(defun vhdl-fix-case-word (&optional arg)
+  "Convert word after cursor to upper case if necessary."
+  (interactive "p")
+  (save-excursion
+    (when arg (backward-word 1))
+    (vhdl-prepare-search-1
+     (when (and vhdl-upper-case-keywords
+               (looking-at vhdl-keywords-regexp))
+       (upcase-word 1))
+     (when (and vhdl-upper-case-types
+               (looking-at vhdl-types-regexp))
+       (upcase-word 1))
+     (when (and vhdl-upper-case-attributes
+               (looking-at vhdl-attributes-regexp))
+       (upcase-word 1))
+     (when (and vhdl-upper-case-enum-values
+               (looking-at vhdl-enum-values-regexp))
+       (upcase-word 1))
+     (when (and vhdl-upper-case-constants
+               (looking-at vhdl-constants-regexp))
+       (upcase-word 1)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Fix statements
+;; - force each statement to be on a separate line except when on same line
+;;   with 'end' keyword
+
+(defun vhdl-fix-statement-region (beg end &optional arg)
+  "Force statements in region on separate line except when on same line
+with 'end' keyword (necessary for correct indentation).
+Currently supported keywords: 'begin', 'if'."
+  (interactive "r\nP")
+  (vhdl-prepare-search-2
+   (let (point)
+     (save-excursion
+       (goto-char end)
+       (setq end (point-marker))
+       (goto-char beg)
+       ;; `begin' keyword
+       (while (re-search-forward
+              "^\\s-*[^ \t\n].*?\\(\\<begin\\>\\)\\(.*\\<end\\>\\)?" end t)
+        (goto-char (match-end 0))
+        (setq point (point-marker))
+        (when (and (match-string 1)
+                   (or (not (match-string 2))
+                       (save-excursion (goto-char (match-end 2))
+                                       (vhdl-in-literal)))
+                   (not (save-excursion (goto-char (match-beginning 1))
+                                        (vhdl-in-literal))))
+          (goto-char (match-beginning 1))
+          (insert "\n")
+          (indent-according-to-mode))
+        (goto-char point))
+       (goto-char beg)
+       ;; `for', `if' keywords
+       (while (re-search-forward "\\<\\(for\\|if\\)\\>" end t)
+        (goto-char (match-end 1))
+        (setq point (point-marker))
+        ;; exception: in literal or preceded by `end' or label
+        (when (and (not (save-excursion (goto-char (match-beginning 1))
+                                        (vhdl-in-literal)))
+                   (save-excursion
+                     (beginning-of-line 1)
+                     (save-match-data
+                       (and (re-search-forward "^\\s-*\\([^ \t\n].*\\)"
+                                               (match-beginning 1) t)
+                            (not (string-match
+                                  "\\(\\<end\\>\\|\\<wait\\>\\|\\w+\\s-*:\\)\\s-*$"
+                                  (match-string 1)))))))
+          (goto-char (match-beginning 1))
+          (insert "\n")
+          (indent-according-to-mode))
+        (goto-char point))))))
+
+(defun vhdl-fix-statement-buffer ()
+  "Force statements in buffer on separate line except when on same line
+with 'end' keyword (necessary for correct indentation)."
+  (interactive)
+  (vhdl-fix-statement-region (point-min) (point-max)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Trailing spaces
+
+(defun vhdl-remove-trailing-spaces-region (beg end &optional arg)
+  "Remove trailing spaces in region."
+  (interactive "r\nP")
+  (save-excursion
+    (goto-char end)
+    (setq end (point-marker))
+    (goto-char beg)
+    (while (re-search-forward "[ \t]+$" end t)
+      (unless (vhdl-in-literal)
+       (replace-match "" nil nil)))))
+
+(defun vhdl-remove-trailing-spaces ()
+  "Remove trailing spaces in buffer."
+  (interactive)
+  (vhdl-remove-trailing-spaces-region (point-min) (point-max)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Beautify
 
@@ -7639,10 +8131,17 @@ case fixing to a region.  Calls functions `vhdl-indent-buffer',
 `vhdl-fix-case-buffer'."
   (interactive "r")
   (setq end (save-excursion (goto-char end) (point-marker)))
-  (vhdl-indent-region beg end nil)
+  (save-excursion ; remove DOS EOL characters in UNIX file
+    (goto-char beg)
+    (while (search-forward "\r" nil t)
+      (replace-match "" nil t)))
+  (when (nth 0 vhdl-beautify-options) (vhdl-fixup-whitespace-region beg end t))
+  (when (nth 1 vhdl-beautify-options) (vhdl-fix-statement-region beg end))
+  (when (nth 2 vhdl-beautify-options) (vhdl-indent-region beg end))
   (let ((vhdl-align-groups t))
-    (vhdl-align-region beg end))
-  (vhdl-fix-case-region beg end))
+    (when (nth 3 vhdl-beautify-options) (vhdl-align-region beg end)))
+  (when (nth 4 vhdl-beautify-options) (vhdl-fix-case-region beg end))
+  (when (nth 0 vhdl-beautify-options) (vhdl-remove-trailing-spaces-region beg end)))
 
 (defun vhdl-beautify-buffer ()
   "Beautify buffer by applying indentation, whitespace fixup, alignment, and
@@ -7720,7 +8219,7 @@ buffer."
     (vhdl-prepare-search-2
      (end-of-line)
      ;; look whether in process
-     (if (not (and (re-search-backward "^\\s-*\\(\\w+[ \t\n]*:[ \t\n]*\\)?\\(process\\|end\\s-+process\\)\\>" nil t)
+     (if (not (and (re-search-backward "^\\s-*\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(process\\|end\\s-+process\\)\\>" nil t)
                   (equal (upcase (match-string 2)) "PROCESS")
                   (save-excursion (re-search-forward "^\\s-*end\\s-+process\\>" nil t))))
         (error "ERROR:  Not within a process")
@@ -7735,18 +8234,23 @@ buffer."
     (vhdl-prepare-search-2
      (goto-char (point-min))
      (message "Updating sensitivity lists...")
-     (while (re-search-forward "^\\s-*\\(\\w+[ \t\n]*:[ \t\n]*\\)?process\\>" nil t)
+     (while (re-search-forward "^\\s-*\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?process\\>" nil t)
        (goto-char (match-beginning 0))
        (condition-case nil (vhdl-update-sensitivity-list) (error "")))
-     (message "Updating sensitivity lists...done"))))
+     (message "Updating sensitivity lists...done")))
+  (when noninteractive (save-buffer)))
 
 (defun vhdl-update-sensitivity-list ()
   "Update sensitivity list."
     (let ((proc-beg (point))
          (proc-end (re-search-forward "^\\s-*end\\s-+process\\>" nil t))
-         (proc-mid (re-search-backward "^\\s-*begin\\>" nil t))
+         (proc-mid (vhdl-re-search-backward
+                    "\\(\\(\\<begin\\>\\)\\|^\\s-*process\\>\\)" nil t))
          seq-region-list)
       (cond
+       ;; error if 'begin' keyword missing
+       ((not (match-string 2))
+       (error "ERROR:  No 'begin' keyword found"))
        ;; search for wait statement (no sensitivity list allowed)
        ((progn (goto-char proc-mid)
               (vhdl-re-search-forward "\\<wait\\>" proc-end t))
@@ -7760,57 +8264,57 @@ buffer."
             (scan-regions-list
              '(;; right-hand side of signal/variable assignment
                ;; (special case: "<=" is relational operator in a condition)
-               ((re-search-forward "[<:]=" proc-end t)
-                (re-search-forward ";\\|\\<\\(then\\|loop\\|report\\|severity\\|is\\)\\>" proc-end t))
+               ((vhdl-re-search-forward "[<:]=" proc-end t)
+                (vhdl-re-search-forward ";\\|\\<\\(then\\|loop\\|report\\|severity\\|is\\)\\>" proc-end t))
                ;; if condition
-               ((re-search-forward "^\\s-*if\\>" proc-end t)
-                (re-search-forward "\\<then\\>" proc-end t))
+               ((vhdl-re-search-forward "^\\s-*if\\>" proc-end t)
+                (vhdl-re-search-forward "\\<then\\>" proc-end t))
                ;; elsif condition
-               ((re-search-forward "\\<elsif\\>" proc-end t)
-                (re-search-forward "\\<then\\>" proc-end t))
+               ((vhdl-re-search-forward "\\<elsif\\>" proc-end t)
+                (vhdl-re-search-forward "\\<then\\>" proc-end t))
                ;; while loop condition
-               ((re-search-forward "^\\s-*while\\>" proc-end t)
-                (re-search-forward "\\<loop\\>" proc-end t))
+               ((vhdl-re-search-forward "^\\s-*while\\>" proc-end t)
+                (vhdl-re-search-forward "\\<loop\\>" proc-end t))
                ;; exit/next condition
-               ((re-search-forward "\\<\\(exit\\|next\\)\\s-+\\w+\\s-+when\\>" proc-end t)
-                (re-search-forward ";" proc-end t))
+               ((vhdl-re-search-forward "\\<\\(exit\\|next\\)\\s-+\\w+\\s-+when\\>" proc-end t)
+                (vhdl-re-search-forward ";" proc-end t))
                ;; assert condition
-               ((re-search-forward "\\<assert\\>" proc-end t)
-                (re-search-forward "\\(\\<report\\>\\|\\<severity\\>\\|;\\)" proc-end t))
+               ((vhdl-re-search-forward "\\<assert\\>" proc-end t)
+                (vhdl-re-search-forward "\\(\\<report\\>\\|\\<severity\\>\\|;\\)" proc-end t))
                ;; case expression
-               ((re-search-forward "^\\s-*case\\>" proc-end t)
-                (re-search-forward "\\<is\\>" proc-end t))
-               ;; parameter list of procedure call
-               ((and (re-search-forward "^\\s-*\\w+[ \t\n]*(" proc-end t)
+               ((vhdl-re-search-forward "^\\s-*case\\>" proc-end t)
+                (vhdl-re-search-forward "\\<is\\>" proc-end t))
+               ;; parameter list of procedure call, array index
+               ((and (re-search-forward "^\\s-*\\(\\w\\|\\.\\)+[ \t\n\r\f]*(" proc-end t)
                      (1- (point)))
                 (progn (backward-char) (forward-sexp)
                        (while (looking-at "(") (forward-sexp)) (point)))))
-            name read-list sens-list signal-list
+            name field read-list sens-list signal-list tmp-list
             sens-beg sens-end beg end margin)
          ;; scan for signals in old sensitivity list
          (goto-char proc-beg)
-         (re-search-forward "\\<process\\>" proc-mid t)
-         (if (not (looking-at "[ \t\n]*("))
+         (vhdl-re-search-forward "\\<process\\>" proc-mid t)
+         (if (not (looking-at "[ \t\n\r\f]*("))
              (setq sens-beg (point))
-           (setq sens-beg (re-search-forward "\\([ \t\n]*\\)([ \t\n]*" nil t))
+           (setq sens-beg (vhdl-re-search-forward "\\([ \t\n\r\f]*\\)([ \t\n\r\f]*" nil t))
            (goto-char (match-end 1))
            (forward-sexp)
            (setq sens-end (1- (point)))
            (goto-char sens-beg)
-           (while (and (re-search-forward "\\(\\w+\\)" sens-end t)
+           (while (and (vhdl-re-search-forward "\\(\\w+\\)" sens-end t)
                        (setq sens-list
                              (cons (downcase (match-string 0)) sens-list))
-                       (re-search-forward "\\s-*,\\s-*" sens-end t))))
+                       (vhdl-re-search-forward "\\s-*,\\s-*" sens-end t))))
          (setq signal-list (append visible-list sens-list))
          ;; search for sequential parts
          (goto-char proc-mid)
          (while (setq beg (re-search-forward "^\\s-*\\(els\\)?if\\>" proc-end t))
-           (setq end (re-search-forward "\\<then\\>" proc-end t))
-           (when (re-search-backward "\\('event\\|\\<\\(falling\\|rising\\)_edge\\)\\>" beg t)
+           (setq end (vhdl-re-search-forward "\\<then\\>" proc-end t))
+           (when (vhdl-re-search-backward "\\('event\\|\\<\\(falling\\|rising\\)_edge\\)\\>" beg t)
              (goto-char end)
              (backward-word 1)
              (vhdl-forward-sexp)
-             (setq seq-region-list (cons (cons end (point)) seq-region-list))
+             (push (cons end (point)) seq-region-list)
              (beginning-of-line)))
          ;; scan for signals read in process
          (while scan-regions-list
@@ -7825,15 +8329,37 @@ buffer."
                                             (< (point) (caar tmp-list)))
                                   (setq tmp-list (cdr tmp-list)))
                                 (and tmp-list (< (point) (cdar tmp-list))))))
-               (while (vhdl-re-search-forward "[^'\"]\\<\\([a-zA-Z]\\w*\\)\\>[ \t\n]*\\('\\(\\w+\\)\\|\\(=>\\)\\)?" end t)
+               (while (vhdl-re-search-forward "[^'\".]\\<\\([a-zA-Z]\\w*\\)\\(\\(\\.\\w+\\|[ \t\n\r\f]*([^)]*)\\)*\\)[ \t\n\r\f]*\\('\\(\\w+\\)\\|\\(=>\\)\\)?" end t)
                  (setq name (match-string 1))
-                 (when (and (not (match-string 4)) ; not when formal parameter
-                            (not (and (match-string 3) ; not event attribute
-                                      (not (member (downcase (match-string 3))
+                 ;; get array index range
+                 (when vhdl-array-index-record-field-in-sensitivity-list
+                   (setq field (match-string 2))
+                   ;; not use if it includes a variable name
+                   (save-match-data
+                     (setq tmp-list visible-list)
+                     (while (and field tmp-list)
+                       (when (string-match
+                              (concat "\\<" (car tmp-list) "\\>") field)
+                         (setq field nil))
+                       (setq tmp-list (cdr tmp-list)))))
+                 (when (and (not (match-string 6)) ; not when formal parameter
+                            (not (and (match-string 5) ; not event attribute
+                                      (not (member (downcase (match-string 5))
                                                    '("event" "last_event" "transaction")))))
                             (member (downcase name) signal-list))
-                   (unless (member-ignore-case name read-list)
-                     (setq read-list (cons name read-list))))
+                   ;; not add if name or name+field already exists
+                   (unless
+                       (or (member-ignore-case name read-list)
+                           (member-ignore-case (concat name field) read-list))
+                     (push (concat name field) read-list))
+                   (setq tmp-list read-list)
+                   ;; remove existing name+field if name is added
+                   (save-match-data
+                     (while tmp-list
+                       (when (string-match (concat "^" name field "[(.]")
+                                           (car tmp-list))
+                         (setq read-list (delete (car tmp-list) read-list)))
+                       (setq tmp-list (cdr tmp-list)))))
                  (goto-char (match-end 1)))))
            (setq scan-regions-list (cdr scan-regions-list)))
          ;; update sensitivity list
@@ -7879,17 +8405,17 @@ buffer."
         (goto-char (point-min))
         (if (not (re-search-forward (concat "^entity\\s-+" entity-name "\\>") nil t))
             (error "ERROR:  Entity \"%s\" not found:\n  --> see option `vhdl-entity-file-name'" entity-name)
-          (when (setq beg (re-search-forward
-                           "^\\s-*port[ \t\n]*("
+          (when (setq beg (vhdl-re-search-forward
+                           "\\<port[ \t\n\r\f]*("
                            (save-excursion
                              (re-search-forward "^end\\>" nil t)) t))
             (setq end (save-excursion
                         (backward-char) (forward-sexp) (point)))
             (vhdl-forward-syntactic-ws)
             (while (< (point) end)
-              (when (looking-at "signal[ \t\n]+")
+              (when (looking-at "signal[ \t\n\r\f]+")
                 (goto-char (match-end 0)))
-              (while (looking-at "\\(\\w+\\)[ \t\n,]+")
+              (while (looking-at "\\([a-zA-Z]\\w*\\)[ \t\n\r\f,]+")
                 (setq signal-list
                       (cons (downcase (match-string 1)) signal-list))
                 (goto-char (match-end 0))
@@ -7908,12 +8434,12 @@ buffer."
           (when (= 0 (nth 0 (parse-partial-sexp beg (point))))
             (if (match-string 2)
                 ;; scan signal name
-                (while (looking-at "[ \t\n,]+\\(\\w+\\)")
+                (while (looking-at "[ \t\n\r\f,]+\\([a-zA-Z]\\w*\\)")
                   (setq signal-list
                         (cons (downcase (match-string 1)) signal-list))
                   (goto-char (match-end 0)))
               ;; scan alias name, check is alias of (declared) signal
-              (when (and (looking-at "[ \t\n]+\\(\\w+\\)[^;]*\\<is[ \t\n]+\\(\\w+\\)")
+              (when (and (looking-at "[ \t\n\r\f]+\\([a-zA-Z]\\w*\\)[^;]*\\<is[ \t\n\r\f]+\\([a-zA-Z]\\w*\\)")
                          (member (downcase (match-string 2)) signal-list))
                 (setq signal-list
                       (cons (downcase (match-string 1)) signal-list))
@@ -7950,6 +8476,18 @@ buffer."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Generic/port clause fixing
 
+(defun vhdl-fix-clause-buffer ()
+  "Fix all generic/port clauses in current buffer."
+  (interactive)
+  (save-excursion
+    (vhdl-prepare-search-2
+     (goto-char (point-min))
+     (message "Fixing generic/port clauses...")
+     (while (re-search-forward "^\\s-*\\(generic\\|port\\)[ \t\n\r\f]*(" nil t)
+       (goto-char (match-end 0))
+       (condition-case nil (vhdl-fix-clause) (error "")))
+     (message "Fixing generic/port clauses...done"))))
+
 (defun vhdl-fix-clause ()
   "Fix closing parenthesis within generic/port clause."
   (interactive)
@@ -7957,13 +8495,14 @@ buffer."
     (vhdl-prepare-search-2
      (let ((pos (point))
           beg end)
-       (if (not (re-search-backward "^\\s-*\\(generic\\|port\\)[ \t\n]*(" nil t))
+       (end-of-line)
+       (if (not (re-search-backward "^\\s-*\\(generic\\|port\\)[ \t\n\r\f]*(" nil t))
           (error "ERROR:  Not within a generic/port clause")
         ;; search for end of clause
         (goto-char (match-end 0))
         (setq beg (1- (point)))
         (vhdl-forward-syntactic-ws)
-        (while (looking-at "\\w+\\([ \t\n]*,[ \t\n]*\\w+\\)*[ \t\n]*:[ \t\n]*\\w+[^;]*;")
+        (while (looking-at "\\w+\\([ \t\n\r\f]*,[ \t\n\r\f]*\\w+\\)*[ \t\n\r\f]*:[ \t\n\r\f]*\\w+[^;]*;")
           (goto-char (1- (match-end 0)))
           (setq end (point-marker))
           (forward-char)
@@ -7988,19 +8527,6 @@ buffer."
           (goto-char end)
           (insert ")")))))))
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Miscellaneous
-
-(defun vhdl-remove-trailing-spaces ()
-  "Remove trailing spaces in the whole buffer."
-  (interactive)
-  (save-match-data
-    (save-excursion
-      (goto-char (point-min))
-      (while (re-search-forward "[ \t]+$" (point-max) t)
-       (unless (vhdl-in-literal)
-         (replace-match "" nil nil))))))
-
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Electrification
@@ -8032,14 +8558,14 @@ project is defined."
 With a prefix argument ARG, enable the mode if ARG is positive,
 and disable it otherwise.  If called from Lisp, enable it if ARG
 is omitted or nil."
-  :global t)
+  :global t :group 'vhdl-mode)
 
 (define-minor-mode vhdl-stutter-mode
   "Toggle VHDL stuttering mode.
 With a prefix argument ARG, enable the mode if ARG is positive,
 and disable it otherwise.  If called from Lisp, enable it if ARG
 is omitted or nil."
-  :global t)
+  :global t :group 'vhdl-mode)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Stuttering
@@ -8096,7 +8622,7 @@ is omitted or nil."
 (defun vhdl-electric-quote (count) "'' --> \""
   (interactive "p")
   (if (and vhdl-stutter-mode (= count 1) (not (vhdl-in-literal)))
-      (if (= (preceding-char) last-input-event)
+      (if (= (preceding-char) vhdl-last-input-event)
          (progn (delete-char -1) (insert-char ?\" 1))
        (insert-char ?\' 1))
     (self-insert-command count)))
@@ -8104,7 +8630,7 @@ is omitted or nil."
 (defun vhdl-electric-semicolon (count) "';;' --> ' : ', ': ;' --> ' := '"
   (interactive "p")
   (if (and vhdl-stutter-mode (= count 1) (not (vhdl-in-literal)))
-      (cond ((= (preceding-char) last-input-event)
+      (cond ((= (preceding-char) vhdl-last-input-event)
             (progn (delete-char -1)
                    (unless (eq (preceding-char) ? ) (insert " "))
                    (insert ": ")
@@ -8118,7 +8644,7 @@ is omitted or nil."
 (defun vhdl-electric-comma (count) "',,' --> ' <= '"
   (interactive "p")
   (if (and vhdl-stutter-mode (= count 1) (not (vhdl-in-literal)))
-      (cond ((= (preceding-char) last-input-event)
+      (cond ((= (preceding-char) vhdl-last-input-event)
             (progn (delete-char -1)
                    (unless (eq (preceding-char) ? ) (insert " "))
                    (insert "<= ")))
@@ -8128,7 +8654,7 @@ is omitted or nil."
 (defun vhdl-electric-period (count) "'..' --> ' => '"
   (interactive "p")
   (if (and vhdl-stutter-mode (= count 1) (not (vhdl-in-literal)))
-      (cond ((= (preceding-char) last-input-event)
+      (cond ((= (preceding-char) vhdl-last-input-event)
             (progn (delete-char -1)
                    (unless (eq (preceding-char) ? ) (insert " "))
                    (insert "=> ")))
@@ -8138,7 +8664,7 @@ is omitted or nil."
 (defun vhdl-electric-equal (count) "'==' --> ' == '"
   (interactive "p")
   (if (and vhdl-stutter-mode (= count 1) (not (vhdl-in-literal)))
-      (cond ((= (preceding-char) last-input-event)
+      (cond ((= (preceding-char) vhdl-last-input-event)
             (progn (delete-char -1)
                    (unless (eq (preceding-char) ? ) (insert " "))
                    (insert "== ")))
@@ -8317,7 +8843,8 @@ is omitted or nil."
   (let ((margin (current-indentation))
        (start (point))
        label)
-    (unless kind (setq kind (if (vhdl-sequential-statement-p) 'is 'use)))
+    (unless kind (setq kind (if (or (vhdl-sequential-statement-p)
+                                   (not (vhdl-standard-p 'ams))) 'is 'use)))
     (if (or (not (eq vhdl-optional-labels 'all)) (vhdl-standard-p '87))
        (vhdl-insert-keyword "CASE ")
       (vhdl-insert-keyword ": CASE ")
@@ -8408,12 +8935,13 @@ since these are almost equivalent)."
                    "[COMPONENT | ENTITY | CONFIGURATION]" " " t))
        (setq unit (upcase (or unit "")))
        (cond ((equal unit "ENTITY")
-              (vhdl-template-field "library name" "." nil nil nil nil
+              (let ((begin (point)))
+                (vhdl-template-field "library name" "." t begin (point) nil
                                    (vhdl-work-library))
               (vhdl-template-field "entity name" "(")
               (if (vhdl-template-field "[architecture name]" nil t)
                   (insert ")")
-                (delete-char -1)))
+                  (delete-char -1))))
              ((equal unit "CONFIGURATION")
               (vhdl-template-field "library name" "." nil nil nil nil
                                    (vhdl-work-library))
@@ -8905,7 +9433,7 @@ otherwise."
       (vhdl-insert-keyword
        (concat " " (if (eq kind 'then) "THEN" "USE") "\n\n"))
       (indent-to margin)
-      (vhdl-insert-keyword "END IF")
+      (vhdl-insert-keyword (concat "END " (if (eq kind 'then) "IF" "USE")))
       (when label (insert " " label))
       (insert ";")
       (forward-line -1)
@@ -9226,6 +9754,7 @@ otherwise."
   (interactive)
   (let ((margin (current-indentation))
        (start (point))
+       (reset-kind vhdl-reset-kind)
        label seq input-signals clock reset final-pos)
     (setq seq (if kind (eq kind 'seq)
                (eq (vhdl-decision-query
@@ -9248,7 +9777,13 @@ otherwise."
       (setq clock (or (and (not (equal "" vhdl-clock-name))
                           (progn (insert vhdl-clock-name) vhdl-clock-name))
                      (vhdl-template-field "clock name") "<clock>"))
-      (when (eq vhdl-reset-kind 'async)
+      (when (eq reset-kind 'query)
+       (setq reset-kind
+             (if (eq (vhdl-decision-query
+                      "" "(a)synchronous or (s)ynchronous reset?" t) ?a)
+                 'async
+               'sync)))
+      (when (eq reset-kind 'async)
        (insert ", ")
        (setq reset (or (and (not (equal "" vhdl-reset-name))
                             (progn (insert vhdl-reset-name) vhdl-reset-name))
@@ -9257,7 +9792,7 @@ otherwise."
     (unless (vhdl-standard-p '87) (vhdl-insert-keyword " IS"))
     (insert "\n")
     (vhdl-template-begin-end "PROCESS" label margin)
-    (when seq (setq reset (vhdl-template-seq-process clock reset)))
+    (when seq (setq reset (vhdl-template-seq-process clock reset reset-kind)))
     (when vhdl-prompt-for-comments
       (setq final-pos (point-marker))
       (vhdl-prepare-search-2
@@ -9542,7 +10077,7 @@ otherwise."
       (let ((definition
              (upcase
               (or (vhdl-template-field
-                   "[scalar type | ARRAY | RECORD | ACCESS | FILE]" nil t)
+                   "[scalar type | ARRAY | RECORD | ACCESS | FILE | ENUM]" nil t)
                   ""))))
        (cond ((equal definition "")
               (delete-char -4)
@@ -9560,6 +10095,11 @@ otherwise."
              ((equal definition "FILE")
               (vhdl-insert-keyword " OF ")
               (vhdl-template-field "type" ";"))
+             ((equal definition "ENUM")
+              (kill-word -1)
+              (insert "(")
+              (setq end-pos (point-marker))
+              (insert ");"))
              (t (insert ";")))
        (when mid-pos
          (setq end-pos (point-marker))
@@ -9589,13 +10129,13 @@ otherwise."
        (in-arglist (vhdl-in-argument-list-p)))
     (vhdl-prepare-search-2
      (if (or (save-excursion
-              (and (vhdl-re-search-backward
-                    "\\<function\\|procedure\\|process\\|procedural\\|end\\>"
-                    nil t)
-                   (not (progn (backward-word 1) (looking-at "\\<end\\>")))))
+              (progn (vhdl-beginning-of-block)
+                     (looking-at "\\s-*\\(\\w+\\s-*:\\s-*\\)?\\<\\(\\<function\\|procedure\\|process\\|procedural\\)\\>")))
             (save-excursion (backward-word 1) (looking-at "\\<shared\\>")))
         (vhdl-insert-keyword "VARIABLE ")
-       (vhdl-insert-keyword "SHARED VARIABLE ")))
+       (if (vhdl-standard-p '87)
+          (error "ERROR:  Not within sequential block")
+        (vhdl-insert-keyword "SHARED VARIABLE "))))
     (when (vhdl-template-field "names" nil t start (point))
       (insert " : ")
       (when in-arglist (vhdl-template-field "[IN | OUT | INOUT]" " " t))
@@ -9692,14 +10232,16 @@ otherwise."
        (concat (if vhdl-clock-rising-edge "rising" "falling")
               " clock edge")))))
 
-(defun vhdl-template-seq-process (clock reset)
+(defun vhdl-template-seq-process (clock reset reset-kind)
   "Insert a template for the body of a sequential process."
   (let ((margin (current-indentation))
        position)
     (vhdl-insert-keyword "IF ")
-    (when (eq vhdl-reset-kind 'async)
+    (when vhdl-conditions-in-parenthesis (insert "("))
+    (when (eq reset-kind 'async)
       (insert reset " = "
              (if vhdl-reset-active-high vhdl-one-string vhdl-zero-string))
+      (when vhdl-conditions-in-parenthesis (insert ")"))
       (vhdl-insert-keyword " THEN")
       (vhdl-comment-insert-inline
        (concat "asynchronous reset (active "
@@ -9707,7 +10249,8 @@ otherwise."
       (insert "\n") (indent-to (+ margin vhdl-basic-offset))
       (setq position (point))
       (insert "\n") (indent-to margin)
-      (vhdl-insert-keyword "ELSIF "))
+      (vhdl-insert-keyword "ELSIF ")
+      (when vhdl-conditions-in-parenthesis (insert "(")))
     (if (eq vhdl-clock-edge-condition 'function)
        (insert (if vhdl-clock-rising-edge "rising" "falling")
                "_edge(" clock ")")
@@ -9715,17 +10258,20 @@ otherwise."
       (vhdl-insert-keyword " AND ")
       (insert clock " = "
              (if vhdl-clock-rising-edge vhdl-one-string vhdl-zero-string)))
+    (when vhdl-conditions-in-parenthesis (insert ")"))
     (vhdl-insert-keyword " THEN")
     (vhdl-comment-insert-inline
      (concat (if vhdl-clock-rising-edge "rising" "falling") " clock edge"))
     (insert "\n") (indent-to (+ margin vhdl-basic-offset))
-    (when (eq vhdl-reset-kind 'sync)
+    (when (eq reset-kind 'sync)
       (vhdl-insert-keyword "IF ")
+      (when vhdl-conditions-in-parenthesis (insert "("))
       (setq reset (or (and (not (equal "" vhdl-reset-name))
                           (progn (insert vhdl-reset-name) vhdl-reset-name))
                      (vhdl-template-field "reset name") "<reset>"))
       (insert " = "
              (if vhdl-reset-active-high vhdl-one-string vhdl-zero-string))
+      (when vhdl-conditions-in-parenthesis (insert ")"))
       (vhdl-insert-keyword " THEN")
       (vhdl-comment-insert-inline
        (concat "synchronous reset (active "
@@ -9737,7 +10283,7 @@ otherwise."
       (insert "\n") (indent-to (+ margin (* 2 vhdl-basic-offset)))
       (insert "\n") (indent-to (+ margin vhdl-basic-offset))
       (vhdl-insert-keyword "END IF;"))
-    (when (eq vhdl-reset-kind 'none)
+    (when (eq reset-kind 'none)
       (setq position (point)))
     (insert "\n") (indent-to margin)
     (vhdl-insert-keyword "END IF;")
@@ -9761,21 +10307,11 @@ specification, if not already there."
        (insert library ";")
        (when package
          (insert "\n")
-         (indent-to margin)))
-      (when package
-       (vhdl-insert-keyword "USE ")
-       (insert library "." package)
-       (vhdl-insert-keyword ".ALL;")))))
-
-(defun vhdl-template-package-math-complex ()
-  "Insert specification of `math_complex' package."
-  (interactive)
-  (vhdl-template-standard-package "ieee" "math_complex"))
-
-(defun vhdl-template-package-math-real ()
-  "Insert specification of `math_real' package."
-  (interactive)
-  (vhdl-template-standard-package "ieee" "math_real"))
+         (indent-to margin))))
+    (when package
+      (vhdl-insert-keyword "USE ")
+      (insert library "." package)
+      (vhdl-insert-keyword ".ALL;"))))
 
 (defun vhdl-template-package-numeric-bit ()
   "Insert specification of `numeric_bit' package."
@@ -9822,6 +10358,56 @@ specification, if not already there."
   (interactive)
   (vhdl-template-standard-package "std" "textio"))
 
+(defun vhdl-template-package-fundamental-constants ()
+  "Insert specification of `fundamental_constants' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "fundamental_constants"))
+
+(defun vhdl-template-package-material-constants ()
+  "Insert specification of `material_constants' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "material_constants"))
+
+(defun vhdl-template-package-energy-systems ()
+  "Insert specification of `energy_systems' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "energy_systems"))
+
+(defun vhdl-template-package-electrical-systems ()
+  "Insert specification of `electrical_systems' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "electrical_systems"))
+
+(defun vhdl-template-package-mechanical-systems ()
+  "Insert specification of `mechanical_systems' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "mechanical_systems"))
+
+(defun vhdl-template-package-radiant-systems ()
+  "Insert specification of `radiant_systems' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "radiant_systems"))
+
+(defun vhdl-template-package-thermal-systems ()
+  "Insert specification of `thermal_systems' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "thermal_systems"))
+
+(defun vhdl-template-package-fluidic-systems ()
+  "Insert specification of `fluidic_systems' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "fluidic_systems"))
+
+(defun vhdl-template-package-math-complex ()
+  "Insert specification of `math_complex' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "math_complex"))
+
+(defun vhdl-template-package-math-real ()
+  "Insert specification of `math_real' package."
+  (interactive)
+  (vhdl-template-standard-package "ieee" "math_real"))
+
 (defun vhdl-template-directive (directive)
   "Insert directive."
   (unless (= (current-indentation) (current-column))
@@ -9900,6 +10486,9 @@ specification, if not already there."
         (insert (user-full-name))
         (when user-mail-address (insert "  <" user-mail-address ">")))
        (goto-char beg)
+       (while (search-forward "<authorfull>" end t)
+        (replace-match (user-full-name) t t))
+       (goto-char beg)
        (while (search-forward "<login>" end t)
         (replace-match (user-login-name) t t))
        (goto-char beg)
@@ -9915,7 +10504,7 @@ specification, if not already there."
        (while (search-forward "<standard>" end t)
         (replace-match
          (concat "VHDL" (cond ((vhdl-standard-p '87) "'87")
-                              ((vhdl-standard-p '93) "'93"))
+                              ((vhdl-standard-p '93) "'93/02"))
                  (when (vhdl-standard-p 'ams) ", VHDL-AMS")
                  (when (vhdl-standard-p 'math) ", Math Packages")) t t))
        (goto-char beg)
@@ -10021,9 +10610,10 @@ If starting after end-comment-column, start a new line."
   "Displays one line of dashes."
   (interactive)
   (while (= (preceding-char) ?-) (delete-char -2))
+  (insert "--")
   (let* ((col (current-column))
         (len (- end-comment-column col)))
-    (insert-char ?- len)))
+    (insert-char vhdl-comment-display-line-char len)))
 
 (defun vhdl-comment-append-inline ()
   "Append empty inline comment to current line."
@@ -10084,7 +10674,7 @@ If starting after end-comment-column, start a new line."
     (goto-char beg)
     (beginning-of-line)
     (setq beg (point))
-    (if (looking-at comment-start)
+    (if (looking-at (concat "\\s-*" comment-start))
        (comment-region beg end '(4))
       (comment-region beg end))))
 
@@ -10119,7 +10709,7 @@ If starting after end-comment-column, start a new line."
     (goto-char beg)
     (beginning-of-line)
     (while (< (point) end)
-      (when (looking-at "^.*[^ \t\n-]+\\(\\s-*--.*\\)$")
+      (when (looking-at "^.*[^ \t\n\r\f-]+\\(\\s-*--.*\\)$")
        (delete-region (match-beginning 1) (match-end 1)))
       (beginning-of-line 2))))
 
@@ -10323,9 +10913,9 @@ if in comment and past end-comment-column."
         (self-insert-command count)
         (cond ((>= (current-column) (+ 2 end-comment-column))
                (backward-char 1)
-               (skip-chars-backward "^ \t\n")
+               (skip-chars-backward "^ \t\n\r\f")
                (indent-new-comment-line)
-               (skip-chars-forward "^ \t\n")
+               (skip-chars-forward "^ \t\n\r\f")
                (forward-char 1))
               ((>= (current-column) end-comment-column)
                (indent-new-comment-line))
@@ -10369,7 +10959,9 @@ with double-quotes is to be inserted.  DEFAULT specifies a default string."
       (vhdl-fix-case-region-1 position (point) vhdl-upper-case-attributes
                              (concat "'" vhdl-attributes-regexp))
       (vhdl-fix-case-region-1 position (point) vhdl-upper-case-enum-values
-                             vhdl-enum-values-regexp))
+                             vhdl-enum-values-regexp)
+      (vhdl-fix-case-region-1 position (point) vhdl-upper-case-constants
+                             vhdl-constants-regexp))
     (when (or (not (equal string "")) (not optional))
       (insert (or follow-string "")))
     (if (equal string "") nil string)))
@@ -10455,55 +11047,57 @@ else insert tab (used for word completion in VHDL minibuffer)."
 (defun vhdl-beginning-of-block ()
   "Move cursor to the beginning of the enclosing block."
   (let (pos)
-    (save-excursion
-      (beginning-of-line)
-      ;; search backward for block beginning or end
-      (while (or (while (and (setq pos (re-search-backward "^\\s-*\\(\\(end\\)\\|\\(\\(impure\\|pure\\)[ \t\n]+\\)?\\(function\\|procedure\\)\\|\\(for\\)\\|\\(architecture\\|component\\|configuration\\|entity\\|package\\|record\\|units\\)\\|\\(\\w+[ \t\n]*:[ \t\n]*\\)?\\(postponed[ \t\n]+\\)?\\(block\\|case\\|for\\|if\\|procedural\\|process\\|while\\)\\)\\>" nil t))
-                            ;; not consider subprogram declarations
-                            (or (and (match-string 5)
-                                     (save-match-data
-                                       (save-excursion
-                                         (goto-char (match-end 5))
-                                         (forward-word 1)
-                                         (vhdl-forward-syntactic-ws)
-                                         (when (looking-at "(")
-                                           (forward-sexp))
-                                         (re-search-forward "\\<is\\>\\|\\(;\\)" nil t))
-                                       (match-string 1)))
-                                ;; not consider configuration specifications
-                                (and (match-string 6)
-                                     (save-match-data
-                                       (save-excursion
-                                         (vhdl-end-of-block)
-                                         (beginning-of-line)
-                                         (not (looking-at "^\\s-*end\\s-+\\(for\\|generate\\|loop\\)\\>"))))))))
-                (match-string 2))
-       ;; skip subblock if block end found
-       (vhdl-beginning-of-block)))
+    (vhdl-prepare-search-2
+     (save-excursion
+       (beginning-of-line)
+       ;; search backward for block beginning or end
+       (while (or (while (and (setq pos (re-search-backward "^\\s-*\\(\\(end\\)\\|\\(\\(impure\\|pure\\)[ \t\n\r\f]+\\)?\\(function\\|procedure\\)\\|\\(for\\)\\|\\(architecture\\|component\\|configuration\\|entity\\|package\\(\\s-+body\\)?\\|type[ \t\n\r\f]+\\w+[ \t\n\r\f]+is[ \t\n\r\f]+\\(record\\|protected\\(\\s-+body\\)?\\)\\|units\\)\\|\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(postponed[ \t\n\r\f]+\\)?\\(block\\|case\\|for\\|if\\|procedural\\|process\\|while\\|loop\\)\\)\\>" nil t))
+                             ;; not consider subprogram declarations
+                             (or (and (match-string 5)
+                                      (save-match-data
+                                        (save-excursion
+                                          (goto-char (match-end 5))
+                                          (forward-word 1)
+                                          (vhdl-forward-syntactic-ws)
+                                          (when (looking-at "(")
+                                            (forward-sexp))
+                                          (re-search-forward "\\<is\\>\\|\\(;\\)" nil t))
+                                        (match-string 1)))
+                                 ;; not consider configuration specifications
+                                 (and (match-string 6)
+                                      (save-match-data
+                                        (save-excursion
+                                          (vhdl-end-of-block)
+                                          (beginning-of-line)
+                                          (not (looking-at "^\\s-*end\\s-+\\(for\\|generate\\|loop\\)\\>"))))))))
+                 (match-string 2))
+        ;; skip subblock if block end found
+        (vhdl-beginning-of-block))))
     (when pos (goto-char pos))))
 
 (defun vhdl-end-of-block ()
   "Move cursor to the end of the enclosing block."
   (let (pos)
-    (save-excursion
-      (end-of-line)
-      ;; search forward for block beginning or end
-      (while (or (while (and (setq pos (re-search-forward "^\\s-*\\(\\(end\\)\\|\\(\\(impure\\|pure\\)[ \t\n]+\\)?\\(function\\|procedure\\)\\|\\(for\\)\\|\\(architecture\\|component\\|configuration\\|entity\\|package\\|record\\|units\\)\\|\\(\\w+[ \t\n]*:[ \t\n]*\\)?\\(postponed[ \t\n]+\\)?\\(block\\|case\\|for\\|if\\|procedural\\|process\\|while\\)\\)\\>" nil t))
-                            ;; not consider subprogram declarations
-                            (or (and (match-string 5)
-                                     (save-match-data
-                                       (save-excursion (re-search-forward "\\<is\\>\\|\\(;\\)" nil t))
-                                       (match-string 1)))
-                                ;; not consider configuration specifications
-                                (and (match-string 6)
-                                     (save-match-data
-                                       (save-excursion
-                                         (vhdl-end-of-block)
-                                         (beginning-of-line)
-                                         (not (looking-at "^\\s-*end\\s-+\\(for\\|generate\\|loop\\)\\>"))))))))
-                (not (match-string 2)))
-       ;; skip subblock if block beginning found
-       (vhdl-end-of-block)))
+    (vhdl-prepare-search-2
+     (save-excursion
+       (end-of-line)
+       ;; search forward for block beginning or end
+       (while (or (while (and (setq pos (re-search-forward "^\\s-*\\(\\(end\\)\\|\\(\\(impure\\|pure\\)[ \t\n\r\f]+\\)?\\(function\\|procedure\\)\\|\\(for\\)\\|\\(architecture\\|component\\|configuration\\|entity\\|package\\(\\s-+body\\)?\\|type[ \t\n\r\f]+\\w+[ \t\n\r\f]+is[ \t\n\r\f]+\\(record\\|protected\\(\\s-+body\\)?\\)\\|units\\)\\|\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(postponed[ \t\n\r\f]+\\)?\\(block\\|case\\|for\\|if\\|procedural\\|process\\|while\\|loop\\)\\)\\>" nil t))
+                             ;; not consider subprogram declarations
+                             (or (and (match-string 5)
+                                      (save-match-data
+                                        (save-excursion (re-search-forward "\\<is\\>\\|\\(;\\)" nil t))
+                                        (match-string 1)))
+                                 ;; not consider configuration specifications
+                                 (and (match-string 6)
+                                      (save-match-data
+                                        (save-excursion
+                                          (vhdl-end-of-block)
+                                          (beginning-of-line)
+                                          (not (looking-at "^\\s-*end\\s-+\\(for\\|generate\\|loop\\)\\>"))))))))
+                 (not (match-string 2)))
+        ;; skip subblock if block beginning found
+        (vhdl-end-of-block))))
     (when pos (goto-char pos))))
 
 (defun vhdl-sequential-statement-p ()
@@ -10518,7 +11112,7 @@ else insert tab (used for word completion in VHDL minibuffer)."
                   (< start (point)))
            ;; ... a sequential block
            (progn (vhdl-beginning-of-block)
-                  (looking-at "^\\s-*\\(\\(\\w+[ \t\n]+\\)?\\(function\\|procedure\\)\\|\\(\\w+[ \t\n]*:[ \t\n]*\\)?\\(\\w+[ \t\n]+\\)?\\(procedural\\|process\\)\\)\\>")))))))
+                  (looking-at "^\\s-*\\(\\(\\w+[ \t\n\r\f]+\\)?\\(function\\|procedure\\)\\|\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(\\w+[ \t\n\r\f]+\\)?\\(procedural\\|process\\)\\)\\>")))))))
 
 (defun vhdl-in-argument-list-p ()
   "Check if within an argument list."
@@ -10542,7 +11136,9 @@ but not if inside a comment or quote."
       (progn
        (insert " ")
        (unexpand-abbrev)
-       (delete-char -1))
+       (backward-word 1)
+       (vhdl-case-word 1)
+       (delete-char 1))
     (if (not vhdl-electric-mode)
        (progn
          (insert " ")
@@ -10550,7 +11146,7 @@ but not if inside a comment or quote."
          (backward-word 1)
          (vhdl-case-word 1)
          (delete-char 1))
-      (let ((invoke-char last-command-event)
+      (let ((invoke-char vhdl-last-input-event)
            (abbrev-mode -1)
            (vhdl-template-invoked-by-hook t))
        (let ((caught (catch 'abort
@@ -10821,7 +11417,10 @@ but not if inside a comment or quote."
 (defun vhdl-parse-string (string &optional optional)
   "Check that the text following point matches the regexp in STRING."
   (if (looking-at string)
-      (goto-char (match-end 0))
+      (progn (goto-char (match-end 0))
+            (when (vhdl-in-literal)
+              (end-of-line))
+            (point))
     (unless optional
       (throw 'parse (format "ERROR:  Syntax error near line %s, expecting \"%s\""
                            (vhdl-current-line) string)))
@@ -10919,7 +11518,9 @@ reflected in a subsequent paste operation."
              port-dir (car port-dir-car))
        (setcar port-dir-car
                (cond ((equal port-dir "in") "out")
+                     ((equal port-dir "IN") "OUT")
                      ((equal port-dir "out") "in")
+                     ((equal port-dir "OUT") "IN")
                      (t port-dir)))
        (setq port-list (cdr port-list)))
       (setq vhdl-port-reversed-direction (not vhdl-port-reversed-direction))
@@ -10949,20 +11550,23 @@ reflected in a subsequent paste operation."
          (message "Reading port of %s \"%s\"..." decl-type name)
          (vhdl-forward-syntactic-ws)
          ;; parse generic clause
-         (when (vhdl-parse-string "generic[ \t\n]*(" t)
+         (when (vhdl-parse-string "generic[ \t\n\r\f]*(" t)
            ;; parse group comment and spacing
            (setq group-comment (vhdl-parse-group-comment))
-           (setq end-of-list (vhdl-parse-string ")[ \t\n]*;[ \t\n]*" t))
+           (setq end-of-list (vhdl-parse-string ")[ \t\n\r\f]*;[ \t\n\r\f]*" t))
            (while (not end-of-list)
              ;; parse names (accept extended identifiers)
-             (vhdl-parse-string "\\(\\w+\\|\\\\[^\\]+\\\\\\)[ \t\n]*")
+             (vhdl-parse-string "\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*")
              (setq names (list (match-string-no-properties 1)))
-             (while (vhdl-parse-string ",[ \t\n]*\\(\\w+\\)[ \t\n]*" t)
+             (while (vhdl-parse-string ",[ \t\n\r\f]*\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*" t)
                (setq names
                      (append names (list (match-string-no-properties 1)))))
              ;; parse type
-             (vhdl-parse-string ":[ \t\n]*\\([^():;\n]+\\)")
+             (vhdl-parse-string ":[ \t\n\r\f]*\\([^():;\n]+\\)")
              (setq type (match-string-no-properties 1))
+             (when (vhdl-in-comment-p) ; if stuck in comment
+               (setq type (concat type (and (vhdl-parse-string ".*")
+                                            (match-string-no-properties 0)))))
              (setq comment nil)
              (while (looking-at "(")
                (setq type
@@ -10980,7 +11584,7 @@ reflected in a subsequent paste operation."
              (setq type (substring type 0 (match-end 1)))
              ;; parse initialization expression
              (setq init nil)
-             (when (vhdl-parse-string ":=[ \t\n]*" t)
+             (when (vhdl-parse-string ":=[ \t\n\r\f]*" t)
                (vhdl-parse-string "\\([^();\n]*\\)")
                (setq init (match-string-no-properties 1))
                (while (looking-at "(")
@@ -11014,28 +11618,31 @@ reflected in a subsequent paste operation."
              ;; parse group comment and spacing
              (setq group-comment (vhdl-parse-group-comment))))
          ;; parse port clause
-         (when (vhdl-parse-string "port[ \t\n]*(" t)
+         (when (vhdl-parse-string "port[ \t\n\r\f]*(" t)
            ;; parse group comment and spacing
            (setq group-comment (vhdl-parse-group-comment))
-           (setq end-of-list (vhdl-parse-string ")[ \t\n]*;[ \t\n]*" t))
+           (setq end-of-list (vhdl-parse-string ")[ \t\n\r\f]*;[ \t\n\r\f]*" t))
            (while (not end-of-list)
              ;; parse object
              (setq object
-                   (and (vhdl-parse-string "\\<\\(signal\\|quantity\\|terminal\\)\\>[ \t\n]*" t)
+                   (and (vhdl-parse-string "\\<\\(signal\\|quantity\\|terminal\\)\\>[ \t\n\r\f]*" t)
                         (match-string-no-properties 1)))
              ;; parse names (accept extended identifiers)
-             (vhdl-parse-string "\\(\\w+\\|\\\\[^\\]+\\\\\\)[ \t\n]*")
+             (vhdl-parse-string "\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*")
              (setq names (list (match-string-no-properties 1)))
-             (while (vhdl-parse-string ",[ \t\n]*\\(\\w+\\|\\\\[^\\]+\\\\\\)[ \t\n]*" t)
+             (while (vhdl-parse-string ",[ \t\n\r\f]*\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*" t)
                (setq names (append names (list (match-string-no-properties 1)))))
              ;; parse direction
-             (vhdl-parse-string ":[ \t\n]*")
+             (vhdl-parse-string ":[ \t\n\r\f]*")
              (setq direct
-                   (and (vhdl-parse-string "\\<\\(in\\|out\\|inout\\|buffer\\|linkage\\)\\>[ \t\n]+" t)
+                   (and (vhdl-parse-string "\\<\\(in\\|out\\|inout\\|buffer\\|linkage\\)\\>[ \t\n\r\f]+" t)
                         (match-string-no-properties 1)))
              ;; parse type
              (vhdl-parse-string "\\([^();\n]+\\)")
              (setq type (match-string-no-properties 1))
+             (when (vhdl-in-comment-p) ; if stuck in comment
+               (setq type (concat type (and (vhdl-parse-string ".*")
+                                            (match-string-no-properties 0)))))
              (setq comment nil)
              (while (looking-at "(")
                (setq type (concat type
@@ -11263,7 +11870,8 @@ reflected in a subsequent paste operation."
          ;; paste formal and actual generic
          (insert (car (nth 0 generic)) " => "
                  (if no-constants
-                     (car (nth 0 generic))
+                     (vhdl-replace-string vhdl-actual-generic-name
+                                          (car (nth 0 generic)))
                    (or (nth 2 generic) "")))
          (setq generic-list (cdr generic-list))
          (insert (if generic-list "," ")"))
@@ -11313,7 +11921,7 @@ reflected in a subsequent paste operation."
          (setq port-list (cdr port-list))
          (insert (if port-list "," ");"))
          ;; paste comment
-         (when (or vhdl-include-direction-comments
+         (when (or (and vhdl-include-direction-comments (nth 2 port))
                    vhdl-include-type-comments
                    (and vhdl-include-port-comments (nth 4 port)))
            (vhdl-comment-insert-inline
@@ -11406,7 +12014,7 @@ reflected in a subsequent paste operation."
            ;; paste generic constants
            (setq name (nth 0 generic))
            (when name
-             (insert (car name))
+             (insert (vhdl-replace-string vhdl-actual-generic-name (car name)))
              ;; paste type
              (insert " : " (nth 1 generic))
              ;; paste initialization
@@ -11432,7 +12040,7 @@ reflected in a subsequent paste operation."
     (message "Pasting port as signals...")
     (unless no-indent (indent-according-to-mode))
     (let ((margin (current-indentation))
-         start port names
+         start port names type generic-list port-name constant-name pos
          (port-list (nth 2 vhdl-port-list)))
       (when port-list
        (setq start (point))
@@ -11452,14 +12060,33 @@ reflected in a subsequent paste operation."
            (setq names (cdr names))
            (when names (insert ", ")))
          ;; paste type
-         (insert " : " (nth 3 port))
+         (setq type (nth 3 port))
+         (setq generic-list (nth 1 vhdl-port-list))
+         (vhdl-prepare-search-1
+          (setq pos 0)
+          ;; replace formal by actual generics
+          (while generic-list
+            (setq port-name (car (nth 0 (car generic-list))))
+            (while (string-match (concat "\\<" port-name "\\>") type pos)
+              (setq constant-name
+                    (save-match-data (vhdl-replace-string
+                                      vhdl-actual-generic-name port-name)))
+              (setq type (replace-match constant-name t nil type))
+              (setq pos (match-end 0)))
+            (setq generic-list (cdr generic-list))))
+         (insert " : " type)
          ;; paste initialization (inputs only)
-         (when (and initialize (equal "IN" (upcase (nth 2 port))))
-           (insert " := " (if (string-match "(.+)" (nth 3 port))
-                              "(others => '0')" "'0'")))
+         (when (and initialize (nth 2 port) (equal "IN" (upcase (nth 2 port))))
+           (insert " := "
+                   (cond ((string-match "integer" (nth 3 port)) "0")
+                         ((string-match "natural" (nth 3 port)) "0")
+                         ((string-match "positive" (nth 3 port)) "0")
+                         ((string-match "real" (nth 3 port)) "0.0")
+                         ((string-match "(.+)" (nth 3 port)) "(others => '0')")
+                         (t "'0'"))))
          (insert ";")
          ;; paste comment
-         (when (or vhdl-include-direction-comments
+         (when (or (and vhdl-include-direction-comments (nth 2 port))
                    (and vhdl-include-port-comments (nth 4 port)))
            (vhdl-comment-insert-inline
             (concat
@@ -11495,8 +12122,14 @@ reflected in a subsequent paste operation."
              (setq name (car (nth 0 port)))
              (insert (vhdl-replace-string vhdl-actual-port-name name))
              ;; paste initialization
-             (insert " <= " (if (string-match "(.+)" (nth 3 port))
-                                "(others => '0')" "'0'") ";"))
+             (insert " <= "
+                     (cond ((string-match "integer" (nth 3 port)) "0")
+                           ((string-match "natural" (nth 3 port)) "0")
+                           ((string-match "positive" (nth 3 port)) "0")
+                           ((string-match "real" (nth 3 port)) "0.0")
+                           ((string-match "(.+)" (nth 3 port)) "(others => '0')")
+                           (t "'0'"))
+                     ";"))
            (setq port-list (cdr port-list))
            (when (and port-list
                       (equal "IN" (upcase (nth 2 (car port-list)))))
@@ -11609,7 +12242,9 @@ reflected in a subsequent paste operation."
       ;; paste custom declarations
       (unless (equal "" vhdl-testbench-declarations)
        (insert "\n")
-       (vhdl-insert-string-or-file vhdl-testbench-declarations))
+       (setq position (point))
+       (vhdl-insert-string-or-file vhdl-testbench-declarations)
+       (vhdl-indent-region position (point)))
       (setq position (point))
       (insert "\n\n")
       (vhdl-comment-display-line) (insert "\n")
@@ -11638,7 +12273,9 @@ reflected in a subsequent paste operation."
       ;; paste custom statements
       (unless (equal "" vhdl-testbench-statements)
        (insert "\n")
-       (vhdl-insert-string-or-file vhdl-testbench-statements))
+       (setq position (point))
+       (vhdl-insert-string-or-file vhdl-testbench-statements)
+       (vhdl-indent-region position (point)))
       (insert "\n")
       (indent-to vhdl-basic-offset)
       (unless (eq vhdl-testbench-create-files 'none)
@@ -11707,8 +12344,8 @@ reflected in a subsequent paste operation."
          ;; check if within function declaration
          (setq pos (point))
          (end-of-line)
-         (when (looking-at "[ \t\n]*\\((\\|;\\|is\\>\\)") (goto-char (match-end 0)))
-         (unless (and (re-search-backward "^\\s-*\\(\\(procedure\\)\\|\\(\\(pure\\|impure\\)\\s-+\\)?function\\)\\s-+\\(\"?\\w+\"?\\)[ \t\n]*\\(\\((\\)\\|;\\|is\\>\\)" nil t)
+         (when (looking-at "[ \t\n\r\f]*\\((\\|;\\|is\\>\\)") (goto-char (match-end 0)))
+         (unless (and (re-search-backward "^\\s-*\\(\\(procedure\\)\\|\\(\\(pure\\|impure\\)\\s-+\\)?function\\)\\s-+\\(\"?\\w+\"?\\)[ \t\n\r\f]*\\(\\((\\)\\|;\\|is\\>\\)" nil t)
                       (goto-char (match-end 0))
                       (save-excursion (backward-char)
                                    (forward-sexp)
@@ -11721,21 +12358,21 @@ reflected in a subsequent paste operation."
          ;; parse parameter list
          (setq group-comment (vhdl-parse-group-comment))
          (setq end-of-list (or end-of-list
-                               (vhdl-parse-string ")[ \t\n]*\\(;\\|\\(is\\|return\\)\\>\\)" t)))
+                               (vhdl-parse-string ")[ \t\n\r\f]*\\(;\\|\\(is\\|return\\)\\>\\)" t)))
          (while (not end-of-list)
            ;; parse object
            (setq object
-                 (and (vhdl-parse-string "\\(constant\\|signal\\|variable\\|file\\|quantity\\|terminal\\)[ \t\n]*" t)
+                 (and (vhdl-parse-string "\\(constant\\|signal\\|variable\\|file\\|quantity\\|terminal\\)[ \t\n\r\f]*" t)
                         (match-string-no-properties 1)))
            ;; parse names (accept extended identifiers)
-           (vhdl-parse-string "\\(\\w+\\|\\\\[^\\]+\\\\\\)[ \t\n]*")
+           (vhdl-parse-string "\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*")
            (setq names (list (match-string-no-properties 1)))
-           (while (vhdl-parse-string ",[ \t\n]*\\(\\w+\\|\\\\[^\\]+\\\\\\)[ \t\n]*" t)
+           (while (vhdl-parse-string ",[ \t\n\r\f]*\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*" t)
              (setq names (append names (list (match-string-no-properties 1)))))
            ;; parse direction
-           (vhdl-parse-string ":[ \t\n]*")
+           (vhdl-parse-string ":[ \t\n\r\f]*")
            (setq direct
-                 (and (vhdl-parse-string "\\(in\\|out\\|inout\\|buffer\\|linkage\\)[ \t\n]+" t)
+                 (and (vhdl-parse-string "\\(in\\|out\\|inout\\|buffer\\|linkage\\)[ \t\n\r\f]+" t)
                       (match-string-no-properties 1)))
            ;; parse type
            (vhdl-parse-string "\\([^():;\n]+\\)")
@@ -11757,7 +12394,7 @@ reflected in a subsequent paste operation."
            (setq type (substring type 0 (match-end 1)))
            ;; parse initialization expression
            (setq init nil)
-           (when (vhdl-parse-string ":=[ \t\n]*" t)
+           (when (vhdl-parse-string ":=[ \t\n\r\f]*" t)
              (vhdl-parse-string "\\([^();\n]*\\)")
              (setq init (match-string-no-properties 1))
              (while (looking-at "(")
@@ -11787,7 +12424,7 @@ reflected in a subsequent paste operation."
            (vhdl-parse-string "\\(;\\|\\(is\\|\\(return\\)\\)\\>\\)\\s-*")
            ;; parse return type
            (when (match-string 3)
-             (vhdl-parse-string "[ \t\n]*\\(.+\\)[ \t\n]*\\(;\\|is\\>\\)\\s-*")
+             (vhdl-parse-string "[ \t\n\r\f]*\\(.+\\)[ \t\n\r\f]*\\(;\\|is\\>\\)\\s-*")
              (setq return-type (match-string-no-properties 1))
              (when (and return-type
                         (string-match "\\(\\s-*--\\s-*\\)\\(.*\\)" return-type))
@@ -12015,83 +12652,15 @@ expressions (e.g. for index ranges of types and signals)."
  (defalias 'he-list-beg 'vhdl-he-list-beg))
 
 ;; function for expanding abbrevs and dabbrevs
-(defun vhdl-expand-abbrev (arg))
-(fset 'vhdl-expand-abbrev (make-hippie-expand-function
-                          '(try-expand-dabbrev
-                            try-expand-dabbrev-all-buffers
-                            vhdl-try-expand-abbrev)))
+(defalias 'vhdl-expand-abbrev (make-hippie-expand-function
+                              '(try-expand-dabbrev
+                                try-expand-dabbrev-all-buffers
+                                vhdl-try-expand-abbrev)))
 
 ;; function for expanding parenthesis
-(defun vhdl-expand-paren (arg))
-(fset 'vhdl-expand-paren (make-hippie-expand-function
-                         '(try-expand-list
-                           try-expand-list-all-buffers)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;  Case fixing
-
-(defun vhdl-fix-case-region-1 (beg end upper-case word-regexp &optional count)
-  "Convert all words matching WORD-REGEXP in region to lower or upper case,
-depending on parameter UPPER-CASE."
-  (let ((case-replace nil)
-       (last-update 0))
-    (vhdl-prepare-search-2
-     (save-excursion
-       (goto-char end)
-       (setq end (point-marker))
-       (goto-char beg)
-       (while (re-search-forward word-regexp end t)
-        (or (vhdl-in-literal)
-            (if upper-case
-                (upcase-word -1)
-              (downcase-word -1)))
-        (when (and count vhdl-progress-interval (not noninteractive)
-                   (< vhdl-progress-interval
-                      (- (nth 1 (current-time)) last-update)))
-          (message "Fixing case... (%2d%s)"
-                   (+ (* count 25) (/ (* 25 (- (point) beg)) (- end beg)))
-                   "%")
-          (setq last-update (nth 1 (current-time)))))
-       (goto-char end)))))
-
-(defun vhdl-fix-case-region (beg end &optional arg)
-  "Convert all VHDL words in region to lower or upper case, depending on
-options vhdl-upper-case-{keywords,types,attributes,enum-values}."
-  (interactive "r\nP")
-  (vhdl-fix-case-region-1
-   beg end vhdl-upper-case-keywords vhdl-keywords-regexp 0)
-  (vhdl-fix-case-region-1
-   beg end vhdl-upper-case-types vhdl-types-regexp 1)
-  (vhdl-fix-case-region-1
-   beg end vhdl-upper-case-attributes (concat "'" vhdl-attributes-regexp) 2)
-  (vhdl-fix-case-region-1
-   beg end vhdl-upper-case-enum-values vhdl-enum-values-regexp 3)
-  (when vhdl-progress-interval (message "Fixing case...done")))
-
-(defun vhdl-fix-case-buffer ()
-  "Convert all VHDL words in buffer to lower or upper case, depending on
-options vhdl-upper-case-{keywords,types,attributes,enum-values}."
-  (interactive)
-  (vhdl-fix-case-region (point-min) (point-max)))
-
-(defun vhdl-fix-case-word (&optional arg)
-  "Convert word after cursor to upper case if necessary."
-  (interactive "p")
-  (save-excursion
-    (when arg (backward-word 1))
-    (vhdl-prepare-search-1
-     (when (and vhdl-upper-case-keywords
-               (looking-at vhdl-keywords-regexp))
-       (upcase-word 1))
-     (when (and vhdl-upper-case-types
-               (looking-at vhdl-types-regexp))
-       (upcase-word 1))
-     (when (and vhdl-upper-case-attributes
-               (looking-at vhdl-attributes-regexp))
-       (upcase-word 1))
-     (when (and vhdl-upper-case-enum-values
-               (looking-at vhdl-enum-values-regexp))
-       (upcase-word 1)))))
+(defalias 'vhdl-expand-paren (make-hippie-expand-function
+                             '(try-expand-list
+                               try-expand-list-all-buffers)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Line handling functions
@@ -12130,6 +12699,7 @@ options vhdl-upper-case-{keywords,types,attributes,enum-values}."
 (defun vhdl-line-expand (&optional prefix-arg)
   "Hippie-expand current line."
   (interactive "P")
+  (require 'hippie-exp)
   (let ((case-fold-search t) (case-replace nil)
        (hippie-expand-try-functions-list
         '(try-expand-line try-expand-line-all-buffers)))
@@ -12205,6 +12775,9 @@ it works within comments too."
   (interactive)
   (let ((no-stats 0)
        (no-code-lines 0)
+       (no-empty-lines 0)
+       (no-comm-lines 0)
+       (no-comments 0)
        (no-lines (count-lines (point-min) (point-max))))
     (save-excursion
       ;; count statements
@@ -12218,15 +12791,40 @@ it works within comments too."
       (while (not (eobp))
        (unless (looking-at "^\\s-*\\(--.*\\)?$")
          (setq no-code-lines (1+ no-code-lines)))
-       (beginning-of-line 2)))
+       (beginning-of-line 2))
+      ;; count empty lines
+      (goto-char (point-min))
+      (while (and (re-search-forward "^\\s-*$" nil t)
+                 (not (eq (point) (point-max))))
+       (if (match-string 1)
+           (goto-char (match-end 1))
+         (setq no-empty-lines (1+ no-empty-lines))
+         (unless (eq (point) (point-max))
+           (forward-char))))
+      ;; count comment-only lines
+      (goto-char (point-min))
+      (while (re-search-forward "^\\s-*--.*" nil t)
+       (if (match-string 1)
+           (goto-char (match-end 1))
+         (setq no-comm-lines (1+ no-comm-lines))))
+      ;; count comments
+      (goto-char (point-min))
+      (while (re-search-forward "--.*" nil t)
+       (if (match-string 1)
+           (goto-char (match-end 1))
+         (setq no-comments (1+ no-comments)))))
     ;; print results
     (message "\n\
 File statistics: \"%s\"\n\
----------------------\n\
-# statements  : %5d\n\
-# code lines  : %5d\n\
-# total lines : %5d\n\ "
-            (buffer-file-name) no-stats no-code-lines no-lines)
+-----------------------\n\
+# statements    : %5d\n\
+# code lines    : %5d\n\
+# empty lines   : %5d\n\
+# comment lines : %5d\n\
+# comments      : %5d\n\
+# total lines   : %5d\n\ "
+            (buffer-file-name) no-stats no-code-lines no-empty-lines
+            no-comm-lines no-comments no-lines)
     (unless vhdl-emacs-21 (vhdl-show-messages))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -12390,18 +12988,18 @@ File statistics: \"%s\"\n\
   (concat
    "\\(^\\)\\s-*\\("
    ;; generic/port clause
-   "\\(generic\\|port\\)[ \t\n]*(\\|"
+   "\\(generic\\|port\\)[ \t\n\r\f]*(\\|"
    ;; component
    "component\\>\\|"
    ;; component instantiation
-   "\\(\\w\\|\\s_\\)+[ \t\n]*:[ \t\n]*"
-   "\\(\\(component\\|configuration\\|entity\\)[ \t\n]+\\)?"
-   "\\(\\w\\|\\s_\\)+\\([ \t\n]*(\\(\\w\\|\\s_\\)+)\\)?[ \t\n]*"
-   "\\(generic\\|port\\)[ \t\n]+map[ \t\n]*(\\|"
+   "\\(\\w\\|\\s_\\)+[ \t\n\r\f]*:[ \t\n\r\f]*"
+   "\\(\\(component\\|configuration\\|entity\\)[ \t\n\r\f]+\\)?"
+   "\\(\\w\\|\\s_\\)+\\([ \t\n\r\f]*(\\(\\w\\|\\s_\\)+)\\)?[ \t\n\r\f]*"
+   "\\(generic\\|port\\)[ \t\n\r\f]+map[ \t\n\r\f]*(\\|"
    ;; subprogram
    "\\(function\\|procedure\\)\\>\\|"
    ;; process, block
-   "\\(\\(\\w\\|\\s_\\)+[ \t\n]*:[ \t\n]*\\)?\\(process\\|block\\)\\>\\|"
+   "\\(\\(\\w\\|\\s_\\)+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(process\\|block\\)\\>\\|"
    ;; configuration declaration
    "configuration\\>"
    "\\)")
@@ -12414,7 +13012,7 @@ File statistics: \"%s\"\n\
      (beginning-of-line)
      (cond
       ;; generic/port clause
-      ((looking-at "^\\s-*\\(generic\\|port\\)[ \t\n]*(")
+      ((looking-at "^\\s-*\\(generic\\|port\\)[ \t\n\r\f]*(")
        (goto-char (match-end 0))
        (backward-char)
        (forward-sexp))
@@ -12424,16 +13022,16 @@ File statistics: \"%s\"\n\
       ;; component instantiation
       ((looking-at
        (concat
-        "^\\s-*\\w+\\s-*:[ \t\n]*"
-        "\\(\\(component\\|configuration\\|entity\\)[ \t\n]+\\)?"
-        "\\w+\\(\\s-*(\\w+)\\)?[ \t\n]*"
-        "\\(generic\\|port\\)\\s-+map[ \t\n]*("))
+        "^\\s-*\\w+\\s-*:[ \t\n\r\f]*"
+        "\\(\\(component\\|configuration\\|entity\\)[ \t\n\r\f]+\\)?"
+        "\\w+\\(\\s-*(\\w+)\\)?[ \t\n\r\f]*"
+        "\\(generic\\|port\\)\\s-+map[ \t\n\r\f]*("))
        (goto-char (match-end 0))
        (backward-char)
        (forward-sexp)
        (setq pos (point))
        (vhdl-forward-syntactic-ws)
-       (when (looking-at "port\\s-+map[ \t\n]*(")
+       (when (looking-at "port\\s-+map[ \t\n\r\f]*(")
         (goto-char (match-end 0))
         (backward-char)
         (forward-sexp)
@@ -12585,7 +13183,7 @@ This does highlighting of keywords and standard identifiers.")
    ;; highlight labels of common constructs
    (list
     (concat
-     "^\\s-*\\(\\w+\\)\\s-*:[ \t\n]*\\(\\("
+     "^\\s-*\\(\\w+\\)\\s-*:[ \t\n\r\f]*\\(\\("
      "assert\\|block\\|case\\|exit\\|for\\|if\\|loop\\|next\\|null\\|"
      "postponed\\|process\\|"
      (when (vhdl-standard-p 'ams) "procedural\\|")
@@ -12596,14 +13194,14 @@ This does highlighting of keywords and standard identifiers.")
    ;; highlight label and component name of component instantiations
    (list
     (concat
-     "^\\s-*\\(\\w+\\)\\s-*:[ \t\n]*\\(\\w+\\)"
-     "\\(\\s-*\\(--[^\n]*\\)?$\\|\\s-+\\(generic\\|port\\)\\s-+map\\>\\)")
+     "^\\s-*\\(\\w+\\)\\s-*:[ \t\n\r\f]*\\(\\w+\\)[ \t\n\r\f]*"
+     "\\(--[^\n]*[ \t\n\r\f]+\\)*\\(generic\\|port\\)\\s-+map\\>")
     '(1 font-lock-function-name-face) '(2 font-lock-function-name-face))
 
    ;; highlight label and instantiated unit of component instantiations
    (list
     (concat
-     "^\\s-*\\(\\w+\\)\\s-*:[ \t\n]*"
+     "^\\s-*\\(\\w+\\)\\s-*:[ \t\n\r\f]*"
      "\\(component\\|configuration\\|entity\\)\\s-+"
      "\\(\\w+\\)\\(\\.\\(\\w+\\)\\)?\\(\\s-*(\\(\\w+\\))\\)?")
     '(1 font-lock-function-name-face) '(3 font-lock-function-name-face)
@@ -12638,7 +13236,7 @@ This does highlighting of keywords and standard identifiers.")
    (list
     (concat
      "^\\s-*for\\s-+\\(\\w+\\(,\\s-*\\w+\\)*\\)\\>\\s-*"
-     "\\(:[ \t\n]*\\(\\w+\\)\\|[^i \t]\\)")
+     "\\(:[ \t\n\r\f]*\\(\\w+\\)\\|[^i \t]\\)")
     '(1 font-lock-function-name-face) '(4 font-lock-function-name-face nil t))
 
    ;; highlight names in library clauses
@@ -12662,8 +13260,8 @@ This does highlighting of keywords and standard identifiers.")
    ;; highlight type/nature name in (sub)type/(sub)nature declarations
    (list
     (concat
-     "^\\s-*\\(sub\\)?\\(nature\\|type\\)\\s-+\\(\\w+\\)")
-    3 'font-lock-type-face)
+     "^\\s-*\\(\\(sub\\)?\\(nature\\|type\\)\\|end\\s-+\\(record\\|protected\\)\\)\\s-+\\(\\w+\\)")
+    5 'font-lock-type-face)
 
    ;; highlight signal/variable/constant declaration names
    (list "\\(:[^=]\\)"
@@ -12867,6 +13465,7 @@ This does background highlighting of translate-off regions.")
         (list vhdl-functions-regexp   1 'vhdl-font-lock-function-face)
         (list vhdl-packages-regexp    1 'vhdl-font-lock-function-face)
         (list vhdl-enum-values-regexp 1 'vhdl-font-lock-enumvalue-face)
+        (list vhdl-constants-regexp   1 'font-lock-constant-face)
         (list vhdl-keywords-regexp    1 'font-lock-keyword-face)))
   ;; highlight words with special syntax.
   (setq vhdl-font-lock-keywords-3
@@ -12875,9 +13474,10 @@ This does background highlighting of translate-off regions.")
          (while syntax-alist
            (setq keywords
                  (cons
-                  (cons (concat "\\<\\(" (nth 1 (car syntax-alist)) "\\)\\>")
+                  (list (concat "\\(" (nth 1 (car syntax-alist)) "\\)") 1
                         (vhdl-function-name
-                         "vhdl-font-lock" (nth 0 (car syntax-alist)) "face"))
+                         "vhdl-font-lock" (nth 0 (car syntax-alist)) "face")
+                        (nth 4 (car syntax-alist)))
                   keywords))
            (setq syntax-alist (cdr syntax-alist)))
          keywords))
@@ -13066,10 +13666,10 @@ hierarchy otherwise.")
       (when (re-search-backward "^[ \t]*\\(architecture\\|configuration\\|entity\\|package\\)\\>" nil t)
        (while (and (re-search-backward "^[ \t]*\\(end\\|use\\)\\>" nil t)
                    (equal "USE" (upcase (match-string 1))))
-         (when (looking-at "^[ \t]*use[ \t\n]*\\(\\w+\\)\\.\\(\\w+\\)\\.\\w+")
-           (setq lib-alist (cons (cons (match-string-no-properties 1)
+         (when (looking-at "^[ \t]*use[ \t\n\r\f]*\\(\\w+\\)\\.\\(\\w+\\)\\.\\w+")
+           (push (cons (match-string-no-properties 1)
                                        (vhdl-match-string-downcase 2))
-                                 lib-alist))))))
+                 lib-alist)))))
     lib-alist))
 
 (defun vhdl-scan-directory-contents (name &optional project update num-string
@@ -13115,7 +13715,7 @@ hierarchy otherwise.")
              file-tmp-list)
          (while file-list
            (unless (string-match file-exclude-regexp (car file-list))
-             (setq file-tmp-list (cons (car file-list) file-tmp-list)))
+             (push (car file-list) file-tmp-list))
            (setq file-list (cdr file-list)))
          (setq file-list (nreverse file-tmp-list))))
       ;; do for all files
@@ -13140,7 +13740,7 @@ hierarchy otherwise.")
                         (setq big-files t))
                ;; scan for entities
                (goto-char (point-min))
-               (while (re-search-forward "^[ \t]*entity[ \t\n]+\\(\\w+\\)[ \t\n]+is\\>" nil t)
+               (while (re-search-forward "^[ \t]*entity[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t)
                  (let* ((ent-name (match-string-no-properties 1))
                         (ent-key (downcase ent-name))
                         (ent-entry (aget ent-alist ent-key t))
@@ -13150,14 +13750,14 @@ hierarchy otherwise.")
                         "Entity declared twice (used 1.): \"%s\"\n  1. in \"%s\" (line %d)\n  2. in \"%s\" (line %d)"
                         ent-name  (nth 1 ent-entry) (nth 2 ent-entry)
                         file-name (vhdl-current-line))
-                     (setq ent-list (cons ent-key ent-list))
+                     (push ent-key ent-list)
                      (aput 'ent-alist ent-key
                            (list ent-name file-name (vhdl-current-line)
                                  (nth 3 ent-entry) (nth 4 ent-entry)
                                  lib-alist)))))
                ;; scan for architectures
                (goto-char (point-min))
-               (while (re-search-forward "^[ \t]*architecture[ \t\n]+\\(\\w+\\)[ \t\n]+of[ \t\n]+\\(\\w+\\)[ \t\n]+is\\>" nil t)
+               (while (re-search-forward "^[ \t]*architecture[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t)
                  (let* ((arch-name (match-string-no-properties 1))
                         (arch-key (downcase arch-name))
                         (ent-name (match-string-no-properties 2))
@@ -13183,7 +13783,7 @@ hierarchy otherwise.")
                                  arch-key (nth 5 ent-entry))))))
                ;; scan for configurations
                (goto-char (point-min))
-               (while (re-search-forward "^[ \t]*configuration[ \t\n]+\\(\\w+\\)[ \t\n]+of[ \t\n]+\\(\\w+\\)[ \t\n]+is\\>" nil t)
+               (while (re-search-forward "^[ \t]*configuration[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t)
                  (let* ((conf-name (match-string-no-properties 1))
                         (conf-key (downcase conf-name))
                         (conf-entry (aget conf-alist conf-key t))
@@ -13195,22 +13795,22 @@ hierarchy otherwise.")
                         arch-key comp-conf-list inst-key-list
                         inst-comp-key inst-ent-key inst-arch-key
                         inst-conf-key inst-lib-key)
-                   (when (vhdl-re-search-forward "\\<for[ \t\n]+\\(\\w+\\)")
+                   (when (vhdl-re-search-forward "\\<for[ \t\n\r\f]+\\(\\w+\\)")
                      (setq arch-key (vhdl-match-string-downcase 1)))
                    (if conf-entry
                        (vhdl-warning-when-idle
                         "Configuration declared twice (used 1.): \"%s\" of \"%s\"\n  1. in \"%s\" (line %d)\n  2. in \"%s\" (line %d)"
                         conf-name ent-name (nth 1 conf-entry)
                         (nth 2 conf-entry) file-name conf-line)
-                     (setq conf-list (cons conf-key conf-list))
+                     (push conf-key conf-list)
                      ;; scan for subconfigurations and subentities
-                     (while (re-search-forward "^[ \t]*for[ \t\n]+\\(\\w+\\([ \t\n]*,[ \t\n]*\\w+\\)*\\)[ \t\n]*:[ \t\n]*\\(\\w+\\)[ \t\n]+" end-of-unit t)
+                     (while (re-search-forward "^[ \t]*for[ \t\n\r\f]+\\(\\w+\\([ \t\n\r\f]*,[ \t\n\r\f]*\\w+\\)*\\)[ \t\n\r\f]*:[ \t\n\r\f]*\\(\\w+\\)[ \t\n\r\f]+" end-of-unit t)
                        (setq inst-comp-key (vhdl-match-string-downcase 3)
                              inst-key-list (split-string
                                             (vhdl-match-string-downcase 1)
-                                            "[ \t\n]*,[ \t\n]*"))
+                                            "[ \t\n\r\f]*,[ \t\n\r\f]*"))
                        (vhdl-forward-syntactic-ws)
-                       (when (looking-at "use[ \t\n]+\\(\\(entity\\)\\|configuration\\)[ \t\n]+\\(\\w+\\)\\.\\(\\w+\\)[ \t\n]*\\((\\(\\w+\\))\\)?")
+                       (when (looking-at "use[ \t\n\r\f]+\\(\\(entity\\)\\|configuration\\)[ \t\n\r\f]+\\(\\w+\\)\\.\\(\\w+\\)[ \t\n\r\f]*\\((\\(\\w+\\))\\)?")
                          (setq
                           inst-lib-key (vhdl-match-string-downcase 3)
                           inst-ent-key (and (match-string 2)
@@ -13232,7 +13832,7 @@ hierarchy otherwise.")
                                  arch-key comp-conf-list lib-alist)))))
                ;; scan for packages
                (goto-char (point-min))
-               (while (re-search-forward "^[ \t]*package[ \t\n]+\\(body[ \t\n]+\\)?\\(\\w+\\)[ \t\n]+is\\>" nil t)
+               (while (re-search-forward "^[ \t]*package[ \t\n\r\f]+\\(body[ \t\n\r\f]+\\)?\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t)
                  (let* ((pack-name (match-string-no-properties 2))
                         (pack-key (downcase pack-name))
                         (is-body (match-string-no-properties 1))
@@ -13250,7 +13850,7 @@ hierarchy otherwise.")
                      ;; scan for context clauses
                      (setq lib-alist (vhdl-scan-context-clause))
                      ;; scan for component and subprogram declarations/bodies
-                     (while (re-search-forward "^[ \t]*\\(component\\|function\\|procedure\\)[ \t\n]+\\(\\w+\\|\".*\"\\)" end-of-unit t)
+                     (while (re-search-forward "^[ \t]*\\(component\\|function\\|procedure\\)[ \t\n\r\f]+\\(\\w+\\|\".*\"\\)" end-of-unit t)
                        (if (equal (upcase (match-string 1)) "COMPONENT")
                            (setq comp-name (match-string-no-properties 2)
                                  comp-alist
@@ -13265,8 +13865,8 @@ hierarchy otherwise.")
                      (setq func-alist (nreverse func-alist))
                      (setq comp-alist (nreverse comp-alist))
                      (if is-body
-                         (setq pack-body-list (cons pack-key pack-body-list))
-                       (setq pack-list (cons pack-key pack-list)))
+                         (push pack-key pack-body-list)
+                       (push pack-key pack-list))
                      (aput
                       'pack-alist pack-key
                       (if is-body
@@ -13286,7 +13886,7 @@ hierarchy otherwise.")
                         (setq big-files t))
                ;; scan for architectures
                (goto-char (point-min))
-               (while (re-search-forward "^[ \t]*architecture[ \t\n]+\\(\\w+\\)[ \t\n]+of[ \t\n]+\\(\\w+\\)[ \t\n]+is\\>" nil t)
+               (while (re-search-forward "^[ \t]*architecture[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t)
                  (let* ((ent-name (match-string-no-properties 2))
                         (ent-key (downcase ent-name))
                         (arch-name (match-string-no-properties 1))
@@ -13300,12 +13900,12 @@ hierarchy otherwise.")
                         inst-alist inst-path)
                    ;; scan for contained instantiations
                    (while (and (re-search-forward
-                                (concat "^[ \t]*\\(\\w+\\)[ \t\n]*:[ \t\n]*\\("
-                                        "\\(\\w+\\)[ \t\n]+\\(--[^\n]*\n[ \t\n]*\\)*\\(generic\\|port\\)[ \t\n]+map\\>\\|"
-                                        "component[ \t\n]+\\(\\w+\\)\\|"
-                                        "\\(\\(entity\\)\\|configuration\\)[ \t\n]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n]*(\\(\\w+\\))\\)?\\|"
+                                (concat "^[ \t]*\\(\\w+\\)[ \t\n\r\f]*:[ \t\n\r\f]*\\("
+                                        "\\(\\w+\\)[ \t\n\r\f]+\\(--[^\n]*\n[ \t\n\r\f]*\\)*\\(generic\\|port\\)[ \t\n\r\f]+map\\>\\|"
+                                        "component[ \t\n\r\f]+\\(\\w+\\)\\|"
+                                        "\\(\\(entity\\)\\|configuration\\)[ \t\n\r\f]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n\r\f]*(\\(\\w+\\))\\)?\\|"
                                         "\\(\\(for\\|if\\)\\>[^;:]+\\<generate\\>\\|block\\>\\)\\)\\|"
-                                        "\\(^[ \t]*end[ \t\n]+\\(generate\\|block\\)\\>\\)") end-of-unit t)
+                                        "\\(^[ \t]*end[ \t\n\r\f]+\\(generate\\|block\\)\\>\\)") end-of-unit t)
                                (or (not limit-hier-inst-no)
                                    (<= (setq inst-no (1+ inst-no))
                                        limit-hier-inst-no)))
@@ -13349,8 +13949,8 @@ hierarchy otherwise.")
                    ;; scan for contained configuration specifications
                    (goto-char beg-of-unit)
                    (while (re-search-forward
-                           (concat "^[ \t]*for[ \t\n]+\\(\\w+\\([ \t\n]*,[ \t\n]*\\w+\\)*\\)[ \t\n]*:[ \t\n]*\\(\\w+\\)[ \t\n]+\\(--[^\n]*\n[ \t\n]*\\)*"
-                                   "use[ \t\n]+\\(\\(entity\\)\\|configuration\\)[ \t\n]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n]*(\\(\\w+\\))\\)?") end-of-unit t)
+                           (concat "^[ \t]*for[ \t\n\r\f]+\\(\\w+\\([ \t\n\r\f]*,[ \t\n\r\f]*\\w+\\)*\\)[ \t\n\r\f]*:[ \t\n\r\f]*\\(\\w+\\)[ \t\n\r\f]+\\(--[^\n]*\n[ \t\n\r\f]*\\)*"
+                                   "use[ \t\n\r\f]+\\(\\(entity\\)\\|configuration\\)[ \t\n\r\f]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n\r\f]*(\\(\\w+\\))\\)?") end-of-unit t)
                      (let* ((inst-comp-name (match-string-no-properties 3))
                             (inst-ent-key
                              (and (match-string 6)
@@ -13362,7 +13962,7 @@ hierarchy otherwise.")
                             (inst-lib-key (vhdl-match-string-downcase 8))
                             (inst-key-list
                              (split-string (vhdl-match-string-downcase 1)
-                                           "[ \t\n]*,[ \t\n]*"))
+                                           "[ \t\n\r\f]*,[ \t\n\r\f]*"))
                             (tmp-inst-alist inst-alist)
                             inst-entry)
                        (while tmp-inst-alist
@@ -13520,7 +14120,7 @@ of PROJECT."
       (let ((case-fold-search nil))
        (while dir-list
          (unless (string-match file-exclude-regexp (car dir-list))
-           (setq dir-list-tmp (cons (car dir-list) dir-list-tmp)))
+           (push (car dir-list) dir-list-tmp))
          (setq dir-list (cdr dir-list)))
        (setq dir-list (nreverse dir-list-tmp))))
     (message "Collecting source files...done")
@@ -13912,12 +14512,19 @@ if required."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Add hierarchy browser functionality to speedbar
 
-(defvar vhdl-speedbar-key-map nil
+(defvar vhdl-speedbar-mode-map nil
   "Keymap used when in the VHDL hierarchy browser mode.")
 
 (defvar vhdl-speedbar-menu-items nil
   "Additional menu-items to add to speedbar frame.")
 
+(declare-function speedbar-add-supported-extension "speedbar" (extension))
+(declare-function speedbar-add-mode-functions-list "speedbar" (new-list))
+(declare-function speedbar-make-specialized-keymap "speedbar" ())
+(declare-function speedbar-change-initial-expansion-list "speedbar"
+                 (new-default))
+(declare-function speedbar-add-expansion-list "speedbar" (new-list))
+
 (defun vhdl-speedbar-initialize ()
   "Initialize speedbar."
   ;; general settings
@@ -13940,30 +14547,30 @@ if required."
        (speedbar-item-info . vhdl-speedbar-item-info)
        (speedbar-line-directory . vhdl-speedbar-line-project)))
     ;; keymap
-    (unless vhdl-speedbar-key-map
-      (setq vhdl-speedbar-key-map (speedbar-make-specialized-keymap))
-      (define-key vhdl-speedbar-key-map "e" 'speedbar-edit-line)
-      (define-key vhdl-speedbar-key-map "\C-m" 'speedbar-edit-line)
-      (define-key vhdl-speedbar-key-map "+" 'speedbar-expand-line)
-      (define-key vhdl-speedbar-key-map "=" 'speedbar-expand-line)
-      (define-key vhdl-speedbar-key-map "-" 'vhdl-speedbar-contract-level)
-      (define-key vhdl-speedbar-key-map "_" 'vhdl-speedbar-contract-all)
-      (define-key vhdl-speedbar-key-map "C" 'vhdl-speedbar-port-copy)
-      (define-key vhdl-speedbar-key-map "P" 'vhdl-speedbar-place-component)
-      (define-key vhdl-speedbar-key-map "F" 'vhdl-speedbar-configuration)
-      (define-key vhdl-speedbar-key-map "A" 'vhdl-speedbar-select-mra)
-      (define-key vhdl-speedbar-key-map "K" 'vhdl-speedbar-make-design)
-      (define-key vhdl-speedbar-key-map "R" 'vhdl-speedbar-rescan-hierarchy)
-      (define-key vhdl-speedbar-key-map "S" 'vhdl-save-caches)
+    (unless vhdl-speedbar-mode-map
+      (setq vhdl-speedbar-mode-map (speedbar-make-specialized-keymap))
+      (define-key vhdl-speedbar-mode-map "e" 'speedbar-edit-line)
+      (define-key vhdl-speedbar-mode-map "\C-m" 'speedbar-edit-line)
+      (define-key vhdl-speedbar-mode-map "+" 'speedbar-expand-line)
+      (define-key vhdl-speedbar-mode-map "=" 'speedbar-expand-line)
+      (define-key vhdl-speedbar-mode-map "-" 'vhdl-speedbar-contract-level)
+      (define-key vhdl-speedbar-mode-map "_" 'vhdl-speedbar-contract-all)
+      (define-key vhdl-speedbar-mode-map "C" 'vhdl-speedbar-port-copy)
+      (define-key vhdl-speedbar-mode-map "P" 'vhdl-speedbar-place-component)
+      (define-key vhdl-speedbar-mode-map "F" 'vhdl-speedbar-configuration)
+      (define-key vhdl-speedbar-mode-map "A" 'vhdl-speedbar-select-mra)
+      (define-key vhdl-speedbar-mode-map "K" 'vhdl-speedbar-make-design)
+      (define-key vhdl-speedbar-mode-map "R" 'vhdl-speedbar-rescan-hierarchy)
+      (define-key vhdl-speedbar-mode-map "S" 'vhdl-save-caches)
       (let ((key 0))
        (while (<= key 9)
-         (define-key vhdl-speedbar-key-map (int-to-string key)
+         (define-key vhdl-speedbar-mode-map (int-to-string key)
            `(lambda () (interactive) (vhdl-speedbar-set-depth ,key)))
          (setq key (1+ key)))))
-    (define-key speedbar-key-map "h"
+    (define-key speedbar-mode-map "h"
       (lambda () (interactive)
        (speedbar-change-initial-expansion-list "vhdl directory")))
-    (define-key speedbar-key-map "H"
+    (define-key speedbar-mode-map "H"
       (lambda () (interactive)
        (speedbar-change-initial-expansion-list "vhdl project")))
     ;; menu
@@ -14010,10 +14617,10 @@ if required."
         ["Save Caches" vhdl-save-caches vhdl-updated-project-list])))
     ;; hook-ups
     (speedbar-add-expansion-list
-     '("vhdl directory" vhdl-speedbar-menu-items vhdl-speedbar-key-map
+     '("vhdl directory" vhdl-speedbar-menu-items vhdl-speedbar-mode-map
        vhdl-speedbar-display-directory))
     (speedbar-add-expansion-list
-     '("vhdl project" vhdl-speedbar-menu-items vhdl-speedbar-key-map
+     '("vhdl project" vhdl-speedbar-menu-items vhdl-speedbar-mode-map
        vhdl-speedbar-display-projects))
     (setq speedbar-stealthy-function-list
          (append
@@ -14047,11 +14654,15 @@ if required."
   "Name of last selected project.")
 
 ;; macros must be defined in the file they are used (copied from `speedbar.el')
-(defmacro speedbar-with-writable (&rest forms)
-  "Allow the buffer to be writable and evaluate FORMS."
-  (list 'let '((inhibit-read-only t))
-       (cons 'progn forms)))
-(put 'speedbar-with-writable 'lisp-indent-function 0)
+;;; (defmacro speedbar-with-writable (&rest forms)
+;;;   "Allow the buffer to be writable and evaluate FORMS."
+;;;   (list 'let '((inhibit-read-only t))
+;;;    (cons 'progn forms)))
+;;; (put 'speedbar-with-writable 'lisp-indent-function 0)
+
+(declare-function speedbar-extension-list-to-regex "speedbar" (extlist))
+(declare-function speedbar-directory-buttons "speedbar" (directory _index))
+(declare-function speedbar-file-lists "speedbar" (directory))
 
 (defun vhdl-speedbar-display-directory (directory depth &optional rescan)
   "Display directory and hierarchy information in speedbar."
@@ -14087,6 +14698,9 @@ if required."
       (error (vhdl-warning-when-idle "ERROR:  Invalid hierarchy information, unable to display correctly"))))
   (setq speedbar-full-text-cache nil)) ; prevent caching
 
+(declare-function speedbar-make-tag-line "speedbar"
+                 (type char func data tag tfunc tdata tface depth))
+
 (defun vhdl-speedbar-insert-projects ()
   "Insert all projects in speedbar."
   (vhdl-speedbar-make-title-line "Projects:")
@@ -14190,6 +14804,8 @@ otherwise use cached data."
         depth)
        (setq pack-alist (cdr pack-alist))))))
 
+(declare-function speedbar-line-directory "speedbar" (&optional depth))
+
 (defun vhdl-speedbar-rescan-hierarchy ()
   "Rescan hierarchy for the directory or project under the cursor."
   (interactive)
@@ -14211,6 +14827,8 @@ otherwise use cached data."
         (abbreviate-file-name (match-string 1 path)))))
     (vhdl-speedbar-refresh key)))
 
+(declare-function speedbar-goto-this-file "speedbar" (file))
+
 (defun vhdl-speedbar-expand-dirs (directory)
   "Expand subdirectories in DIRECTORY according to
  `speedbar-shown-directories'."
@@ -14260,6 +14878,8 @@ otherwise use cached data."
         (setq unit-alist (cdr unit-alist))))))
   (vhdl-speedbar-update-current-unit nil t))
 
+(declare-function speedbar-center-buffer-smartly "speedbar" ())
+
 (defun vhdl-speedbar-contract-level ()
   "Contract current level in current directory/project."
   (interactive)
@@ -14300,21 +14920,24 @@ otherwise use cached data."
       (setq arch-alist (nth 4 (car ent-alist)))
       (setq subunit-alist nil)
       (while arch-alist
-       (setq subunit-alist (cons (caar arch-alist) subunit-alist))
+       (push (caar arch-alist) subunit-alist)
        (setq arch-alist (cdr arch-alist)))
-      (setq unit-alist (cons (list (caar ent-alist) subunit-alist) unit-alist))
+      (push (list (caar ent-alist) subunit-alist) unit-alist)
       (setq ent-alist (cdr ent-alist)))
     (while conf-alist
-      (setq unit-alist (cons (list (caar conf-alist)) unit-alist))
+      (push (list (caar conf-alist)) unit-alist)
       (setq conf-alist (cdr conf-alist)))
     (while pack-alist
-      (setq unit-alist (cons (list (caar pack-alist)) unit-alist))
+      (push (list (caar pack-alist)) unit-alist)
       (setq pack-alist (cdr pack-alist)))
     (aput 'vhdl-speedbar-shown-unit-alist key unit-alist)
     (vhdl-speedbar-refresh)
     (when (memq 'display vhdl-speedbar-save-cache)
       (add-to-list 'vhdl-updated-project-list key))))
 
+(declare-function speedbar-change-expand-button-char "speedbar" (char))
+(declare-function speedbar-delete-subblock "speedbar" (indent))
+
 (defun vhdl-speedbar-expand-project (text token indent)
   "Expand/contract the project under the cursor."
   (cond
@@ -14643,6 +15266,8 @@ otherwise use cached data."
       (setq vhdl-speedbar-last-selected-project vhdl-project)))
   t)
 
+(declare-function speedbar-position-cursor-on-line "speedbar" ())
+
 (defun vhdl-speedbar-update-current-unit (&optional no-position always)
   "Highlight all design units that are contained in the current file.
 NO-POSITION non-nil means do not re-position cursor."
@@ -14732,6 +15357,9 @@ NO-POSITION non-nil means do not re-position cursor."
     (setq unit-list (cdr unit-list)))
   pos)
 
+(declare-function speedbar-make-button "speedbar"
+                 (start end face mouse function &optional token))
+
 (defun vhdl-speedbar-make-inst-line (inst-name inst-file-marker
                                               ent-name ent-file-marker
                                               arch-name arch-file-marker
@@ -14918,6 +15546,8 @@ NO-POSITION non-nil means do not re-position cursor."
                              'speedbar-directory-face level)
       (setq dirs (cdr dirs)))))
 
+(declare-function speedbar-reset-scanners "speedbar" ())
+
 (defun vhdl-speedbar-dired (text token indent)
   "Speedbar click handler for directory expand button in hierarchy mode."
   (cond ((string-match "+" text)       ; we have to expand this dir
@@ -14948,7 +15578,7 @@ NO-POSITION non-nil means do not re-position cursor."
                    (concat (speedbar-line-directory indent) token))))
           (while oldl
             (if (not (string-match (concat "^" (regexp-quote td)) (car oldl)))
-                (setq newl (cons (car oldl) newl)))
+                (push (car oldl) newl))
             (setq oldl (cdr oldl)))
           (setq speedbar-shown-directories (nreverse newl)))
         (speedbar-change-expand-button-char ?+)
@@ -14957,6 +15587,8 @@ NO-POSITION non-nil means do not re-position cursor."
   (when (equal (selected-frame) speedbar-frame)
     (speedbar-center-buffer-smartly)))
 
+(declare-function speedbar-files-item-info "speedbar" ())
+
 (defun vhdl-speedbar-item-info ()
   "Derive and display information about this line item."
   (save-excursion
@@ -15005,6 +15637,8 @@ NO-POSITION non-nil means do not re-position cursor."
          (vhdl-default-directory)))))
      (t (message "")))))
 
+(declare-function speedbar-line-text "speedbar" (&optional p))
+
 (defun vhdl-speedbar-line-text ()
   "Calls `speedbar-line-text' and removes text properties."
   (let ((string (speedbar-line-text)))
@@ -15055,7 +15689,7 @@ NO-POSITION non-nil means do not re-position cursor."
       (setq dir (car path-list))
       (string-match "\\(-r \\)?\\(\\([^?*]*[/\\]\\)*\\)" dir)
       (if (file-directory-p (match-string 2 dir))
-         (setq path-list-1 (cons dir path-list-1))
+         (push dir path-list-1)
        (vhdl-warning-when-idle "No such directory: \"%s\"" (match-string 2 dir)))
       (setq path-list (cdr path-list)))
     ;; resolve path wildcards
@@ -15077,13 +15711,13 @@ NO-POSITION non-nil means do not re-position cursor."
                          dir-list)
                      (while all-list
                        (when (file-directory-p (car all-list))
-                         (setq dir-list (cons (car all-list) dir-list)))
+                         (push (car all-list) dir-list))
                        (setq all-list (cdr all-list)))
                      dir-list))
                   (cdr path-list-1))))
        (string-match "\\(-r \\)?\\(.*\\)[/\\].*" dir)
        (when (file-directory-p (match-string 2 dir))
-         (setq path-list-2 (cons dir path-list-2)))
+         (push dir path-list-2))
        (setq path-list-1 (cdr path-list-1))))
     (nreverse path-list-2)))
 
@@ -15099,6 +15733,11 @@ NO-POSITION non-nil means do not re-position cursor."
       (goto-char dest)
       nil)))
 
+(declare-function speedbar-find-file-in-frame "speedbar" (file))
+(declare-function speedbar-set-timer "speedbar" (timeout))
+;; speedbar loads dframe at runtime.
+(declare-function dframe-maybee-jump-to-attached-frame "dframe" ())
+
 (defun vhdl-speedbar-find-file (text token indent)
   "When user clicks on TEXT, load file with name and position in TOKEN.
 Jump to the design unit if `vhdl-speedbar-jump-to-unit' is t or if the file
@@ -15108,12 +15747,11 @@ is already shown in a buffer."
     (let ((buffer (get-file-buffer (car token))))
       (speedbar-find-file-in-frame (car token))
       (when (or vhdl-speedbar-jump-to-unit buffer)
-       (goto-char (point-min))
-       (forward-line (1- (cdr token)))
+       (vhdl-goto-line (cdr token))
        (recenter))
       (vhdl-speedbar-update-current-unit t t)
       (speedbar-set-timer dframe-update-speed)
-      (speedbar-maybee-jump-to-attached-frame))))
+      (dframe-maybee-jump-to-attached-frame))))
 
 (defun vhdl-speedbar-port-copy ()
   "Copy the port of the entity/component or subprogram under the cursor."
@@ -15127,8 +15765,7 @@ is already shown in a buffer."
              (let ((token (get-text-property
                            (match-beginning 3) 'speedbar-token)))
                (vhdl-visit-file (car token) t
-                                (progn (goto-char (point-min))
-                                       (forward-line (1- (cdr token)))
+                                (progn (vhdl-goto-line (cdr token))
                                        (end-of-line)
                                        (if is-entity
                                            (vhdl-port-copy)
@@ -15174,6 +15811,8 @@ is already shown in a buffer."
       (setcar (cddr (cddr ent-entry)) arch-key) ; (nth 4 ent-entry)
       (speedbar-refresh))))
 
+(declare-function speedbar-line-file "speedbar" (&optional p))
+
 (defun vhdl-speedbar-make-design ()
   "Make (compile) design unit or directory/project under the cursor."
   (interactive)
@@ -15347,7 +15986,7 @@ expansion function)."
              (read-from-minibuffer "architecture name: "
                                    nil vhdl-minibuffer-local-map)
            (vhdl-replace-string vhdl-compose-architecture-name ent-name)))
-        ent-file-name arch-file-name ent-buffer arch-buffer project)
+        ent-file-name arch-file-name ent-buffer arch-buffer project end-pos)
     (message "Creating component \"%s(%s)\"..." ent-name arch-name)
     ;; open entity file
     (unless (eq vhdl-compose-create-files 'none)
@@ -15364,6 +16003,7 @@ expansion function)."
     ;; insert header
     (if vhdl-compose-include-header
        (progn (vhdl-template-header)
+              (setq end-pos (point))
               (goto-char (point-max)))
       (vhdl-comment-display-line) (insert "\n\n"))
     ;; insert library clause
@@ -15390,6 +16030,7 @@ expansion function)."
     ;; open architecture file
     (if (not (eq vhdl-compose-create-files 'separate))
        (insert "\n")
+      (goto-char (or end-pos (point-min)))
       (setq ent-buffer (current-buffer))
       (setq arch-file-name
            (concat (vhdl-replace-string vhdl-architecture-file-name
@@ -15434,7 +16075,7 @@ expansion function)."
     (if (and vhdl-compose-include-header (not (equal vhdl-file-footer "")))
        (vhdl-template-footer)
       (vhdl-comment-display-line) (insert "\n"))
-    (goto-char (point-min))
+    (goto-char (or end-pos (point-min)))
     (setq arch-buffer (current-buffer))
     (when ent-buffer (set-buffer ent-buffer) (save-buffer))
     (set-buffer arch-buffer) (save-buffer)
@@ -15453,8 +16094,8 @@ component instantiation."
       (error "ERROR:  No port has been read")
     (save-excursion
       (vhdl-prepare-search-2
-       (unless (or (re-search-backward "^architecture[ \t\n]+\\w+[ \t\n]+of[ \t\n]+\\(\\w+\\)[ \t\n]+is\\>" nil t)
-                  (re-search-forward "^architecture[ \t\n]+\\w+[ \t\n]+of[ \t\n]+\\(\\w+\\)[ \t\n]+is\\>" nil t))
+       (unless (or (re-search-backward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t)
+                  (re-search-forward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t))
         (error "ERROR:  No architecture found"))
        (let* ((ent-name (match-string 1))
              (ent-file-name
@@ -15471,13 +16112,13 @@ component instantiation."
                                (car vhdl-port-list) "\\>") nil t)))
           (re-search-forward "^begin\\>" nil)
           (beginning-of-line)
-          (skip-chars-backward " \t\n")
+          (skip-chars-backward " \t\n\r\f")
           (insert "\n\n") (indent-to vhdl-basic-offset)
           (vhdl-port-paste-component t))
         ;; place component instantiation
         (re-search-forward "^end\\>" nil)
         (beginning-of-line)
-        (skip-chars-backward " \t\n")
+        (skip-chars-backward " \t\n\r\f")
         (insert "\n\n") (indent-to vhdl-basic-offset)
         (vhdl-port-paste-instance nil t t)
         ;; place use clause for used packages
@@ -15486,7 +16127,7 @@ component instantiation."
           (when (file-exists-p ent-file-name)
             (find-file ent-file-name))
           (goto-char (point-min))
-          (unless (re-search-forward (concat "^entity[ \t\n]+" ent-name "[ \t\n]+is\\>") nil t)
+          (unless (re-search-forward (concat "^entity[ \t\n\r\f]+" ent-name "[ \t\n\r\f]+is\\>") nil t)
             (error "ERROR:  Entity not found: \"%s\"" ent-name))
           (goto-char (match-beginning 0))
           (if (and (save-excursion
@@ -15505,8 +16146,8 @@ component instantiation."
   (interactive)
   (save-excursion
     (vhdl-prepare-search-2
-     (unless (or (re-search-backward "^architecture[ \t\n]+\\w+[ \t\n]+of[ \t\n]+\\(\\w+\\)[ \t\n]+is\\>" nil t)
-                (re-search-forward "^architecture[ \t\n]+\\w+[ \t\n]+of[ \t\n]+\\(\\w+\\)[ \t\n]+is\\>" nil t))
+     (unless (or (re-search-backward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t)
+                (re-search-forward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t))
        (error "ERROR:  No architecture found"))
      (let* ((ent-name (match-string 1))
            (ent-file-name
@@ -15532,11 +16173,11 @@ component instantiation."
        ;; process all instances
        (goto-char arch-stat-pos)
        (while (re-search-forward
-              (concat "^[ \t]*\\(\\w+\\)[ \t\n]*:[ \t\n]*\\("
-                      "\\(component[ \t\n]+\\)?\\(\\w+\\)"
-                      "[ \t\n]+\\(--[^\n]*\n[ \t\n]*\\)*\\(\\(generic\\)\\|port\\)[ \t\n]+map\\|"
-                      "\\(\\(entity\\)\\|configuration\\)[ \t\n]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n]*(\\(\\w+\\))\\)?"
-                      "[ \t\n]+\\(--[^\n]*\n[ \t\n]*\\)*\\(\\(generic\\)\\|port\\)[ \t\n]+map\\)[ \t\n]*(") arch-end-pos t)
+              (concat "^[ \t]*\\(\\w+\\)[ \t\n\r\f]*:[ \t\n\r\f]*\\("
+                      "\\(component[ \t\n\r\f]+\\)?\\(\\w+\\)"
+                      "[ \t\n\r\f]+\\(--[^\n]*\n[ \t\n\r\f]*\\)*\\(\\(generic\\)\\|port\\)[ \t\n\r\f]+map\\|"
+                      "\\(\\(entity\\)\\|configuration\\)[ \t\n\r\f]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n\r\f]*(\\(\\w+\\))\\)?"
+                      "[ \t\n\r\f]+\\(--[^\n]*\n[ \t\n\r\f]*\\)*\\(\\(generic\\)\\|port\\)[ \t\n\r\f]+map\\)[ \t\n\r\f]*(") arch-end-pos t)
         (setq inst-name (match-string-no-properties 1)
               comp-name (match-string-no-properties 4)
               comp-ent-name (match-string-no-properties 12)
@@ -15548,7 +16189,7 @@ component instantiation."
              (when vhdl-use-components-package pack-file-name) t
              (save-excursion
                (goto-char (point-min))
-               (unless (re-search-forward (concat "^\\s-*component[ \t\n]+" comp-name "\\>") nil t)
+               (unless (re-search-forward (concat "^\\s-*component[ \t\n\r\f]+" comp-name "\\>") nil t)
                  (error "ERROR:  Component declaration not found: \"%s\"" comp-name))
                (vhdl-port-copy)))
           ;; ... from entity declaration (direct instantiation)
@@ -15559,7 +16200,7 @@ component instantiation."
            comp-ent-file-name t
            (save-excursion
              (goto-char (point-min))
-             (unless (re-search-forward (concat "^\\s-*entity[ \t\n]+" comp-ent-name "\\>") nil t)
+             (unless (re-search-forward (concat "^\\s-*entity[ \t\n\r\f]+" comp-ent-name "\\>") nil t)
                (error "ERROR:  Entity declaration not found: \"%s\"" comp-ent-name))
              (vhdl-port-copy))))
         (vhdl-port-flatten t)
@@ -15571,7 +16212,7 @@ component instantiation."
         (when has-generic
           ;; process all constants in generic map
           (vhdl-forward-syntactic-ws)
-          (while (vhdl-parse-string "\\(\\(\\w+\\)[ \t\n]*=>[ \t\n]*\\)?\\(\\w+\\),?" t)
+          (while (vhdl-parse-string "\\(\\(\\w+\\)[ \t\n\r\f]*=>[ \t\n\r\f]*\\)?\\(\\w+\\),?" t)
             (setq constant-name (match-string-no-properties 3))
             (setq constant-entry
                   (cons constant-name
@@ -15579,7 +16220,7 @@ component instantiation."
                             (or (aget generic-alist (match-string 2) t)
                                 (error "ERROR:  Formal generic \"%s\" mismatch for instance \"%s\"" (match-string 2) inst-name))
                           (cdar generic-alist))))
-            (setq constant-alist (cons constant-entry constant-alist))
+            (push constant-entry constant-alist)
             (setq constant-name (downcase constant-name))
             (if (or (member constant-name single-list)
                     (member constant-name multi-list))
@@ -15589,17 +16230,17 @@ component instantiation."
             (unless (match-string 1)
               (setq generic-alist (cdr generic-alist)))
             (vhdl-forward-syntactic-ws))
-          (vhdl-re-search-forward "\\<port\\s-+map[ \t\n]*(" nil t))
+          (vhdl-re-search-forward "\\<port\\s-+map[ \t\n\r\f]*(" nil t))
         ;; process all signals in port map
         (vhdl-forward-syntactic-ws)
-        (while (vhdl-parse-string "\\(\\(\\w+\\)[ \t\n]*=>[ \t\n]*\\)?\\(\\w+\\),?" t)
+        (while (vhdl-parse-string "\\(\\(\\w+\\)[ \t\n\r\f]*=>[ \t\n\r\f]*\\)?\\(\\w+\\),?" t)
           (setq signal-name (match-string-no-properties 3))
           (setq signal-entry (cons signal-name
                                    (if (match-string 1)
                                        (or (aget port-alist (match-string 2) t)
                                            (error "ERROR:  Formal port \"%s\" mismatch for instance \"%s\"" (match-string 2) inst-name))
                                      (cdar port-alist))))
-          (setq signal-alist (cons signal-entry signal-alist))
+          (push signal-entry signal-alist)
           (setq signal-name (downcase signal-name))
           (if (equal (upcase (nth 2 signal-entry)) "IN")
               ;; input signal
@@ -15633,12 +16274,12 @@ component instantiation."
           (unless (match-string 1)
             (setq port-alist (cdr port-alist)))
           (vhdl-forward-syntactic-ws))
-        (setq inst-alist (cons (list inst-name (nreverse constant-alist)
-                                     (nreverse signal-alist)) inst-alist)))
+        (push (list inst-name (nreverse constant-alist)
+                    (nreverse signal-alist)) inst-alist))
        ;; prepare signal insertion
        (vhdl-goto-marker arch-decl-pos)
        (forward-line 1)
-       (re-search-forward "^\\s-*-- Internal signal declarations[ \t\n]*-*\n" arch-stat-pos t)
+       (re-search-forward "^\\s-*-- Internal signal declarations[ \t\n\r\f]*-*\n" arch-stat-pos t)
        (setq signal-pos (point-marker))
        (while (progn (vhdl-forward-syntactic-ws)
                     (looking-at "signal\\>"))
@@ -15649,10 +16290,10 @@ component instantiation."
        (when (file-exists-p ent-file-name)
         (find-file ent-file-name))
        (goto-char (point-min))
-       (unless (re-search-forward (concat "^entity[ \t\n]+" ent-name "[ \t\n]+is\\>") nil t)
+       (unless (re-search-forward (concat "^entity[ \t\n\r\f]+" ent-name "[ \t\n\r\f]+is\\>") nil t)
         (error "ERROR:  Entity not found: \"%s\"" ent-name))
        ;; prepare generic clause insertion
-       (unless (and (re-search-forward "\\(^\\s-*generic[ \t\n]*(\\)\\|^end\\>" nil t)
+       (unless (and (re-search-forward "\\(^\\s-*generic[ \t\n\r\f]*(\\)\\|^end\\>" nil t)
                    (match-string 1))
         (goto-char (match-beginning 0))
         (indent-to vhdl-basic-offset)
@@ -15670,7 +16311,7 @@ component instantiation."
        (setq generic-beg-pos (point-marker) generic-pos (point-marker)
             generic-inst-pos (point-marker) generic-end-pos (point-marker))
        ;; prepare port clause insertion
-       (unless (and (re-search-forward "\\(^\\s-*port[ \t\n]*(\\)\\|^end\\>" nil t)
+       (unless (and (re-search-forward "\\(^\\s-*port[ \t\n\r\f]*(\\)\\|^end\\>" nil t)
                    (match-string 1))
         (goto-char (match-beginning 0))
         (indent-to vhdl-basic-offset)
@@ -15701,6 +16342,7 @@ component instantiation."
         (while constant-alist
           (setq constant-name (downcase (caar constant-alist))
                 constant-entry (car constant-alist))
+          (unless (string-match "^[0-9]+" constant-name)
           (cond ((member constant-name written-list)
                  nil)
                 ((member constant-name multi-list)
@@ -15717,7 +16359,7 @@ component instantiation."
                  (setq generic-end-pos
                        (vhdl-compose-insert-generic constant-entry))
                  (setq generic-inst-pos (point-marker))
-                 (add-to-list 'written-list constant-name)))
+                   (add-to-list 'written-list constant-name))))
           (setq constant-alist (cdr constant-alist)))
         (when (/= constant-temp-pos generic-inst-pos)
           (vhdl-goto-marker (vhdl-max-marker constant-temp-pos generic-pos))
@@ -15877,8 +16519,7 @@ current project/directory."
     ;; insert component declarations
     (while ent-alist
       (vhdl-visit-file (nth 2 (car ent-alist)) nil
-                      (progn (goto-char (point-min))
-                             (forward-line (1- (nth 3 (car ent-alist))))
+                      (progn (vhdl-goto-line (nth 3 (car ent-alist)))
                              (end-of-line)
                              (vhdl-port-copy)))
       (goto-char component-pos)
@@ -15894,7 +16535,8 @@ current project/directory."
     (message "Generating components package \"%s\"...done\n  File created: \"%s\""
             pack-name pack-file-name)))
 
-(defun vhdl-compose-configuration-architecture (ent-name arch-name inst-alist
+(defun vhdl-compose-configuration-architecture (ent-name arch-name ent-alist
+                                                        conf-alist inst-alist
                                                         &optional insert-conf)
   "Generate block configuration for architecture."
   (let ((margin (current-indentation))
@@ -15970,7 +16612,7 @@ current project/directory."
                       (nth 3 ent-entry))
              (indent-to (+ margin vhdl-basic-offset))
              (vhdl-compose-configuration-architecture
-              (nth 0 ent-entry) arch-name
+              (nth 0 ent-entry) arch-name ent-alist conf-alist
               (nth 3 (aget (nth 3 ent-entry) (downcase arch-name) t))))))
        ;; insert component configuration end
        (indent-to margin)
@@ -16052,7 +16694,8 @@ current project/directory."
      (vhdl-insert-keyword " IS\n")
      (indent-to vhdl-basic-offset)
      ;; insert block configuration (for architecture)
-     (vhdl-compose-configuration-architecture ent-name arch-name inst-alist t)
+     (vhdl-compose-configuration-architecture
+      ent-name arch-name ent-alist conf-alist inst-alist t)
      (vhdl-insert-keyword "END ") (insert conf-name ";")
      (when conf-file-name
        ;; insert footer and save
@@ -16072,6 +16715,9 @@ current project/directory."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; (using `compile.el')
 
+(defvar vhdl-compile-post-command ""
+  "String appended to compile command after file name.")
+
 (defun vhdl-makefile-name ()
   "Return the Makefile name of the current project or the current compiler if
 no project is defined."
@@ -16129,12 +16775,12 @@ no project is defined."
        (setq sublist (nth 11 (car commands-alist)))
        (unless (or (equal "" (car sublist))
                    (assoc (car sublist) regexp-alist))
-         (setq regexp-alist (cons (list (nth 0 sublist)
-                                        (if (= 0 (nth 1 sublist))
-                                            (if (featurep 'xemacs) 9 nil)
+         (push (list (nth 0 sublist)
+                     (if (and (featurep 'xemacs) (not (nth 1 sublist)))
+                         9
                                           (nth 1 sublist))
                                         (nth 2 sublist) (nth 3 sublist))
-                                  regexp-alist)))
+               regexp-alist))
        (setq commands-alist (cdr commands-alist)))
       (setq compilation-error-regexp-alist
            (append compilation-error-regexp-alist (nreverse regexp-alist))))
@@ -16147,7 +16793,7 @@ no project is defined."
        (setq sublist (nth 12 (car commands-alist)))
        (unless (or (equal "" (car sublist))
                    (assoc (car sublist) regexp-alist))
-         (setq regexp-alist (cons sublist regexp-alist)))
+         (push sublist regexp-alist))
        (setq commands-alist (cdr commands-alist)))
       (setq compilation-file-regexp-alist
            (append compilation-file-regexp-alist (nreverse regexp-alist))))))
@@ -16226,9 +16872,11 @@ do not print any file names."
         (compiler (or (aget vhdl-compiler-alist vhdl-compiler nil)
                       (error "ERROR:  No such compiler: \"%s\"" vhdl-compiler)))
         (command (nth 0 compiler))
-        (file-name (buffer-file-name))
-        (options (vhdl-get-compile-options project compiler file-name))
         (default-directory (vhdl-compile-directory))
+        (file-name (if vhdl-compile-absolute-path
+                       (buffer-file-name)
+                     (file-relative-name (buffer-file-name))))
+        (options (vhdl-get-compile-options project compiler file-name))
         compilation-process-setup-function)
     (unless (file-directory-p default-directory)
       (error "ERROR:  Compile directory does not exist: \"%s\"" default-directory))
@@ -16236,14 +16884,18 @@ do not print any file names."
     (when (string-match " " file-name)
       (setq file-name (concat "\"" file-name "\"")))
     ;; print out file name if compiler does not
-    (setq vhdl-compile-file-name (buffer-file-name))
+    (setq vhdl-compile-file-name (if vhdl-compile-absolute-path
+                                    (buffer-file-name)
+                                  (file-relative-name (buffer-file-name))))
     (when (and (= 0 (nth 1 (nth 10 compiler)))
               (= 0 (nth 1 (nth 11 compiler))))
       (setq compilation-process-setup-function 'vhdl-compile-print-file-name))
     ;; run compilation
     (if options
        (when command
-         (compile (concat command " " options " " file-name)))
+         (compile (concat command " " options " " file-name
+                          (unless (equal vhdl-compile-post-command "")
+                            (concat " " vhdl-compile-post-command)))))
       (vhdl-warning "Your project settings tell me not to compile this file"))))
 
 (defvar vhdl-make-target "all"
@@ -16270,6 +16922,42 @@ specified by a target."
     (compile (concat (if (equal command "") "make" command)
                     " " options " " vhdl-make-target))))
 
+;; Emacs 22+ setup
+(defvar vhdl-error-regexp-emacs-alist
+  ;; Get regexps from `vhdl-compiler-alist'
+  (let ((compiler-alist vhdl-compiler-alist)
+       (error-regexp-alist '((vhdl-directory "^ *Compiling \"\\(.+\\)\"" 1))))
+   (while compiler-alist
+     ;; add error message regexps
+     (setq error-regexp-alist
+          (cons (append (list (make-symbol (concat "vhdl-" (subst-char-in-string ?  ?- (downcase (nth 0 (car compiler-alist)))))))
+                        (nth 11 (car compiler-alist)))
+                error-regexp-alist))
+     ;; add filename regexps
+     (when (/= 0 (nth 1 (nth 12 (car compiler-alist))))
+       (setq error-regexp-alist
+            (cons (append (list (make-symbol (concat "vhdl-" (subst-char-in-string ?  ?- (downcase (nth 0 (car compiler-alist)))) "-file")))
+                          (nth 12 (car compiler-alist)))
+                  error-regexp-alist)))
+     (setq compiler-alist (cdr compiler-alist)))
+   error-regexp-alist)
+  "List of regexps for VHDL compilers.  For Emacs 22+.")
+
+;; Add error regexps using compilation-mode-hook.
+(defun vhdl-error-regexp-add-emacs ()
+  "Set up Emacs compile for VHDL."
+  (interactive)
+  (when (and (boundp 'compilation-error-regexp-alist-alist)
+            (not (assoc 'vhdl-modelsim compilation-error-regexp-alist-alist)))
+    (mapcar
+     (lambda (item)
+       (push (car item) compilation-error-regexp-alist)
+       (push item compilation-error-regexp-alist-alist))
+     vhdl-error-regexp-emacs-alist)))
+
+(when vhdl-emacs-22
+  (add-hook 'compilation-mode-hook 'vhdl-error-regexp-add-emacs))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Makefile generation
 
@@ -16292,7 +16980,7 @@ specified by a target."
   (let (pack-list)
     (while lib-alist
       (when (equal (downcase (caar lib-alist)) (downcase work-library))
-       (setq pack-list (cons (cdar lib-alist) pack-list)))
+       (push (cdar lib-alist) pack-list))
       (setq lib-alist (cdr lib-alist)))
     pack-list))
 
@@ -16344,8 +17032,10 @@ specified by a target."
       (setq ent-entry (car ent-alist)
            ent-key (nth 0 ent-entry))
       (when (nth 2 ent-entry)
-       (setq ent-file-name (file-relative-name
-                            (nth 2 ent-entry) compile-directory)
+       (setq ent-file-name (if vhdl-compile-absolute-path
+                               (nth 2 ent-entry)
+                             (file-relative-name (nth 2 ent-entry)
+                                                 compile-directory))
              arch-alist (nth 4 ent-entry)
              lib-alist (nth 6 ent-entry)
              rule (aget rule-alist ent-file-name)
@@ -16355,9 +17045,9 @@ specified by a target."
              subcomp-list nil)
        (setq tmp-key (vhdl-replace-string
                       ent-regexp (funcall adjust-case ent-key)))
-       (setq unit-list (cons (cons ent-key tmp-key) unit-list))
+       (push (cons ent-key tmp-key) unit-list)
        ;; rule target for this entity
-       (setq target-list (cons ent-key target-list))
+       (push ent-key target-list)
        ;; rule dependencies for all used packages
        (setq pack-list (vhdl-get-packages lib-alist work-library))
        (setq depend-list (append depend-list pack-list))
@@ -16369,8 +17059,10 @@ specified by a target."
          (setq arch-entry (car arch-alist)
                arch-key (nth 0 arch-entry)
                ent-arch-key (concat ent-key "-" arch-key)
-               arch-file-name (file-relative-name (nth 2 arch-entry)
-                                                  compile-directory)
+               arch-file-name (if vhdl-compile-absolute-path
+                                  (nth 2 arch-entry)
+                                (file-relative-name (nth 2 arch-entry)
+                                                    compile-directory))
                inst-alist (nth 4 arch-entry)
                lib-alist (nth 5 arch-entry)
                rule (aget rule-alist arch-file-name)
@@ -16381,11 +17073,11 @@ specified by a target."
                         (funcall adjust-case (concat arch-key " " ent-key))))
          (setq unit-list
                (cons (cons ent-arch-key tmp-key) unit-list))
-         (setq second-list (cons ent-arch-key second-list))
+         (push ent-arch-key second-list)
          ;; rule target for this architecture
-         (setq target-list (cons ent-arch-key target-list))
+         (push ent-arch-key target-list)
          ;; rule dependency for corresponding entity
-         (setq depend-list (cons ent-key depend-list))
+         (push ent-key depend-list)
          ;; rule dependencies for contained component instantiations
          (while inst-alist
            (setq inst-entry (car inst-alist))
@@ -16403,9 +17095,8 @@ specified by a target."
          ;; add rule
          (aput 'rule-alist arch-file-name (list target-list depend-list))
          (setq arch-alist (cdr arch-alist)))
-       (setq prim-list (cons (list ent-key second-list
-                                   (append subcomp-list all-pack-list))
-                             prim-list)))
+       (push (list ent-key second-list (append subcomp-list all-pack-list))
+             prim-list))
       (setq ent-alist (cdr ent-alist)))
     (setq ent-alist tmp-list)
     ;; rules for all configurations
@@ -16413,8 +17104,10 @@ specified by a target."
     (while conf-alist
       (setq conf-entry (car conf-alist)
            conf-key (nth 0 conf-entry)
-           conf-file-name (file-relative-name
-                           (nth 2 conf-entry) compile-directory)
+           conf-file-name (if vhdl-compile-absolute-path
+                              (nth 2 conf-entry)
+                            (file-relative-name (nth 2 conf-entry)
+                                                compile-directory))
            ent-key (nth 4 conf-entry)
            arch-key (nth 5 conf-entry)
            inst-alist (nth 6 conf-entry)
@@ -16425,9 +17118,9 @@ specified by a target."
            subcomp-list (list ent-key))
       (setq tmp-key (vhdl-replace-string
                     conf-regexp (funcall adjust-case conf-key)))
-      (setq unit-list (cons (cons conf-key tmp-key) unit-list))
+      (push (cons conf-key tmp-key) unit-list)
       ;; rule target for this configuration
-      (setq target-list (cons conf-key target-list))
+      (push conf-key target-list)
       ;; rule dependency for corresponding entity and architecture
       (setq depend-list
            (cons ent-key (cons (concat ent-key "-" arch-key) depend-list)))
@@ -16445,16 +17138,14 @@ specified by a target."
            (setq depend-list (cons inst-ent-key depend-list)
                  subcomp-list (cons inst-ent-key subcomp-list)))
 ;          (when comp-arch-key
-;            (setq depend-list (cons (concat comp-ent-key "-" comp-arch-key)
-;                                    depend-list)))
+;            (push (concat comp-ent-key "-" comp-arch-key) depend-list))
          (when inst-conf-key
            (setq depend-list (cons inst-conf-key depend-list)
                  subcomp-list (cons inst-conf-key subcomp-list))))
        (setq inst-alist (cdr inst-alist)))
       ;; add rule
       (aput 'rule-alist conf-file-name (list target-list depend-list))
-      (setq prim-list (cons (list conf-key nil (append subcomp-list pack-list))
-                           prim-list))
+      (push (list conf-key nil (append subcomp-list pack-list)) prim-list)
       (setq conf-alist (cdr conf-alist)))
     (setq conf-alist tmp-list)
     ;; rules for all packages
@@ -16464,16 +17155,18 @@ specified by a target."
            pack-key (nth 0 pack-entry)
            pack-body-key nil)
       (when (nth 2 pack-entry)
-       (setq pack-file-name (file-relative-name (nth 2 pack-entry)
-                                                compile-directory)
+       (setq pack-file-name (if vhdl-compile-absolute-path
+                                (nth 2 pack-entry)
+                              (file-relative-name (nth 2 pack-entry)
+                                                  compile-directory))
              lib-alist (nth 6 pack-entry) lib-body-alist (nth 10 pack-entry)
              rule (aget rule-alist pack-file-name)
              target-list (nth 0 rule) depend-list (nth 1 rule))
        (setq tmp-key (vhdl-replace-string
                       pack-regexp (funcall adjust-case pack-key)))
-       (setq unit-list (cons (cons pack-key tmp-key) unit-list))
+       (push (cons pack-key tmp-key) unit-list)
        ;; rule target for this package
-       (setq target-list (cons pack-key target-list))
+       (push pack-key target-list)
        ;; rule dependencies for all used packages
        (setq pack-list (vhdl-get-packages lib-alist work-library))
        (setq depend-list (append depend-list pack-list))
@@ -16483,8 +17176,10 @@ specified by a target."
        ;; rules for this package's body
        (when (nth 7 pack-entry)
          (setq pack-body-key (concat pack-key "-body")
-               pack-body-file-name (file-relative-name (nth 7 pack-entry)
-                                                       compile-directory)
+               pack-body-file-name (if vhdl-compile-absolute-path
+                                       (nth 7 pack-entry)
+                                     (file-relative-name (nth 7 pack-entry)
+                                                         compile-directory))
                rule (aget rule-alist pack-body-file-name)
                target-list (nth 0 rule)
                depend-list (nth 1 rule))
@@ -16493,9 +17188,9 @@ specified by a target."
          (setq unit-list
                (cons (cons pack-body-key tmp-key) unit-list))
          ;; rule target for this package's body
-         (setq target-list (cons pack-body-key target-list))
+         (push pack-body-key target-list)
          ;; rule dependency for corresponding package declaration
-         (setq depend-list (cons pack-key depend-list))
+         (push pack-key depend-list)
          ;; rule dependencies for all used packages
          (setq pack-list (vhdl-get-packages lib-body-alist work-library))
          (setq depend-list (append depend-list pack-list))
@@ -16551,6 +17246,8 @@ specified by a target."
       (insert "\n\n# Define compilation command and options\n"
              "\nCOMPILE = " (nth 0 compiler)
              "\nOPTIONS = " (vhdl-get-compile-options project compiler nil)
+             (if (equal vhdl-compile-post-command "") ""
+               (concat "\nPOST-COMPILE = " vhdl-compile-post-command))
              "\n")
       ;; insert library paths
       (setq library-directory
@@ -16580,16 +17277,16 @@ specified by a target."
       (setq unit-list tmp-list)
       ;; insert `make all' rule
       (insert "\n\n\n# Rule for compiling entire design\n"
-             "\nall :"
-             " \\\n\t\tlibrary"
+             "\n" (nth 0 vhdl-makefile-default-targets) " :"
+             " \\\n\t\t" (nth 2 vhdl-makefile-default-targets)
              " \\\n\t\t$(ALL_UNITS)\n")
       ;; insert `make clean' rule
       (insert "\n\n# Rule for cleaning entire design\n"
-             "\nclean : "
+             "\n" (nth 1 vhdl-makefile-default-targets) " : "
              "\n\t-rm -f $(ALL_UNITS)\n")
       ;; insert `make library' rule
       (insert "\n\n# Rule for creating library directory\n"
-             "\nlibrary :"
+             "\n" (nth 2 vhdl-makefile-default-targets) " :"
              " \\\n\t\t$(LIBRARY-" work-library ")\n"
              "\n$(LIBRARY-" work-library ") :"
              "\n\t"
@@ -16597,6 +17294,11 @@ specified by a target."
               (cons "\\(.*\\)\n\\(.*\\)" (nth 5 compiler))
               (concat "$(LIBRARY-" work-library ")\n" (vhdl-work-library)))
              "\n")
+      ;; insert '.PHONY' declaration
+      (insert "\n\n.PHONY : "
+             (nth 0 vhdl-makefile-default-targets) " "
+             (nth 1 vhdl-makefile-default-targets) " "
+             (nth 2 vhdl-makefile-default-targets) "\n")
       ;; insert rule for each library unit
       (insert "\n\n# Rules for compiling single library units and their subhierarchy\n")
       (while prim-list
@@ -16611,16 +17313,16 @@ specified by a target."
        (unless (equal unit-key unit-name)
          (insert " \\\n" unit-name))
        (insert " :"
-               " \\\n\t\tlibrary"
-               " \\\n\t\t$(UNIT-" work-library "-" unit-key ")")
-       (while second-list
-         (insert " \\\n\t\t$(UNIT-" work-library "-" (car second-list) ")")
-         (setq second-list (cdr second-list)))
+               " \\\n\t\t" (nth 2 vhdl-makefile-default-targets))
        (while subcomp-list
          (when (and (assoc (car subcomp-list) unit-list)
                     (not (equal unit-key (car subcomp-list))))
            (insert " \\\n\t\t" (car subcomp-list)))
          (setq subcomp-list (cdr subcomp-list)))
+       (insert " \\\n\t\t$(UNIT-" work-library "-" unit-key ")")
+       (while second-list
+         (insert " \\\n\t\t$(UNIT-" work-library "-" (car second-list) ")")
+         (setq second-list (cdr second-list)))
        (insert "\n")
        (setq prim-list (cdr prim-list)))
       ;; insert rule for each library unit file
@@ -16653,7 +17355,9 @@ specified by a target."
        (if options
            (insert "\n\t$(COMPILE) "
                    (if (eq options 'default) "$(OPTIONS)" options) " "
-                   (nth 0 rule) "\n")
+                   (nth 0 rule)
+                   (if (equal vhdl-compile-post-command "") ""
+                     " $(POST-COMPILE)") "\n")
          (setq tmp-list target-list)
          (while target-list
            (insert "\n\t@touch $(UNIT-" work-library "-" (car target-list) ")"
@@ -16712,6 +17416,7 @@ specified by a target."
        'vhdl-compiler-alist
        'vhdl-compiler
        'vhdl-compile-use-local-error-regexp
+       'vhdl-makefile-default-targets
        'vhdl-makefile-generation-hook
        'vhdl-default-library
        'vhdl-standard
@@ -16722,6 +17427,7 @@ specified by a target."
        'vhdl-upper-case-enum-values
        'vhdl-upper-case-constants
        'vhdl-use-direct-instantiation
+       'vhdl-array-index-record-field-in-sensitivity-list
        'vhdl-compose-configuration-name
        'vhdl-entity-file-name
        'vhdl-architecture-file-name
@@ -16755,6 +17461,7 @@ specified by a target."
        'vhdl-include-direction-comments
        'vhdl-include-type-comments
        'vhdl-include-group-comments
+       'vhdl-actual-generic-name
        'vhdl-actual-port-name
        'vhdl-instance-name
        'vhdl-testbench-entity-name
@@ -16812,6 +17519,7 @@ specified by a target."
        'vhdl-print-customize-faces
        'vhdl-intelligent-tab
        'vhdl-indent-syntax-based
+       'vhdl-indent-comment-like-next-code-line
        'vhdl-word-completion-case-sensitive
        'vhdl-word-completion-in-minibuffer
        'vhdl-underscore-is-part-of-word
@@ -16836,12 +17544,20 @@ specified by a target."
 
 (defconst vhdl-doc-release-notes nil
   "\
-Release Notes for VHDL Mode 3.33
+Release Notes for VHDL Mode 3.34
 ================================
 
-  - New Features
-  - User Options
+- Added support for GNU Emacs 22/23/24:
+  - Compilation error parsing fixed for new `compile.el' package.
 
+- Port translation: Derive actual generic name from formal generic name.
+
+- New user options:
+  `vhdl-actual-generic-name': Specify how actual generic names are obtained.
+
+
+Release Notes for VHDL Mode 3.33
+================================
 
 New Features
 ------------
@@ -16851,6 +17567,17 @@ CONFIGURATION DECLARATION GENERATION:
     (See documentation (`C-c C-h') in section on STRUCTURAL COMPOSITION.)
 
 
+Key Bindings
+------------
+
+For Emacs compliance the following key bindings have been changed:
+
+- `C-c c'        ->  `C-c C-c'      `vhdl-comment-uncomment-region'
+- `C-c f'        ->  `C-c C-i C-f'  `vhdl-fontify-buffer'
+- `C-c s'        ->  `C-c C-i C-s'  `vhdl-statistics-buffer'
+- `C-c C-c ...'  ->  `C-c C-m ...'  `vhdl-compose-...'
+
+
 User Options
 ------------
 
@@ -16864,6 +17591,12 @@ User Options
   Specify whether hierarchical configurations should be created.
 `vhdl-compose-configuration-use-subconfiguration': (new)
   Specify whether subconfigurations should be used inside configurations.
+`vhdl-makefile-default-targets': (new)
+  Customize names of Makefile default targets.
+`vhdl-indent-comment-like-next-code-line': (new)
+  Specify whether comment lines are indented like following code line.
+`vhdl-array-index-record-field-in-sensitivity-list': (new)
+  Specify whether to include array indices / record fields in sensitivity list.
 ")
 
 
@@ -16872,19 +17605,20 @@ User Options
 Reserved words in VHDL
 ----------------------
 
-VHDL'93 (IEEE Std 1076-1993):
-  `vhdl-93-keywords'      : keywords
-  `vhdl-93-types'         : standardized types
-  `vhdl-93-attributes'    : standardized attributes
-  `vhdl-93-enum-values'   : standardized enumeration values
-  `vhdl-93-functions'     : standardized functions
-  `vhdl-93-packages'      : standardized packages and libraries
+VHDL'93/02 (IEEE Std 1076-1993/2002):
+  `vhdl-02-keywords'      : keywords
+  `vhdl-02-types'         : standardized types
+  `vhdl-02-attributes'    : standardized attributes
+  `vhdl-02-enum-values'   : standardized enumeration values
+  `vhdl-02-functions'     : standardized functions
+  `vhdl-02-packages'      : standardized packages and libraries
 
-VHDL-AMS (IEEE Std 1076.1):
+VHDL-AMS (IEEE Std 1076.1 / 1076.1.1):
   `vhdl-ams-keywords'     : keywords
   `vhdl-ams-types'        : standardized types
   `vhdl-ams-attributes'   : standardized attributes
   `vhdl-ams-enum-values'  : standardized enumeration values
+  `vhdl-ams-constants'    : standardized constants
   `vhdl-ams-functions'    : standardized functions
 
 Math Packages (IEEE Std 1076.2):
@@ -16932,7 +17666,8 @@ to visually support naming conventions.")
   "Display VARIABLE's documentation in *Help* buffer."
   (interactive)
   (unless (featurep 'xemacs)
-    (help-setup-xref (list #'vhdl-doc-variable variable) (interactive-p)))
+    (help-setup-xref (list #'vhdl-doc-variable variable)
+                    (called-interactively-p 'interactive)))
   (with-output-to-temp-buffer
       (if (fboundp 'help-buffer) (help-buffer) "*Help*")
     (princ (documentation-property variable 'variable-documentation))
@@ -16944,7 +17679,8 @@ to visually support naming conventions.")
   "Display VHDL Mode documentation in *Help* buffer."
   (interactive)
   (unless (featurep 'xemacs)
-    (help-setup-xref (list #'vhdl-doc-mode) (interactive-p)))
+    (help-setup-xref (list #'vhdl-doc-mode)
+                    (called-interactively-p 'interactive)))
   (with-output-to-temp-buffer
       (if (fboundp 'help-buffer) (help-buffer) "*Help*")
     (princ mode-name)