🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.vhdl
Article #480

Emacs VHDL editing mode (vhdl-mode.el version 2.71)

#480
From: Rod Whitby
Date: Thu, 28 Sep 1995 00:00
3998 lines
148310 bytes
Here is the latest version of my VHDL editing mode for emacs.  There
are two distribution lists available that allow you to automatically
receive updates to vhdl-mode - see the file header for details.

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1995-09-28 17:03 CST by <rwhitby@asc.corp.mot.com>.
# Source directory was `/usr/local/lib/xemacs/site-lisp/vhdl-mode'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#  91988 -r--r--r-- vhdl-mode.el
#  46573 -r--r--r-- vhdl-mode.texi
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  echo 'WARNING: not restoring timestamps.  Consider getting and'
  echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
# ============= vhdl-mode.el ==============
if test -f 'vhdl-mode.el' && test X"$1" != X"-c"; then
  echo 'x - skipping vhdl-mode.el (file already exists)'
else
  echo 'x - extracting vhdl-mode.el (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vhdl-mode.el' &&
;;; vhdl-mode.el --- major mode for editing VHDL code
X
;; Copyright (C) 1994, 1995 Rodney J. Whitby
;; Copyright (C) 1992, 1993, 1994 Barry A. Warsaw
;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
X
;; Author:	  Rodney J. Whitby <rwhitby@asc.corp.mot.com>
;; Maintainer:	  Rodney J. Whitby <rwhitby@asc.corp.mot.com>
;; Created:	  June 1994, adapted from cc-mode.el 4.29 by Barry A. Warsaw.
;; Version:	  $Revision: 2.71 $
;; Last Modified: $Date: 1995/09/28 07:32:40 $
;; Keywords:	  languages VHDL
X
;; NOTE: Read the commentary below for the right way to submit bug reports!
X
;; This file is not yet part of GNU Emacs.
X
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
X
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
X
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
X
;;; Commentary:
X
;; This package provides indentation support for VHDL code.
X
;; Details on VHDL-MODE are  now contained in an  accompanying texinfo
;; manual (vhdl-mode.texi).
X
;; To submit bug reports, hit "C-c C-b", and please try to include a
;; code sample so I can reproduce your problem.  If you have other
;; questions contact me at the address listed at the top of this file.
X
;; YOU CAN IGNORE ALL BYTE-COMPILER WARNINGS. They are the result of
;; the multi-Emacsen support. FSF Emacs 19 and XEmacs 19 (formerly
;; Lucid) do things differently and there's no way to shut the
;; byte-compiler up at the necessary granularity.  Let me say this
;; again: YOU CAN IGNORE ALL BYTE-COMPILER WARNINGS (you'd be
;; surprised at how many people don't follow this advice :-).
X
;; To use VHDL-MODE, add the following to your .emacs file.  This
;; assumes you will use .vhd extensions for your VHDL source:
;;
;; (autoload 'vhdl-mode   "vhdl-mode" "VHDL Editing Mode" t)
;; (setq auto-mode-alist
;;   (append '(("\\.vhd$"  . vhdl-mode)   ; to edit VHDL code
;;            ) auto-mode-alist))
;;
;; If you would like to join the `vhdl-mode-announce' announcements
;; list or the `vhdl-mode-victims' beta testers list, send add/drop
;; requests to the address listed at the top of this file.
;;
;; Many, many thanks go out to all the folks on the beta test list.
;; Without their patience, testing, insight, and code contributions,
;; and encouragement vhdl-mode.el would be a far inferior package.
X
;; LCD Archive Entry:
;; vhdl-mode.el|Rodney J. Whitby|rwhitby@asc.corp.mot.com
;; |Major mode for editing VHDL code
;; |$Date: 1995/09/28 07:32:40 $|$Revision: 2.71 $|
X
X
;;; Code:
X
;; user definable variables
;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
X
(defvar vhdl-inhibit-startup-warnings-p nil
X  "*If non-nil, inhibits start up compatibility warnings.")
(defvar vhdl-strict-syntax-p nil
X  "*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
X  "*If non-nil, syntactic info is echoed when the line is indented.")
(defvar vhdl-basic-offset 2
X  "*Amount of basic offset used by + and - symbols in `vhdl-offsets-alist'.")
X
(defconst vhdl-offsets-alist-default
X  '((string                . -1000)
X    (block-open            . 0)
X    (block-close           . 0)
X    (statement             . 0)
X    (statement-cont        . vhdl-lineup-statement-cont)
X    (statement-block-intro . +)
X    (statement-case-intro  . +)
X    (case-alternative      . +)
X    (comment               . vhdl-lineup-comment)
X    (arglist-intro         . vhdl-lineup-arglist-intro)
X    (arglist-cont          . 0)
X    (arglist-cont-nonempty . vhdl-lineup-arglist)
X    (arglist-close         . vhdl-lineup-arglist)
X    (entity                . 0)
X    (configuration         . 0)
X    (package               . 0)
X    (architecture          . 0)
X    (package-body          . 0)
X    )
X  "Default settings for offsets of syntactic elements.
Do not change this constant!  See the variable `vhdl-offsets-alist' for
more information.")
X
(defvar vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default)
X  "*Association list of syntactic element symbols and indentation offsets.
As described below, each cons cell in this list has the form:
X
X    (SYNTACTIC-SYMBOL . OFFSET)
X
When a line is indented, vhdl-mode first determines the syntactic
context of the line by generating a list of symbols called syntactic
elements.  This list can contain more than one syntactic element and
the global variable `vhdl-syntactic-context' contains the context list
for the line being indented.  Each element in this list is actually a
cons cell of the syntactic symbol and a buffer position.  This buffer
position is call the relative indent point for the line.  Some
syntactic symbols may not have a relative indent point associated with
them.
X
After the syntactic context list for a line is generated, vhdl-mode
calculates the absolute indentation for the line by looking at each
syntactic element in the list.  First, it compares the syntactic
element against the SYNTACTIC-SYMBOL's in `vhdl-offsets-alist'.  When it
finds a match, it adds the OFFSET to the column of the relative indent
point.  The sum of this calculation for each element in the syntactic
list is the absolute offset for line being indented.
X
If the syntactic element does not match any in the `vhdl-offsets-alist',
an error is generated if `vhdl-strict-syntax-p' is non-nil, otherwise
the element is ignored.
X
Actually, OFFSET can be an integer, a function, a variable, or one of
the following symbols: `+', `-', `++', or `--'.  These latter
designate positive or negative multiples of `vhdl-basic-offset',
respectively: *1, *-1, *2, and *-2. If OFFSET is a function, it is
called with a single argument containing the cons of the syntactic
element symbol and the relative indent point.  The function should
return an integer offset.
X
Here is the current list of valid syntactic element symbols:
X
X string                 -- inside multi-line string
X block-open             -- statement block open
X block-close            -- statement block close
X statement              -- a VHDL statement
X statement-cont         -- a continuation of a VHDL statement
X statement-block-intro  -- the first line in a new statement block
X statement-case-intro   -- the first line in a case alternative block
X case-alternative       -- a case statement alternative clause
X comment                -- a line containing only a comment
X arglist-intro          -- the first line in an argument list
X arglist-cont           -- subsequent argument list lines when no
X                           arguments follow on the same line as the
X                           the arglist opening paren
X arglist-cont-nonempty  -- subsequent argument list lines when at
X                           least one argument follows on the same
X                           line as the arglist opening paren
X arglist-close          -- the solo close paren of an argument list
X entity                 -- inside an entity declaration
X configuration          -- inside a configuration declaration
X package                -- inside a package declaration
X architecture           -- inside an architecture body
X package-body           -- inside a package body
")
X
(defvar vhdl-tab-always-indent t
X  "*Controls the operation of the TAB key.
If t, hitting TAB always just indents the current line.  If nil,
hitting TAB indents the current line if point is at the left margin or
in the line's indentation, otherwise it insert a real tab character.
If other than nil or t, then tab is inserted only within literals
-- defined as comments and strings -- and inside preprocessor
directives, but line is always reindented.
X
Note that indentation of lines containing only comments is also
controlled by the `vhdl-comment-only-line-offset' variable.")
X
(defvar vhdl-comment-only-line-offset 0
X  "*Extra offset for line which contains only the start of a comment.
Can contain an integer or a cons cell of the form:
X
X (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
X
Where NON-ANCHORED-OFFSET is the amount of offset given to
non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is
the amount of offset to give column-zero anchored comment-only lines.
Just an integer as value is equivalent to (<val> . 0)")
X
(defvar vhdl-special-indent-hook nil
X  "*Hook for user defined special indentation adjustments.
This hook gets called after a line is indented by the mode.")
X
(defvar vhdl-style-alist
X  '(("IEEE"
X     (vhdl-basic-offset . 4)
X     (vhdl-offsets-alist . ())
X     )
X    )
X  "Styles of Indentation.
Elements of this alist are of the form:
X
X  (STYLE-STRING (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
X
where STYLE-STRING is a short descriptive string used to select a
style, VARIABLE is any vhdl-mode variable, and VALUE is the intended
value for that variable when using the selected style.
X
There is one special case when VARIABLE is `vhdl-offsets-alist'.  In this
case, the VALUE is a list containing elements of the form:
X
X  (SYNTACTIC-SYMBOL . VALUE)
X
as described in `vhdl-offsets-alist'.  These are passed directly to
`vhdl-set-offset' so there is no need to set every syntactic symbol in
your style, only those that are different from the default.")
X
;; dynamically append the default value of most variables
(or (assoc "Default" vhdl-style-alist)
X    (let* ((varlist '(vhdl-inhibit-startup-warnings-p
X		      vhdl-strict-syntax-p
X		      vhdl-echo-syntactic-information-p
X		      vhdl-basic-offset
X		      vhdl-offsets-alist
X		      vhdl-tab-always-indent
X		      vhdl-comment-only-line-offset))
X	   (default (cons "Default"
X			  (mapcar
X			   (function
X			    (lambda (var)
X			      (cons var (symbol-value var))
X			      ))
X			   varlist))))
X      (setq vhdl-style-alist (cons default vhdl-style-alist))))
X
(defvar vhdl-mode-hook nil
X  "*Hook called by `vhdl-mode'.")
X
(defvar vhdl-mode-menu
X  '(["Comment Out Region"     comment-region (mark)]
X    ;; ["Indent Expression"      vhdl-indent-exp
X    ;; (memq (following-char) '(?\( ?\[ ?\{))]
X    ["Indent Line"            vhdl-indent-command t]
X    ["Backward Statement"     vhdl-beginning-of-statement t]
X    ;; ["Forward Statement"      vhdl-end-of-statement t]
X    )
X  "XEmacs 19 (formerly Lucid) menu for VHDL mode.")
X
;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; NO USER DEFINABLE VARIABLES BEYOND THIS POINT
X
X
;; Emacs variant handling, and standard mode variables and functions:
X
(defconst vhdl-emacs-features
X  (let ((major (and (boundp 'emacs-major-version)
X		    emacs-major-version))
X	(minor (and (boundp 'emacs-minor-version)
X		    emacs-minor-version))
X	flavor)
X    ;; figure out version numbers if not already discovered
X    (and (or (not major) (not minor))
X	 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
X	 (setq major (string-to-int (substring emacs-version
X					       (match-beginning 1)
X					       (match-end 1)))
X	       minor (string-to-int (substring emacs-version
X					       (match-beginning 2)
X					       (match-end 2)))))
X    (if (not (and major minor))
X	(error "Cannot figure out the major and minor version numbers."))
X    ;; calculate the major version
X    (cond
X     ((= major 18) (setq major 'v18))	;Emacs 18
X     ((= major 4)  (setq major 'v18))	;Epoch 4
X     ((= major 19) (setq major 'v19	;Emacs 19
X			 flavor (cond
X				 ((string-match "Win-Emacs" emacs-version)
X				  'Win-Emacs)
X				 ((or (string-match "Lucid" emacs-version)
X				      (string-match "XEmacs" emacs-version))
X				  'XEmacs)
X				 (t
X				  'FSF))))
X     ;; I don't know
X     (t (error "Cannot recognize major version number: %s" major)))
X    ;; lets do some minimal sanity checking.
X    (if (and (or
X	      ;; Emacs 18 is brain dead
X	      (eq major 'v18)
X	      ;; Lemacs before 19.6 had bugs
X	      (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6))
X	      ;; FSF 19 before 19.21 had bugs
X	      (and (eq major 'v19) (eq flavor 'FSF) (< minor 21)))
X	     (not vhdl-inhibit-startup-warnings-p))
X	(with-output-to-temp-buffer "*vhdl-mode warnings*"
X	  (print (format
"The version of Emacs that you are running, %s,
has known bugs in its syntax.c parsing routines which will affect the
performance of vhdl-mode. You should strongly consider upgrading to the
latest available version.  vhdl-mode may continue to work, after a
fashion, but strange indentation errors could be encountered."
X		     emacs-version))))
X    (list major flavor))
X  "A list of features extant in the Emacs you are using.
There are many flavors of Emacs out there, each with different
features supporting those needed by vhdl-mode.  Here's the current
supported list, along with the values for this variable:
X
X Emacs 18/Epoch 4:           (v18)
X XEmacs (formerly Lucid) 19: (v19 XEmacs)
X Win-Emacs 1.35:             (V19 Win-Emacs)
X FSF Emacs 19:               (v19 FSF).")
X
(defvar vhdl-mode-abbrev-table nil
X  "Abbrev table in use in vhdl-mode buffers.")
(define-abbrev-table 'vhdl-mode-abbrev-table ())
X
(defvar vhdl-mode-map ()
X  "Keymap used in vhdl-mode buffers.")
(if vhdl-mode-map
X    ()
X  ;; TBD: should we even worry about naming this keymap. My vote: no,
X  ;; because FSF and XEmacs (formerly Lucid) do it differently.
X  (setq vhdl-mode-map (make-sparse-keymap))
X  ;; put standard keybindings into MAP
X  (define-key vhdl-mode-map "\M-a"	'vhdl-beginning-of-statement)
X  ;;(define-key vhdl-mode-map "\M-e"	'vhdl-end-of-statement)
X  (define-key vhdl-mode-map "\M-\C-f"   'vhdl-forward-sexp)
X  (define-key vhdl-mode-map "\M-\C-b"   'vhdl-backward-sexp)
X  (define-key vhdl-mode-map "\M-\C-u"	'vhdl-backward-up-list)
X  ;;(define-key vhdl-mode-map "\M-\C-d"	'vhdl-down-list)
X  (define-key vhdl-mode-map "\M-\C-a"	'vhdl-beginning-of-defun)
X  (define-key vhdl-mode-map "\M-\C-e"	'vhdl-end-of-defun)
X  (define-key vhdl-mode-map "\M-\C-h"	'vhdl-mark-defun)
X  (define-key vhdl-mode-map "\M-\C-q"	'vhdl-indent-sexp)
X  (define-key vhdl-mode-map "\t"        'vhdl-indent-command)
X  (define-key vhdl-mode-map "\177"      'backward-delete-char-untabify)
X  ;; these are new keybindings, with no counterpart to BOCM
X  (define-key vhdl-mode-map "\C-c\C-b"  'vhdl-submit-bug-report)
X  (define-key vhdl-mode-map "\C-c\C-c"  'comment-region)
X  (define-key vhdl-mode-map "\C-c\C-o"  'vhdl-set-offset)
X  (define-key vhdl-mode-map "\C-c\C-r"  'vhdl-regress-line)
X  (define-key vhdl-mode-map "\C-c\C-s"  'vhdl-show-syntactic-information)
X  (define-key vhdl-mode-map "\C-c\C-v"  'vhdl-version)
X  ;; in XEmacs (formerly Lucid) 19, we want the menu to popup when
X  ;; the 3rd button is hit.  In 19.10 and beyond this is done
X  ;; automatically if we put the menu on mode-popup-menu variable,
X  ;; see c-common-init. RMS decided that this feature should not be
X  ;; included for FSF's Emacs.
X  (if (and (boundp 'current-menubar)
X	   (not (boundp 'mode-popup-menu)))
X      (define-key vhdl-mode-map 'button3 'vhdl-popup-menu))
X  )
X
(defvar vhdl-mode-syntax-table nil
X  "Syntax table used in vhdl-mode buffers.")
(if vhdl-mode-syntax-table
X    ()
X  (setq vhdl-mode-syntax-table (make-syntax-table))
X  ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
X  (modify-syntax-entry ?\" "\""    vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\$ "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\% "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\& "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\' "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\( "()"    vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\) ")("    vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\* "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\+ "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\. "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\/ "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\: "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\; "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\< "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\= "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\> "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\[ "(]"    vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\\ "\\"    vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\] ")["    vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\{ "(}"    vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\| "."     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\} "){"    vhdl-mode-syntax-table)
X  ;; add comment syntax
X  (modify-syntax-entry ?\- ". 12"  vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\n ">"     vhdl-mode-syntax-table)
X  (modify-syntax-entry ?\^M ">"    vhdl-mode-syntax-table))
X
(defvar vhdl-syntactic-context nil
X  "Buffer local variable containing syntactic analysis list.")
(make-variable-buffer-local 'vhdl-syntactic-context)
X
;; Support for outline modes
X
(defconst vhdl-outline-regexp
X  (concat "\\(entity\\)\\|\\(package\\)\\|"
X	  "\\( *procedure\\)\\|\\( *function\\)\\|"
X	  "\\( *component\\)\\|\\(architecture\\)\\|"
X	  "\\(package body\\)\\|\\( *[A-Za-z][A-Za-z0-9_]* : block\\)\\|"
X	  "\\( *[A-Za-z][A-Za-z0-9_]* : process\\)\\|\\(configuration\\)"))
X
(defun vhdl-outline-level ()		; was copied from c-outline-level
X  (save-excursion
X    (skip-chars-forward "\t ")
X    (current-column)))
X
;; Support for font-lock
X
(defconst vhdl-font-lock-keywords-1
X  (purecopy
X   (list
X    ;; Highlight names of common constructs
X    (list
X     (concat
X      "^[ \t]*\\(entity\\|architecture\\|configuration\\|function\\|"
X      "procedure\\|component\\|package[ \t]+body\\|package\\|"
X      "end[ \t]+\\(block\\|process\\|case\\|generate\\|loop\\)\\)[ \t]+"
X      "\\(\\(\\w\\|\\s_\\)+\\)")
X     3 'font-lock-function-name-face)
X    
X    ;; Highlight labels of common constructs
X    (list
X     (concat
X      "^[ \t]*\\(\\(\\w\\|\\s_\\)+\\)[ \t]*:[ \t\n]*\\(block\\|process\\|"
X      "if\\|for\\|case\\|exit\\|loop\\|next\\|null\\|with\\|"
X      "\\(\\w\\|\\s_\\)+[ \t\n]+port[ \t]+map\\)\\>[^_]")
X     1 'font-lock-function-name-face)
X    
X    ;; Highlight OF labels
X    (list
X     (concat
X      "^[ \t]*\\(configuration\\|architecture\\|attribute\\)[ \t]+"
X      "\\(\\(\\w\\|\\s_\\)+\\)[ \t]+of[ \t]+\\(\\(\\w\\|\\s_\\)+\\)")
X     4 'font-lock-function-name-face)
X    
X    ;; Fontify library useage clauses.
X    (list
X     (concat
X      "[^\\s_]\\<\\(library\\|use\\)[ \t\n]+\\(entity[ \t\n]+\\)?"
X      "\\(\\(\\w\\|\\s_\\|[\.()]\\)+\\)")
X     4 'font-lock-function-name-face)
X    ))
X  "For consideration as a value of `vhdl-font-lock-keywords'.
This does fairly subdued highlighting of function names.")
X
(defconst vhdl-font-lock-keywords-2
X  (purecopy
X   (append
X    vhdl-font-lock-keywords-1
X    (list
X     (list
X      (concat
X       "[^\\s_]\\<\\("
X       (mapconcat
X	'identity
X	'(
X	  ;; the following is a list of all reserved words known in VHDL'93
X	  "abs" "access" "after" "alias" "all" "and" "assert"
X	  "architecture" "array" "attribute"
X	  "begin" "block" "body" "buffer" "bus"
X	  "case" "component" "configuration" "constant"
X	  "disconnect" "downto"
X	  "else" "elsif" "end" "entity" "exit"
X	  "file" "for" "function"
X	  "generate" "generic" "group" "guarded"
X	  "if" "impure" "in" "inertial" "inout" "is"
X	  "label" "library" "linkage" "literal" "loop" 
X	  "map" "mod" 
X	  "nand" "new" "next" "nor" "not" "null"
X	  "of" "on" "open" "or" "others" "out"
X	  "package" "port" "postponed" "procedure" "process" "pure"
X	  "range" "record" "register" "reject" "rem" "report" "return"
X	  "rol" "ror"
X	  "select" "severity" "signal" "shared" "sla" "sll" "sra" "srl"
X	  "subtype"
X	  "then" "to" "transport" "type" 
X	  "unaffected" "units" "until" "use"
X	  "variable" "wait" "when" "while" "with" 
X	  "xnor" "xor"
X	  "note" "warning" "error" "failure"
X	  ;; the following list contains predefined attributes
X	  "base" "left" "right" "high" "low" "pos" "val" "succ"
X	  "pred" "leftof" "rightof" "range" "reverse_range"
X	  "length" "delayed" "stable" "quiet" "transaction"
X	  "event" "active" "last_event" "last_active" "last_value"
X	  "driving" "driving_value" "ascending" "value" "image"
X	  "simple_name" "instance_name" "path_name"
X	  "foreign"
X	  ;; the following list contains standardized types
X	  "boolean" "bit" "bit_vector" "character" "severity_level" "integer"
X	  "real" "time" "natural" "positive" "string" "text" "line"
X	  "unsigned" "signed"
X	  "std_logic" "std_logic_vector"
X	  "std_ulogic" "std_ulogic_vector"
X	  )
X	"\\|")
X       "\\)\\>[^\\s_]")
X      1 'font-lock-keyword-face)
X     )))
X  "For consideration as a value of `vhdl-font-lock-keywords'.
This does a lot more highlighting.")
X
;; The keywords in the preceding lists assume case-insensitivity.
(put 'vhdl-mode 'font-lock-keywords-case-fold-search t)
X
(defvar vhdl-font-lock-keywords vhdl-font-lock-keywords-1
X  "Additional expressions to highlight in VHDL mode.")
X
;; This should eventually be subsumed into the respective functions in
;; the source for "font-lock.el".
(if (featurep 'advice)
X    (progn
X      (defadvice font-lock-use-default-minimal-decoration
X	(before vhdl-mode activate)
X	"Do it for VHDL mode too."
X	(setq vhdl-font-lock-keywords vhdl-font-lock-keywords-1))
X      
X      (defadvice font-lock-use-default-maximal-decoration
X	(before vhdl-mode activate)
X	"Do it for VHDL mode too."
X	(setq vhdl-font-lock-keywords vhdl-font-lock-keywords-2))
X      ))
X
X
;; Main entry point for VHDL mode:
X
;;;###autoload
(defun vhdl-mode ()
X  "Major mode for editing VHDL code.
vhdl-mode $Revision: 2.71 $
To submit a problem report, enter `\\[vhdl-submit-bug-report]' from a
vhdl-mode buffer.  This automatically sets up a mail buffer with version
information already added.  You just need to add a description of the
problem, including a reproducable test case and send the message.
X
Note that the details of configuring vhdl-mode will soon be moved to the
accompanying texinfo manual.  Until then, please read the README file
that came with the vhdl-mode distribution.
X
The hook variable `vhdl-mode-hook' is run with no args, if that value is
bound and has a non-nil value.
X
Key bindings:
\\{vhdl-mode-map}"
X  (interactive)
X  (kill-all-local-variables)
X  (set-syntax-table vhdl-mode-syntax-table)
X  (setq major-mode 'vhdl-mode
X	mode-name "VHDL"
X	local-abbrev-table vhdl-mode-abbrev-table)
X  (use-local-map vhdl-mode-map)
X  ;; set local variable values
X  (set (make-local-variable 'paragraph-start) (concat "^$\\|" page-delimiter))
X  (set (make-local-variable 'paragraph-separate) paragraph-start)
X  (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
X  (set (make-local-variable 'require-final-newline) t)
X  (set (make-local-variable 'parse-sexp-ignore-comments) t)
X  (set (make-local-variable 'indent-line-function) 'vhdl-indent-line)
X  (set (make-local-variable 'comment-start) "-- ")
X  (set (make-local-variable 'comment-end) "")
X  (set (make-local-variable 'comment-column) 32)
X  (set (make-local-variable 'comment-start-skip) "--+ *")
X  (set (make-local-variable 'outline-regexp) vhdl-outline-regexp)
X  (set (make-local-variable 'outline-level) 'vhdl-outline-level)
X
X  ;; setup the comment indent variable in a Emacs version portable way
X  ;; ignore any byte compiler warnings you might get here
X  (if (boundp 'comment-indent-function)
X      (progn
X	   (make-local-variable 'comment-indent-function)
X	   (setq comment-indent-function 'vhdl-comment-indent))
X    (make-local-variable 'comment-indent-hook)
X    (setq comment-indent-hook 'vhdl-comment-indent))
X  ;; put VHDL menu into menubar and on popup menu for XEmacs (formerly
X  ;; Lucid) 19. I think this happens automatically for FSF Emacs 19.
X  (if (and (boundp 'current-menubar)
X	   current-menubar
X	   (not (assoc mode-name current-menubar)))
X      (progn
X	(set-buffer-menubar (copy-sequence current-menubar))
X	(add-menu nil mode-name vhdl-mode-menu)))
X  (if (boundp 'mode-popup-menu)
X      (setq mode-popup-menu
X	    (cons (concat mode-name " Mode Commands") vhdl-mode-menu)))
X  (run-hooks 'vhdl-mode-hook))
X
;; menus for XEmacs (formerly Lucid)
X
(defun vhdl-popup-menu (e)
X  "Pops up the VHDL menu."
X  (interactive "@e")
X  (popup-menu (cons (concat mode-name " Mode Commands") vhdl-mode-menu))
X  (vhdl-keep-region-active))
X
;; active regions
X
(defun vhdl-keep-region-active ()
X  ;; do whatever is necessary to keep the region active in XEmacs
X  ;; (formerly Lucid). ignore byte-compiler warnings you might see
X  (and (boundp 'zmacs-region-stays)
X       (setq zmacs-region-stays t)))
X
;; constant regular expressions for looking at various constructs
X
(defconst vhdl-symbol-key "\\(\\w\\|\\s_\\)+"
X  "Regexp describing a VHDL symbol.
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.")
X
(defconst vhdl-case-alternative-key "when[( \t\n][^;=>]+=>"
X  "Regexp describing a case statement alternative key.")
X
(defconst vhdl-case-header-key "case[( \t\n][^;=>]+[) \t\n]is"
X  "Regexp describing a case statement header key.")
X
(defconst vhdl-label-key
X  (concat vhdl-symbol-key "\\s-*:")
X  "Regexp describing a VHDL label.")
X
X
;; Macro definitions:
X
(defmacro vhdl-point (position)
X  ;; Returns the value of point at certain commonly referenced POSITIONs.
X  ;; POSITION can be one of the following symbols:
X  ;; 
X  ;; bol  -- beginning of line
X  ;; eol  -- end of line
X  ;; bod  -- beginning of defun
X  ;; boi  -- back to indentation
X  ;; eoi  -- last whitespace on line
X  ;; ionl -- indentation of next line
X  ;; iopl -- indentation of previous line
X  ;; bonl -- beginning of next line
X  ;; bopl -- beginning of previous line
X  ;; 
X  ;; This function does not modify point or mark.
X  (or (and (eq 'quote (car-safe position))
X	   (null (cdr (cdr position))))
X      (error "bad buffer position requested: %s" position))
X  (setq position (nth 1 position))
X  (` (let ((here (point)))
X       (,@ (cond
X	    ((eq position 'bol)  '((beginning-of-line)))
X	    ((eq position 'eol)  '((end-of-line)))
X	    ((eq position 'bod)  '((save-match-data
X				     (vhdl-beginning-of-defun))))
X	    ((eq position 'boi)  '((back-to-indentation)))
X	    ((eq position 'eoi)  '((end-of-line)(skip-chars-backward " \t")))
X	    ((eq position 'bonl) '((forward-line 1)))
X	    ((eq position 'bopl) '((forward-line -1)))
X	    ((eq position 'iopl)
X	     '((forward-line -1)
X	       (back-to-indentation)))
X	    ((eq position 'ionl)
X	     '((forward-line 1)
X	       (back-to-indentation)))
X	    (t (error "unknown buffer position requested: %s" position))
X	    ))
X       (prog1
X	   (point)
X	 (goto-char here))
X       ;; workaround for an Emacs18 bug -- blech! Well, at least it
X       ;; doesn't hurt for v19
X       (,@ nil)
X       )))
X
(defmacro vhdl-safe (&rest body)
X  ;; safely execute BODY, return nil if an error occurred
X  (` (condition-case nil
X	 (progn (,@ body))
X       (error nil))))
X
(defmacro vhdl-add-syntax (symbol &optional relpos)
X  ;; a simple macro to append the syntax in symbol to the syntax list.
X  ;; try to increase performance by using this macro
X  (` (setq vhdl-syntactic-context
X	   (cons (cons (, symbol) (, relpos)) vhdl-syntactic-context))))
X
(defmacro vhdl-has-syntax (symbol)
X  ;; a simple macro to return check the syntax list.
X  ;; try to increase performance by using this macro
X  (` (assoc (, symbol) vhdl-syntactic-context)))
X
X
;; Syntactic element offset manipulation:
X
(defun vhdl-read-offset (langelem)
X  ;; read new offset value for LANGELEM from minibuffer. return a
X  ;; legal value only
X  (let ((oldoff (format "%s" (cdr-safe (assq langelem vhdl-offsets-alist))))
X	(errmsg "Offset must be int, func, var, or one of +, -, ++, --: ")
X	(prompt "Offset: ")
X	offset input interned)
X    (while (not offset)
X      (setq input (read-string prompt oldoff)
X	    offset (cond ((string-equal "+" input) '+)
X			 ((string-equal "-" input) '-)
X			 ((string-equal "++" input) '++)
X			 ((string-equal "--" input) '--)
X			 ((string-match "^-?[0-9]+$" input)
X			  (string-to-int input))
X			 ((fboundp (setq interned (intern input)))
X			  interned)
X			 ((boundp interned) interned)
X			 ;; error, but don't signal one, keep trying
X			 ;; to read an input value
X			 (t (ding)
X			    (setq prompt errmsg)
X			    nil))))
X    offset))
X
(defun vhdl-set-offset (symbol offset &optional add-p)
X  "Change the value of a syntactic element symbol in `vhdl-offsets-alist'.
SYMBOL is the syntactic element symbol to change and OFFSET is the new
offset for that syntactic element.  Optional ADD says to add SYMBOL to
`vhdl-offsets-alist' if it doesn't already appear there."
X  (interactive
X   (let* ((langelem
X	   (intern (completing-read
X		    (concat "Syntactic symbol to change"
X			    (if current-prefix-arg " or add" "")
X			    ": ")
X		    (mapcar
X		     (function
X		      (lambda (langelem)
X			(cons (format "%s" (car langelem)) nil)))
X		     vhdl-offsets-alist)
X		    nil (not current-prefix-arg)
X		    ;; initial contents tries to be the last element
X		    ;; on the syntactic analysis list for the current
X		    ;; line
X		    (let* ((syntax (vhdl-get-syntactic-context))
X			   (len (length syntax))
X			   (ic (format "%s" (car (nth (1- len) syntax)))))
X		      (if (memq 'v19 vhdl-emacs-features)
X			  (cons ic 0)
X			ic))
X		    )))
X	  (offset (vhdl-read-offset langelem)))
X     (list langelem offset current-prefix-arg)))
X  ;; sanity check offset
X  (or (eq offset '+)
X      (eq offset '-)
X      (eq offset '++)
X      (eq offset '--)
X      (integerp offset)
X      (fboundp offset)
X      (boundp offset)
X      (error "Offset must be int, func, var, or one of +, -, ++, --: %s"
X	     offset))
X  (let ((entry (assq symbol vhdl-offsets-alist)))
X    (if entry
X	(setcdr entry offset)
X      (if add-p
X	  (setq vhdl-offsets-alist (cons (cons symbol offset) vhdl-offsets-alist))
X	(error "%s is not a valid syntactic symbol." symbol))))
X  (vhdl-keep-region-active))
X
(defun vhdl-set-style (style &optional local)
X  "Set vhdl-mode variables to use one of several different indentation styles.
STYLE is a string representing the desired style and optional LOCAL is
a flag which, if non-nil, means to make the style variables being
changed buffer local, instead of the default, which is to set the
global variables.  Interactively, the flag comes from the prefix
argument.  The styles are chosen from the `vhdl-style-alist' variable."
X  (interactive (list (completing-read "Use which VHDL indentation style? "
X                                      vhdl-style-alist nil t)
X		     current-prefix-arg))
X  (let ((vars (cdr (assoc style vhdl-style-alist))))
X    (or vars
X	(error "Invalid VHDL indentation style `%s'" style))
X    ;; set all the variables
X    (mapcar
X     (function
X      (lambda (varentry)
X	(let ((var (car varentry))
X	      (val (cdr varentry)))
X	  (and local
X	       (make-local-variable var))
X	  ;; special case for vhdl-offsets-alist
X	  (if (not (eq var 'vhdl-offsets-alist))
X	      (set var val)
X	    ;; reset vhdl-offsets-alist to the default value first
X	    (setq vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default))
X	    ;; now set the langelems that are different
X	    (mapcar
X	     (function
X	      (lambda (langentry)
X		(let ((langelem (car langentry))
X		      (offset (cdr langentry)))
X		  (vhdl-set-offset langelem offset)
X		  )))
X	     val))
X	  )))
X     vars))
X  (vhdl-keep-region-active))
X
(defun vhdl-get-offset (langelem)
X  ;; Get offset from LANGELEM which is a cons cell of the form:
X  ;; (SYMBOL . RELPOS).  The symbol is matched against
X  ;; vhdl-offsets-alist and the offset found there is either returned,
X  ;; or added to the indentation at RELPOS.  If RELPOS is nil, then
X  ;; the offset is simply returned.
X  (let* ((symbol (car langelem))
X	 (relpos (cdr langelem))
X	 (match  (assq symbol vhdl-offsets-alist))
X	 (offset (cdr-safe match)))
X    ;; offset can be a number, a function, a variable, or one of the
X    ;; symbols + or -
X    (cond
X     ((not match)
X      (if vhdl-strict-syntax-p
X	  (error "don't know how to indent a %s" symbol)
X	(setq offset 0
X	      relpos 0)))
X     ((eq offset '+)  (setq offset vhdl-basic-offset))
X     ((eq offset '-)  (setq offset (- vhdl-basic-offset)))
X     ((eq offset '++) (setq offset (* 2 vhdl-basic-offset)))
X     ((eq offset '--) (setq offset (* 2 (- vhdl-basic-offset))))
X     ((and (not (numberp offset))
X	   (fboundp offset))
X      (setq offset (funcall offset langelem)))
X     ((not (numberp offset))
X      (setq offset (eval offset)))
X     )
X    (+ (if (and relpos
X		(< relpos (vhdl-point 'bol)))
X	   (save-excursion
X	     (goto-char relpos)
X	     (current-column))
X	 0)
X       offset)))
X
X
;; Syntactic support functions:
X
;; Returns `comment' if in a comment, `string' if in a string literal,
;; or nil if not in a literal at all.  Optional LIM is used as the
;; backward limit of the search.  If omitted, or nil, (point-min) is
;; used.
X
(defun vhdl-in-literal (&optional lim)
X  ;; Determine if point is in a VHDL literal.
X  (save-excursion
X    (let* ((lim (or lim (point-min)))
X	   (state (parse-partial-sexp lim (point))))
X      (cond
X       ((nth 3 state) 'string)
X       ((nth 4 state) 'comment)
X       (t nil)))
X    ))
X
;; This is the best we can do in Win-Emacs.
(defun vhdl-win-il (&optional lim)
X  ;; Determine if point is in a VHDL literal
X  (save-excursion
X    (let* ((here (point))
X	   (state nil)
X	   (match nil)
X	   (lim  (or lim (vhdl-point 'bod))))
X      (goto-char lim )
X      (while (< (point) here)
X	(setq match
X	      (and (re-search-forward "--\\|[\"']"
X				      here 'move)
X		   (buffer-substring (match-beginning 0) (match-end 0))))
X	(setq state
X	      (cond
X	       ;; no match
X	       ((null match) nil)
X	       ;; looking at the opening of a VHDL style comment
X	       ((string= "--" match)
X		(if (<= here (progn (end-of-line) (point))) 'comment))
X	       ;; looking at the opening of a double quote string
X	       ((string= "\"" match)
X		(if (not (save-restriction
X			   ;; this seems to be necessary since the
X			   ;; re-search-forward will not work without it
X			   (narrow-to-region (point) here)
X			   (re-search-forward
X			    ;; this regexp matches a double quote
X			    ;; which is preceded by an even number
X			    ;; of backslashes, including zero
X			    "\\([^\\]\\|^\\)\\(\\\\\\\\\\)*\"" here 'move)))
X		    'string))
X	       ;; looking at the opening of a single quote string
X	       ((string= "'" match)
X		(if (not (save-restriction
X			   ;; see comments from above
X			   (narrow-to-region (point) here)
X			   (re-search-forward
X			    ;; this matches a single quote which is
X			    ;; preceded by zero or two backslashes.
X			    "\\([^\\]\\|^\\)\\(\\\\\\\\\\)?'"
X			    here 'move)))
X		    'string))
X	       (t nil)))
X	) ; end-while
X      state)))
X
(and (memq 'Win-Emacs vhdl-emacs-features)
X     (fset 'vhdl-in-literal 'vhdl-win-il))
X
;; Skipping of "syntactic whitespace".  Syntactic whitespace is
;; defined as lexical whitespace or comments.  Search no farther back
;; or forward than optional LIM.  If LIM is omitted, (point-min) is
;; used for backward skipping, (point-max) is used for forward
;; skipping.
X
(defun vhdl-forward-syntactic-ws (&optional lim)
X  ;; Forward skip of syntactic whitespace.
X  (save-restriction
X    (let* ((lim (or lim (point-max)))
X	   (here lim)
X	   (hugenum (point-max)))
X      (narrow-to-region lim (point))
X      (while (/= here (point))
X	(setq here (point))
X	(forward-comment hugenum))
X      )))
X
;; This is the best we can do in Win-Emacs.
(defun vhdl-win-fsws (&optional lim)
X  ;; Forward skip syntactic whitespace for Win-Emacs.
X  (let ((lim (or lim (point-max)))
X	stop)
X    (while (not stop)
X      (skip-chars-forward " \t\n\r\f" lim)
X      (cond
X       ;; vhdl comment
X       ((looking-at "--") (end-of-line))
X       ;; none of the above
X       (t (setq stop t))
X       ))))
X
(and (memq 'Win-Emacs vhdl-emacs-features)
X     (fset 'vhdl-forward-syntactic-ws 'vhdl-win-fsws))
X
(defun vhdl-backward-syntactic-ws (&optional lim)
X  ;; Backward skip over syntactic whitespace.
X  (save-restriction
X    (let* ((lim (or lim (point-min)))
X	   (here lim)
X	   (hugenum (- (point-max))))
X      (if (< lim (point))
X	  (progn
X	    (narrow-to-region lim (point))
X	    (while (/= here (point))
X	      (setq here (point))
X	      (forward-comment hugenum)
X	      )))
X      )))
X
;; This is the best we can do in Win-Emacs.
(defun vhdl-win-bsws (&optional lim)
X  ;; Backward skip syntactic whitespace for Win-Emacs.
X  (let ((lim (or lim (vhdl-point 'bod)))
X	stop)
X    (while (not stop)
X      (skip-chars-backward " \t\n\r\f" lim)
X      (cond
X       ;; vhdl comment
X       ((eq (vhdl-in-literal lim) 'comment)
X	(skip-chars-backward "^-" lim)
X	(skip-chars-backward "-" lim)
X	(while (not (or (and (= (following-char) ?-)
X			     (= (char-after (1+ (point))) ?-))
X			(<= (point) lim)))
X	  (skip-chars-backward "^-" lim)
X	  (skip-chars-backward "-" lim)))
X       ;; none of the above
X       (t (setq stop t))
X       ))))
X
(and (memq 'Win-Emacs vhdl-emacs-features)
X    (fset 'vhdl-backward-syntactic-ws 'vhdl-win-bsws))
X
;; Functions to help finding the correct indentation column:
X
(defun vhdl-first-word (point)
X  "If the keyword at POINT is at boi, then return (current-column) at
that point, else nil."
X  (save-excursion
X    (and (goto-char point)
X	 (eq (point) (vhdl-point 'boi))
X	 (current-column))))
X
(defun vhdl-last-word (point)
X  "If the keyword at POINT is at eoi, then return (current-column) at
that point, else nil."
X  (save-excursion
X    (and (goto-char point)
X	 (save-excursion (or (eq (progn (forward-sexp) (point))
X				 (vhdl-point 'eoi))
X			     (looking-at "\\s-*\\(--\\)?")))
X	 (current-column))))
X
X
;; Core syntactic evaluation functions:
X
(defconst vhdl-libunit-re
X  "\\b\\(architecture\\|configuration\\|entity\\|package\\)\\b[^_]")
X
(defun vhdl-libunit-p ()
X  (and
X   (save-excursion
X     (forward-sexp)
X     (skip-chars-forward " \t\n")
X     (not (looking-at "is\\b[^_]")))
X   (save-excursion
X     (backward-sexp)
X     (not (looking-at "use\\b[^_]")))))
X
(defconst vhdl-defun-re
X  "\\b\\(architecture\\|block\\|configuration\\|entity\\|package\\|process\\|procedure\\|function\\)\\b[^_]")
X
(defun vhdl-defun-p ()
X  (save-excursion
X    (if (looking-at "block\\|process")
X	;; "block", "process":
X	(save-excursion
X	  (backward-sexp)
X	  (not (looking-at "end\\s-+\\w")))
X      ;; "architecture", "configuration", "entity",
X      ;; "package", "procedure", "function":
X      t)))
X  
(defun vhdl-corresponding-defun ()
X  "If the word at the current position corresponds to a \"defun\"
keyword, then return a string that can be used to find the
corresponding \"begin\" keyword, else return nil."
X  (save-excursion
X    (and (looking-at vhdl-defun-re)
X	 (vhdl-defun-p)
X	 (if (looking-at "block\\|process")
X	     ;; "block", "process":
X	     (buffer-substring (match-beginning 0) (match-end 0))
X	   ;; "architecture", "configuration", "entity", "package",
X	   ;; "procedure", "function":
X	   "is"))))
X
(defconst vhdl-begin-fwd-re
X  "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|units\\|record\\|for\\)\\b\\([^_]\\|\\'\\)"
X  "A regular expression for searching forward that matches all known
\"begin\" keywords.")
X
(defconst vhdl-begin-bwd-re
X  "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|units\\|record\\|for\\)\\b"
X  "A regular expression for searching backward that matches all known
\"begin\" keywords.")
X
(defun vhdl-begin-p (&optional lim)
X  "Return t if we are looking at a real \"begin\" keyword.
Assumes that the caller will make sure that we are looking at
vhdl-begin-fwd-re, and are not inside a literal, and that we are not in
the middle of an identifier that just happens to contain a \"begin\"
keyword."
X  (cond
X   ;; "[architecture|case|configuration|entity|package|
X   ;;   procedure|function] ... is":
X   ((and (looking-at "i")
X	 (save-excursion
X	   ;; Skip backward over first sexp (needed to skip over a
X	   ;; procedure interface list, and is harmless in other
X	   ;; situations).  Note that we need "return" in the
X	   ;; following search list so that we don't run into
X	   ;; semicolons in the function interface list.
X	   (backward-sexp)
X	   (let (foundp)
X	     (while (and (not foundp)
X			 (re-search-backward
X			  ";\\|\\b\\(architecture\\|case\\|configuration\\|entity\\|package\\|procedure\\|return\\|is\\|begin\\|process\\|block\\)\\b[^_]"
X			  lim 'move))
X	       (if (or (= (preceding-char) ?_)
X		       (vhdl-in-literal lim))
X		   (backward-char)
X		 (setq foundp t))))
X	   (and (/= (following-char) ?\;)
X		(not (looking-at "is\\|begin\\|process\\|block")))))
X    t)
X   ;; "begin", "then":
X   ((looking-at "be\\|t")
X    t)
X   ;; "else":
X   ((and (looking-at "e")
X	 ;; make sure that the "else" isn't inside a
X	 ;; conditional signal assignment.
X	 (save-excursion
X	   (re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
X	   (or (eq (following-char) ?\;)
X	       (eq (point) lim))))
X    t)
X   ;; "block", "component", "generate", "loop", "process",
X   ;; "units", "record":
X   ((and (looking-at "bl\\|[cglpur]")
X	 (save-excursion
X	   (backward-sexp)
X	   (not (looking-at "end\\s-+\\w"))))
X    t)
X   ;; "for" (inside configuration declaration):
X   ((and (looking-at "f")
X	 (save-excursion
X	   (backward-sexp)
X	   (not (looking-at "end\\s-+\\w")))
X	 (vhdl-has-syntax 'configuration))
X    t)
X   ))
X  
(defun vhdl-corresponding-mid (&optional lim)
X  (cond
X   ((looking-at "is\\|block\\|process")
X    "begin")
X   ((looking-at "then")
X    "<else>")
X   (t
X    "end")))
X
(defun vhdl-corresponding-end (&optional lim)
X  "If the word at the current position corresponds to a \"begin\"
keyword, then return a vector containing enough information to find
the corresponding \"end\" keyword, else return nil.  The keyword to
search forward for is aref 0.  The column in which the keyword must
appear is aref 1 or nil if any column is suitable.
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."
X  (save-excursion
X    (and (looking-at vhdl-begin-fwd-re)
X	 (/= (preceding-char) ?_)
X	 (not (vhdl-in-literal lim))
X	 (vhdl-begin-p lim)
X	 (cond
X	  ;; "is", "generate", "loop":
X	  ((looking-at "[igl]")
X	   (vector "end"
X		   (and (vhdl-last-word (point))
X			(or (vhdl-first-word (point))
X			    (save-excursion
X			      (vhdl-beginning-of-statement-1 lim)
X			      (vhdl-backward-skip-label lim)
X			      (vhdl-first-word (point)))))))
X	  ;; "begin", "else", "for":
X	  ((looking-at "be\\|[ef]")
X	   (vector "end"
X		   (and (vhdl-last-word (point))
X			(or (vhdl-first-word (point))
X			    (save-excursion
X			      (vhdl-beginning-of-statement-1 lim)
X			      (vhdl-backward-skip-label lim)
X			      (vhdl-first-word (point)))))))
X	  ;; "component", "units", "record":
X	  ((looking-at "[cur]")
X	   ;; The first end found will close the block
X	   (vector "end" nil))
X	  ;; "block", "process":
X	  ((looking-at "bl\\|p")
X	   (vector "end"
X		   (or (vhdl-first-word (point))
X		       (save-excursion
X			 (vhdl-beginning-of-statement-1 lim)
X			 (vhdl-backward-skip-label lim)
X			 (vhdl-first-word (point))))))
X	  ;; "then":
X	  ((looking-at "t")
X	   (vector "elsif\\|else\\|end"
X		   (and (vhdl-last-word (point))
X			(or (vhdl-first-word (point))
X			    (save-excursion
X			      (vhdl-beginning-of-statement-1 lim)
X			      (vhdl-backward-skip-label lim)
X			      (vhdl-first-word (point)))))))
X	  ))))
X
(defconst vhdl-end-fwd-re "\\b\\(end\\|else\\|elsif\\)\\b\\([^_]\\|\\'\\)")
X
(defconst vhdl-end-bwd-re "\\b\\(end\\|else\\|elsif\\)\\b")
X
(defun vhdl-end-p (&optional lim)
X  "Return t if we are looking at a real \"end\" keyword.
Assumes that the caller will make sure that we are looking at
vhdl-end-fwd-re, and are not inside a literal, and that we are not in
the middle of an identifier that just happens to contain an \"end\"
keyword."
X  (or (not (looking-at "else"))
X      ;; make sure that the "else" isn't inside a conditional signal
X      ;; assignment.
X      (save-excursion
X	(re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
X	(or (eq (following-char) ?\;)
X	    (eq (point) lim)))))
X
(defun vhdl-corresponding-begin (&optional lim)
X  "If the word at the current position corresponds to an \"end\"
keyword, then return a vector containing enough information to find
the corresponding \"begin\" keyword, else return nil.  The keyword to
search backward for is aref 0.  The column in which the keyword must
appear is aref 1 or nil if any column is suitable.  The supplementary
keyword to search forward for is aref 2 or nil if this is not
required.  If aref 3 is t, then the \"begin\" keyword may be found in
the middle of a statement.
Assumes that the caller will make sure that we are not in the middle
of an identifier that just happens to contain an \"end\" keyword."
X  (save-excursion
X    (let (pos)
X      (if (and (looking-at vhdl-end-fwd-re)
X	       (not (vhdl-in-literal lim))
X	       (vhdl-end-p lim))
X	  (if (looking-at "el")
X	      ;; "else", "elsif":
X	      (vector "if\\|elsif" (vhdl-first-word (point)) "then" nil)
X	    ;; "end ...":
X	    (setq pos (point))
X	    (forward-sexp)
X	    (skip-chars-forward " \t\n")
X	    (cond
X	     ;; "end if":
X	     ((looking-at "if\\b[^_]")
X	      (vector "else\\|elsif\\|if"
X		      (vhdl-first-word pos)
X		      "else\\|then" nil))
X	     ;; "end component":
X	     ((looking-at "component\\b[^_]")
X	      (vector (buffer-substring (match-beginning 1)
X					(match-end 1))
X		      (vhdl-first-word pos)
X		      nil nil))
X	     ;; "end units", "end record":
X	     ((looking-at "\\(units\\|record\\)\\b[^_]")
X	      (vector (buffer-substring (match-beginning 1)
X					(match-end 1))
X		      (vhdl-first-word pos)
X		      nil t))
X	     ;; "end block", "end process":
X	     ((looking-at "\\(block\\|process\\)\\b[^_]")
X	      (vector "begin" (vhdl-first-word pos) nil nil))
X	     ;; "end case":
X	     ((looking-at "case\\b[^_]")
X	      (vector "case" (vhdl-first-word pos) "is" nil))
X	     ;; "end generate":
X	     ((looking-at "generate\\b[^_]")
X	      (vector "generate\\|for\\|if"
X		      (vhdl-first-word pos)
X		      "generate" nil))
X	     ;; "end loop":
X	     ((looking-at "loop\\b[^_]")
X	      (vector "loop\\|while\\|for"
X		      (vhdl-first-word pos)
X		      "loop" nil))
X	     ;; "end for" (inside configuration declaration):
X	     ((looking-at "for\\b[^_]")
X	      (vector "for" (vhdl-first-word pos) nil nil))
X	     ;; "end [id]":
X	     (t
X	      (vector "begin\\|architecture\\|configuration\\|entity\\|package\\|procedure\\|function"
X		      (vhdl-first-word pos)
X		      ;; return an alist of (statement . keyword) mappings
X		      '(
X			;; "begin ... end [id]":
X			("begin"          . nil)
X			;; "architecture ... is ... begin ... end [id]":
X			("architecture"   . "is")
X			;; "configuration ... is ... end [id]":
X			("configuration"  . "is")
X			;; "entity ... is ... end [id]":
X			("entity"         . "is")
X			;; "package ... is ... end [id]":
X			("package"        . "is")
X			;; "procedure ... is ... begin ... end [id]":
X			("procedure"      . "is")
X			;; "function ... is ... begin ... end [id]":
X			("function"       . "is")
X			)
X		      nil))
X	     ))) ; "end ..."
X      )))
X
(defconst vhdl-leader-re
X  "\\b\\(block\\|component\\|process\\|for\\)\\b[^_]")
X
(defun vhdl-end-of-leader ()
X  (save-excursion
X    (cond ((looking-at "block\\|process")
X	   (if (save-excursion
X		 (forward-sexp)
X		 (skip-chars-forward " \t\n")
X		 (= (following-char) ?\())
X	       (forward-sexp 2)
X	     (forward-sexp))
X	   (point))
X	  ((looking-at "component")
X	   (forward-sexp 2)
X	   (point))
X	  ((looking-at "for")
X	   (forward-sexp 2)
X	   (skip-chars-forward " \t\n")
X	   (while (looking-at "[,:(]")
X	     (forward-sexp)
X	     (skip-chars-forward " \t\n"))
X	   (point))
X	  (t nil)
X	  )))
X
(defconst vhdl-trailer-re
X  "\\b\\(is\\|then\\|generate\\|loop\\)\\b[^_]")
X
(defconst vhdl-statement-fwd-re
X  "\\b\\(if\\|for\\|while\\)\\b\\([^_]\\|\\'\\)"
X  "A regular expression for searching forward that matches all known
\"statement\" keywords.")
X
(defconst vhdl-statement-bwd-re
X  "\\b\\(if\\|for\\|while\\)\\b"
X  "A regular expression for searching backward that matches all known
\"statement\" keywords.")
X
(defun vhdl-statement-p (&optional lim)
X  "Return t if we are looking at a real \"statement\" keyword.
Assumes that the caller will make sure that we are looking at
vhdl-statement-fwd-re, and are not inside a literal, and that we are not in
the middle of an identifier that just happens to contain a \"statement\"
keyword."
X  (cond
X   ;; "for" ... "generate":
X   ((and (looking-at "f")
X	 ;; Make sure it's the start of a parameter specification.
X	 (save-excursion
X	   (forward-sexp 2)
X	   (skip-chars-forward " \t\n")
X	   (looking-at "in\\b[^_]"))
X	 ;; Make sure it's not an "end for".
X	 (save-excursion
X	   (backward-sexp)
X	   (not (looking-at "end\\s-+\\w"))))
X    t)
X   ;; "if" ... "then", "if" ... "generate", "if" ... "loop":
X   ((and (looking-at "i")
X	 ;; Make sure it's not an "end if".
X	 (save-excursion
X	   (backward-sexp)
X	   (not (looking-at "end\\s-+\\w"))))
X    t)
X   ;; "while" ... "loop":
X   ((looking-at "w")
X    t)
X   ))
X  
X
;; Core syntactic movement functions:
X
(defconst vhdl-b-t-b-re
X  (concat vhdl-begin-bwd-re "\\|" vhdl-end-bwd-re))
X
(defun vhdl-backward-to-block (&optional lim)
X  "Move backward to the previous \"begin\" or \"end\" keyword."
X  (let (foundp)
X    (while (and (not foundp)
X		(re-search-backward vhdl-b-t-b-re lim 'move))
X      (if (or (= (preceding-char) ?_)
X	      (vhdl-in-literal lim))
X	  (backward-char)
X	(cond
X	 ;; "begin" keyword:
X	 ((and (looking-at vhdl-begin-fwd-re)
X	       (/= (preceding-char) ?_)
X	       (vhdl-begin-p lim))
X	  (setq foundp 'begin))
X	 ;; "end" keyword:
X	 ((and (looking-at vhdl-end-fwd-re)
X	       (/= (preceding-char) ?_)
X	       (vhdl-end-p lim))
X	  (setq foundp 'end))
X	 ))
X      )
X    foundp
X    ))
X
(defun vhdl-forward-sexp (&optional count lim)
X  "Move forward across one balanced expression (sexp).
With COUNT, do it that many times."
X  (interactive "p")
X  (let ((count (or count 1))
X	(case-fold-search t)
X	end-vec target)
X    (save-excursion
X      (while (> count 0)
X	;; skip whitespace
X	(skip-chars-forward " \t\n")
X	;; Check for an unbalanced "end" keyword
X	(if (and (looking-at vhdl-end-fwd-re)
X		 (/= (preceding-char) ?_)
X		 (not (vhdl-in-literal lim))
X		 (vhdl-end-p lim)
X		 (not (looking-at "else")))
X	    (error
X	     "Containing expression ends prematurely in vhdl-forward-sexp"))
X	;; If the current keyword is a "begin" keyword, then find the
X	;; corresponding "end" keyword.
X	(if (setq end-vec (vhdl-corresponding-end lim))
X	    (let (
X		  ;; end-re is the statement keyword to search for
X		  (end-re
X		   (concat "\\b\\(" (aref end-vec 0) "\\)\\b\\([^_]\\|\\'\\)"))
X		  ;; column is either the statement keyword target column
X		  ;; or nil
X		  (column (aref end-vec 1))
X		  (eol (vhdl-point 'eol))
X		  foundp literal placeholder)
X	      ;; Look for the statement keyword.
X	      (while (and (not foundp)
X			  (re-search-forward end-re nil t)
X			  (setq placeholder (match-end 1))
X			  (goto-char (match-beginning 0)))
X		;; If we are in a literal, or not in the right target
X		;; column and not on the same line as the begin, then
X		;; try again.
X		(if (or (and column
X			     (/= (current-indentation) column)
X			     (> (point) eol))
X			(= (preceding-char) ?_)
X			(setq literal (vhdl-in-literal lim)))
X		    (if (eq literal 'comment)
X			(end-of-line)
X		      (forward-char))
X		  ;; An "else" keyword corresponds to both the opening brace
X		  ;; of the following sexp and the closing brace of the
X		  ;; previous sexp.
X		  (if (not (looking-at "else"))
X		      (goto-char placeholder))
X		  (setq foundp t))
X		)
X	      (if (not foundp)
X		  (error "Unbalanced keywords in vhdl-forward-sexp"))
X	      )
X	  ;; If the current keyword is not a "begin" keyword, then just
X	  ;; perform the normal forward-sexp.
X	  (forward-sexp)
X	  )
X	(setq count (1- count))
X	)
X      (setq target (point)))
X    (goto-char target)
X    nil))
X
(defun vhdl-backward-sexp (&optional count lim)
X  "Move backward across one balanced expression (sexp).
With COUNT, do it that many times.  LIM bounds any required backward
searches."
X  (interactive "p")
X  (let ((count (or count 1))
X	(case-fold-search t)
X	begin-vec target)
X    (save-excursion
X      (while (> count 0)
X	;; Perform the normal backward-sexp, unless we are looking at
X	;; "else" - an "else" keyword corresponds to both the opening brace
X	;; of the following sexp and the closing brace of the previous sexp.
X	(if (and (looking-at "else\\b\\([^_]\\|\\'\\)")
X		 (/= (preceding-char) ?_)
X		 (not (vhdl-in-literal lim)))
X	    nil
X	  (backward-sexp)
X	  (if (and (looking-at vhdl-begin-fwd-re)
X		   (/= (preceding-char) ?_)
X		   (not (vhdl-in-literal lim))
X		   (vhdl-begin-p lim))
X	      (error "Containing expression ends prematurely in vhdl-backward-sexp")))
X	;; If the current keyword is an "end" keyword, then find the
X	;; corresponding "begin" keyword.
X	(if (and (setq begin-vec (vhdl-corresponding-begin lim))
X		 (/= (preceding-char) ?_))
X	    (let (
X		  ;; begin-re is the statement keyword to search for
X		  (begin-re
X		   (concat "\\b\\(" (aref begin-vec 0) "\\)\\b[^_]"))
X		  ;; column is either the statement keyword target column
X		  ;; or nil
X		  (column (aref begin-vec 1))
X		  ;; internal-p controls where the statement keyword can
X		  ;; be found.
X		  (internal-p (aref begin-vec 3))
X		  (last-backward (point)) last-forward
X		  foundp literal keyword)
X	      ;; Look for the statement keyword.
X	      (while (and (not foundp)
X			  (re-search-backward begin-re lim t)
X			  (setq keyword
X				(buffer-substring (match-beginning 1)
X						  (match-end 1))))
X		;; If we are in a literal or in the wrong column,
X		;; then try again.
X		(if (or (and column
X			     (and (/= (current-indentation) column)
X				  ;; possibly accept current-column as
X				  ;; well as current-indentation.
X				  (or (not internal-p)
X				      (/= (current-column) column))))
X			(= (preceding-char) ?_)
X			(vhdl-in-literal lim))
X		    (backward-char)
X		  ;; If there is a supplementary keyword, then
X		  ;; search forward for it. 
X		  (if (and (setq begin-re (aref begin-vec 2))
X			   (or (not (listp begin-re))
X			       ;; If begin-re is an alist, then find the
X			       ;; element corresponding to the actual
X			       ;; keyword that we found.
X			       (progn
X				 (setq begin-re
X				       (assoc keyword begin-re))
X				 (and begin-re
X				      (setq begin-re (cdr begin-re))))))
X		      (and
X		       (setq begin-re
X			     (concat "\\b\\(" begin-re "\\)\\b[^_]"))
X		       (save-excursion
X			 (setq last-forward (point))
X			 ;; Look for the supplementary keyword
X			 ;; (bounded by the backward search start
X			 ;; point).
X			 (while (and (not foundp)
X				     (re-search-forward begin-re
X							last-backward t)
X				     (goto-char (match-beginning 1)))
X			   ;; If we are in a literal, then try again.
X			   (if (or (= (preceding-char) ?_)
X				   (setq literal
X					 (vhdl-in-literal last-forward)))
X			       (if (eq literal 'comment)
X				   (goto-char
X				    (min (vhdl-point 'eol) last-backward))
X				 (forward-char))
X			     ;; We have found the supplementary keyword.
X			     ;; Save the position of the keyword in foundp.
X			     (setq foundp (point)))
X			   )
X			 foundp)
X		       ;; If the supplementary keyword was found, then
X		       ;; move point to the supplementary keyword.
X		       (goto-char foundp))
X		    ;; If there was no supplementary keyword, then
X		    ;; point is already at the statement keyword.
X		    (setq foundp t)))
X		) ; end of the search for the statement keyword
X	      (if (not foundp)
X		  (error "Unbalanced keywords in vhdl-backward-sexp"))
X	      ))
X	(setq count (1- count))
X	)
X      (setq target (point)))
X    (goto-char target)
X    nil))
X
(defun vhdl-backward-up-list (&optional count limit)
X  "Move backward out of one level of blocks.
With argument, do this that many times."
X  (interactive "p")
X  (let ((count (or count 1))
X	target)
X    (save-excursion
X      (while (> count 0)
X	(if (looking-at vhdl-defun-re)
X	    (error "Unbalanced blocks"))
X	(vhdl-backward-to-block limit)
X	(setq count (1- count)))
X      (setq target (point)))
X    (goto-char target)))
X
(defun vhdl-end-of-defun (&optional count)
X  "Move forward to the end of a VHDL defun."
X  (interactive)
X  (let ((case-fold-search t))
X    (vhdl-beginning-of-defun)
X    (if (not (looking-at "block\\|process"))
X	(re-search-forward "\\bis\\b"))
X    (vhdl-forward-sexp)))
X    
(defun vhdl-mark-defun ()
X  "Put mark at end of this \"defun\", point at beginning."
X  (interactive)
X  (let ((case-fold-search t))
X    (push-mark)
X    (vhdl-beginning-of-defun)
X    (push-mark)
X    (if (not (looking-at "block\\|process"))
X	(re-search-forward "\\bis\\b"))
X    (vhdl-forward-sexp)
X    (exchange-point-and-mark)))
X
(defun vhdl-beginning-of-libunit ()
X  "Move backward to the beginning of a VHDL library unit.
Returns the location of the corresponding begin keyword, unless search
stops due to beginning or end of buffer." 
X  ;; Note that if point is between the "libunit" keyword and the
X  ;; corresponding "begin" keyword, then that libunit will not be
X  ;; recognised, and the search will continue backwards.  If point is
X  ;; at the "begin" keyword, then the defun will be recognised.  The
X  ;; returned point is at the first character of the "libunit" keyword.
X  (let ((last-forward (point))
X	(last-backward
X	 ;; Just in case we are actually sitting on the "begin"
X	 ;; keyword, allow for the keyword and an extra character,
X	 ;; as this will be used when looking forward for the
X	 ;; "begin" keyword.
X	 (save-excursion (forward-word 1) (1+ (point))))
X	foundp literal placeholder)
X    ;; Find the "libunit" keyword.
X    (while (and (not foundp)
X		(re-search-backward vhdl-libunit-re nil 'move))
X      ;; If we are in a literal, or not at a real libunit, then try again.
X      (if (or (= (preceding-char) ?_)
X	      (vhdl-in-literal (point-min))
X	      (not (vhdl-libunit-p)))
X	  (backward-char)
X	;; Find the corresponding "begin" keyword.
X	(setq last-forward (point))
X	(while (and (not foundp)
X		    (re-search-forward "\\bis\\b[^_]" last-backward t)
X		    (setq placeholder (match-beginning 0)))
X	  (if (or (= (preceding-char) ?_)
X		  (setq literal (vhdl-in-literal last-forward)))
X	      ;; It wasn't a real keyword, so keep searching.
X	      (if (eq literal 'comment)
X		  (goto-char
X		   (min (vhdl-point 'eol) last-backward))
X		(forward-char))
X	    ;; We have found the begin keyword, loop will exit.
X	    (setq foundp placeholder)))
X	;; Go back to the libunit keyword
X	(goto-char last-forward)))
X    foundp))
X    
(defun vhdl-beginning-of-defun (&optional count)
X  "Move backward to the beginning of a VHDL defun.
With argument, do it that many times.
Returns the location of the corresponding begin keyword, unless search
stops due to beginning or end of buffer." 
X  ;; Note that if point is between the "defun" keyword and the
X  ;; corresponding "begin" keyword, then that defun will not be
X  ;; recognised, and the search will continue backwards.  If point is
X  ;; at the "begin" keyword, then the defun will be recognised.  The
X  ;; returned point is at the first character of the "defun" keyword.
X  (interactive "p")
X  (let ((count (or count 1))
X	(case-fold-search t)
X	(last-forward (point))
X	foundp)
X    (while (> count 0)
X      (setq foundp nil)
X      (goto-char last-forward)
X      (let ((last-backward
X	     ;; Just in case we are actually sitting on the "begin"
X	     ;; keyword, allow for the keyword and an extra character,
X	     ;; as this will be used when looking forward for the
X	     ;; "begin" keyword.
X	     (save-excursion (forward-word 1) (1+ (point))))
X	    begin-string literal)
X	(while (and (not foundp)
X		    (re-search-backward vhdl-defun-re nil 'move))
X	  ;; If we are in a literal, then try again.
X	  (if (or (= (preceding-char) ?_)
X		  (vhdl-in-literal (point-min)))
X	      (backward-char)
X	    (if (setq begin-string (vhdl-corresponding-defun))
X		;; This is a real defun keyword.
X		;; Find the corresponding "begin" keyword.
X		;; Look for the begin keyword.
X		(progn
X		  ;; Save the search start point.
X		  (setq last-forward (point))
X		  (while (and (not foundp)
X			      (search-forward begin-string last-backward t))
X		    (if (or (= (preceding-char) ?_)
X			    (save-match-data
X			      (setq literal (vhdl-in-literal last-forward))))
X			;; It wasn't a real keyword, so keep searching.
X			(if (eq literal 'comment)
X			    (goto-char
X			     (min (vhdl-point 'eol) last-backward))
X			  (forward-char))
X		      ;; We have found the begin keyword, loop will exit.
X		      (setq foundp (match-beginning 0)))
X		    )
X		  ;; Go back to the defun keyword
X		  (goto-char last-forward)) ; end search for begin keyword
X	      ))
X	  ) ; end of the search for the defun keyword
X	)
X      (setq count (1- count))
X      )
X    (vhdl-keep-region-active)
X    foundp))
X    
(defun vhdl-beginning-of-statement (&optional count lim)
X  "Go to the beginning of the innermost VHDL statement.
With prefix arg, go back N - 1 statements.  If already at the
beginning of a statement then go to the beginning of the preceding
one.  If within a string or comment, or next to a comment (only
whitespace between), move by sentences instead of statements.
X
When called from a program, this function takes 2 optional args: the
prefix arg, and a buffer position limit which is the farthest back to
search."
X  (interactive "p")
X  (let ((count (or count 1))
X	(case-fold-search t)
X	(lim (or lim (point-min)))
X	(here (point))
X	state)
X    (save-excursion
X      (goto-char lim)
X      (setq state (parse-partial-sexp (point) here nil nil)))
X    (if (and (interactive-p)
X	     (or (nth 3 state)
X		 (nth 4 state)
X		 (looking-at (concat "[ \t]*" comment-start-skip))))
X	(forward-sentence (- count))
X      (while (> count 0)
X	(vhdl-beginning-of-statement-1 lim)
X	(setq count (1- count))))
X    ;; its possible we've been left up-buf of lim
X    (goto-char (max (point) lim))
X    )
X  (vhdl-keep-region-active))
X
(defconst vhdl-b-o-s-re
X  (concat ";\\|\(\\|\)\\|\\bwhen\\b[^_]\\|"
X	  vhdl-begin-bwd-re "\\|" vhdl-statement-bwd-re))
X
(defun vhdl-beginning-of-statement-1 (&optional lim)
X  ;; move to the start of the current statement, or the previous
X  ;; statement if already at the beginning of one.
X  (let ((lim (or lim (point-min)))
X	(here (point))
X	(pos (point))
X	donep)
X    ;; go backwards one balanced expression, but be careful of
X    ;; unbalanced paren being reached
X    (if (not (vhdl-safe (progn (backward-sexp) t)))
X	(progn
X	  (backward-up-list 1)
X	  (forward-char)
X	  (vhdl-forward-syntactic-ws here)
X	  (setq donep t)))
X    (while (and (not donep)
X		(not (bobp))
X		;; look backwards for a statement boundary
X		(re-search-backward vhdl-b-o-s-re lim 'move))
X      (if (or (= (preceding-char) ?_)
X	      (vhdl-in-literal lim))
X	  (backward-char)
X	(cond
X	 ;; If we are looking at an open paren, then stop after it
X	 ((eq (following-char) ?\()
X	  (forward-char)
X	  (vhdl-forward-syntactic-ws here)
X	  (setq donep t))
X	 ;; If we are looking at a close paren, then skip it
X	 ((eq (following-char) ?\))
X	  (forward-char)
X	  (setq pos (point))
X	  (backward-sexp)
X	  (if (< (point) lim)
X	      (progn (goto-char pos)
X		     (vhdl-forward-syntactic-ws here)
X		     (setq donep t))))
X	 ;; If we are looking at a semicolon, then stop
X	 ((eq (following-char) ?\;)
X	  (progn
X	    (forward-char)
X	    (vhdl-forward-syntactic-ws here)
X	    (setq donep t)))
X	 ;; If we are looking at a "begin", then stop
X	 ((and (looking-at vhdl-begin-fwd-re)
X	       (/= (preceding-char) ?_)
X	       (vhdl-begin-p nil))
X	  ;; If it's a leader "begin", then find the
X	  ;; right place
X	  (if (looking-at vhdl-leader-re)
X	      (save-excursion
X		;; set a default stop point at the begin
X		(setq pos (point))
X		;; is the start point inside the leader area ?
X		(goto-char (vhdl-end-of-leader))
X		(vhdl-forward-syntactic-ws here)
X		(if (< (point) here)
X		    ;; start point was not inside leader area
X		    ;; set stop point at word after leader
X		    (setq pos (point))))
X	    (forward-word 1)
X	    (vhdl-forward-syntactic-ws here)
X	    (setq pos (point)))
X	  (goto-char pos)
X	  (setq donep t))
X	 ;; If we are looking at a "statement", then stop
X	 ((and (looking-at vhdl-statement-fwd-re)
X	       (/= (preceding-char) ?_)
X	       (vhdl-statement-p nil))
X	  (setq donep t))
X	 ;; If we are looking at a case alternative key, then stop
X	 ((looking-at vhdl-case-alternative-key)
X	  (save-excursion
X	    ;; set a default stop point at the when
X	    (setq pos (point))
X	    ;; is the start point inside the case alternative key ?
X	    (goto-char (match-end 0))
X	    (vhdl-forward-syntactic-ws here)
X	    (if (< (point) here)
X		;; start point was not inside the case alternative key
X		;; set stop point at word after case alternative keyleader
X		(setq pos (point))))
X	  (goto-char pos)
X	  (setq donep t))
X	 ;; Bogus find, continue
X	 (t
X	  (backward-char)))))
X    ))
X
X
;; Defuns for calculating the current syntactic state:
X
(defun vhdl-get-library-unit (bod placeholder)
X  ;; If there is an enclosing library unit at bod, with it's \"begin\"
X  ;; keyword at placeholder, then return the library unit type.
X  (let ((here (vhdl-point 'bol)))
X    (if (save-excursion
X	  (goto-char placeholder)
X	  (vhdl-safe (vhdl-forward-sexp 1 bod))
X	  (<= here (point)))
X	(save-excursion
X	  (goto-char bod)
X	  (cond
X	   ((looking-at "e") 'entity)
X	   ((looking-at "a") 'architecture)
X	   ((looking-at "c") 'configuration)
X	   ((looking-at "p")
X	    (save-excursion
X	      (goto-char bod)
X	      (forward-sexp)
X	      (vhdl-forward-syntactic-ws here)
X	      (if (looking-at "body\\b[^_]")
X		  'package-body 'package))))))
X    ))
X
(defun vhdl-get-block-state (&optional lim)
X  ;; Finds and records all the closest opens.
X  ;; lim is the furthest back we need to search (it should be the
X  ;; previous libunit keyword).
X  (let ((here (point))
X	(lim (or lim (point-min)))
X	keyword sexp-start sexp-mid sexp-end
X	preceding-sexp containing-sexp
X	containing-begin containing-mid containing-paren)
X    (save-excursion
X      ;; Find the containing-paren, and use that as the limit
X      (if (setq containing-paren
X		(save-restriction
X		  (narrow-to-region lim (point))
X		  (vhdl-safe (scan-lists (point) -1 1))))
X	  (setq lim containing-paren))
X      ;; Look backwards for "begin" and "end" keywords.
X      (while (and (> (point) lim)
X		  (not containing-sexp))
X	(setq keyword (vhdl-backward-to-block lim))
X	(cond
X	 ((eq keyword 'begin)
X	  ;; Found a "begin" keyword
X	  (setq sexp-start (point))
X	  (setq sexp-mid (vhdl-corresponding-mid lim))
X	  (setq sexp-end (vhdl-safe
X			  (save-excursion
X			    (vhdl-forward-sexp 1 lim) (point))))
X	  (if (and sexp-end (<= sexp-end here))
X	      ;; we want to record this sexp, but we only want to
X	      ;; record the last-most of any of them before here
X	      (or preceding-sexp
X		  (setq preceding-sexp sexp-start))
X	    ;; we're contained in this sexp so put sexp-start on
X	    ;; front of list
X	    (setq containing-sexp sexp-start)
X	    (setq containing-mid sexp-mid)
X	    (setq containing-begin t)))
X	 ((eq keyword 'end)
X	  ;; Found an "end" keyword
X	  (forward-sexp)
X	  (setq sexp-end (point))
X	  (setq sexp-mid nil)
X	  (setq sexp-start
X		(or (vhdl-safe (vhdl-backward-sexp 1 lim) (point))
X		    (progn (backward-sexp) (point))))
X	  ;; we want to record this sexp, but we only want to
X	  ;; record the last-most of any of them before here
X	  (or preceding-sexp
X	      (setq preceding-sexp sexp-start)))
X	 )))
X    ;; Check if the containing-paren should be the containing-sexp
X    (if (and containing-paren
X	     (or (null containing-sexp)
X		 (< containing-sexp containing-paren)))
X	(setq containing-sexp containing-paren
X	      preceding-sexp nil
X	      containing-begin nil
X	      containing-mid nil))
X    (vector containing-sexp preceding-sexp containing-begin containing-mid)
X    ))
X	      
X
(defconst vhdl-s-c-a-re
X  (concat vhdl-case-alternative-key "\\|" vhdl-case-header-key))
X
(defun vhdl-skip-case-alternative (&optional lim)
X  ;; skip forward over case/when bodies, with optional maximal
X  ;; limit. if no next case alternative is found, nil is returned and point
X  ;; is not moved
X  (let ((lim (or lim (point-max)))
X	(here (point))
X	donep foundp)
X    (while (and (< (point) lim)
X		(not donep))
X      (if (and (re-search-forward vhdl-s-c-a-re lim 'move)
X	       (save-match-data
X		 (not (vhdl-in-literal)))
X	       (/= (match-beginning 0) here))
X	  (progn
X	    (goto-char (match-beginning 0))
X	    (cond
X	     ((and (looking-at "case")
X		   (re-search-forward "\\bis[^_]" lim t))
X	      (backward-sexp)
X	      (vhdl-forward-sexp))
X	     (t
X	      (setq donep t
X		    foundp t))))))
X    (if (not foundp)
X	(goto-char here))
X    foundp))
X
(defun vhdl-backward-skip-label (&optional lim)
X  ;; skip backward over a label, with optional maximal
X  ;; limit. if label is found, nil is returned and point
X  ;; is not moved
X  (let ((lim (or lim (point-min)))
X	placeholder)
X    (if (save-excursion
X	  (vhdl-backward-syntactic-ws lim)
X	  (and (eq (preceding-char) ?:)
X	       (progn
X		 (backward-sexp)
X		 (setq placeholder (point))
X		 (looking-at vhdl-label-key))))
X	(goto-char placeholder))
X    ))
X
(defun vhdl-get-syntactic-context ()
X  ;; guess the syntactic description of the current line of VHDL code.
X  (save-excursion
X    (save-restriction
X      (beginning-of-line)
X      (let* ((indent-point (point))
X	     (case-fold-search t)
X	     vec literal containing-sexp preceding-sexp
X	     containing-begin containing-mid containing-leader
X	     char-before-ip char-after-ip begin-after-ip end-after-ip
X	     placeholder lim library-unit
X	    )
X
X	;; Reset the syntactic context
X	(setq vhdl-syntactic-context nil)
X
X	(save-excursion
X	  ;; Move to the start of the previous library unit, and
X	  ;; record the position of the "begin" keyword.
X	  (setq placeholder (vhdl-beginning-of-libunit))
X	  ;; The position of the "libunit" keyword gives us a gross
X	  ;; limit point.
X	  (setq lim (point))
X	  )
X
X	;; If there is a previous library unit, and we are enclosed by
X	;; it, then set the syntax accordingly.
X	(and placeholder
X	     (setq library-unit (vhdl-get-library-unit lim placeholder))
X	     (vhdl-add-syntax library-unit lim))
X	    
X	;; Find the surrounding state.
X	(if (setq vec (vhdl-get-block-state lim))
X	    (progn
X	      (setq containing-sexp (aref vec 0))
X	      (setq preceding-sexp (aref vec 1))
X	      (setq containing-begin (aref vec 2))
X	      (setq containing-mid (aref vec 3))
X	      ))
X
X	;; set the limit on the farthest back we need to search
X	(setq lim (if containing-sexp
X		      (save-excursion
X			(goto-char containing-sexp)
X			;; set containing-leader if required
X			(if (looking-at vhdl-leader-re)
X			    (setq containing-leader (vhdl-end-of-leader)))
X			(vhdl-point 'bol))
X		    (point-min)))
X
X	;; cache char before and after indent point, and move point to
X	;; the most likely position to perform the majority of tests
X	(goto-char indent-point)
X	(skip-chars-forward " \t")
X	(setq literal (vhdl-in-literal lim))
X	(setq char-after-ip (following-char))
X	(setq begin-after-ip (and
X			      (not literal)
X			      (looking-at vhdl-begin-fwd-re)
X			      (vhdl-begin-p)))
X	(setq end-after-ip (and
X			    (not literal)
X			    (looking-at vhdl-end-fwd-re)
X			    (vhdl-end-p)))
X	(vhdl-backward-syntactic-ws lim)
X	(setq char-before-ip (preceding-char))
X	(goto-char indent-point)
X	(skip-chars-forward " \t")
X
X	;; now figure out syntactic qualities of the current line
X	(cond
X	 ;; CASE 1: in a string or comment.
X	 ((memq literal '(string comment))
X	  (vhdl-add-syntax literal (vhdl-point 'bopl)))
X	 ;; CASE 2: Line is at top level.
X	 ((null containing-sexp)
X	  ;; Find the point to which indentation will be relative
X	  (save-excursion
X	    (if (null preceding-sexp)
X		;; CASE 2X.1
X		;; no preceding-sexp -> use the preceding statement
X		(vhdl-beginning-of-statement-1 lim)
X	      ;; CASE 2X.2
X	      ;; if there is a preceding-sexp then indent relative to it
X	      (goto-char preceding-sexp)
X	      ;; if not at boi, then the block-opening keyword is
X	      ;; probably following a label, so we need a different
X	      ;; relpos
X	      (if (/= (point) (vhdl-point 'boi))
X		  ;; CASE 2X.3
X		  (vhdl-beginning-of-statement-1 lim)))
X	    ;; v-b-o-s could have left us at point-min
X	    (and (bobp)
X		 ;; CASE 2X.4
X		 (vhdl-forward-syntactic-ws indent-point))
X	    (setq placeholder (point)))
X	  (cond
X	   ;; CASE 2A : we are looking at a block-open
X	   (begin-after-ip
X	    (vhdl-add-syntax 'block-open placeholder))
X	   ;; CASE 2B: we are looking at a block-close
X	   (end-after-ip
X	    (vhdl-add-syntax 'block-close placeholder))
X	   ;; CASE 2C: we are looking at a top-level statement
X	   ((progn
X	      (vhdl-backward-syntactic-ws lim)
X	      (or (bobp)
X		  (= (preceding-char) ?\;)))
X	    (vhdl-add-syntax 'statement placeholder))
X	   ;; CASE 2D: we are looking at a top-level statement-cont
X	   (t
X	    (vhdl-beginning-of-statement-1 lim)
X	    ;; v-b-o-s could have left us at point-min
X	    (and (bobp)
X		 ;; CASE 2D.1
X		 (vhdl-forward-syntactic-ws indent-point))
X	    (vhdl-add-syntax 'statement-cont (point)))
X	   )) ; end CASE 2
X	 ;; CASE 3: line is inside parentheses.  Most likely we are
X	 ;; either in a subprogram argument (interface) list, or a
X	 ;; continued expression containing parentheses.
X	 ((null containing-begin)
X	  (vhdl-backward-syntactic-ws containing-sexp)
X	  (cond
X	   ;; CASE 3A: we are looking at the arglist closing paren
X	   ((eq char-after-ip ?\))
X	    (goto-char containing-sexp)
X	    (vhdl-add-syntax 'arglist-close (vhdl-point 'boi)))
X	   ;; CASE 3B: we are looking at the first argument in an empty
X	   ;; argument list.
X	   ((eq char-before-ip ?\()
X	    (goto-char containing-sexp)
X	    (vhdl-add-syntax 'arglist-intro (vhdl-point 'boi)))
X	   ;; CASE 3C: we are looking at an arglist continuation line,
X	   ;; but the preceding argument is on the same line as the
X	   ;; opening paren.  This case includes multi-line
X	   ;; expression paren groupings.
X	   ((and (save-excursion
X		   (goto-char (1+ containing-sexp))
X		   (skip-chars-forward " \t")
X		   (not (eolp))
X		   (not (looking-at "--")))
X		 (save-excursion
X		   (vhdl-beginning-of-statement-1 containing-sexp)
X		   (skip-chars-backward " \t(")
X		   (<= (point) containing-sexp)))
X	    (goto-char containing-sexp)
X	    (vhdl-add-syntax 'arglist-cont-nonempty (vhdl-point 'boi)))
X	   ;; CASE 3D: we are looking at just a normal arglist
X	   ;; continuation line
X	   (t (vhdl-beginning-of-statement-1 containing-sexp)
X	      (vhdl-forward-syntactic-ws indent-point)
X	      (vhdl-add-syntax 'arglist-cont (vhdl-point 'boi)))
X	   ))
X	 ;; CASE 4: A block mid open
X	 ((and begin-after-ip
X	       (looking-at containing-mid))
X	  (goto-char containing-sexp)
X	  ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
X	  (if (looking-at vhdl-trailer-re)
X	      ;; CASE 4.1
X	      (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
X	  (vhdl-backward-skip-label (vhdl-point 'boi))
X	  (vhdl-add-syntax 'block-open (point)))
X	 ;; CASE 5: block close brace
X	 (end-after-ip
X	  (goto-char containing-sexp)
X	  ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
X	  (if (looking-at vhdl-trailer-re)
X	      ;; CASE 5.1
X	      (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
X	  (vhdl-backward-skip-label (vhdl-point 'boi))
X	  (vhdl-add-syntax 'block-close (point)))
X	 ;; CASE 6: A continued statement
X	 ((and (/= char-before-ip ?\;)
X	       ;; check it's not a trailer begin keyword, or a begin
X	       ;; keyword immediately following a label.
X	       (not (and begin-after-ip
X			 (or (looking-at vhdl-trailer-re)
X			     (save-excursion
X			       (vhdl-backward-skip-label containing-sexp)))))
X	       ;; check it's not a statement keyword
X	       (not (and (looking-at vhdl-statement-fwd-re)
X			 (vhdl-statement-p)))
X	       ;; see if the b-o-s is before the indent point
X	       (> indent-point
X		  (save-excursion
X		    (vhdl-beginning-of-statement-1 containing-sexp)
X		    ;; If we ended up after a leader, then this will
X		    ;; move us forward to the start of the first
X		    ;; statement.  Note that a containing sexp here is
X		    ;; always a keyword, not a paren, so this will
X		    ;; have no effect if we hit the containing-sexp.
X		    (vhdl-forward-syntactic-ws indent-point)
X		    (setq placeholder (point))))
X	       ;; check it's not a block-intro
X	       (/= placeholder containing-sexp)
X	       ;; check it's not a case block-intro
X	       (save-excursion
X		 (goto-char placeholder)
X		 (or (not (looking-at vhdl-case-alternative-key))
X		     (> (match-end 0) indent-point))))
X	  (vhdl-add-syntax 'statement-cont placeholder)
X	  (if begin-after-ip
X	      (vhdl-add-syntax 'block-open)))
X	 ;; Statement. But what kind?
X	 ;; CASE 7: A case alternative key
X	 ((looking-at vhdl-case-alternative-key)
X	  ;; for a case alternative key, we set relpos to the first
X	  ;; non-whitespace char on the line containing the "case"
X	  ;; keyword.
X	  (goto-char containing-sexp)
X	  ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
X	  (if (looking-at vhdl-trailer-re)
X	      (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
X	  (vhdl-add-syntax 'case-alternative (vhdl-point 'boi)))
X	 ;; CASE 8: statement catchall
X	 (t
X	  ;; we know its a statement, but we need to find out if it is
X	  ;; the first statement in a block
X	  (if containing-leader
X	      (goto-char containing-leader)
X	    (goto-char containing-sexp)
X	    ;; Note that a containing sexp here is always a keyword,
X	    ;; not a paren, so skip over the keyword.
X	    (forward-sexp))
X	  ;; move to the start of the first statement
X	  (vhdl-forward-syntactic-ws indent-point)
X	  (setq placeholder (point))
X	  ;; we want to ignore case alternatives keys when skipping forward
X	  (let (incase-p)
X	    (while (looking-at vhdl-case-alternative-key)
X	      (setq incase-p (point))
X	      ;; we also want to skip over the body of the
X	      ;; case/when statement if that doesn't put us at
X	      ;; after the indent-point
X	      (while (vhdl-skip-case-alternative indent-point))
X	      ;; set up the match end
X	      (looking-at vhdl-case-alternative-key)
X	      (goto-char (match-end 0))
X	      ;; move to the start of the first case alternative statement
X	      (vhdl-forward-syntactic-ws indent-point)
X	      (setq placeholder (point)))
X	    (cond
X	     ;; CASE 8A: we saw a case/when statement so we must be
X	     ;; in a switch statement.  find out if we are at the
X	     ;; statement just after a case alternative key
X	     ((and incase-p
X		   (= (point) indent-point))
X	      ;; relpos is the "when" keyword
X	      (vhdl-add-syntax 'statement-case-intro incase-p))
X	     ;; CASE 8B: any old statement
X	     ((< (point) indent-point)
X	      ;; relpos is the first statement of the block
X	      (vhdl-add-syntax 'statement placeholder)
X	      (if begin-after-ip
X		  (vhdl-add-syntax 'block-open)))
X	     ;; CASE 8C: first statement in a block
X	     (t
X	      (goto-char containing-sexp)
X	      ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
X	      (if (looking-at vhdl-trailer-re)
X		  (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
X	      (vhdl-backward-skip-label (vhdl-point 'boi))
X	      (vhdl-add-syntax 'statement-block-intro (point))
X	      (if begin-after-ip
X		  (vhdl-add-syntax 'block-open)))
X	     )))
X	 )
X
X	;; now we need to look at any modifiers
X	(goto-char indent-point)
X	(skip-chars-forward " \t")
X	(if (looking-at "--")
X	    (vhdl-add-syntax 'comment))
X	;; return the syntax
X	vhdl-syntactic-context))))
X
X
;; Standard indentation line-ups:
X
(defun vhdl-lineup-arglist (langelem)
X  ;; lineup the current arglist line with the arglist appearing just
X  ;; after the containing paren which starts the arglist.
X  (save-excursion
X    (let* ((containing-sexp
X	    (save-excursion
X	      ;; arglist-cont-nonempty gives relpos ==
X	      ;; to boi of containing-sexp paren. This
X	      ;; is good when offset is +, but bad
X	      ;; when it is vhdl-lineup-arglist, so we
X	      ;; have to special case a kludge here.
X	      (if (memq (car langelem) '(arglist-intro arglist-cont-nonempty))
X		  (progn
X		    (beginning-of-line)
X		    (backward-up-list 1)
X		    (skip-chars-forward " \t" (vhdl-point 'eol)))
X		(goto-char (cdr langelem)))
X	      (point)))
X	   (cs-curcol (save-excursion
X			(goto-char (cdr langelem))
X			(current-column))))
X      (if (save-excursion
X	    (beginning-of-line)
X	    (looking-at "[ \t]*)"))
X	  (progn (goto-char (match-end 0))
X		 (backward-sexp)
X		 (forward-char)
X		 (vhdl-forward-syntactic-ws)
X		 (- (current-column) cs-curcol))
X	(goto-char containing-sexp)
X	(or (eolp)
X	    (let ((eol (vhdl-point 'eol))
X		  (here (progn
X			  (forward-char)
X			  (skip-chars-forward " \t")
X			  (point))))
X	      (vhdl-forward-syntactic-ws)
X	      (if (< (point) eol)
X		  (goto-char here))))
X	(- (current-column) cs-curcol)
X	))))
X
(defun vhdl-lineup-arglist-intro (langelem)
X  ;; lineup an arglist-intro line to just after the open paren
X  (save-excursion
X    (let ((cs-curcol (save-excursion
X		       (goto-char (cdr langelem))
X		       (current-column)))
X	  (ce-curcol (save-excursion
X		       (beginning-of-line)
X		       (backward-up-list 1)
X		       (skip-chars-forward " \t" (vhdl-point 'eol))
X		       (current-column))))
X      (- ce-curcol cs-curcol -1))))
X
(defun vhdl-lineup-comment (langelem)
X  ;; support old behavior for comment indentation. we look at
X  ;; vhdl-comment-only-line-offset to decide how to indent comment
X  ;; only-lines
X  (save-excursion
X    (back-to-indentation)
X    ;; at or to the right of comment-column
X    (if (>= (current-column) comment-column)
X	(vhdl-comment-indent)
X      ;; otherwise, indent as specified by vhdl-comment-only-line-offset
X      (if (not (bolp))
X	  (or (car-safe vhdl-comment-only-line-offset)
X	      vhdl-comment-only-line-offset)
X	(or (cdr-safe vhdl-comment-only-line-offset)
X	    (car-safe vhdl-comment-only-line-offset)
X	    -1000			;jam it against the left side
X	    )))))
X
(defun vhdl-lineup-statement-cont (langelem)
X  ;; line up statement-cont after the assignment operator
X  (save-excursion
X    (let* ((relpos (cdr langelem))
X	   (assignp (save-excursion
X		     (goto-char (vhdl-point 'boi))
X		     (and (re-search-forward "\\(<\\|:\\)="
X					     (vhdl-point 'eol) t)
X			  (- (point) (vhdl-point 'boi)))))
X	   (curcol (progn
X		     (goto-char relpos)
X		     (current-column)))
X	   foundp)
X      (while (and (not foundp)
X		  (< (point) (vhdl-point 'eol)))
X	(re-search-forward "\\(<\\|:\\)=\\|(" (vhdl-point 'eol) 'move)
X	(if (vhdl-in-literal (cdr langelem))
X	    (forward-char)
X	  (if (= (preceding-char) ?\()
X	      ;; skip over any parenthesized expressions
X	      (goto-char (min (vhdl-point 'eol)
X			      (scan-lists (point) 1 1)))
X	    ;; found an assignment operator (not at eol)
X	    (setq foundp (not (looking-at "\\s-*$"))))))
X      (if (not foundp)
X	  ;; there's no assignment operator on the line
X	  vhdl-basic-offset
X	;; calculate indentation column after assign and ws, unless
X	;; our line contains an assignment operator
X	(if (not assignp)
X	    (progn
X	      (forward-char)
X	      (skip-chars-forward " \t")
X	      (setq assignp 0)))
X	(- (current-column) assignp curcol))
X      )))
X
X
;; Indentation commands:
X
;; This is used by indent-for-comment to decide how much to indent a
;; comment in VHDL code based on its context.
(defun vhdl-comment-indent ()
X  (if (looking-at (concat "^--"))
X      0				;Existing comment at bol stays there.
X    (let ((opoint (point))
X	  placeholder)
X      (save-excursion
X	(beginning-of-line)
X	(cond
X	 ;; CASE 1: use comment-column if previous line is a
X	 ;; comment-only line indented to the left of comment-column
X	 ((save-excursion
X	    (beginning-of-line)
X	    (and (not (bobp))
X		 (forward-line -1))
X	    (skip-chars-forward " \t")
X	    (prog1
X		(looking-at "--")
X	      (setq placeholder (point))))
X	  (goto-char placeholder)
X	  (if (< (current-column) comment-column)
X	      comment-column
X	    (current-column)))
X	 ;; CASE 2: If comment-column is 0, and nothing but space
X	 ;; before the comment, align it at 0 rather than 1.
X	 ((progn
X	    (goto-char opoint)
X	    (skip-chars-backward " \t")
X	    (and (= comment-column 0) (bolp)))
X	  0)
X	 ;; CASE 3: indent at comment column except leave at least one
X	 ;; space.
X	 (t (max (1+ (current-column))
X		 comment-column))
X	 )))))
X
(defun vhdl-indent-line ()
X  ;; indent the current line as VHDL code. Returns the amount of
X  ;; indentation change
X  (let* ((syntax (vhdl-get-syntactic-context))
X	 (pos (- (point-max) (point)))
X	 (indent (apply '+ (mapcar 'vhdl-get-offset syntax)))
X	 (shift-amt  (- (current-indentation) indent)))
X    (and vhdl-echo-syntactic-information-p
X	 (message "syntax: %s, indent= %d" syntax indent))
X    (if (zerop shift-amt)
X	nil
X      (delete-region (vhdl-point 'bol) (vhdl-point 'boi))
X      (beginning-of-line)
X      (indent-to indent))
X    (if (< (point) (vhdl-point 'boi))
X	(back-to-indentation)
X      ;; If initial point was within line's indentation, position after
X      ;; the indentation.  Else stay at same point in text.
X      (if (> (- (point-max) pos) (point))
X	  (goto-char (- (point-max) pos)))
X      )
X    (run-hooks 'vhdl-special-indent-hook)
X    shift-amt))
X
(defun vhdl-indent-command (&optional whole-exp)
X  "Indent current line as VHDL code, or in some cases insert a tab character.
X
If `vhdl-tab-always-indent' is t, always just indent the current line.
If nil, indent the current line only if point is at the left margin or
in the line's indentation; otherwise insert a tab.  If other than nil
or t, then tab is inserted only within literals (comments and strings)
and inside preprocessor directives, but line is always reindented.
X
A numeric argument, regardless of its value, means indent rigidly all
the lines of the expression starting after point so that this line
becomes properly indented.  The relative indentation among the lines
of the expression are preserved."
X  (interactive "P")
X  (if whole-exp
X      ;; If arg, always indent this line as VHDL
X      ;; and shift remaining lines of expression the same amount.
X      (let ((shift-amt (vhdl-indent-line))
X	    beg end)
X	(save-excursion
X	  (if (eq vhdl-tab-always-indent t)
X	      (beginning-of-line))
X	  (setq beg (point))
X	  (forward-sexp)
X	  (setq end (point))
X	  (goto-char beg)
X	  (forward-line 1)
X	  (setq beg (point)))
X	(if (> end beg)
X	    (indent-code-rigidly beg end (- shift-amt))))
X    ;; No arg supplied, use vhdl-tab-always-indent to determine
X    ;; behavior
X    (cond
X     ;; CASE 1: indent when at column zero or in lines indentation,
X     ;; otherwise insert a tab
X     ((not vhdl-tab-always-indent)
X      (if (save-excursion
X	    (skip-chars-backward " \t")
X	    (not (bolp)))
X	  (insert-tab)
X	(vhdl-indent-line)))
X     ;; CASE 2: just indent the line
X     ((eq vhdl-tab-always-indent t)
X      (vhdl-indent-line))
X     ;; CASE 3: if in a literal, insert a tab, but always indent the
X     ;; line
X     (t
X      (if (vhdl-in-literal (vhdl-point 'bod))
X	  (insert-tab))
X      (vhdl-indent-line)
X      ))))
X
(defun vhdl-indent-sexp (&optional endpos)
X  "Indent each line of the list starting just after point.
If optional arg ENDPOS is given, indent each line, stopping when
ENDPOS is encountered.  (interactive)"
X  (interactive)
X  (save-excursion
X    (let ((beg (point))
X	  (end (progn
X		 (vhdl-forward-sexp nil endpos)
X		 (point))))
X      (indent-region beg end nil))))
X
(defun vhdl-show-syntactic-information ()
X  "Show syntactic information for current line."
X  (interactive)
X  (message "syntactic analysis: %s" (vhdl-get-syntactic-context))
X  (vhdl-keep-region-active))
X
X
;; Verification and regression functions:
X
(defun vhdl-regress-line (&optional arg)
X  "Check syntactic information for current line."
X  (interactive "P")
X  (let ((expected (save-excursion
X		    (end-of-line)
X		    (if (search-backward " -- ((" (vhdl-point 'bol) t)
X			(progn
X			  (forward-char 4)
X			  (read (current-buffer))))))
X	(actual (vhdl-get-syntactic-context))
X	(expurgated))
X    ;; remove the library unit symbols
X    (mapcar
X     (function
X      (lambda (elt)
X	(if (memq (car elt) '(entity configuration package
X				     package-body architecture))
X	    nil
X	  (setq expurgated (append expurgated (list elt))))))
X     actual)
X    (if (and (not arg) expected (listp expected))
X	(if (not (equal expected expurgated))
X	    (error "Should be: %s, is: %s" expected expurgated))
X      (save-excursion
X	(beginning-of-line)
X	(if (not (looking-at "^\\s-*\\(--.*\\)?$"))
X	    (progn
X	      (end-of-line)
X	      (if (search-backward " -- ((" (vhdl-point 'bol) t)
X		  (kill-line))
X	      (insert " -- ")
X	      (insert (format "%s" expurgated)))))))
X  (vhdl-keep-region-active))
X
(defun test-vhdl-get-block-state ()
X  (interactive)
X  (let ((case-fold-search t)
X	here vec (delay 0.5))
X    (setq here (point))
X    (message "%s" (prin1-to-string (setq vec (vhdl-get-block-state))))
X    (and (aref vec 0)
X	 (goto-char (aref vec 0))
X	 (sit-for delay))
X    (and (aref vec 1)
X	 (goto-char (aref vec 1))
X	 (sit-for delay))
X    (goto-char here)
X    ))
X
;; Support for Barry Warsaw's elp (emacs lisp profiler) package:
X
(setq elp-all-instrumented-list nil)
(setq elp-function-list
X      '(
X	vhdl-indent-command
X	vhdl-indent-line
X	vhdl-comment-indent
X	vhdl-lineup-statement-cont
X	vhdl-lineup-comment
X	vhdl-lineup-arglist-intro
X	vhdl-lineup-arglist
X	vhdl-get-syntactic-context
X	vhdl-skip-case-alternative
X	vhdl-get-block-state
X	vhdl-get-library-unit
X	vhdl-beginning-of-statement
X	vhdl-beginning-of-statement-1
X	vhdl-beginning-of-defun
X	vhdl-beginning-of-libunit
X	vhdl-backward-sexp
X	vhdl-forward-sexp
X	vhdl-backward-to-block
X	vhdl-statement-p
X	vhdl-end-of-leader
X	vhdl-corresponding-begin
X	vhdl-end-p
X	vhdl-corresponding-end
X	vhdl-corresponding-mid
X	vhdl-begin-p
X	vhdl-corresponding-defun
X	vhdl-defun-p
X	vhdl-libunit-p
X	vhdl-last-word
X	vhdl-first-word
X	vhdl-backward-syntactic-ws
X	vhdl-forward-syntactic-ws
X	vhdl-in-literal
X	vhdl-keep-region-active
X	))
X
;; (elp-instrument-list elp-function-list)
X
(defun vhdl-trace-all-functions ()
X  (interactive)
X  (let ((list elp-function-list))
X    (while list
X      (trace-function-background (car list))
X      (setq list (cdr list)))))
X
X
;; Defuns for submitting bug reports:
X
(defconst vhdl-version "$Revision: 2.71 $"
X  "vhdl-mode version number.")
(defconst vhdl-mode-help-address "rwhitby@asc.corp.mot.com"
X  "Address accepting submission of bug reports.")
X
(defun vhdl-version ()
X  "Echo the current version of vhdl-mode in the minibuffer."
X  (interactive)
X  (message "Using vhdl-mode %s" vhdl-version)
X  (vhdl-keep-region-active))
X
;; get reporter-submit-bug-report when byte-compiling
(and (fboundp 'eval-when-compile)
X     (eval-when-compile
X      (require 'reporter)))
X
(defun vhdl-submit-bug-report ()
X  "Submit via mail a bug report on vhdl-mode."
X  (interactive)
X  ;; load in reporter
X  (and
X   (y-or-n-p "Do you want to submit a report on vhdl-mode? ")
X   (require 'reporter)
X   (reporter-submit-bug-report
X    vhdl-mode-help-address
X    (concat "vhdl-mode " vhdl-version)
X    (list
X     ;; report only the vars that affect indentation
X     'vhdl-basic-offset
X     'vhdl-offsets-alist
X     'vhdl-comment-only-line-offset
X     'vhdl-tab-always-indent
X     'tab-width
X     )
X    (function
X     (lambda ()
X       (insert
X	(if vhdl-special-indent-hook
X	    (concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
X		    "vhdl-special-indent-hook is set to '"
X		    (format "%s" vhdl-special-indent-hook)
X		    ".\nPerhaps this is your problem?\n"
X		    "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n")
X	  "\n")
X	(format "vhdl-emacs-features: %s\n" vhdl-emacs-features)
X	)))
X    nil
X    "Dear Rod,"
X    )))
X
(provide 'vhdl-mode)
;;; vhdl-mode.el ends here
SHAR_EOF
  $shar_touch -am 0928170095 'vhdl-mode.el' &&
  chmod 0444 'vhdl-mode.el' ||
  echo 'restore of vhdl-mode.el failed'
  shar_count="`wc -c < 'vhdl-mode.el'`"
  test 91988 -eq "$shar_count" ||
    echo "vhdl-mode.el: original size 91988, current size $shar_count"
fi
# ============= vhdl-mode.texi ==============
if test -f 'vhdl-mode.texi' && test X"$1" != X"-c"; then
  echo 'x - skipping vhdl-mode.texi (file already exists)'
else
  echo 'x - extracting vhdl-mode.texi (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'vhdl-mode.texi' &&
\input texinfo   @c -*- texinfo -*-
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment %**start of header (This is for running Texinfo on a region)
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@setfilename  vhdl-mode.info
@settitle     VHDL-MODE Version 2 Documentation
@footnotestyle end
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment @setchapternewpage odd !! we don't want blank pages !!
@comment %**end of header (This is for running Texinfo on a region)
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment 
@comment texinfo manual for @file{vhdl-mode.el} version 2
@comment manual version: 2.1
@comment adapted from the cc-mode texinfo manual by Barry A. Warsaw
@comment <bwarsaw@cnri.reston.va.us>
@comment 
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment The following line inserts the copyright notice 
@comment into the Info file.
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@ifinfo
Copyright @copyright{} 1995 Rodney J. Whitby
@end ifinfo
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment !!!The titlepage section does not appear in the Info file.!!!
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@titlepage
@sp 10
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment The title is printed in a large font.
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@center @titlefont{VHDL-MODE Version 2}
@sp 2
@center A GNU Emacs mode for editing VHDL code.
@center (manual revision: 2.1)
@sp 2
@center Rod Whitby
@center @code{rwhitby@asc.corp.mot.com}
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment  The following two commands start the copyright page
@comment  for the printed manual.  This will not appear in the Info file.
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1995 Rodney J. Whitby
@end titlepage
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment The Top node contains the master menu for the Info file.
@comment This appears only in the Info file, not the printed manual.
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@node    Top,       Introduction, (dir),    (dir)
@comment node-name, next,          previous, up
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@menu
* Introduction::                
* Getting Connected::           
* New Indentation Engine::
* Customizing Indentation::
* Syntactic Symbols::
* Indentation Commands::
* Frequently Asked Questions::
* Getting the latest vhdl-mode release::
* Sample .emacs File::
* Requirements::                
* Limitations and Known Bugs::  
* Mailing Lists and Submitting Bug Reports::  
* Concept Index::               
* Command Index::               Command Index
* Key Index::                   Key Index
* Variable Index::              Variable Index
@end menu
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@node     Introduction, Getting Connected, Top,      Top
@comment  node-name,    next,            previous, up
@chapter  Introduction
@cindex   Introduction
X
Welcome to @code{vhdl-mode}, version 2.  This is a GNU Emacs mode for
editing files containing VHDL code.  
X
This manual will describe the following:
X
@itemize @bullet
@item
How to get started using @code{vhdl-mode}.
X
@item
How the new indentation engine works.
X
@item
How to customize the new indentation engine.
X
@end itemize
X
@findex vhdl-version
The major version number was incremented to 2 with the addition of the
new indentation engine. To find the minor revision number of this
release, use @kbd{M-x vhdl-version RET}.
X
A special word of thanks goes to Barry Warsaw, who wrote the
@code{cc-mode} indentation engine that formed the basis of the
@code{vhdl-mode} indentation engine.  This manual is also based upon the
manual for @code{cc-mode}.
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@node     Getting Connected, New Indentation Engine, Introduction,      Top
@comment  node-name,       next,                   previous,          up
@chapter  Getting Connected
@cindex   Getting Connected
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@file{vhdl-mode.el} works well with the 3 main branches of Emacs 19:
XXEmacs, Win-Emacs (which has the same heritage as XEmacs) and the Emacs
19 maintained by the FSF.  FSF's Emacs 19 users will want to use Emacs
version 19.21 or better, Win-Emacs users will want 1.35 or better, and
XXEmacs users will want 19.6 or better.  Earlier versions of these
Emacsen have deficiencies and/or bugs which will adversely affect the
performance and usability of @code{vhdl-mode}.
X
Similarly if you use the @file{vhdl-mode-18.el} compatibility file,
@file{vhdl-mode.el} will work with Emacs 18, but only moderately well.
A word of warning though, @emph{Emacs 18 lacks some fundamental
functionality and that ultimately means using Emacs 18 is a losing
battle}.  Hence @code{vhdl-mode} under Emacs 18 is no longer supported
and it is highly recommended that you upgrade to Emacs 19.  If you use
@code{vhdl-mode} under Emacs 18, you're on your own.  With
@code{vhdl-mode} version 3, Emacs 18 support will be dropped altogether.
X
@cindex .emacs file
The first thing you will want to do is put @file{vhdl-mode.el} somewhere
on your @code{load-path} so Emacs can find it.  Do a @kbd{C-h v
load-path RET} to see all the directories Emacs looks at when loading a
file.  If none of these directories are appropriate, create a new
directory and add it to your @code{load-path}:
X
@noindent
@emph{[in the shell]}
@example
@group
X
% cd
% mkdir mylisp
% mv vhdl-mode.el mylisp
% cd mylisp
X
@end group
@end example
X
@noindent
@emph{[in your .emacs file add]}
@example
X
(setq load-path (cons "~/mylisp" load-path))
X
@end example
X
@cindex byte compile
Next you want to @dfn{byte compile} @file{vhdl-mode.el}.  The mode uses a
lot of macros so if you don't byte compile it, things will be unbearably
slow.  @emph{You can ignore all byte-compiler warnings!}  They are the
result of the supporting different versions of Emacs, and none of the
warnings have any effect on operation. Let me say this again:
@strong{You really can ignore all byte-compiler warnings!}
X
Here's what to do to byte-compile the file [in emacs]:
@example
X
M-x byte-compile-file RET ~/mylisp/vhdl-mode.el RET
X
@end example
X
Now add the following autoloads to your @file{.emacs} file so that
@code{vhdl-mode} gets loaded at the right time:
@example
X
(autoload 'vhdl-mode "vhdl-mode" "VHDL Editing Mode" t)
X
@end example
X
Alternatively, if you want to make sure @code{vhdl-mode} is loaded when
Emacs starts up, you could use this line instead of the autoload above:
@example
X
(require 'vhdl-mode)
X
@end example
X
Next, you will want to set up Emacs so that it edits VHDL files in
@code{vhdl-mode}. All users should add the following to their
@file{.emacs} file.  Note that this assumes you'll be editing @code{.vhd}
and files as VHDL. YMMV:
@example
@group
X
(setq auto-mode-alist
X  (append
X    '(("\\.vhd$" . vhdl-mode)
X     ) auto-mode-alist))
X
@end group
@end example
X
That's all you need -- I know, I know, it sounds like a lot @code{:-)},
but after you've done all this, you should only need to quit and restart
Emacs.  The next time you visit a VHDL file you should be using
@code{vhdl-mode}.  You can check this easily by hitting @kbd{M-x
vhdl-version RET} in the @code{vhdl-mode} buffer.  You should see this
message in the echo area:
@example
X
Using @code{vhdl-mode} version 2.@var{XXX}
X
@end example
X
@noindent
where @var{XXX} will be some minor revision number.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@node     New Indentation Engine, Indentation Commands, Getting Connected, Top
@comment  node-name,              next,                    previous,up
X
@chapter  New Indentation Engine
@cindex   New Indentation Engine
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@code{vhdl-mode} has a new indentation engine, providing a simplified, yet
flexible and general mechanism for customizing indentation. It breaks
indentation calculation into two steps. First for the line of code being
indented, @code{vhdl-mode} analyzes what kind of language construct it's
looking at, then it applies user defined offsets to the current line
based on this analysis.
X
This section will briefly cover how indentation is calculated in
@code{vhdl-mode}. It is important to understand the indentation model
being used so that you will know how to customize @code{vhdl-mode} for
your personal coding style.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@menu
* Syntactic Analysis::       Step 1 -- Syntactic Analysis
* Indentation Calculation::  Step 2 -- Indentation Calculation
@end menu
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Syntactic Analysis, Indentation Calculation, , New Indentation Engine
@comment  node-name,              next,                    previous,up
@section  Syntactic Analysis
@cindex   Syntactic Analysis
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@vindex vhdl-offsets-alist
@vindex offsets-alist (vhdl-)
@cindex relative buffer position
@cindex syntactic symbol
@cindex syntactic component
@cindex syntactic component list
@cindex relative buffer position
The first thing @code{vhdl-mode} does when indenting a line of code, is
to analyze the line, determining the @dfn{syntactic component list} of
the construct on that line.  A @dfn{syntactic component} consists of a
pair of information (in lisp parlance, a @emph{cons cell}), where the
first part is a @dfn{syntactic symbol}, and the second part is a
@dfn{relative buffer position}.  Syntactic symbols describe elements of
VHDL code, e.g. @code{statement}, @code{comment}, @code{block-open},
@code{block-close}, etc.  @xref{Syntactic Symbols}, for a complete list
of currently recognized syntactic symbols and their semantics.  Also,
the variable @code{vhdl-offsets-alist} contains the list of currently
supported syntactic symbols.
X
Conceptually, a line of VHDL code is always indented relative to the
indentation of some line higher up in the buffer.  This is represented
by the relative buffer position in the syntactic component.
X
It might help to see an example. Suppose we had the following code as
the only thing in a @code{vhdl-mode} buffer @footnote{The line numbers
in this and future examples don't actually appear in the buffer.}:
@example
@group
X
X  1: inverter : process
X  2: begin
X  3:   q <= not d;
X  4:   wait on d;
X  5: end inverter;
X
@end group
@end example
X
@kindex C-c C-s
@findex vhdl-show-syntactic-information
@findex show-syntactic-information (vhdl-)
We can use the command @kbd{C-c C-s}
(@code{vhdl-show-syntactic-information}) to simply report what the
syntactic analysis is for the current line.  Running this command on
line 4 of example 1, we'd see in the echo area:
@example
X
((statement . 28))
X
@end example
X
This tells us that the line is a statement and it is indented relative
to buffer position 28, which happens to be the @samp{q} on line 3.  If
you were to move point to line 3 and hit @kbd{C-c C-s}, you would see:
@example
X
((statement-block-intro . 20))
X
@end example
X
This indicates that line 3 is the first statement in a block, and is
indented relative to buffer position 20, which is the @samp{b} in the
@code{begin} keyword on line 2.
X
@cindex comment only line
Syntactic component lists can contain more than one component, and
individual syntactic compenents need not have relative buffer positions.
The most common example of this is a line that contains a @dfn{comment
only line}.
@example
@group
X
%%% TBD %%%
X
@end group
@end example
X
@noindent
Hitting @kbd{C-c C-s} on line 3 of the example gives us:
@example
X
((comment-intro) (block-intro . 46))
X
@end example
X
@noindent
so you can see that the syntactic component list contains two syntactic
components.  Also notice that the first component,
@samp{(comment-intro)} has no relative buffer position.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Indentation Calculation, , Syntactic Analysis, New Indentation Engine
@comment  node-name,              next,                    previous,up
@section  Indentation Calculation
@cindex   Indentation Calculation
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@vindex vhdl-offsets-alist
@vindex offsets-alist (vhdl-)
Indentation for the current line is calculated using the syntactic
component list derived in step 1 above (see @ref{Syntactic
Analysis}).  Each component contributes to the final total indentation
of the line in two ways.
X
First, the syntactic symbols are looked up in the @code{vhdl-offsets-alist}
variable, which is an association list of syntactic symbols and the
offsets to apply for those symbols.  These offsets are added to the
running total.
X
Second, if the component has a relative buffer position, @code{vhdl-mode}
adds the column number of that position to the running total.  By adding
up the offsets and columns for every syntactic component on the list,
the final total indentation for the current line is computed.
X
Let's use our code example above to see how this works.  Here is our
example again.
@example
@group
X
X  1: inverter : process
X  2: begin
X  3:   q <= not d;
X  4:   wait on d;
X  5: end inverter;
X
@end group
@end example
X
@kindex TAB
Let's say point is on line 3 and we hit the @key{TAB} key to re-indent
the line.  Remember that the syntactic component list for that
line is:
@example
X
((statement-block-intro . 20))
X
@end example
X
@noindent
@code{vhdl-mode} looks up @code{statement-block-intro} in the
@code{vhdl-offsets-alist} variable.  Let's say it finds the value @samp{2};
it adds this to the running total (initialized to zero), yielding a
running total indentation of 2 spaces.
X
Next @code{vhdl-mode} goes to buffer position 20 and asks for the
current column.  Since the @code{begin} keyword at buffer position 20 is
in column zero, it adds @samp{0} to the running total.  Since there is
only one syntactic component on the list for this line, indentation
calculation is complete, and the total indentation for the line is 2
spaces.
Simple, huh?
X
Actually, the mode usually just does The Right Thing without you having
to think about it in this much detail.  But when customizing
indentation, it's helpful to understand the general indentation model
being used.
X
@vindex vhdl-echo-syntactic-information-p
@vindex echo-syntactic-information-p (vhdl-)
@cindex TAB
To help you configure @code{vhdl-mode}, you can set the variable
@code{vhdl-echo-syntactic-information-p} to non-@code{nil} so that the
syntactic component list and calculated offset will always be echoed in
the minibuffer when you hit @kbd{TAB}.
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Indentation Commands, Customizing Indentation, New Indentation Engine, Top
@comment  node-name,              next,                    previous,up
X
@chapter  Indentation Commands
@cindex   Indentation Commands
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@strong{<TBD>}
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Customizing Indentation, Syntactic Symbols, Indentation Commands, Top
@comment  node-name,              next,                    previous,up
X
@chapter  Customizing Indentation
@cindex   Customizing Indentation
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@cindex vhdl-set-offset
@cindex set-offset (vhdl-)
The @code{vhdl-offsets-alist} variable is where you customize all your
indentations.  You simply need to decide what additional offset you want
to add for every syntactic symbol.  You can use the command @kbd{C-c
C-o} (@code{vhdl-set-offset}) as the way to set offsets, both
interactively and from your mode hook.  Also, you can set up
@emph{styles} of indentation.  Most likely, you'll find one of the
pre-defined styles will suit your needs, but if not, this section will
describe how to set up basic editing configurations.  @xref{Styles} for
an explanation of how to set up named styles.
X
@cindex vhdl-basic-offset
@cindex basic-offset (vhdl-)
As mentioned previously, the variable @code{vhdl-offsets-alist} is an
association list between syntactic symbols and the offsets to be applied
for those symbols.  In fact, these offset values can be an integer, a
function or variable name, or one of the following symbols: @code{+},
@code{-}, @code{++}, @code{--}, @code{*}, or @code{/}.  The symbol
values have the following meanings:
X
@itemize @bullet
X
@item
@code{+}  --  1 x @code{vhdl-basic-offset}
@item
@code{-}  --  -1 x @code{vhdl-basic-offset}
@item
@code{++} --  2 x @code{vhdl-basic-offset}
@item
@code{--} --  -2 x @code{vhdl-basic-offset}
@item
@code{*}  --  0.5 x @code{vhdl-basic-offset}
@item
@code{/}  --  -0.5 x @code{vhdl-basic-offset}
X
@end itemize
X
@noindent
So, for example, because most of the default offsets are defined in
terms of @code{+}, @code{-}, and @code{0}, if you like the general
indentation style, but you use 2 spaces instead of 4 spaces per level,
you can probably achieve your style just by changing
@code{vhdl-basic-offset} like so (in your @file{.emacs} file):
@example
X
(setq vhdl-basic-offset 2)
X
@end example
X
To change indentation styles more radically, you will want to change the
value associated with the syntactic symbols in the
@code{vhdl-offsets-alist} variable.  First, I'll show you how to do that
interactively, then I'll describe how to make changes to your
@file{.emacs} file so that your changes are more permanent.
X
@menu
* Interactive Customization::
* Permanent Customization::
* Styles::
* Advanced Customizations::
@end menu
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Interactive Customization, Permanent Customization, , Customizing Indentation
@comment  node-name,              next,                    previous,up
X
@section  Interactive Customization
@cindex   Interactive Customization
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
As an example of how to customize indentation, let's change the
style of the example above from:
@example
@group
X
X  1: inverter : process
X  2: begin
X  3:   q <= not d;
X  4:   wait on d;
X  5: end inverter;
X
@end group
@end example
@noindent
to:
@example
@group
X
X  1: inverter : process
X  2: begin
X  3:     q <= not d;
X  4:     wait on d;
X  5: end inverter;
X
@end group
@end example
X
In other words, we want to change the indentation of the statments
inside the inverter process.  Notice that the construct we want to
change starts on line 3.  To change the indentation of a line, we need
to see which syntactic component affect the offset calculations for that
line.  Hitting @kbd{C-c C-s} on line 3 yields:
@example
X
((statement-block-intro . 20))
X
@end example
X
@findex vhdl-set-offset
@findex set-offset (vhdl-)
@kindex C-c C-o
@noindent
So we know that to change the offset of the first signal assignment, we need to
change the indentation for the @code{statement-block-intro} syntactic
symbol.  To do this interactively, just hit @kbd{C-c C-o}
(@code{vhdl-set-offset}).  This prompts you for the syntactic symbol to
change, providing a reasonable default.  In this case, the default is
@code{statement-block-intro}, which is just the syntactic symbol we want to
change!
X
After you hit return, @code{vhdl-mode} will then prompt you for the new
offset value, with the old value as the default.  The default in this
case is @samp{+}, so hit backspace to delete the @samp{+}, then hit
@samp{++} and @kbd{RET}.  This will associate an offset of twice the
basic indent with the syntactic symbol @code{statement-block-intro} in
the @code{vhdl-offsets-alist} variable.
X
@findex vhdl-indent-defun
@findex indent-defun (vhdl-)
@kindex C-c C-q
To check your changes quickly, just hit @kbd{C-c C-q}
(@code{vhdl-indent-defun}) to reindent the entire function.  The example
should now look like:
@example
@group
X
X  1: inverter : process
X  2: begin
X  3:     q <= not d;
X  4:     wait on d;
X  5: end inverter;
X
@end group
@end example
X
Notice how just changing the offset on line 3 is all we needed to do.
Since the other affected lines are indented relative to line 3, they are
automatically indented the way you'd expect.  For more complicated
examples, this may not always work.  The general approach to take is to
always start adjusting offsets for lines higher up in the file, then
re-indent and see if any following lines need further adjustments.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Permanent Customization, Styles, Interactive Customization, Customizing Indentation
@comment  node-name,              next,                    previous,up
X
@section  Permanent Indentation
@cindex   Permanent Indentation
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@vindex vhdl-mode-hook
@cindex hooks
To make this change permanent, you need to add some lisp code to your
@file{.emacs} file.  @code{vhdl-mode} provides a @code{vhdl-mode-hook}
that you can use to customize your language editing styles.  This hook
gets run as the last thing when you enter @code{vhdl-mode}.
X
Here's a simplified example of what you can add to your @file{.emacs}
file to make the changes described in the previous section
(@ref{Interactive Customization}) more permanent.  See the Emacs
manuals for more information on customizing Emacs via hooks.
@xref{Sample .emacs File} for a more complete sample @file{.emacs} file.
@footnote{The use of @code{add-hook} in this example only works for
Emacs 19.  Workarounds are available if you are using Emacs 18, but this
just points out another reason for you to upgrade to Emacs 19!
@code{:-)}}
@example
@group
X
(defun my-vhdl-mode-hook ()
X  ;; my customizations for all of vhdl-mode
X  (vhdl-set-offset 'statement-block-intro '++)
X  ;; other customizations can go here
X  )
(add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
X
@end group
@end example
X
For complex customizations, you will probably want to set up a
@emph{style} that groups all your customizations under a single
name. @xref{Styles} for details.
X
The offset value can also be a function, and this is how power users
gain enormous flexibility in customizing indentation. @xref{Advanced
Customizations} for details.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Styles, Advanced Customizations, Permanent Customization, Customizing Indentation
@comment  node-name,              next,                    previous,up
X
@section  Styles
@cindex   Styles
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
Most people only need to edit code formatted in just a few well-defined
and consistent styles.  For example, their organization might impose a
``blessed'' style that all its programmers must conform to.  Similarly,
people who work on GNU software will have to use the GNU coding style on
C code.  Some shops are more lenient, allowing some variety of coding
styles, and as programmers come and go, there could be a number of
styles in use.  For this reason, @code{vhdl-mode} makes it convenient for
you to set up logical groupings of customizations called @dfn{styles},
associate a single name for any particular style, and pretty easily
start editing new or existing code using these styles.  This chapter
describes how to set up styles and how to edit your C code using styles.
X
@menu
* Built-in Styles::
* Adding Styles::
* File Styles::
@end menu
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Built-in Styles, Adding Styles, , Styles
@comment  node-name,              next,                    previous,up
X
@subsection  Built-in Styles
@cindex   Built-in Styles
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
If you're lucky, one of @code{vhdl-mode}'s built-in styles might be just
what you're looking for.  Some of the most common VHDL styles are
already built-in.  These include:
X
@itemize @bullet
@item
@cindex IEEE style
@code{GNU} -- the coding style in the IEEE Language Reference Manual.
X
@end itemize
X
@findex vhdl-set-style
@findex set-style (vhdl-)
If you'd like to experiment with these built-in styles you can simply
type the following in a @code{vhdl-mode} buffer:
@example
@group
X
@kbd{M-x vhdl-set-style RET}.
X
@end group
@end example
@noindent
You will be prompted for one of the above styles (with completion).
Enter one of the styles and hit @kbd{RET}.  Note however that setting a
style in this way does @emph{not} automatically re-indent your file.
For commands that you can use to view the effect of your changes, see
@ref{Indentation Commands}.
X
Once you find a built-in style you like, you can make the change
permanent by adding a call to your @file{.emacs} file.  Let's say for
example that you want to use the @code{IEEE} style in all your
files.  You would add this:
@example
@group
X
(defun my-vhdl-mode-hook ()
X  ;; use IEEE style for all VHDL code
X  (vhdl-set-style "IEEE")
X  ;; other customizations can go here
X  )
(add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
X
@end group
@end example
X
@noindent
@xref{Permanent Customization}.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Adding Styles, File Styles, Built-in Styles, Styles
@comment  node-name,              next,                    previous,up
X
@subsection  Adding Styles
@cindex   Adding Styles
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@vindex vhdl-style-alist
@vindex style-alist (vhdl-)
@findex vhdl-add-style
@findex add-style (vhdl-)
If none of the built-in styles is appropriate, you'll probably want to
add a new style definition.  Styles are kept in the @code{vhdl-style-alist}
variable, but you probably won't want to modify this variable directly.
@code{vhdl-mode} provides a function, called @code{vhdl-add-style}, that you
can use to easily add new styles or update existing styles.  This
function takes two arguments, a @var{stylename} string, and an
association list @var{description} of style customizations.  If
@var{stylename} is not already in @code{vhdl-style-alist}, the new style is
added, otherwise the style already associated with @var{stylename} is
changed to the new @var{description}.  This function also takes an
optional third argument, which if non-@code{nil}, automatically
institutes the new style in the current buffer.
X
The sample @file{.emacs} file provides a concrete example of how a new
style can be added and automatically set.  @xref{Sample .emacs File}.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     File Styles, ,  Adding Styles, Styles
@comment  node-name,              next,                    previous,up
X
@subsection  File Styles
@cindex   File Styles
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@cindex local variables
The Emacs manual describes how you can customize certain variables on a
per-file basis by including a @dfn{Local Variable} block at the end of
the file.  So far, you've only seen a functional interface to
@code{vhdl-mode}, which is highly inconvenient for use in a Local Variable
block.  @code{vhdl-mode} provides two variables that make it easier for
you to customize your style on a per-file basis.
X
@vindex vhdl-file-style
@vindex file-style (vhdl-)
@vindex vhdl-file-offsets
@vindex file-offsets (vhdl-)
X
The variable @code{vhdl-file-style} can be set to a style name string as
described in @ref{Built-in Styles}.  When the file is visited,
@code{vhdl-mode} will automatically set the file's style to this style
using @code{vhdl-set-style}.
X
@vindex vhdl-offsets-alist
@vindex offsets-alist (vhdl-)
@findex vhdl-set-offset
@findex set-offset (vhdl-)
Another variable, @code{vhdl-file-offsets}, takes an association list
similar to what is allowed in @code{vhdl-offsets-alist}.  When the file is
visited, @code{vhdl-mode} will automatically institute these offets using
@code{vhdl-set-offset}.  @xref{Customizing Indentation}.
X
Note that file style settings (i.e. @code{vhdl-file-style}) are applied
before file offset settings (i.e. @code{vhdl-file-offsets}).
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Advanced Customizations, , Styles, Customizing Indentation
@comment  node-name,              next,                    previous,up
X
@section  Advanced Customizations
@cindex   Advanced Customizations
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@vindex vhdl-style-alist
@vindex style-alist (vhdl-)
@vindex vhdl-basic-offset
@vindex basic-offset (vhdl-)
For most users, @code{vhdl-mode} will support their coding styles with
very little need for customizations.  Usually, one of the standard
styles defined in @code{vhdl-style-alist} will do the trick.  Sometimes,
one of the syntactic symbol offsets will need to be tweeked slightly, or
perhaps @code{vhdl-basic-offset} will need to be changed.  However, some
styles require a more advanced ability for customization, and one of the
real strengths of @code{vhdl-mode} is that the syntactic analysis model
provides a very flexible framework for customizing indentation. This
allows you to perform special indentation calculations for situations
not handled by the mode directly.
X
@menu
* Custom Indentation Functions::
* Other Special Indentations::
@end menu
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Custom Indentation Functions, Other Special Indentations, , Advanced Customizations
@comment  node-name,              next,                    previous,up
X
@subsection  Custom Indentation Functions
@cindex   Custom Indentation Functions
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@cindex custom indentation functions
One of the most common ways to customize @code{vhdl-mode} is by writing
@dfn{custom indentation functions} and associating them with specific
syntactic symbols (see @ref{Syntactic Symbols}).  @code{vhdl-mode} itself
uses custom indentation functions to provide more sophisticated
indentation, for example when lining up selected signal assignments:
@example
@group
X
%%% TBD %%%
X
@end group
@end example
X
In this example, the @code{statement-cont} syntactic symbol has an
offset of @code{+}, and @code{vhdl-basic-offset} is 2, so lines 4
through 6 are simply indented two spaces to the right of line 3.  But
perhaps we'd like @code{vhdl-mode} to be a little more intelligent so
that it offsets the waveform descriptions relative to the signal
assignment operator in line 3.  To do this, we have to write a custom
indentation function which finds the column of signal assignment
operator on the first line of the statement.  Here is the lisp code
(from the @file{vhdl-mode.el} source file) that implements this:
@example
@group
X
(defun vhdl-lineup-statement-cont (langelem)
X  ;; line up statement-cont after the assignment operator
X  (save-excursion
X    (let* ((relpos (cdr langelem))
X	   (assignp (save-excursion
X		     (goto-char (vhdl-point 'boi))
X		     (and (re-search-forward "\\(<\\|:\\)="
X					     (vhdl-point 'eol) t)
X			  (- (point) (vhdl-point 'boi)))))
X	   (curcol (progn
X		     (goto-char relpos)
X		     (current-column)))
X	   foundp)
X      (while (and (not foundp)
X		  (< (point) (vhdl-point 'eol)))
X	(re-search-forward "\\(<\\|:\\)=\\|(" (vhdl-point 'eol) 'move)
X	(if (vhdl-in-literal (cdr langelem))
X	    (forward-char)
X	  (if (= (preceding-char) ?\()
X	      ;; skip over any parenthesized expressions
X	      (goto-char (min (vhdl-point 'eol)
X			      (scan-lists (point) 1 1)))
X	    ;; found an assignment operator (not at eol)
X	    (setq foundp (not (looking-at "\\s-*$"))))))
X      (if (not foundp)
X	  ;; there's no assignment operator on the line
X	  vhdl-basic-offset
X	;; calculate indentation column after assign and ws, unless
X	;; our line contains an assignment operator
X	(if (not assignp)
X	    (progn
X	      (forward-char)
X	      (skip-chars-forward " \t")
X	      (setq assignp 0)))
X	(- (current-column) assignp curcol))
X      )))
X
@end group
@end example
@noindent
Custom indent functions take a single argument, which is a syntactic
component cons cell (see @ref{Syntactic Analysis}).  The
function returns an integer offset value that will be added to the
running total indentation for the lne.  Note that what actually gets
returned is the difference between the column that the signal assignment
operator is on, and the column of the buffer relative position passed in
the function's argument.  Remember that @code{vhdl-mode} automatically
adds in the column of the component's relative buffer position and we
don't want that value added into the final total twice.
X
@cindex statement-cont syntactic symbol
@findex vhdl-lineup-statement-cont
@findex lineup-statement-cont (vhdl-)
Now, to associate the function @code{vhdl-lineup-statement-cont} with the
@code{statement-cont} syntactic symbol, we can add something like the
following to our @code{vhdl-mode-hook}:
@example
X
(vhdl-set-offset 'statement-cont 'vhdl-lineup-statement-cont)
X
@end example
X
@kindex C-c C-q
Now the function looks like this after re-indenting (using @kbd{C-c
C-q}):
@example
@group
X
%%% TBD %%%
X
@end group
@end example
X
@vindex vhdl-offsets-alist
@vindex offsets-alist (vhdl-)
Custom indentation functions can be as simple or as complex as you like,
and any syntactic symbol that appears in @code{vhdl-offsets-alist} can have
a custom indentation function associated with it.  Note however that
using many custom indentation functions may have a performance impact on
@code{vhdl-mode}.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node     Other Special Indentations, , Custom Indentation Functions, Advanced Customizations
@comment  node-name,              next,                    previous,up
X
@subsection  Other Special Indentations
@cindex   Other Special Indentations
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@vindex vhdl-special-indent-hook
@vindex special-indent-hook (vhdl-)
One other variable is available for you to customize @code{vhdl-mode}:
@code{vhdl-special-indent-hook}.  This is a standard hook variable that
is called after every line is indented by @code{vhdl-mode}.  You can use
it to do any special indentation or line adjustments your style
dictates, such as adding extra indentation to the port map clause in a
component instantiation, etc.  Note however, that you should not change
@code{point} or @code{mark} inside your @code{vhdl-special-indent-hook}
functions.
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Syntactic Symbols, Frequently Asked Questions, Customizing Indentation, Top
@comment  node-name,              next,                    previous,up
X
@chapter  Syntactic Symbols
@cindex   Syntactic Symbols
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@vindex vhdl-offsets-alist
The complete list of recognized syntactic symbols is described in the
@code{vhdl-offsets-alist} variable.  This chapter will provide some
examples to help clarify these symbols.
X
@cindex -open syntactic symbols
@cindex -close syntactic symbols
Most syntactic symbol names follow a general naming convention.  When a
line begins with a @code{begin} or @code{end} keyword, the syntactic
symbol will contain the suffix @code{-open} or @code{-close}
respectively.
X
@cindex -intro syntactic symbols
@cindex -cont syntactic symbols
@cindex -block-intro syntactic symbols
Usually, a distinction is made between the first line that introduces a
construct and lines that continue a construct, and the syntactic symbols
that represent these lines will contain the suffix @code{-intro} or
@code{-cont} respectively.  As a sub-classification of this scheme, a
line which is the first of a particular block construct will contain the
suffix @code{-block-intro}.
X
@strong{<TBD> include the name and a brief example of every syntactic
symbol currently recognized}
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Frequently Asked Questions, Getting the latest vhdl-mode release, Syntactic Symbols, Top
@comment  node-name,              next,                    previous,up
X
@chapter  Frequently Asked Questions
@cindex   Frequently Asked Questions
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@kindex C-x h
@kindex ESC C-\
@kindex C-c C-q
@kindex ESC C-q
@kindex ESC C-u
@kindex RET
@kindex LFD
@findex newline-and-indent
@quotation
X
@strong{Q.} @emph{How do I re-indent the whole file?}
X
@strong{A.} Visit the file and hit @kbd{C-x h} to mark the whole
buffer. Then hit @kbd{@key{ESC} C-\} to re-indent the entire region
which you've just marked.
@sp 2
X
@strong{Q.} @emph{How do I re-indent the entire function?}
X
@strong{A.} Hit @kbd{@key{ESC} C-h} to mark the entire function. Then
hit @kbd{@key{ESC} C-\} to re-indent the entire region which you've just
marked.
@sp 2
X
@strong{Q.} @emph{How do I re-indent the current block?}
X
@strong{A.} First move to the brace which opens the block with
@kbd{@key{ESC} C-u}, then re-indent that expression with
@kbd{@key{ESC} C-q}.
@sp 2
X
@strong{Q.} @emph{How do I re-indent the current statement?}
X
@strong{A.} First move to the beginning of the statement with
@kbd{@key{ESC} a}, then re-indent that expression with @kbd{@key{ESC}
C-q}.
@sp 2
X
@strong{Q.} @emph{Why doesn't the @key{RET} key indent the line to
where the new text should go after inserting the newline?}
X
@strong{A.} Emacs' convention is that @key{RET} just adds a newline,
and that @key{LFD} adds a newline and indents it.  You can make
@key{RET} do this too by adding this to your
@code{vhdl-mode-hook} (see the sample @file{.emacs} file
@ref{Sample .emacs File}):
@example
X
(define-key vhdl-mode-map "\C-m" 'newline-and-indent)
X
@end example
X
This is a very common question. @code{:-)} If you want this to be the
default behavior, don't lobby me, lobby RMS!
@sp 2
X
@strong{Q.} @emph{I put @code{(vhdl-set-offset 'statement-cont 0)}
in my @file{.emacs} file but I get an error saying that
@code{vhdl-set-offset}'s function definition is void.}
X
@strong{A.} This means that @code{vhdl-mode} wasn't loaded into your
Emacs session by the time the @code{vhdl-set-offset} call was reached,
mostly likely because @code{vhdl-mode} is being autoloaded.  Instead
of putting the @code{vhdl-set-offset} line in your top-level
@file{.emacs} file, put it in your @code{vhdl-mode-hook}, or
simply add the following to the top of your @file{.emacs} file:
@example
X
(require 'vhdl-mode)
X
@end example
X
See the sample @file{.emacs} file @ref{Sample .emacs File} for
details.
X
@end quotation
X
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Getting the latest vhdl-mode release, Sample .emacs File, Frequently Asked Questions, Top
@comment  node-name,              next,                    previous,up
X
@chapter  Getting the latest @code{vhdl-mode} release
@cindex   Getting the latest @code{vhdl-mode} release
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
The best way to be sure you always have the latest @code{vhdl-mode}
release is to join the @code{vhdl-mode-announce} mailing list.  If you
are a brave soul, and wish to participate in beta testing of new
releases of @code{vhdl-mode}, you may also join the
@code{vhdl-mode-victims} mailing list.  Send email to the author to join
either of these lists.
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Sample .emacs File, Requirements, Getting the latest vhdl-mode release, Top
@comment  node-name,              next,                    previous,up
X
@chapter  Sample @file{.emacs} file
@cindex   Sample @file{.emacs} file
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@example
;; Here's a sample .emacs file that might help you along the way.  Just
;; copy this region and paste it into your .emacs file.  You may want to
;; change some of the actual values.
X
(defconst my-vhdl-style
X  '((vhdl-tab-always-indent        . t)
X    (vhdl-comment-only-line-offset . 4)
X    (vhdl-offsets-alist            . ((arglist-close    . vhdl-lineup-arglist)
X                                      (statement-cont   . 0)
X                                      (case-alternative . 4)
X                                      (block-open       . 0)))
X    (vhdl-echo-syntactic-information-p . t)
X    )
X  "My VHDL Programming Style")
X
;; Customizations for vhdl-mode
(defun my-vhdl-mode-hook ()
X  ;; add my personal style and set it for the current buffer
X  (vhdl-add-style "PERSONAL" my-vhdl-style t)
X  ;; offset customizations not in my-vhdl-style
X  (vhdl-set-offset 'statement-case-intro '++)
X  ;; other customizations
X  (setq tab-width 8
X        ;; this will make sure spaces are used instead of tabs
X        indent-tabs-mode nil)
X  ;; keybindings for VHDL are put in vhdl-mode-map
X  (define-key vhdl-mode-map "\C-m" 'newline-and-indent)
X  )
X
;; the following only works in Emacs 19
;; Emacs 18ers can use (setq vhdl-mode-hook 'my-vhdl-mode-hook)
(add-hook 'vhdl-mode-hook 'my-vhdl-mode-hook)
@end example
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Requirements, Limitations and Known Bugs, Sample .emacs File, Top
@comment  node-name,              next,                    previous,up
@chapter  Requirements
@cindex   Requirements
@comment * Requirements
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@cindex reporter.el
@file{vhdl-mode.el} requires @file{reporter.el} for submission of bug
reports.  @file{reporter.el} is distributed with the latest FSF and
XXEmacs 19's.  Here is the Emacs Lisp Archive anonymous ftp'ing
record for those of you who are using older Emacsen.
X
@comment * Here's the Emacs Lisp Archive information for @file{reporter.el}:
@example
X
X         GNU Emacs Lisp Code Directory Apropos -- "reporter"
"~/" refers to archive.cis.ohio-state.edu:/pub/gnu/emacs/elisp-archive/
X
reporter (2.12)       06-Jul-1994
X     Barry A. Warsaw, <bwarsaw@@cen.com>
X     ~/misc/reporter.el.Z
X     Customizable bug reporting of lisp programs.
X
@end example
X
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node  Limitations and Known Bugs, Mailing Lists and Submitting Bug Reports, Requirements, Top
@comment  node-name,              next,                    previous,up
@chapter  Limitations and Known Bugs
@cindex   Limitations and Known Bugs
@comment * Limitations and Known Bugs
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@itemize @bullet
@item
Re-indenting large regions or expressions can be slow.
X
@item
Use with Emacs 18 can be slow and annoying. You should seriously
consider upgrading to Emacs 19.
X
@end itemize
X
@node  Mailing Lists and Submitting Bug Reports, Concept Index, Limitations and Known Bugs, Top
@comment  node-name,              next,                    previous,up
@chapter  Mailing Lists and Submitting Bug Reports
@cindex   Mailing Lists and Submitting Bug Reports
@comment * Mailing Lists and Submitting Bug Reports
X
@kindex C-c C-b
@findex vhdl-submit-bug-report
@findex submit-bug-report (vhdl-)
@cindex beta testers mailing list
@cindex announcement mailing list
To report bugs, use the @kbd{C-c C-b} (@code{vhdl-submit-bug-report})
command.  This provides vital information I need to reproduce your
problem.  Make sure you include a concise, but complete code example.
Please try to boil your example down to just the essential code needed
to reproduce the problem, and include an exact recipe of steps needed to
expose the bug.  Be especially sure to include any code that appears
@emph{before} your bug example.
X
For other help or suggestions, send a message to
@code{rwhitby@@asc.corp.mot.com}.
X
Send an add message to @code{rwhitby@@asc.corp.mot.com} to get on the
@code{vhdl-mode-victims} beta testers list where beta releases of
@code{vhdl-mode} are posted.  Note that you shouldn't expect beta
releases to be as stable as public releases.
X
There is also an announce only list where the latest public releases of
@code{vhdl-mode} are posted.  Send an add message to
@code{rwhitby@@asc.corp.mot.com} to be added to this list.
X
@c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node    Concept Index, Command Index,  Mailing Lists and Submitting Bug Reports, Top
@comment node-name,    next,  previous,      up
@unnumbered Concept Index
@c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@printindex cp
X
X
@c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node    Command Index, Key Index,  Concept Index, Top
@comment node-name,    next,  previous,      up
@unnumbered Command Index
@c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@ifinfo
X
@end ifinfo
Since all @code{vhdl-mode} commands are prepended with the string
@samp{vhdl-}, each appears under its @code{vhdl-<thing>} name and its
@code{<thing> (vhdl-)} name.
@iftex
@sp 2
@end iftex
@printindex fn
X
X
@c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node    Key Index, Variable Index,  Command Index, Top
@comment node-name,    next,  previous,      up
@unnumbered Key Index
@c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@printindex ky
X
X
@c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@node    Variable Index,    ,  Key Index, Top
@comment node-name,    next,  previous,      up
@unnumbered Variable Index
@c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
X
@ifinfo
X
@end ifinfo
Since all @code{vhdl-mode} variables are prepended with the string
@samp{vhdl-}, each appears under its @code{vhdl-<thing>} name and its
@code{<thing> (vhdl-)} name.
@iftex
@sp 2
@end iftex
@printindex vr
@summarycontents
@contents
@bye
SHAR_EOF
  $shar_touch -am 0913095795 'vhdl-mode.texi' &&
  chmod 0444 'vhdl-mode.texi' ||
  echo 'restore of vhdl-mode.texi failed'
  shar_count="`wc -c < 'vhdl-mode.texi'`"
  test 46573 -eq "$shar_count" ||
    echo "vhdl-mode.texi: original size 46573, current size $shar_count"
fi
exit 0
-- 
-- Rod Whitby -- (rwhitby@asc.corp.mot.com, A11375@email.mot.com) _--_|\ 
-- Motorola Australian Software Centre, HW/SW Codesign Programme / MASC \
-- 2 Second Avenue, Technology Park, Adelaide SA 5095, Australia \_.-*._/
-- Phone: +61 8 203 3526, Fax: +61 8 203 3501, Timezone: GMT+9:30      v 
Technical Details
Message-ID: <RWHITBY.95Sep28171135@wattle.asc.corp.mot.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 107729,3378754dd88335f4,start
X-Google-Attributes: gid107729,public
X-Google-Thread: 1089ad,3378754dd88335f4,start
X-Google-Attributes: gid1089ad,public
From: rwhitby@asc.corp.mot.com (Rod Whitby)
Subject: Emacs VHDL editing mode (vhdl-mode.el version 2.71)
Date: 1995/09/28
Message-ID: <RWHITBY.95Sep28171135@wattle.asc.corp.mot.com>
X-Deja-AN: 110926415
sender: news@schbbs.mot.com (SCHBBS News Account)
organization: Motorola Australian Software Centre
newsgroups: comp.lang.vhdl,gnu.emacs.sources
originator: rwhitby@wattle.asc.corp.mot.com