annotate lisp/modes/vhdl-mode.el @ 157:6b37e6ddd302 r20-3b5

Import from CVS: tag r20-3b5
author cvs
date Mon, 13 Aug 2007 09:40:41 +0200
parents 43dd3413c7c7
children 28f395d8dc7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1 ;;; vhdl-mode.el --- major mode for editing VHDL code
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994, 1995 Rodney J. Whitby
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
4 ;; Copyright (C) 1992, 1993, 1994 Barry A. Warsaw
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
5 ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
6
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
7 ;; Author: Rodney J. Whitby <rwhitby@asc.corp.mot.com>
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
8 ;; Maintainer: Rodney J. Whitby <rwhitby@asc.corp.mot.com>
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
9 ;; Created: June 1994, adapted from cc-mode.el 4.29 by Barry A. Warsaw.
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
10 ;; Version: $Revision: 1.4 $
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
11 ;; Last Modified: $Date: 1997/06/06 00:57:20 $
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
12 ;; Keywords: languages VHDL
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
13 ;; Archive: ftp.eda.com.au:/pub/emacs/vhdl-mode.tar.gz
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
14
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
15 ;; NOTE: Read the commentary below for the right way to submit bug reports!
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
16
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
17 ;; This file is not yet part of GNU Emacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
18
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
19 ;; GNU Emacs is free software; you can redistribute it and/or modify
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
20 ;; it under the terms of the GNU General Public License as published by
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
21 ;; the Free Software Foundation; either version 2, or (at your option)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
22 ;; any later version.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
23
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
24 ;; GNU Emacs is distributed in the hope that it will be useful,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
25 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
26 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
27 ;; GNU General Public License for more details.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
28
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
29 ;; You should have received a copy of the GNU General Public License
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
30 ;; along with GNU Emacs; see the file COPYING. If not, write to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
31 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
32
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
33 ;;; Commentary:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
34
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
35 ;; This package provides indentation support for VHDL code.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
36
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
37 ;; Details on VHDL-MODE are now contained in an accompanying texinfo
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
38 ;; manual (vhdl-mode.texi).
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
39
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
40 ;; To submit bug reports, hit "C-c C-b", and please try to include a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
41 ;; code sample so I can reproduce your problem. If you have other
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
42 ;; questions contact me at the address listed at the top of this file.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
43
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
44 ;; YOU CAN IGNORE ALL BYTE-COMPILER WARNINGS. They are the result of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
45 ;; the multi-Emacsen support. FSF Emacs 19 and XEmacs 19 (formerly
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
46 ;; Lucid) do things differently and there's no way to shut the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
47 ;; byte-compiler up at the necessary granularity. Let me say this
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
48 ;; again: YOU CAN IGNORE ALL BYTE-COMPILER WARNINGS (you'd be
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
49 ;; surprised at how many people don't follow this advice :-).
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
50
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
51 ;; To use VHDL-MODE, add the following to your .emacs file. This
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
52 ;; assumes you will use .vhd extensions for your VHDL source:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
53 ;;
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
54 ;; (autoload 'vhdl-mode "vhdl-mode" "VHDL Editing Mode" t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
55 ;; (setq auto-mode-alist
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
56 ;; (append '(("\\.vhd$" . vhdl-mode) ; to edit VHDL code
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
57 ;; ) auto-mode-alist))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
58 ;;
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
59 ;; If you would like to join the `vhdl-mode-announce' announcements
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
60 ;; list or the `vhdl-mode-victims' beta testers list, send add/drop
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
61 ;; requests to the address listed at the top of this file.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
62 ;;
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
63 ;; Many, many thanks go out to all the folks on the beta test list.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
64 ;; Without their patience, testing, insight, and code contributions,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
65 ;; and encouragement vhdl-mode.el would be a far inferior package.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
66 ;; Special thanks to Ken Wood <ken@eda.com.au> for providing an FTP
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
67 ;; repository for vhdl-mode.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
68
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
69 ;; LCD Archive Entry:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
70 ;; vhdl-mode.el|Rodney J. Whitby|rwhitby@asc.corp.mot.com
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
71 ;; |Major mode for editing VHDL code
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
72 ;; |$Date: 1997/06/06 00:57:20 $|$Revision: 1.4 $
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
73 ;; |ftp.eda.com.au:/pub/emacs/vhdl-mode.tar.gz
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
74
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
75
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
76 ;;; Code:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
77
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
78 ;; user definable variables
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
79 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
80
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
81 (defvar vhdl-inhibit-startup-warnings-p nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
82 "*If non-nil, inhibits start up compatibility warnings.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
83 (defvar vhdl-strict-syntax-p nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
84 "*If non-nil, all syntactic symbols must be found in `vhdl-offsets-alist'.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
85 If the syntactic symbol for a particular line does not match a symbol
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
86 in the offsets alist, an error is generated, otherwise no error is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
87 reported and the syntactic symbol is ignored.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
88 (defvar vhdl-echo-syntactic-information-p nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
89 "*If non-nil, syntactic info is echoed when the line is indented.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
90 (defvar vhdl-basic-offset 2
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
91 "*Amount of basic offset used by + and - symbols in `vhdl-offsets-alist'.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
92
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
93 (defconst vhdl-offsets-alist-default
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
94 '((string . -1000)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
95 (block-open . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
96 (block-close . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
97 (statement . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
98 (statement-cont . vhdl-lineup-statement-cont)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
99 (statement-block-intro . +)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
100 (statement-case-intro . +)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
101 (case-alternative . +)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
102 (comment . vhdl-lineup-comment)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
103 (arglist-intro . vhdl-lineup-arglist-intro)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
104 (arglist-cont . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
105 (arglist-cont-nonempty . vhdl-lineup-arglist)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
106 (arglist-close . vhdl-lineup-arglist)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
107 (entity . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
108 (configuration . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
109 (package . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
110 (architecture . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
111 (package-body . 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
112 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
113 "Default settings for offsets of syntactic elements.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
114 Do not change this constant! See the variable `vhdl-offsets-alist' for
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
115 more information.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
116
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
117 (defvar vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
118 "*Association list of syntactic element symbols and indentation offsets.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
119 As described below, each cons cell in this list has the form:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
120
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
121 (SYNTACTIC-SYMBOL . OFFSET)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
122
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
123 When a line is indented, vhdl-mode first determines the syntactic
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
124 context of the line by generating a list of symbols called syntactic
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
125 elements. This list can contain more than one syntactic element and
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
126 the global variable `vhdl-syntactic-context' contains the context list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
127 for the line being indented. Each element in this list is actually a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
128 cons cell of the syntactic symbol and a buffer position. This buffer
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
129 position is call the relative indent point for the line. Some
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
130 syntactic symbols may not have a relative indent point associated with
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
131 them.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
132
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
133 After the syntactic context list for a line is generated, vhdl-mode
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
134 calculates the absolute indentation for the line by looking at each
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
135 syntactic element in the list. First, it compares the syntactic
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
136 element against the SYNTACTIC-SYMBOL's in `vhdl-offsets-alist'. When it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
137 finds a match, it adds the OFFSET to the column of the relative indent
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
138 point. The sum of this calculation for each element in the syntactic
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
139 list is the absolute offset for line being indented.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
140
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
141 If the syntactic element does not match any in the `vhdl-offsets-alist',
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
142 an error is generated if `vhdl-strict-syntax-p' is non-nil, otherwise
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
143 the element is ignored.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
144
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
145 Actually, OFFSET can be an integer, a function, a variable, or one of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
146 the following symbols: `+', `-', `++', or `--'. These latter
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
147 designate positive or negative multiples of `vhdl-basic-offset',
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
148 respectively: *1, *-1, *2, and *-2. If OFFSET is a function, it is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
149 called with a single argument containing the cons of the syntactic
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
150 element symbol and the relative indent point. The function should
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
151 return an integer offset.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
152
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
153 Here is the current list of valid syntactic element symbols:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
154
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
155 string -- inside multi-line string
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
156 block-open -- statement block open
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
157 block-close -- statement block close
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
158 statement -- a VHDL statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
159 statement-cont -- a continuation of a VHDL statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
160 statement-block-intro -- the first line in a new statement block
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
161 statement-case-intro -- the first line in a case alternative block
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
162 case-alternative -- a case statement alternative clause
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
163 comment -- a line containing only a comment
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
164 arglist-intro -- the first line in an argument list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
165 arglist-cont -- subsequent argument list lines when no
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
166 arguments follow on the same line as the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
167 the arglist opening paren
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
168 arglist-cont-nonempty -- subsequent argument list lines when at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
169 least one argument follows on the same
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
170 line as the arglist opening paren
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
171 arglist-close -- the solo close paren of an argument list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
172 entity -- inside an entity declaration
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
173 configuration -- inside a configuration declaration
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
174 package -- inside a package declaration
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
175 architecture -- inside an architecture body
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
176 package-body -- inside a package body
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
177 ")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
178
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
179 (defvar vhdl-tab-always-indent t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
180 "*Controls the operation of the TAB key.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
181 If t, hitting TAB always just indents the current line. If nil,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
182 hitting TAB indents the current line if point is at the left margin or
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
183 in the line's indentation, otherwise it insert a real tab character.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
184 If other than nil or t, then tab is inserted only within literals
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
185 -- defined as comments and strings -- and inside preprocessor
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
186 directives, but line is always reindented.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
187
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
188 Note that indentation of lines containing only comments is also
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
189 controlled by the `vhdl-comment-only-line-offset' variable.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
190
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
191 (defvar vhdl-comment-only-line-offset 0
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
192 "*Extra offset for line which contains only the start of a comment.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
193 Can contain an integer or a cons cell of the form:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
194
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
195 (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
196
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
197 Where NON-ANCHORED-OFFSET is the amount of offset given to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
198 non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
199 the amount of offset to give column-zero anchored comment-only lines.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
200 Just an integer as value is equivalent to (<val> . 0)")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
201
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
202 (defvar vhdl-special-indent-hook nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
203 "*Hook for user defined special indentation adjustments.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
204 This hook gets called after a line is indented by the mode.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
205
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
206 (defvar vhdl-style-alist
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
207 '(("IEEE"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
208 (vhdl-basic-offset . 4)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
209 (vhdl-offsets-alist . ())
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
210 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
211 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
212 "Styles of Indentation.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
213 Elements of this alist are of the form:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
214
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
215 (STYLE-STRING (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
216
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
217 where STYLE-STRING is a short descriptive string used to select a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
218 style, VARIABLE is any vhdl-mode variable, and VALUE is the intended
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
219 value for that variable when using the selected style.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
220
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
221 There is one special case when VARIABLE is `vhdl-offsets-alist'. In this
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
222 case, the VALUE is a list containing elements of the form:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
223
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
224 (SYNTACTIC-SYMBOL . VALUE)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
225
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
226 as described in `vhdl-offsets-alist'. These are passed directly to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
227 `vhdl-set-offset' so there is no need to set every syntactic symbol in
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
228 your style, only those that are different from the default.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
229
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
230 ;; dynamically append the default value of most variables
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
231 (or (assoc "Default" vhdl-style-alist)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
232 (let* ((varlist '(vhdl-inhibit-startup-warnings-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
233 vhdl-strict-syntax-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
234 vhdl-echo-syntactic-information-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
235 vhdl-basic-offset
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
236 vhdl-offsets-alist
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
237 vhdl-tab-always-indent
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
238 vhdl-comment-only-line-offset))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
239 (default (cons "Default"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
240 (mapcar
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
241 (function
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
242 (lambda (var)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
243 (cons var (symbol-value var))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
244 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
245 varlist))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
246 (setq vhdl-style-alist (cons default vhdl-style-alist))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
247
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
248 (defvar vhdl-mode-hook nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
249 "*Hook called by `vhdl-mode'.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
250
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
251 (defvar vhdl-mode-menu
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
252 '(["Comment Out Region" comment-region (mark)]
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
253 ;; ["Indent Expression" vhdl-indent-exp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
254 ;; (memq (following-char) '(?\( ?\[ ?\{))]
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
255 ["Indent Line" vhdl-indent-command t]
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
256 ["Backward Statement" vhdl-beginning-of-statement t]
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
257 ;; ["Forward Statement" vhdl-end-of-statement t]
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
258 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
259 "XEmacs 19 (formerly Lucid) menu for VHDL mode.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
260
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
261 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
262 ;; NO USER DEFINABLE VARIABLES BEYOND THIS POINT
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
263
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
264
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
265 ;; Emacs variant handling, and standard mode variables and functions:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
266
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
267 (defconst vhdl-emacs-features
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
268 (let ((major (and (boundp 'emacs-major-version)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
269 emacs-major-version))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
270 (minor (and (boundp 'emacs-minor-version)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
271 emacs-minor-version))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
272 flavor)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
273 ;; figure out version numbers if not already discovered
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
274 (and (or (not major) (not minor))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
275 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
276 (setq major (string-to-int (substring emacs-version
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
277 (match-beginning 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
278 (match-end 1)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
279 minor (string-to-int (substring emacs-version
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
280 (match-beginning 2)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
281 (match-end 2)))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
282 (if (not (and major minor))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
283 (error "Cannot figure out the major and minor version numbers."))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
284 ;; calculate the major version
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
285 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
286 ((= major 18) (setq major 'v18)) ;Emacs 18
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
287 ((= major 4) (setq major 'v18)) ;Epoch 4
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
288 ((>= major 19) (setq major 'v19 ;Emacs 19
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
289 flavor (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
290 ((string-match "Win-Emacs" emacs-version)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
291 'Win-Emacs)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
292 ((or (string-match "Lucid" emacs-version)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
293 (string-match "XEmacs" emacs-version))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
294 'XEmacs)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
295 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
296 'FSF))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
297 ;; I don't know
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
298 (t (error "Cannot recognize major version number: %s" major)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
299 ;; lets do some minimal sanity checking.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
300 (if (and (or
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
301 ;; Emacs 18 is brain dead
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
302 (eq major 'v18)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
303 ;; Lemacs before 19.6 had bugs
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
304 (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
305 ;; FSF 19 before 19.21 had bugs
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
306 (and (eq major 'v19) (eq flavor 'FSF) (< minor 21)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
307 (not vhdl-inhibit-startup-warnings-p))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
308 (with-output-to-temp-buffer "*vhdl-mode warnings*"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
309 (print (format
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
310 "The version of Emacs that you are running, %s,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
311 has known bugs in its syntax.c parsing routines which will affect the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
312 performance of vhdl-mode. You should strongly consider upgrading to the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
313 latest available version. vhdl-mode may continue to work, after a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
314 fashion, but strange indentation errors could be encountered."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
315 emacs-version))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
316 (list major flavor))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
317 "A list of features extant in the Emacs you are using.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
318 There are many flavors of Emacs out there, each with different
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
319 features supporting those needed by vhdl-mode. Here's the current
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
320 supported list, along with the values for this variable:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
321
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
322 Emacs 18/Epoch 4: (v18)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
323 XEmacs (formerly Lucid) 19: (v19 XEmacs)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
324 Win-Emacs 1.35: (V19 Win-Emacs)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
325 FSF Emacs 19: (v19 FSF).")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
326
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
327 (defvar vhdl-mode-abbrev-table nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
328 "Abbrev table in use in vhdl-mode buffers.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
329 (define-abbrev-table 'vhdl-mode-abbrev-table ())
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
330
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
331 (defvar vhdl-mode-map ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
332 "Keymap used in vhdl-mode buffers.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
333 (if vhdl-mode-map
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
334 ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
335 ;; TBD: should we even worry about naming this keymap. My vote: no,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
336 ;; because FSF and XEmacs (formerly Lucid) do it differently.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
337 (setq vhdl-mode-map (make-sparse-keymap))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
338 ;; put standard keybindings into MAP
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
339 (define-key vhdl-mode-map "\M-a" 'vhdl-beginning-of-statement)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
340 ;;(define-key vhdl-mode-map "\M-e" 'vhdl-end-of-statement)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
341 (define-key vhdl-mode-map "\M-\C-f" 'vhdl-forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
342 (define-key vhdl-mode-map "\M-\C-b" 'vhdl-backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
343 (define-key vhdl-mode-map "\M-\C-u" 'vhdl-backward-up-list)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
344 ;;(define-key vhdl-mode-map "\M-\C-d" 'vhdl-down-list)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
345 (define-key vhdl-mode-map "\M-\C-a" 'vhdl-beginning-of-defun)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
346 (define-key vhdl-mode-map "\M-\C-e" 'vhdl-end-of-defun)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
347 (define-key vhdl-mode-map "\M-\C-h" 'vhdl-mark-defun)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
348 (define-key vhdl-mode-map "\M-\C-q" 'vhdl-indent-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
349 (define-key vhdl-mode-map "\t" 'vhdl-indent-command)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 108
diff changeset
350 ;; GDF - leave the DEL key alone!
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 108
diff changeset
351 ;; (define-key vhdl-mode-map "\177" 'backward-delete-char-untabify)
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
352 ;; these are new keybindings, with no counterpart to BOCM
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
353 (define-key vhdl-mode-map "\C-c\C-b" 'vhdl-submit-bug-report)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
354 (define-key vhdl-mode-map "\C-c\C-c" 'comment-region)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
355 (define-key vhdl-mode-map "\C-c\C-o" 'vhdl-set-offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
356 (define-key vhdl-mode-map "\C-c\C-r" 'vhdl-regress-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
357 (define-key vhdl-mode-map "\C-c\C-s" 'vhdl-show-syntactic-information)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
358 (define-key vhdl-mode-map "\C-c\C-v" 'vhdl-version)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
359 ;; in XEmacs (formerly Lucid) 19, we want the menu to popup when
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
360 ;; the 3rd button is hit. In 19.10 and beyond this is done
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
361 ;; automatically if we put the menu on mode-popup-menu variable,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
362 ;; see c-common-init. RMS decided that this feature should not be
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
363 ;; included for FSF's Emacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
364 (if (and (boundp 'current-menubar)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
365 (not (boundp 'mode-popup-menu)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
366 (define-key vhdl-mode-map 'button3 'vhdl-popup-menu))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
367 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
368
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
369 (defvar vhdl-mode-syntax-table nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
370 "Syntax table used in vhdl-mode buffers.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
371 (if vhdl-mode-syntax-table
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
372 ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
373 (setq vhdl-mode-syntax-table (make-syntax-table))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
374 ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
375 (modify-syntax-entry ?\" "\"" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
376 (modify-syntax-entry ?\$ "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
377 (modify-syntax-entry ?\% "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
378 (modify-syntax-entry ?\& "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
379 (modify-syntax-entry ?\' "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
380 (modify-syntax-entry ?\( "()" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
381 (modify-syntax-entry ?\) ")(" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
382 (modify-syntax-entry ?\* "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
383 (modify-syntax-entry ?\+ "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
384 (modify-syntax-entry ?\. "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
385 (modify-syntax-entry ?\/ "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
386 (modify-syntax-entry ?\: "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
387 (modify-syntax-entry ?\; "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
388 (modify-syntax-entry ?\< "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
389 (modify-syntax-entry ?\= "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
390 (modify-syntax-entry ?\> "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
391 (modify-syntax-entry ?\[ "(]" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
392 (modify-syntax-entry ?\\ "\\" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
393 (modify-syntax-entry ?\] ")[" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
394 (modify-syntax-entry ?\{ "(}" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
395 (modify-syntax-entry ?\| "." vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
396 (modify-syntax-entry ?\} "){" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
397 ;; add comment syntax
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
398 (modify-syntax-entry ?\- ". 12" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
399 (modify-syntax-entry ?\n ">" vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
400 (modify-syntax-entry ?\^M ">" vhdl-mode-syntax-table))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
401
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
402 (defvar vhdl-syntactic-context nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
403 "Buffer local variable containing syntactic analysis list.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
404 (make-variable-buffer-local 'vhdl-syntactic-context)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
405
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
406 ;; Support for outline modes
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
407
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
408 (defconst vhdl-outline-regexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
409 (concat "\\(entity\\)\\|\\(package\\)\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
410 "\\( *procedure\\)\\|\\( *function\\)\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
411 "\\( *component\\)\\|\\(architecture\\)\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
412 "\\(package body\\)\\|\\( *[A-Za-z][A-Za-z0-9_]* : block\\)\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
413 "\\( *[A-Za-z][A-Za-z0-9_]* : process\\)\\|\\(configuration\\)"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
414
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
415 (defun vhdl-outline-level () ; was copied from c-outline-level
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
416 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
417 (skip-chars-forward "\t ")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
418 (current-column)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
419
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
420 ;; Support for font-lock
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
421
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
422 (defconst vhdl-font-lock-keywords-1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
423 (purecopy
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
424 (list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
425 ;; Highlight names of common constructs
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
426 (list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
427 (concat
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
428 "^[ \t]*\\(entity\\|architecture\\|configuration\\|function\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
429 "procedure\\|component\\|package[ \t]+body\\|package\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
430 "end[ \t]+\\(block\\|process\\|case\\|generate\\|loop\\)\\)[ \t]+"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
431 "\\(\\(\\w\\|\\s_\\)+\\)")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
432 3 'font-lock-function-name-face)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
433
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
434 ;; Highlight labels of common constructs
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
435 (list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
436 (concat
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
437 "^[ \t]*\\(\\(\\w\\|\\s_\\)+\\)[ \t]*:[ \t\n]*\\(block\\|process\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
438 "if\\|for\\|case\\|exit\\|loop\\|next\\|null\\|with\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
439 "\\(\\w\\|\\s_\\)+[ \t\n]+port[ \t]+map\\)\\>[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
440 1 'font-lock-function-name-face)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
441
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
442 ;; Highlight OF labels
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
443 (list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
444 (concat
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
445 "^[ \t]*\\(configuration\\|architecture\\|attribute\\)[ \t]+"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
446 "\\(\\(\\w\\|\\s_\\)+\\)[ \t]+of[ \t]+\\(\\(\\w\\|\\s_\\)+\\)")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
447 4 'font-lock-function-name-face)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
448
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
449 ;; Fontify library useage clauses.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
450 (list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
451 (concat
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
452 "[^\\s_]\\<\\(library\\|use\\)[ \t\n]+\\(entity[ \t\n]+\\)?"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
453 "\\(\\(\\w\\|\\s_\\|[\.()]\\)+\\)")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
454 3 'font-lock-function-name-face)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
455 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
456 "For consideration as a value of `vhdl-font-lock-keywords'.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
457 This does fairly subdued highlighting of function names.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
458
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
459 (defconst vhdl-font-lock-keywords-2
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
460 (purecopy
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
461 (append
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
462 vhdl-font-lock-keywords-1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
463 (list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
464 (list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
465 (concat
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
466 "[^\\s_]\\<\\("
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
467 (mapconcat
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
468 'identity
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
469 '(
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
470 ;; the following is a list of all reserved words known in VHDL'93
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
471 "abs" "access" "after" "alias" "all" "and" "assert"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
472 "architecture" "array" "attribute"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
473 "begin" "block" "body" "buffer" "bus"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
474 "case" "component" "configuration" "constant"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
475 "disconnect" "downto"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
476 "else" "elsif" "end" "entity" "exit"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
477 "file" "for" "function"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
478 "generate" "generic" "group" "guarded"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
479 "if" "impure" "in" "inertial" "inout" "is"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
480 "label" "library" "linkage" "literal" "loop"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
481 "map" "mod"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
482 "nand" "new" "next" "nor" "not" "null"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
483 "of" "on" "open" "or" "others" "out"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
484 "package" "port" "postponed" "procedure" "process" "pure"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
485 "range" "record" "register" "reject" "rem" "report" "return"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
486 "rol" "ror"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
487 "select" "severity" "signal" "shared" "sla" "sll" "sra" "srl"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
488 "subtype"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
489 "then" "to" "transport" "type"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
490 "unaffected" "units" "until" "use"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
491 "variable" "wait" "when" "while" "with"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
492 "xnor" "xor"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
493 "note" "warning" "error" "failure"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
494 ;; the following list contains predefined attributes
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
495 "base" "left" "right" "high" "low" "pos" "val" "succ"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
496 "pred" "leftof" "rightof" "range" "reverse_range"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
497 "length" "delayed" "stable" "quiet" "transaction"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
498 "event" "active" "last_event" "last_active" "last_value"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
499 "driving" "driving_value" "ascending" "value" "image"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
500 "simple_name" "instance_name" "path_name"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
501 "foreign"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
502 ;; the following list contains standardized types
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
503 "boolean" "bit" "bit_vector" "character" "severity_level" "integer"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
504 "real" "time" "natural" "positive" "string" "text" "line"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
505 "unsigned" "signed"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
506 "std_logic" "std_logic_vector"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
507 "std_ulogic" "std_ulogic_vector"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
508 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
509 "\\|")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
510 "\\)\\>[^\\s_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
511 1 'font-lock-keyword-face)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
512 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
513 "For consideration as a value of `vhdl-font-lock-keywords'.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
514 This does a lot more highlighting.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
515
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
516 ;; The keywords in the preceding lists assume case-insensitivity.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
517 (put 'vhdl-mode 'font-lock-keywords-case-fold-search t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
518
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
519 (defvar vhdl-font-lock-keywords vhdl-font-lock-keywords-1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
520 "Additional expressions to highlight in VHDL mode.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
521
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
522 ;; This should eventually be subsumed into the respective functions in
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
523 ;; the source for "font-lock.el".
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
524 (if (featurep 'advice)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
525 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
526 (defadvice font-lock-use-default-minimal-decoration
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
527 (before vhdl-mode activate)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
528 "Do it for VHDL mode too."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
529 (setq vhdl-font-lock-keywords vhdl-font-lock-keywords-1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
530
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
531 (defadvice font-lock-use-default-maximal-decoration
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
532 (before vhdl-mode activate)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
533 "Do it for VHDL mode too."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
534 (setq vhdl-font-lock-keywords vhdl-font-lock-keywords-2))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
535 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
536
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
537
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
538 ;; Main entry point for VHDL mode:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
539
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
540 ;;;###autoload
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
541 (defun vhdl-mode ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
542 "Major mode for editing VHDL code.
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
543 vhdl-mode $Revision: 1.4 $
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
544 To submit a problem report, enter `\\[vhdl-submit-bug-report]' from a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
545 vhdl-mode buffer. This automatically sets up a mail buffer with version
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
546 information already added. You just need to add a description of the
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 72
diff changeset
547 problem, including a reproducible test case and send the message.
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
548
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
549 Note that the details of configuring vhdl-mode will soon be moved to the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
550 accompanying texinfo manual. Until then, please read the README file
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
551 that came with the vhdl-mode distribution.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
552
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
553 The hook variable `vhdl-mode-hook' is run with no args, if that value is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
554 bound and has a non-nil value.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
555
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
556 Key bindings:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
557 \\{vhdl-mode-map}"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
558 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
559 (kill-all-local-variables)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
560 (set-syntax-table vhdl-mode-syntax-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
561 (setq major-mode 'vhdl-mode
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
562 mode-name "VHDL"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
563 local-abbrev-table vhdl-mode-abbrev-table)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
564 (use-local-map vhdl-mode-map)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
565 ;; set local variable values
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
566 (set (make-local-variable 'paragraph-start) (concat "^$\\|" page-delimiter))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
567 (set (make-local-variable 'paragraph-separate) paragraph-start)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
568 (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
569 (set (make-local-variable 'require-final-newline) t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
570 (set (make-local-variable 'parse-sexp-ignore-comments) t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
571 (set (make-local-variable 'indent-line-function) 'vhdl-indent-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
572 (set (make-local-variable 'comment-start) "-- ")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
573 (set (make-local-variable 'comment-end) "")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
574 (set (make-local-variable 'comment-column) 32)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
575 (set (make-local-variable 'comment-start-skip) "--+ *")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
576 (set (make-local-variable 'outline-regexp) vhdl-outline-regexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
577 (set (make-local-variable 'outline-level) 'vhdl-outline-level)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
578
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
579 ;; setup the comment indent variable in a Emacs version portable way
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
580 ;; ignore any byte compiler warnings you might get here
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
581 (if (boundp 'comment-indent-function)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
582 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
583 (make-local-variable 'comment-indent-function)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
584 (setq comment-indent-function 'vhdl-comment-indent))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
585 (make-local-variable 'comment-indent-hook)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
586 (setq comment-indent-hook 'vhdl-comment-indent))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
587 ;; put VHDL menu into menubar and on popup menu for XEmacs (formerly
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
588 ;; Lucid) 19. I think this happens automatically for FSF Emacs 19.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
589 (if (and (boundp 'current-menubar)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
590 current-menubar
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
591 (not (assoc mode-name current-menubar)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
592 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
593 (set-buffer-menubar (copy-sequence current-menubar))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
594 (add-menu nil mode-name vhdl-mode-menu)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
595 (if (boundp 'mode-popup-menu)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
596 (setq mode-popup-menu
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
597 (cons (concat mode-name " Mode Commands") vhdl-mode-menu)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
598 (run-hooks 'vhdl-mode-hook))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
599
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
600 ;; menus for XEmacs (formerly Lucid)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
601
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
602 (defun vhdl-popup-menu (e)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
603 "Pops up the VHDL menu."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
604 (interactive "@e")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
605 (popup-menu (cons (concat mode-name " Mode Commands") vhdl-mode-menu))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
606 (vhdl-keep-region-active))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
607
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
608 ;; active regions
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
609
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
610 (defun vhdl-keep-region-active ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
611 ;; do whatever is necessary to keep the region active in XEmacs
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
612 ;; (formerly Lucid). ignore byte-compiler warnings you might see
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
613 (and (boundp 'zmacs-region-stays)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
614 (setq zmacs-region-stays t)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
615
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
616 ;; constant regular expressions for looking at various constructs
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
617
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
618 (defconst vhdl-symbol-key "\\(\\w\\|\\s_\\)+"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
619 "Regexp describing a VHDL symbol.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
620 We cannot use just `word' syntax class since `_' cannot be in word
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
621 class. Putting underscore in word class breaks forward word movement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
622 behavior that users are familiar with.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
623
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
624 (defconst vhdl-case-alternative-key "when[( \t\n][^;=>]+=>"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
625 "Regexp describing a case statement alternative key.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
626
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
627 (defconst vhdl-case-header-key "case[( \t\n][^;=>]+[) \t\n]is"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
628 "Regexp describing a case statement header key.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
629
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
630 (defconst vhdl-label-key
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
631 (concat vhdl-symbol-key "\\s-*:")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
632 "Regexp describing a VHDL label.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
633
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
634
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
635 ;; Macro definitions:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
636
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
637 (defmacro vhdl-point (position)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
638 ;; Returns the value of point at certain commonly referenced POSITIONs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
639 ;; POSITION can be one of the following symbols:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
640 ;;
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
641 ;; bol -- beginning of line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
642 ;; eol -- end of line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
643 ;; bod -- beginning of defun
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
644 ;; boi -- back to indentation
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
645 ;; eoi -- last whitespace on line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
646 ;; ionl -- indentation of next line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
647 ;; iopl -- indentation of previous line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
648 ;; bonl -- beginning of next line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
649 ;; bopl -- beginning of previous line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
650 ;;
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
651 ;; This function does not modify point or mark.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
652 (or (and (eq 'quote (car-safe position))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
653 (null (cdr (cdr position))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
654 (error "bad buffer position requested: %s" position))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
655 (setq position (nth 1 position))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
656 (` (let ((here (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
657 (,@ (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
658 ((eq position 'bol) '((beginning-of-line)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
659 ((eq position 'eol) '((end-of-line)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
660 ((eq position 'bod) '((save-match-data
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
661 (vhdl-beginning-of-defun))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
662 ((eq position 'boi) '((back-to-indentation)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
663 ((eq position 'eoi) '((end-of-line)(skip-chars-backward " \t")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
664 ((eq position 'bonl) '((forward-line 1)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
665 ((eq position 'bopl) '((forward-line -1)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
666 ((eq position 'iopl)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
667 '((forward-line -1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
668 (back-to-indentation)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
669 ((eq position 'ionl)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
670 '((forward-line 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
671 (back-to-indentation)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
672 (t (error "unknown buffer position requested: %s" position))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
673 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
674 (prog1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
675 (point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
676 (goto-char here))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
677 ;; workaround for an Emacs18 bug -- blech! Well, at least it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
678 ;; doesn't hurt for v19
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
679 (,@ nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
680 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
681
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
682 (defmacro vhdl-safe (&rest body)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
683 ;; safely execute BODY, return nil if an error occurred
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
684 (` (condition-case nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
685 (progn (,@ body))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
686 (error nil))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
687
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
688 (defmacro vhdl-add-syntax (symbol &optional relpos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
689 ;; a simple macro to append the syntax in symbol to the syntax list.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
690 ;; try to increase performance by using this macro
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
691 (` (setq vhdl-syntactic-context
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
692 (cons (cons (, symbol) (, relpos)) vhdl-syntactic-context))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
693
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
694 (defmacro vhdl-has-syntax (symbol)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
695 ;; a simple macro to return check the syntax list.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
696 ;; try to increase performance by using this macro
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
697 (` (assoc (, symbol) vhdl-syntactic-context)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
698
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
699
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
700 ;; Syntactic element offset manipulation:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
701
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
702 (defun vhdl-read-offset (langelem)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
703 ;; read new offset value for LANGELEM from minibuffer. return a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
704 ;; legal value only
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
705 (let ((oldoff (format "%s" (cdr-safe (assq langelem vhdl-offsets-alist))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
706 (errmsg "Offset must be int, func, var, or one of +, -, ++, --: ")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
707 (prompt "Offset: ")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
708 offset input interned)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
709 (while (not offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
710 (setq input (read-string prompt oldoff)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
711 offset (cond ((string-equal "+" input) '+)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
712 ((string-equal "-" input) '-)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
713 ((string-equal "++" input) '++)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
714 ((string-equal "--" input) '--)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
715 ((string-match "^-?[0-9]+$" input)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
716 (string-to-int input))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
717 ((fboundp (setq interned (intern input)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
718 interned)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
719 ((boundp interned) interned)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
720 ;; error, but don't signal one, keep trying
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
721 ;; to read an input value
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
722 (t (ding)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
723 (setq prompt errmsg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
724 nil))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
725 offset))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
726
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
727 (defun vhdl-set-offset (symbol offset &optional add-p)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
728 "Change the value of a syntactic element symbol in `vhdl-offsets-alist'.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
729 SYMBOL is the syntactic element symbol to change and OFFSET is the new
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
730 offset for that syntactic element. Optional ADD says to add SYMBOL to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
731 `vhdl-offsets-alist' if it doesn't already appear there."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
732 (interactive
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
733 (let* ((langelem
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
734 (intern (completing-read
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
735 (concat "Syntactic symbol to change"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
736 (if current-prefix-arg " or add" "")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
737 ": ")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
738 (mapcar
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
739 (function
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
740 (lambda (langelem)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
741 (cons (format "%s" (car langelem)) nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
742 vhdl-offsets-alist)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
743 nil (not current-prefix-arg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
744 ;; initial contents tries to be the last element
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
745 ;; on the syntactic analysis list for the current
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
746 ;; line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
747 (let* ((syntax (vhdl-get-syntactic-context))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
748 (len (length syntax))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
749 (ic (format "%s" (car (nth (1- len) syntax)))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
750 (if (memq 'v19 vhdl-emacs-features)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
751 (cons ic 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
752 ic))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
753 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
754 (offset (vhdl-read-offset langelem)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
755 (list langelem offset current-prefix-arg)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
756 ;; sanity check offset
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
757 (or (eq offset '+)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
758 (eq offset '-)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
759 (eq offset '++)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
760 (eq offset '--)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
761 (integerp offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
762 (fboundp offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
763 (boundp offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
764 (error "Offset must be int, func, var, or one of +, -, ++, --: %s"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
765 offset))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
766 (let ((entry (assq symbol vhdl-offsets-alist)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
767 (if entry
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
768 (setcdr entry offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
769 (if add-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
770 (setq vhdl-offsets-alist (cons (cons symbol offset) vhdl-offsets-alist))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
771 (error "%s is not a valid syntactic symbol." symbol))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
772 (vhdl-keep-region-active))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
773
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
774 (defun vhdl-set-style (style &optional local)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
775 "Set vhdl-mode variables to use one of several different indentation styles.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
776 STYLE is a string representing the desired style and optional LOCAL is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
777 a flag which, if non-nil, means to make the style variables being
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
778 changed buffer local, instead of the default, which is to set the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
779 global variables. Interactively, the flag comes from the prefix
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
780 argument. The styles are chosen from the `vhdl-style-alist' variable."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
781 (interactive (list (completing-read "Use which VHDL indentation style? "
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
782 vhdl-style-alist nil t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
783 current-prefix-arg))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
784 (let ((vars (cdr (assoc style vhdl-style-alist))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
785 (or vars
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
786 (error "Invalid VHDL indentation style `%s'" style))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
787 ;; set all the variables
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
788 (mapcar
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
789 (function
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
790 (lambda (varentry)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
791 (let ((var (car varentry))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
792 (val (cdr varentry)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
793 (and local
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
794 (make-local-variable var))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
795 ;; special case for vhdl-offsets-alist
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
796 (if (not (eq var 'vhdl-offsets-alist))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
797 (set var val)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
798 ;; reset vhdl-offsets-alist to the default value first
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
799 (setq vhdl-offsets-alist (copy-alist vhdl-offsets-alist-default))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
800 ;; now set the langelems that are different
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
801 (mapcar
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
802 (function
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
803 (lambda (langentry)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
804 (let ((langelem (car langentry))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
805 (offset (cdr langentry)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
806 (vhdl-set-offset langelem offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
807 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
808 val))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
809 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
810 vars))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
811 (vhdl-keep-region-active))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
812
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
813 (defun vhdl-get-offset (langelem)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
814 ;; Get offset from LANGELEM which is a cons cell of the form:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
815 ;; (SYMBOL . RELPOS). The symbol is matched against
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
816 ;; vhdl-offsets-alist and the offset found there is either returned,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
817 ;; or added to the indentation at RELPOS. If RELPOS is nil, then
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
818 ;; the offset is simply returned.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
819 (let* ((symbol (car langelem))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
820 (relpos (cdr langelem))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
821 (match (assq symbol vhdl-offsets-alist))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
822 (offset (cdr-safe match)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
823 ;; offset can be a number, a function, a variable, or one of the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
824 ;; symbols + or -
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
825 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
826 ((not match)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
827 (if vhdl-strict-syntax-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
828 (error "don't know how to indent a %s" symbol)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
829 (setq offset 0
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
830 relpos 0)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
831 ((eq offset '+) (setq offset vhdl-basic-offset))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
832 ((eq offset '-) (setq offset (- vhdl-basic-offset)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
833 ((eq offset '++) (setq offset (* 2 vhdl-basic-offset)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
834 ((eq offset '--) (setq offset (* 2 (- vhdl-basic-offset))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
835 ((and (not (numberp offset))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
836 (fboundp offset))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
837 (setq offset (funcall offset langelem)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
838 ((not (numberp offset))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
839 (setq offset (eval offset)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
840 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
841 (+ (if (and relpos
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
842 (< relpos (vhdl-point 'bol)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
843 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
844 (goto-char relpos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
845 (current-column))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
846 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
847 offset)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
848
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
849
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
850 ;; Syntactic support functions:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
851
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
852 ;; Returns `comment' if in a comment, `string' if in a string literal,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
853 ;; or nil if not in a literal at all. Optional LIM is used as the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
854 ;; backward limit of the search. If omitted, or nil, (point-min) is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
855 ;; used.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
856
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
857 (defun vhdl-in-literal (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
858 ;; Determine if point is in a VHDL literal.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
859 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
860 (let* ((lim (or lim (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
861 (state (parse-partial-sexp lim (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
862 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
863 ((nth 3 state) 'string)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
864 ((nth 4 state) 'comment)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
865 (t nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
866 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
867
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
868 ;; This is the best we can do in Win-Emacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
869 (defun vhdl-win-il (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
870 ;; Determine if point is in a VHDL literal
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
871 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
872 (let* ((here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
873 (state nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
874 (match nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
875 (lim (or lim (vhdl-point 'bod))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
876 (goto-char lim )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
877 (while (< (point) here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
878 (setq match
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
879 (and (re-search-forward "--\\|[\"']"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
880 here 'move)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
881 (buffer-substring (match-beginning 0) (match-end 0))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
882 (setq state
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
883 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
884 ;; no match
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
885 ((null match) nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
886 ;; looking at the opening of a VHDL style comment
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
887 ((string= "--" match)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
888 (if (<= here (progn (end-of-line) (point))) 'comment))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
889 ;; looking at the opening of a double quote string
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
890 ((string= "\"" match)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
891 (if (not (save-restriction
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
892 ;; this seems to be necessary since the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
893 ;; re-search-forward will not work without it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
894 (narrow-to-region (point) here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
895 (re-search-forward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
896 ;; this regexp matches a double quote
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
897 ;; which is preceded by an even number
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
898 ;; of backslashes, including zero
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
899 "\\([^\\]\\|^\\)\\(\\\\\\\\\\)*\"" here 'move)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
900 'string))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
901 ;; looking at the opening of a single quote string
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
902 ((string= "'" match)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
903 (if (not (save-restriction
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
904 ;; see comments from above
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
905 (narrow-to-region (point) here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
906 (re-search-forward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
907 ;; this matches a single quote which is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
908 ;; preceded by zero or two backslashes.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
909 "\\([^\\]\\|^\\)\\(\\\\\\\\\\)?'"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
910 here 'move)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
911 'string))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
912 (t nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
913 ) ; end-while
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
914 state)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
915
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
916 (and (memq 'Win-Emacs vhdl-emacs-features)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
917 (fset 'vhdl-in-literal 'vhdl-win-il))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
918
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
919 ;; Skipping of "syntactic whitespace". Syntactic whitespace is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
920 ;; defined as lexical whitespace or comments. Search no farther back
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
921 ;; or forward than optional LIM. If LIM is omitted, (point-min) is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
922 ;; used for backward skipping, (point-max) is used for forward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
923 ;; skipping.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
924
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
925 (defun vhdl-forward-syntactic-ws (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
926 ;; Forward skip of syntactic whitespace.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
927 (save-restriction
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
928 (let* ((lim (or lim (point-max)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
929 (here lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
930 (hugenum (point-max)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
931 (narrow-to-region lim (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
932 (while (/= here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
933 (setq here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
934 (forward-comment hugenum))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
935 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
936
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
937 ;; This is the best we can do in Win-Emacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
938 (defun vhdl-win-fsws (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
939 ;; Forward skip syntactic whitespace for Win-Emacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
940 (let ((lim (or lim (point-max)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
941 stop)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
942 (while (not stop)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
943 (skip-chars-forward " \t\n\r\f" lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
944 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
945 ;; vhdl comment
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
946 ((looking-at "--") (end-of-line))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
947 ;; none of the above
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
948 (t (setq stop t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
949 ))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
950
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
951 (and (memq 'Win-Emacs vhdl-emacs-features)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
952 (fset 'vhdl-forward-syntactic-ws 'vhdl-win-fsws))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
953
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
954 (defun vhdl-backward-syntactic-ws (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
955 ;; Backward skip over syntactic whitespace.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
956 (save-restriction
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
957 (let* ((lim (or lim (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
958 (here lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
959 (hugenum (- (point-max))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
960 (if (< lim (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
961 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
962 (narrow-to-region lim (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
963 (while (/= here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
964 (setq here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
965 (forward-comment hugenum)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
966 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
967 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
968
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
969 ;; This is the best we can do in Win-Emacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
970 (defun vhdl-win-bsws (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
971 ;; Backward skip syntactic whitespace for Win-Emacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
972 (let ((lim (or lim (vhdl-point 'bod)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
973 stop)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
974 (while (not stop)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
975 (skip-chars-backward " \t\n\r\f" lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
976 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
977 ;; vhdl comment
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
978 ((eq (vhdl-in-literal lim) 'comment)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
979 (skip-chars-backward "^-" lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
980 (skip-chars-backward "-" lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
981 (while (not (or (and (= (following-char) ?-)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
982 (= (char-after (1+ (point))) ?-))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
983 (<= (point) lim)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
984 (skip-chars-backward "^-" lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
985 (skip-chars-backward "-" lim)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
986 ;; none of the above
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
987 (t (setq stop t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
988 ))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
989
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
990 (and (memq 'Win-Emacs vhdl-emacs-features)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
991 (fset 'vhdl-backward-syntactic-ws 'vhdl-win-bsws))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
992
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
993 ;; Functions to help finding the correct indentation column:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
994
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
995 (defun vhdl-first-word (point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
996 "If the keyword at POINT is at boi, then return (current-column) at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
997 that point, else nil."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
998 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
999 (and (goto-char point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1000 (eq (point) (vhdl-point 'boi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1001 (current-column))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1002
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1003 (defun vhdl-last-word (point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1004 "If the keyword at POINT is at eoi, then return (current-column) at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1005 that point, else nil."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1006 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1007 (and (goto-char point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1008 (save-excursion (or (eq (progn (forward-sexp) (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1009 (vhdl-point 'eoi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1010 (looking-at "\\s-*\\(--\\)?")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1011 (current-column))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1012
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1013
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1014 ;; Core syntactic evaluation functions:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1015
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1016 (defconst vhdl-libunit-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1017 "\\b\\(architecture\\|configuration\\|entity\\|package\\)\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1018
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1019 (defun vhdl-libunit-p ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1020 (and
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1021 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1022 (forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1023 (skip-chars-forward " \t\n")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1024 (not (looking-at "is\\b[^_]")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1025 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1026 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1027 (not (looking-at "use\\b[^_]")))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1028
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1029 (defconst vhdl-defun-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1030 "\\b\\(architecture\\|block\\|configuration\\|entity\\|package\\|process\\|procedure\\|function\\)\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1031
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1032 (defun vhdl-defun-p ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1033 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1034 (if (looking-at "block\\|process")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1035 ;; "block", "process":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1036 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1037 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1038 (not (looking-at "end\\s-+\\w")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1039 ;; "architecture", "configuration", "entity",
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1040 ;; "package", "procedure", "function":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1041 t)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1042
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1043 (defun vhdl-corresponding-defun ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1044 "If the word at the current position corresponds to a \"defun\"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1045 keyword, then return a string that can be used to find the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1046 corresponding \"begin\" keyword, else return nil."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1047 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1048 (and (looking-at vhdl-defun-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1049 (vhdl-defun-p)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1050 (if (looking-at "block\\|process")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1051 ;; "block", "process":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1052 (buffer-substring (match-beginning 0) (match-end 0))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1053 ;; "architecture", "configuration", "entity", "package",
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1054 ;; "procedure", "function":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1055 "is"))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1056
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1057 (defconst vhdl-begin-fwd-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1058 "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|units\\|record\\|for\\)\\b\\([^_]\\|\\'\\)"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1059 "A regular expression for searching forward that matches all known
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1060 \"begin\" keywords.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1061
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1062 (defconst vhdl-begin-bwd-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1063 "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|units\\|record\\|for\\)\\b"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1064 "A regular expression for searching backward that matches all known
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1065 \"begin\" keywords.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1066
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1067 (defun vhdl-begin-p (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1068 "Return t if we are looking at a real \"begin\" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1069 Assumes that the caller will make sure that we are looking at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1070 vhdl-begin-fwd-re, and are not inside a literal, and that we are not in
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1071 the middle of an identifier that just happens to contain a \"begin\"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1072 keyword."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1073 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1074 ;; "[architecture|case|configuration|entity|package|
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1075 ;; procedure|function] ... is":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1076 ((and (looking-at "i")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1077 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1078 ;; Skip backward over first sexp (needed to skip over a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1079 ;; procedure interface list, and is harmless in other
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1080 ;; situations). Note that we need "return" in the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1081 ;; following search list so that we don't run into
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1082 ;; semicolons in the function interface list.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1083 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1084 (let (foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1085 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1086 (re-search-backward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1087 ";\\|\\b\\(architecture\\|case\\|configuration\\|entity\\|package\\|procedure\\|return\\|is\\|begin\\|process\\|block\\)\\b[^_]"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1088 lim 'move))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1089 (if (or (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1090 (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1091 (backward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1092 (setq foundp t))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1093 (and (/= (following-char) ?\;)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1094 (not (looking-at "is\\|begin\\|process\\|block")))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1095 t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1096 ;; "begin", "then":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1097 ((looking-at "be\\|t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1098 t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1099 ;; "else":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1100 ((and (looking-at "e")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1101 ;; make sure that the "else" isn't inside a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1102 ;; conditional signal assignment.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1103 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1104 (re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1105 (or (eq (following-char) ?\;)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1106 (eq (point) lim))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1107 t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1108 ;; "block", "component", "generate", "loop", "process",
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1109 ;; "units", "record":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1110 ((and (looking-at "bl\\|[cglpur]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1111 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1112 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1113 (not (looking-at "end\\s-+\\w"))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1114 t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1115 ;; "for" (inside configuration declaration):
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1116 ((and (looking-at "f")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1117 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1118 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1119 (not (looking-at "end\\s-+\\w")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1120 (vhdl-has-syntax 'configuration))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1121 t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1122 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1123
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1124 (defun vhdl-corresponding-mid (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1125 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1126 ((looking-at "is\\|block\\|process")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1127 "begin")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1128 ((looking-at "then")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1129 "<else>")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1130 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1131 "end")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1132
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1133 (defun vhdl-corresponding-end (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1134 "If the word at the current position corresponds to a \"begin\"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1135 keyword, then return a vector containing enough information to find
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1136 the corresponding \"end\" keyword, else return nil. The keyword to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1137 search forward for is aref 0. The column in which the keyword must
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1138 appear is aref 1 or nil if any column is suitable.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1139 Assumes that the caller will make sure that we are not in the middle
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1140 of an identifier that just happens to contain a \"begin\" keyword."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1141 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1142 (and (looking-at vhdl-begin-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1143 (/= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1144 (not (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1145 (vhdl-begin-p lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1146 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1147 ;; "is", "generate", "loop":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1148 ((looking-at "[igl]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1149 (vector "end"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1150 (and (vhdl-last-word (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1151 (or (vhdl-first-word (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1152 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1153 (vhdl-beginning-of-statement-1 lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1154 (vhdl-backward-skip-label lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1155 (vhdl-first-word (point)))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1156 ;; "begin", "else", "for":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1157 ((looking-at "be\\|[ef]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1158 (vector "end"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1159 (and (vhdl-last-word (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1160 (or (vhdl-first-word (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1161 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1162 (vhdl-beginning-of-statement-1 lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1163 (vhdl-backward-skip-label lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1164 (vhdl-first-word (point)))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1165 ;; "component", "units", "record":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1166 ((looking-at "[cur]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1167 ;; The first end found will close the block
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1168 (vector "end" nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1169 ;; "block", "process":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1170 ((looking-at "bl\\|p")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1171 (vector "end"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1172 (or (vhdl-first-word (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1173 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1174 (vhdl-beginning-of-statement-1 lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1175 (vhdl-backward-skip-label lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1176 (vhdl-first-word (point))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1177 ;; "then":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1178 ((looking-at "t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1179 (vector "elsif\\|else\\|end"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1180 (and (vhdl-last-word (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1181 (or (vhdl-first-word (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1182 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1183 (vhdl-beginning-of-statement-1 lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1184 (vhdl-backward-skip-label lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1185 (vhdl-first-word (point)))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1186 ))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1187
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1188 (defconst vhdl-end-fwd-re "\\b\\(end\\|else\\|elsif\\)\\b\\([^_]\\|\\'\\)")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1189
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1190 (defconst vhdl-end-bwd-re "\\b\\(end\\|else\\|elsif\\)\\b")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1191
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1192 (defun vhdl-end-p (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1193 "Return t if we are looking at a real \"end\" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1194 Assumes that the caller will make sure that we are looking at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1195 vhdl-end-fwd-re, and are not inside a literal, and that we are not in
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1196 the middle of an identifier that just happens to contain an \"end\"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1197 keyword."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1198 (or (not (looking-at "else"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1199 ;; make sure that the "else" isn't inside a conditional signal
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1200 ;; assignment.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1201 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1202 (re-search-backward ";\\|\\bwhen\\b[^_]" lim 'move)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1203 (or (eq (following-char) ?\;)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1204 (eq (point) lim)))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1205
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1206 (defun vhdl-corresponding-begin (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1207 "If the word at the current position corresponds to an \"end\"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1208 keyword, then return a vector containing enough information to find
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1209 the corresponding \"begin\" keyword, else return nil. The keyword to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1210 search backward for is aref 0. The column in which the keyword must
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1211 appear is aref 1 or nil if any column is suitable. The supplementary
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1212 keyword to search forward for is aref 2 or nil if this is not
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1213 required. If aref 3 is t, then the \"begin\" keyword may be found in
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1214 the middle of a statement.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1215 Assumes that the caller will make sure that we are not in the middle
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1216 of an identifier that just happens to contain an \"end\" keyword."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1217 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1218 (let (pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1219 (if (and (looking-at vhdl-end-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1220 (not (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1221 (vhdl-end-p lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1222 (if (looking-at "el")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1223 ;; "else", "elsif":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1224 (vector "if\\|elsif" (vhdl-first-word (point)) "then" nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1225 ;; "end ...":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1226 (setq pos (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1227 (forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1228 (skip-chars-forward " \t\n")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1229 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1230 ;; "end if":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1231 ((looking-at "if\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1232 (vector "else\\|elsif\\|if"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1233 (vhdl-first-word pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1234 "else\\|then" nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1235 ;; "end component":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1236 ((looking-at "component\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1237 (vector (buffer-substring (match-beginning 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1238 (match-end 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1239 (vhdl-first-word pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1240 nil nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1241 ;; "end units", "end record":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1242 ((looking-at "\\(units\\|record\\)\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1243 (vector (buffer-substring (match-beginning 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1244 (match-end 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1245 (vhdl-first-word pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1246 nil t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1247 ;; "end block", "end process":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1248 ((looking-at "\\(block\\|process\\)\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1249 (vector "begin" (vhdl-first-word pos) nil nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1250 ;; "end case":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1251 ((looking-at "case\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1252 (vector "case" (vhdl-first-word pos) "is" nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1253 ;; "end generate":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1254 ((looking-at "generate\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1255 (vector "generate\\|for\\|if"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1256 (vhdl-first-word pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1257 "generate" nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1258 ;; "end loop":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1259 ((looking-at "loop\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1260 (vector "loop\\|while\\|for"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1261 (vhdl-first-word pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1262 "loop" nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1263 ;; "end for" (inside configuration declaration):
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1264 ((looking-at "for\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1265 (vector "for" (vhdl-first-word pos) nil nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1266 ;; "end [id]":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1267 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1268 (vector "begin\\|architecture\\|configuration\\|entity\\|package\\|procedure\\|function"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1269 (vhdl-first-word pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1270 ;; return an alist of (statement . keyword) mappings
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1271 '(
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1272 ;; "begin ... end [id]":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1273 ("begin" . nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1274 ;; "architecture ... is ... begin ... end [id]":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1275 ("architecture" . "is")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1276 ;; "configuration ... is ... end [id]":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1277 ("configuration" . "is")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1278 ;; "entity ... is ... end [id]":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1279 ("entity" . "is")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1280 ;; "package ... is ... end [id]":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1281 ("package" . "is")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1282 ;; "procedure ... is ... begin ... end [id]":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1283 ("procedure" . "is")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1284 ;; "function ... is ... begin ... end [id]":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1285 ("function" . "is")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1286 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1287 nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1288 ))) ; "end ..."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1289 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1290
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1291 (defconst vhdl-leader-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1292 "\\b\\(block\\|component\\|process\\|for\\)\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1293
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1294 (defun vhdl-end-of-leader ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1295 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1296 (cond ((looking-at "block\\|process")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1297 (if (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1298 (forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1299 (skip-chars-forward " \t\n")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1300 (= (following-char) ?\())
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1301 (forward-sexp 2)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1302 (forward-sexp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1303 (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1304 ((looking-at "component")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1305 (forward-sexp 2)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1306 (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1307 ((looking-at "for")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1308 (forward-sexp 2)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1309 (skip-chars-forward " \t\n")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1310 (while (looking-at "[,:(]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1311 (forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1312 (skip-chars-forward " \t\n"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1313 (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1314 (t nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1315 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1316
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1317 (defconst vhdl-trailer-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1318 "\\b\\(is\\|then\\|generate\\|loop\\)\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1319
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1320 (defconst vhdl-statement-fwd-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1321 "\\b\\(if\\|for\\|while\\)\\b\\([^_]\\|\\'\\)"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1322 "A regular expression for searching forward that matches all known
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1323 \"statement\" keywords.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1324
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1325 (defconst vhdl-statement-bwd-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1326 "\\b\\(if\\|for\\|while\\)\\b"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1327 "A regular expression for searching backward that matches all known
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1328 \"statement\" keywords.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1329
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1330 (defun vhdl-statement-p (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1331 "Return t if we are looking at a real \"statement\" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1332 Assumes that the caller will make sure that we are looking at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1333 vhdl-statement-fwd-re, and are not inside a literal, and that we are not in
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1334 the middle of an identifier that just happens to contain a \"statement\"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1335 keyword."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1336 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1337 ;; "for" ... "generate":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1338 ((and (looking-at "f")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1339 ;; Make sure it's the start of a parameter specification.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1340 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1341 (forward-sexp 2)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1342 (skip-chars-forward " \t\n")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1343 (looking-at "in\\b[^_]"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1344 ;; Make sure it's not an "end for".
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1345 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1346 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1347 (not (looking-at "end\\s-+\\w"))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1348 t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1349 ;; "if" ... "then", "if" ... "generate", "if" ... "loop":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1350 ((and (looking-at "i")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1351 ;; Make sure it's not an "end if".
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1352 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1353 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1354 (not (looking-at "end\\s-+\\w"))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1355 t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1356 ;; "while" ... "loop":
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1357 ((looking-at "w")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1358 t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1359 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1360
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1361
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1362 ;; Core syntactic movement functions:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1363
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1364 (defconst vhdl-b-t-b-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1365 (concat vhdl-begin-bwd-re "\\|" vhdl-end-bwd-re))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1366
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1367 (defun vhdl-backward-to-block (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1368 "Move backward to the previous \"begin\" or \"end\" keyword."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1369 (let (foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1370 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1371 (re-search-backward vhdl-b-t-b-re lim 'move))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1372 (if (or (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1373 (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1374 (backward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1375 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1376 ;; "begin" keyword:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1377 ((and (looking-at vhdl-begin-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1378 (/= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1379 (vhdl-begin-p lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1380 (setq foundp 'begin))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1381 ;; "end" keyword:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1382 ((and (looking-at vhdl-end-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1383 (/= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1384 (vhdl-end-p lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1385 (setq foundp 'end))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1386 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1387 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1388 foundp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1389 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1390
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1391 (defun vhdl-forward-sexp (&optional count lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1392 "Move forward across one balanced expression (sexp).
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1393 With COUNT, do it that many times."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1394 (interactive "p")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1395 (let ((count (or count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1396 (case-fold-search t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1397 end-vec target)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1398 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1399 (while (> count 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1400 ;; skip whitespace
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1401 (skip-chars-forward " \t\n")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1402 ;; Check for an unbalanced "end" keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1403 (if (and (looking-at vhdl-end-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1404 (/= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1405 (not (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1406 (vhdl-end-p lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1407 (not (looking-at "else")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1408 (error
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1409 "Containing expression ends prematurely in vhdl-forward-sexp"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1410 ;; If the current keyword is a "begin" keyword, then find the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1411 ;; corresponding "end" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1412 (if (setq end-vec (vhdl-corresponding-end lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1413 (let (
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1414 ;; end-re is the statement keyword to search for
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1415 (end-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1416 (concat "\\b\\(" (aref end-vec 0) "\\)\\b\\([^_]\\|\\'\\)"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1417 ;; column is either the statement keyword target column
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1418 ;; or nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1419 (column (aref end-vec 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1420 (eol (vhdl-point 'eol))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1421 foundp literal placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1422 ;; Look for the statement keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1423 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1424 (re-search-forward end-re nil t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1425 (setq placeholder (match-end 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1426 (goto-char (match-beginning 0)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1427 ;; If we are in a literal, or not in the right target
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1428 ;; column and not on the same line as the begin, then
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1429 ;; try again.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1430 (if (or (and column
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1431 (/= (current-indentation) column)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1432 (> (point) eol))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1433 (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1434 (setq literal (vhdl-in-literal lim)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1435 (if (eq literal 'comment)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1436 (end-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1437 (forward-char))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1438 ;; An "else" keyword corresponds to both the opening brace
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1439 ;; of the following sexp and the closing brace of the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1440 ;; previous sexp.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1441 (if (not (looking-at "else"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1442 (goto-char placeholder))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1443 (setq foundp t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1444 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1445 (if (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1446 (error "Unbalanced keywords in vhdl-forward-sexp"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1447 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1448 ;; If the current keyword is not a "begin" keyword, then just
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1449 ;; perform the normal forward-sexp.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1450 (forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1451 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1452 (setq count (1- count))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1453 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1454 (setq target (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1455 (goto-char target)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1456 nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1457
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1458 (defun vhdl-backward-sexp (&optional count lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1459 "Move backward across one balanced expression (sexp).
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1460 With COUNT, do it that many times. LIM bounds any required backward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1461 searches."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1462 (interactive "p")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1463 (let ((count (or count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1464 (case-fold-search t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1465 begin-vec target)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1466 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1467 (while (> count 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1468 ;; Perform the normal backward-sexp, unless we are looking at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1469 ;; "else" - an "else" keyword corresponds to both the opening brace
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1470 ;; of the following sexp and the closing brace of the previous sexp.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1471 (if (and (looking-at "else\\b\\([^_]\\|\\'\\)")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1472 (/= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1473 (not (vhdl-in-literal lim)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1474 nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1475 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1476 (if (and (looking-at vhdl-begin-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1477 (/= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1478 (not (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1479 (vhdl-begin-p lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1480 (error "Containing expression ends prematurely in vhdl-backward-sexp")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1481 ;; If the current keyword is an "end" keyword, then find the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1482 ;; corresponding "begin" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1483 (if (and (setq begin-vec (vhdl-corresponding-begin lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1484 (/= (preceding-char) ?_))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1485 (let (
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1486 ;; begin-re is the statement keyword to search for
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1487 (begin-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1488 (concat "\\b\\(" (aref begin-vec 0) "\\)\\b[^_]"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1489 ;; column is either the statement keyword target column
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1490 ;; or nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1491 (column (aref begin-vec 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1492 ;; internal-p controls where the statement keyword can
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1493 ;; be found.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1494 (internal-p (aref begin-vec 3))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1495 (last-backward (point)) last-forward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1496 foundp literal keyword)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1497 ;; Look for the statement keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1498 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1499 (re-search-backward begin-re lim t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1500 (setq keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1501 (buffer-substring (match-beginning 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1502 (match-end 1))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1503 ;; If we are in a literal or in the wrong column,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1504 ;; then try again.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1505 (if (or (and column
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1506 (and (/= (current-indentation) column)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1507 ;; possibly accept current-column as
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1508 ;; well as current-indentation.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1509 (or (not internal-p)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1510 (/= (current-column) column))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1511 (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1512 (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1513 (backward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1514 ;; If there is a supplementary keyword, then
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1515 ;; search forward for it.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1516 (if (and (setq begin-re (aref begin-vec 2))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1517 (or (not (listp begin-re))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1518 ;; If begin-re is an alist, then find the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1519 ;; element corresponding to the actual
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1520 ;; keyword that we found.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1521 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1522 (setq begin-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1523 (assoc keyword begin-re))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1524 (and begin-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1525 (setq begin-re (cdr begin-re))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1526 (and
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1527 (setq begin-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1528 (concat "\\b\\(" begin-re "\\)\\b[^_]"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1529 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1530 (setq last-forward (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1531 ;; Look for the supplementary keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1532 ;; (bounded by the backward search start
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1533 ;; point).
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1534 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1535 (re-search-forward begin-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1536 last-backward t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1537 (goto-char (match-beginning 1)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1538 ;; If we are in a literal, then try again.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1539 (if (or (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1540 (setq literal
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1541 (vhdl-in-literal last-forward)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1542 (if (eq literal 'comment)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1543 (goto-char
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1544 (min (vhdl-point 'eol) last-backward))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1545 (forward-char))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1546 ;; We have found the supplementary keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1547 ;; Save the position of the keyword in foundp.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1548 (setq foundp (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1549 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1550 foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1551 ;; If the supplementary keyword was found, then
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1552 ;; move point to the supplementary keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1553 (goto-char foundp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1554 ;; If there was no supplementary keyword, then
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1555 ;; point is already at the statement keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1556 (setq foundp t)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1557 ) ; end of the search for the statement keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1558 (if (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1559 (error "Unbalanced keywords in vhdl-backward-sexp"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1560 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1561 (setq count (1- count))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1562 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1563 (setq target (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1564 (goto-char target)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1565 nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1566
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1567 (defun vhdl-backward-up-list (&optional count limit)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1568 "Move backward out of one level of blocks.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1569 With argument, do this that many times."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1570 (interactive "p")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1571 (let ((count (or count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1572 target)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1573 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1574 (while (> count 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1575 (if (looking-at vhdl-defun-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1576 (error "Unbalanced blocks"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1577 (vhdl-backward-to-block limit)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1578 (setq count (1- count)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1579 (setq target (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1580 (goto-char target)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1581
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1582 (defun vhdl-end-of-defun (&optional count)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1583 "Move forward to the end of a VHDL defun."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1584 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1585 (let ((case-fold-search t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1586 (vhdl-beginning-of-defun)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1587 (if (not (looking-at "block\\|process"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1588 (re-search-forward "\\bis\\b"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1589 (vhdl-forward-sexp)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1590
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1591 (defun vhdl-mark-defun ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1592 "Put mark at end of this \"defun\", point at beginning."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1593 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1594 (let ((case-fold-search t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1595 (push-mark)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1596 (vhdl-beginning-of-defun)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1597 (push-mark)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1598 (if (not (looking-at "block\\|process"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1599 (re-search-forward "\\bis\\b"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1600 (vhdl-forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1601 (exchange-point-and-mark)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1602
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1603 (defun vhdl-beginning-of-libunit ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1604 "Move backward to the beginning of a VHDL library unit.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1605 Returns the location of the corresponding begin keyword, unless search
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1606 stops due to beginning or end of buffer."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1607 ;; Note that if point is between the "libunit" keyword and the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1608 ;; corresponding "begin" keyword, then that libunit will not be
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1609 ;; recognised, and the search will continue backwards. If point is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1610 ;; at the "begin" keyword, then the defun will be recognised. The
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1611 ;; returned point is at the first character of the "libunit" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1612 (let ((last-forward (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1613 (last-backward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1614 ;; Just in case we are actually sitting on the "begin"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1615 ;; keyword, allow for the keyword and an extra character,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1616 ;; as this will be used when looking forward for the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1617 ;; "begin" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1618 (save-excursion (forward-word 1) (1+ (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1619 foundp literal placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1620 ;; Find the "libunit" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1621 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1622 (re-search-backward vhdl-libunit-re nil 'move))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1623 ;; If we are in a literal, or not at a real libunit, then try again.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1624 (if (or (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1625 (vhdl-in-literal (point-min))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1626 (not (vhdl-libunit-p)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1627 (backward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1628 ;; Find the corresponding "begin" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1629 (setq last-forward (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1630 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1631 (re-search-forward "\\bis\\b[^_]" last-backward t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1632 (setq placeholder (match-beginning 0)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1633 (if (or (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1634 (setq literal (vhdl-in-literal last-forward)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1635 ;; It wasn't a real keyword, so keep searching.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1636 (if (eq literal 'comment)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1637 (goto-char
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1638 (min (vhdl-point 'eol) last-backward))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1639 (forward-char))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1640 ;; We have found the begin keyword, loop will exit.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1641 (setq foundp placeholder)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1642 ;; Go back to the libunit keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1643 (goto-char last-forward)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1644 foundp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1645
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1646 (defun vhdl-beginning-of-defun (&optional count)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1647 "Move backward to the beginning of a VHDL defun.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1648 With argument, do it that many times.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1649 Returns the location of the corresponding begin keyword, unless search
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1650 stops due to beginning or end of buffer."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1651 ;; Note that if point is between the "defun" keyword and the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1652 ;; corresponding "begin" keyword, then that defun will not be
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1653 ;; recognised, and the search will continue backwards. If point is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1654 ;; at the "begin" keyword, then the defun will be recognised. The
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1655 ;; returned point is at the first character of the "defun" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1656 (interactive "p")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1657 (let ((count (or count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1658 (case-fold-search t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1659 (last-forward (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1660 foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1661 (while (> count 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1662 (setq foundp nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1663 (goto-char last-forward)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1664 (let ((last-backward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1665 ;; Just in case we are actually sitting on the "begin"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1666 ;; keyword, allow for the keyword and an extra character,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1667 ;; as this will be used when looking forward for the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1668 ;; "begin" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1669 (save-excursion (forward-word 1) (1+ (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1670 begin-string literal)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1671 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1672 (re-search-backward vhdl-defun-re nil 'move))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1673 ;; If we are in a literal, then try again.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1674 (if (or (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1675 (vhdl-in-literal (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1676 (backward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1677 (if (setq begin-string (vhdl-corresponding-defun))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1678 ;; This is a real defun keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1679 ;; Find the corresponding "begin" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1680 ;; Look for the begin keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1681 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1682 ;; Save the search start point.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1683 (setq last-forward (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1684 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1685 (search-forward begin-string last-backward t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1686 (if (or (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1687 (save-match-data
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1688 (setq literal (vhdl-in-literal last-forward))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1689 ;; It wasn't a real keyword, so keep searching.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1690 (if (eq literal 'comment)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1691 (goto-char
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1692 (min (vhdl-point 'eol) last-backward))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1693 (forward-char))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1694 ;; We have found the begin keyword, loop will exit.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1695 (setq foundp (match-beginning 0)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1696 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1697 ;; Go back to the defun keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1698 (goto-char last-forward)) ; end search for begin keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1699 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1700 ) ; end of the search for the defun keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1701 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1702 (setq count (1- count))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1703 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1704 (vhdl-keep-region-active)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1705 foundp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1706
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1707 (defun vhdl-beginning-of-statement (&optional count lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1708 "Go to the beginning of the innermost VHDL statement.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1709 With prefix arg, go back N - 1 statements. If already at the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1710 beginning of a statement then go to the beginning of the preceding
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1711 one. If within a string or comment, or next to a comment (only
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1712 whitespace between), move by sentences instead of statements.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1713
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1714 When called from a program, this function takes 2 optional args: the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1715 prefix arg, and a buffer position limit which is the farthest back to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1716 search."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1717 (interactive "p")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1718 (let ((count (or count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1719 (case-fold-search t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1720 (lim (or lim (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1721 (here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1722 state)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1723 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1724 (goto-char lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1725 (setq state (parse-partial-sexp (point) here nil nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1726 (if (and (interactive-p)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1727 (or (nth 3 state)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1728 (nth 4 state)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1729 (looking-at (concat "[ \t]*" comment-start-skip))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1730 (forward-sentence (- count))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1731 (while (> count 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1732 (vhdl-beginning-of-statement-1 lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1733 (setq count (1- count))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1734 ;; its possible we've been left up-buf of lim
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1735 (goto-char (max (point) lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1736 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1737 (vhdl-keep-region-active))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1738
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1739 (defconst vhdl-b-o-s-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1740 (concat ";\\|\(\\|\)\\|\\bwhen\\b[^_]\\|"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1741 vhdl-begin-bwd-re "\\|" vhdl-statement-bwd-re))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1742
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1743 (defun vhdl-beginning-of-statement-1 (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1744 ;; move to the start of the current statement, or the previous
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1745 ;; statement if already at the beginning of one.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1746 (let ((lim (or lim (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1747 (here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1748 (pos (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1749 donep)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1750 ;; go backwards one balanced expression, but be careful of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1751 ;; unbalanced paren being reached
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1752 (if (not (vhdl-safe (progn (backward-sexp) t)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1753 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1754 (backward-up-list 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1755 (forward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1756 (vhdl-forward-syntactic-ws here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1757 (setq donep t)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1758 (while (and (not donep)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1759 (not (bobp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1760 ;; look backwards for a statement boundary
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1761 (re-search-backward vhdl-b-o-s-re lim 'move))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1762 (if (or (= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1763 (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1764 (backward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1765 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1766 ;; If we are looking at an open paren, then stop after it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1767 ((eq (following-char) ?\()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1768 (forward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1769 (vhdl-forward-syntactic-ws here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1770 (setq donep t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1771 ;; If we are looking at a close paren, then skip it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1772 ((eq (following-char) ?\))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1773 (forward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1774 (setq pos (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1775 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1776 (if (< (point) lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1777 (progn (goto-char pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1778 (vhdl-forward-syntactic-ws here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1779 (setq donep t))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1780 ;; If we are looking at a semicolon, then stop
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1781 ((eq (following-char) ?\;)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1782 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1783 (forward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1784 (vhdl-forward-syntactic-ws here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1785 (setq donep t)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1786 ;; If we are looking at a "begin", then stop
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1787 ((and (looking-at vhdl-begin-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1788 (/= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1789 (vhdl-begin-p nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1790 ;; If it's a leader "begin", then find the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1791 ;; right place
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1792 (if (looking-at vhdl-leader-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1793 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1794 ;; set a default stop point at the begin
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1795 (setq pos (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1796 ;; is the start point inside the leader area ?
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1797 (goto-char (vhdl-end-of-leader))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1798 (vhdl-forward-syntactic-ws here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1799 (if (< (point) here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1800 ;; start point was not inside leader area
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1801 ;; set stop point at word after leader
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1802 (setq pos (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1803 (forward-word 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1804 (vhdl-forward-syntactic-ws here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1805 (setq pos (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1806 (goto-char pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1807 (setq donep t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1808 ;; If we are looking at a "statement", then stop
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1809 ((and (looking-at vhdl-statement-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1810 (/= (preceding-char) ?_)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1811 (vhdl-statement-p nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1812 (setq donep t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1813 ;; If we are looking at a case alternative key, then stop
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1814 ((looking-at vhdl-case-alternative-key)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1815 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1816 ;; set a default stop point at the when
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1817 (setq pos (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1818 ;; is the start point inside the case alternative key ?
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1819 (goto-char (match-end 0))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1820 (vhdl-forward-syntactic-ws here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1821 (if (< (point) here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1822 ;; start point was not inside the case alternative key
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1823 ;; set stop point at word after case alternative keyleader
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1824 (setq pos (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1825 (goto-char pos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1826 (setq donep t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1827 ;; Bogus find, continue
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1828 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1829 (backward-char)))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1830 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1831
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1832
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1833 ;; Defuns for calculating the current syntactic state:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1834
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1835 (defun vhdl-get-library-unit (bod placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1836 ;; If there is an enclosing library unit at bod, with it's \"begin\"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1837 ;; keyword at placeholder, then return the library unit type.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1838 (let ((here (vhdl-point 'bol)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1839 (if (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1840 (goto-char placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1841 (vhdl-safe (vhdl-forward-sexp 1 bod))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1842 (<= here (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1843 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1844 (goto-char bod)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1845 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1846 ((looking-at "e") 'entity)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1847 ((looking-at "a") 'architecture)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1848 ((looking-at "c") 'configuration)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1849 ((looking-at "p")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1850 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1851 (goto-char bod)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1852 (forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1853 (vhdl-forward-syntactic-ws here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1854 (if (looking-at "body\\b[^_]")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1855 'package-body 'package))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1856 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1857
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1858 (defun vhdl-get-block-state (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1859 ;; Finds and records all the closest opens.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1860 ;; lim is the furthest back we need to search (it should be the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1861 ;; previous libunit keyword).
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1862 (let ((here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1863 (lim (or lim (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1864 keyword sexp-start sexp-mid sexp-end
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1865 preceding-sexp containing-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1866 containing-begin containing-mid containing-paren)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1867 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1868 ;; Find the containing-paren, and use that as the limit
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1869 (if (setq containing-paren
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1870 (save-restriction
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1871 (narrow-to-region lim (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1872 (vhdl-safe (scan-lists (point) -1 1))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1873 (setq lim containing-paren))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1874 ;; Look backwards for "begin" and "end" keywords.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1875 (while (and (> (point) lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1876 (not containing-sexp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1877 (setq keyword (vhdl-backward-to-block lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1878 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1879 ((eq keyword 'begin)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1880 ;; Found a "begin" keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1881 (setq sexp-start (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1882 (setq sexp-mid (vhdl-corresponding-mid lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1883 (setq sexp-end (vhdl-safe
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1884 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1885 (vhdl-forward-sexp 1 lim) (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1886 (if (and sexp-end (<= sexp-end here))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1887 ;; we want to record this sexp, but we only want to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1888 ;; record the last-most of any of them before here
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1889 (or preceding-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1890 (setq preceding-sexp sexp-start))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1891 ;; we're contained in this sexp so put sexp-start on
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1892 ;; front of list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1893 (setq containing-sexp sexp-start)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1894 (setq containing-mid sexp-mid)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1895 (setq containing-begin t)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1896 ((eq keyword 'end)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1897 ;; Found an "end" keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1898 (forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1899 (setq sexp-end (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1900 (setq sexp-mid nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1901 (setq sexp-start
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1902 (or (vhdl-safe (vhdl-backward-sexp 1 lim) (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1903 (progn (backward-sexp) (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1904 ;; we want to record this sexp, but we only want to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1905 ;; record the last-most of any of them before here
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1906 (or preceding-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1907 (setq preceding-sexp sexp-start)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1908 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1909 ;; Check if the containing-paren should be the containing-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1910 (if (and containing-paren
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1911 (or (null containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1912 (< containing-sexp containing-paren)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1913 (setq containing-sexp containing-paren
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1914 preceding-sexp nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1915 containing-begin nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1916 containing-mid nil))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1917 (vector containing-sexp preceding-sexp containing-begin containing-mid)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1918 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1919
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1920
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1921 (defconst vhdl-s-c-a-re
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1922 (concat vhdl-case-alternative-key "\\|" vhdl-case-header-key))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1923
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1924 (defun vhdl-skip-case-alternative (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1925 ;; skip forward over case/when bodies, with optional maximal
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1926 ;; limit. if no next case alternative is found, nil is returned and point
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1927 ;; is not moved
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1928 (let ((lim (or lim (point-max)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1929 (here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1930 donep foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1931 (while (and (< (point) lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1932 (not donep))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1933 (if (and (re-search-forward vhdl-s-c-a-re lim 'move)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1934 (save-match-data
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1935 (not (vhdl-in-literal)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1936 (/= (match-beginning 0) here))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1937 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1938 (goto-char (match-beginning 0))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1939 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1940 ((and (looking-at "case")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1941 (re-search-forward "\\bis[^_]" lim t))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1942 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1943 (vhdl-forward-sexp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1944 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1945 (setq donep t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1946 foundp t))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1947 (if (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1948 (goto-char here))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1949 foundp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1950
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1951 (defun vhdl-backward-skip-label (&optional lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1952 ;; skip backward over a label, with optional maximal
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1953 ;; limit. if label is found, nil is returned and point
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1954 ;; is not moved
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1955 (let ((lim (or lim (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1956 placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1957 (if (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1958 (vhdl-backward-syntactic-ws lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1959 (and (eq (preceding-char) ?:)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1960 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1961 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1962 (setq placeholder (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1963 (looking-at vhdl-label-key))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1964 (goto-char placeholder))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1965 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1966
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1967 (defun vhdl-get-syntactic-context ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1968 ;; guess the syntactic description of the current line of VHDL code.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1969 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1970 (save-restriction
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1971 (beginning-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1972 (let* ((indent-point (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1973 (case-fold-search t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1974 vec literal containing-sexp preceding-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1975 containing-begin containing-mid containing-leader
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1976 char-before-ip char-after-ip begin-after-ip end-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1977 placeholder lim library-unit
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1978 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1979
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1980 ;; Reset the syntactic context
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1981 (setq vhdl-syntactic-context nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1982
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1983 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1984 ;; Move to the start of the previous library unit, and
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1985 ;; record the position of the "begin" keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1986 (setq placeholder (vhdl-beginning-of-libunit))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1987 ;; The position of the "libunit" keyword gives us a gross
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1988 ;; limit point.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1989 (setq lim (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1990 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1991
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1992 ;; If there is a previous library unit, and we are enclosed by
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1993 ;; it, then set the syntax accordingly.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1994 (and placeholder
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1995 (setq library-unit (vhdl-get-library-unit lim placeholder))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1996 (vhdl-add-syntax library-unit lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1997
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1998 ;; Find the surrounding state.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1999 (if (setq vec (vhdl-get-block-state lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2000 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2001 (setq containing-sexp (aref vec 0))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2002 (setq preceding-sexp (aref vec 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2003 (setq containing-begin (aref vec 2))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2004 (setq containing-mid (aref vec 3))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2005 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2006
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2007 ;; set the limit on the farthest back we need to search
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2008 (setq lim (if containing-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2009 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2010 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2011 ;; set containing-leader if required
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2012 (if (looking-at vhdl-leader-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2013 (setq containing-leader (vhdl-end-of-leader)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2014 (vhdl-point 'bol))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2015 (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2016
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2017 ;; cache char before and after indent point, and move point to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2018 ;; the most likely position to perform the majority of tests
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2019 (goto-char indent-point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2020 (skip-chars-forward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2021 (setq literal (vhdl-in-literal lim))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2022 (setq char-after-ip (following-char))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2023 (setq begin-after-ip (and
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2024 (not literal)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2025 (looking-at vhdl-begin-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2026 (vhdl-begin-p)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2027 (setq end-after-ip (and
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2028 (not literal)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2029 (looking-at vhdl-end-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2030 (vhdl-end-p)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2031 (vhdl-backward-syntactic-ws lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2032 (setq char-before-ip (preceding-char))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2033 (goto-char indent-point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2034 (skip-chars-forward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2035
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2036 ;; now figure out syntactic qualities of the current line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2037 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2038 ;; CASE 1: in a string or comment.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2039 ((memq literal '(string comment))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2040 (vhdl-add-syntax literal (vhdl-point 'bopl)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2041 ;; CASE 2: Line is at top level.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2042 ((null containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2043 ;; Find the point to which indentation will be relative
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2044 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2045 (if (null preceding-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2046 ;; CASE 2X.1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2047 ;; no preceding-sexp -> use the preceding statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2048 (vhdl-beginning-of-statement-1 lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2049 ;; CASE 2X.2
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2050 ;; if there is a preceding-sexp then indent relative to it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2051 (goto-char preceding-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2052 ;; if not at boi, then the block-opening keyword is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2053 ;; probably following a label, so we need a different
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2054 ;; relpos
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2055 (if (/= (point) (vhdl-point 'boi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2056 ;; CASE 2X.3
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2057 (vhdl-beginning-of-statement-1 lim)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2058 ;; v-b-o-s could have left us at point-min
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2059 (and (bobp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2060 ;; CASE 2X.4
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2061 (vhdl-forward-syntactic-ws indent-point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2062 (setq placeholder (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2063 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2064 ;; CASE 2A : we are looking at a block-open
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2065 (begin-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2066 (vhdl-add-syntax 'block-open placeholder))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2067 ;; CASE 2B: we are looking at a block-close
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2068 (end-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2069 (vhdl-add-syntax 'block-close placeholder))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2070 ;; CASE 2C: we are looking at a top-level statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2071 ((progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2072 (vhdl-backward-syntactic-ws lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2073 (or (bobp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2074 (= (preceding-char) ?\;)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2075 (vhdl-add-syntax 'statement placeholder))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2076 ;; CASE 2D: we are looking at a top-level statement-cont
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2077 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2078 (vhdl-beginning-of-statement-1 lim)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2079 ;; v-b-o-s could have left us at point-min
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2080 (and (bobp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2081 ;; CASE 2D.1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2082 (vhdl-forward-syntactic-ws indent-point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2083 (vhdl-add-syntax 'statement-cont (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2084 )) ; end CASE 2
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2085 ;; CASE 3: line is inside parentheses. Most likely we are
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2086 ;; either in a subprogram argument (interface) list, or a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2087 ;; continued expression containing parentheses.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2088 ((null containing-begin)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2089 (vhdl-backward-syntactic-ws containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2090 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2091 ;; CASE 3A: we are looking at the arglist closing paren
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2092 ((eq char-after-ip ?\))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2093 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2094 (vhdl-add-syntax 'arglist-close (vhdl-point 'boi)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2095 ;; CASE 3B: we are looking at the first argument in an empty
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2096 ;; argument list.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2097 ((eq char-before-ip ?\()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2098 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2099 (vhdl-add-syntax 'arglist-intro (vhdl-point 'boi)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2100 ;; CASE 3C: we are looking at an arglist continuation line,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2101 ;; but the preceding argument is on the same line as the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2102 ;; opening paren. This case includes multi-line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2103 ;; expression paren groupings.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2104 ((and (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2105 (goto-char (1+ containing-sexp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2106 (skip-chars-forward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2107 (not (eolp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2108 (not (looking-at "--")))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2109 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2110 (vhdl-beginning-of-statement-1 containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2111 (skip-chars-backward " \t(")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2112 (<= (point) containing-sexp)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2113 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2114 (vhdl-add-syntax 'arglist-cont-nonempty (vhdl-point 'boi)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2115 ;; CASE 3D: we are looking at just a normal arglist
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2116 ;; continuation line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2117 (t (vhdl-beginning-of-statement-1 containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2118 (vhdl-forward-syntactic-ws indent-point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2119 (vhdl-add-syntax 'arglist-cont (vhdl-point 'boi)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2120 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2121 ;; CASE 4: A block mid open
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2122 ((and begin-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2123 (looking-at containing-mid))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2124 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2125 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2126 (if (looking-at vhdl-trailer-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2127 ;; CASE 4.1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2128 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2129 (vhdl-backward-skip-label (vhdl-point 'boi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2130 (vhdl-add-syntax 'block-open (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2131 ;; CASE 5: block close brace
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2132 (end-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2133 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2134 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2135 (if (looking-at vhdl-trailer-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2136 ;; CASE 5.1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2137 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2138 (vhdl-backward-skip-label (vhdl-point 'boi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2139 (vhdl-add-syntax 'block-close (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2140 ;; CASE 6: A continued statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2141 ((and (/= char-before-ip ?\;)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2142 ;; check it's not a trailer begin keyword, or a begin
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2143 ;; keyword immediately following a label.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2144 (not (and begin-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2145 (or (looking-at vhdl-trailer-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2146 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2147 (vhdl-backward-skip-label containing-sexp)))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2148 ;; check it's not a statement keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2149 (not (and (looking-at vhdl-statement-fwd-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2150 (vhdl-statement-p)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2151 ;; see if the b-o-s is before the indent point
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2152 (> indent-point
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2153 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2154 (vhdl-beginning-of-statement-1 containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2155 ;; If we ended up after a leader, then this will
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2156 ;; move us forward to the start of the first
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2157 ;; statement. Note that a containing sexp here is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2158 ;; always a keyword, not a paren, so this will
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2159 ;; have no effect if we hit the containing-sexp.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2160 (vhdl-forward-syntactic-ws indent-point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2161 (setq placeholder (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2162 ;; check it's not a block-intro
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2163 (/= placeholder containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2164 ;; check it's not a case block-intro
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2165 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2166 (goto-char placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2167 (or (not (looking-at vhdl-case-alternative-key))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2168 (> (match-end 0) indent-point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2169 (vhdl-add-syntax 'statement-cont placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2170 (if begin-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2171 (vhdl-add-syntax 'block-open)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2172 ;; Statement. But what kind?
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2173 ;; CASE 7: A case alternative key
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2174 ((looking-at vhdl-case-alternative-key)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2175 ;; for a case alternative key, we set relpos to the first
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2176 ;; non-whitespace char on the line containing the "case"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2177 ;; keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2178 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2179 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2180 (if (looking-at vhdl-trailer-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2181 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2182 (vhdl-add-syntax 'case-alternative (vhdl-point 'boi)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2183 ;; CASE 8: statement catchall
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2184 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2185 ;; we know its a statement, but we need to find out if it is
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2186 ;; the first statement in a block
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2187 (if containing-leader
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2188 (goto-char containing-leader)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2189 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2190 ;; Note that a containing sexp here is always a keyword,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2191 ;; not a paren, so skip over the keyword.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2192 (forward-sexp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2193 ;; move to the start of the first statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2194 (vhdl-forward-syntactic-ws indent-point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2195 (setq placeholder (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2196 ;; we want to ignore case alternatives keys when skipping forward
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2197 (let (incase-p)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2198 (while (looking-at vhdl-case-alternative-key)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2199 (setq incase-p (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2200 ;; we also want to skip over the body of the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2201 ;; case/when statement if that doesn't put us at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2202 ;; after the indent-point
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2203 (while (vhdl-skip-case-alternative indent-point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2204 ;; set up the match end
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2205 (looking-at vhdl-case-alternative-key)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2206 (goto-char (match-end 0))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2207 ;; move to the start of the first case alternative statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2208 (vhdl-forward-syntactic-ws indent-point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2209 (setq placeholder (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2210 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2211 ;; CASE 8A: we saw a case/when statement so we must be
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2212 ;; in a switch statement. find out if we are at the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2213 ;; statement just after a case alternative key
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2214 ((and incase-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2215 (= (point) indent-point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2216 ;; relpos is the "when" keyword
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2217 (vhdl-add-syntax 'statement-case-intro incase-p))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2218 ;; CASE 8B: any old statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2219 ((< (point) indent-point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2220 ;; relpos is the first statement of the block
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2221 (vhdl-add-syntax 'statement placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2222 (if begin-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2223 (vhdl-add-syntax 'block-open)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2224 ;; CASE 8C: first statement in a block
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2225 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2226 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2227 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2228 (if (looking-at vhdl-trailer-re)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2229 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2230 (vhdl-backward-skip-label (vhdl-point 'boi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2231 (vhdl-add-syntax 'statement-block-intro (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2232 (if begin-after-ip
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2233 (vhdl-add-syntax 'block-open)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2234 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2235 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2236
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2237 ;; now we need to look at any modifiers
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2238 (goto-char indent-point)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2239 (skip-chars-forward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2240 (if (looking-at "--")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2241 (vhdl-add-syntax 'comment))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2242 ;; return the syntax
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2243 vhdl-syntactic-context))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2244
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2245
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2246 ;; Standard indentation line-ups:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2247
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2248 (defun vhdl-lineup-arglist (langelem)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2249 ;; lineup the current arglist line with the arglist appearing just
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2250 ;; after the containing paren which starts the arglist.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2251 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2252 (let* ((containing-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2253 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2254 ;; arglist-cont-nonempty gives relpos ==
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2255 ;; to boi of containing-sexp paren. This
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2256 ;; is good when offset is +, but bad
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2257 ;; when it is vhdl-lineup-arglist, so we
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2258 ;; have to special case a kludge here.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2259 (if (memq (car langelem) '(arglist-intro arglist-cont-nonempty))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2260 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2261 (beginning-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2262 (backward-up-list 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2263 (skip-chars-forward " \t" (vhdl-point 'eol)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2264 (goto-char (cdr langelem)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2265 (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2266 (cs-curcol (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2267 (goto-char (cdr langelem))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2268 (current-column))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2269 (if (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2270 (beginning-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2271 (looking-at "[ \t]*)"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2272 (progn (goto-char (match-end 0))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2273 (backward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2274 (forward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2275 (vhdl-forward-syntactic-ws)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2276 (- (current-column) cs-curcol))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2277 (goto-char containing-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2278 (or (eolp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2279 (let ((eol (vhdl-point 'eol))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2280 (here (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2281 (forward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2282 (skip-chars-forward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2283 (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2284 (vhdl-forward-syntactic-ws)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2285 (if (< (point) eol)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2286 (goto-char here))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2287 (- (current-column) cs-curcol)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2288 ))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2289
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2290 (defun vhdl-lineup-arglist-intro (langelem)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2291 ;; lineup an arglist-intro line to just after the open paren
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2292 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2293 (let ((cs-curcol (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2294 (goto-char (cdr langelem))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2295 (current-column)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2296 (ce-curcol (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2297 (beginning-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2298 (backward-up-list 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2299 (skip-chars-forward " \t" (vhdl-point 'eol))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2300 (current-column))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2301 (- ce-curcol cs-curcol -1))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2302
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2303 (defun vhdl-lineup-comment (langelem)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2304 ;; support old behavior for comment indentation. we look at
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2305 ;; vhdl-comment-only-line-offset to decide how to indent comment
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2306 ;; only-lines
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2307 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2308 (back-to-indentation)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2309 ;; at or to the right of comment-column
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2310 (if (>= (current-column) comment-column)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2311 (vhdl-comment-indent)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2312 ;; otherwise, indent as specified by vhdl-comment-only-line-offset
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2313 (if (not (bolp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2314 (or (car-safe vhdl-comment-only-line-offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2315 vhdl-comment-only-line-offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2316 (or (cdr-safe vhdl-comment-only-line-offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2317 (car-safe vhdl-comment-only-line-offset)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2318 -1000 ;jam it against the left side
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2319 )))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2320
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2321 (defun vhdl-lineup-statement-cont (langelem)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2322 ;; line up statement-cont after the assignment operator
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2323 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2324 (let* ((relpos (cdr langelem))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2325 (assignp (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2326 (goto-char (vhdl-point 'boi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2327 (and (re-search-forward "\\(<\\|:\\)="
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2328 (vhdl-point 'eol) t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2329 (- (point) (vhdl-point 'boi)))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2330 (curcol (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2331 (goto-char relpos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2332 (current-column)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2333 foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2334 (while (and (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2335 (< (point) (vhdl-point 'eol)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2336 (re-search-forward "\\(<\\|:\\)=\\|(" (vhdl-point 'eol) 'move)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2337 (if (vhdl-in-literal (cdr langelem))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2338 (forward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2339 (if (= (preceding-char) ?\()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2340 ;; skip over any parenthesized expressions
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2341 (goto-char (min (vhdl-point 'eol)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2342 (scan-lists (point) 1 1)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2343 ;; found an assignment operator (not at eol)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2344 (setq foundp (not (looking-at "\\s-*$"))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2345 (if (not foundp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2346 ;; there's no assignment operator on the line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2347 vhdl-basic-offset
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2348 ;; calculate indentation column after assign and ws, unless
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2349 ;; our line contains an assignment operator
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2350 (if (not assignp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2351 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2352 (forward-char)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2353 (skip-chars-forward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2354 (setq assignp 0)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2355 (- (current-column) assignp curcol))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2356 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2357
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2358
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2359 ;; Indentation commands:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2360
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2361 ;; This is used by indent-for-comment to decide how much to indent a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2362 ;; comment in VHDL code based on its context.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2363 (defun vhdl-comment-indent ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2364 (if (looking-at (concat "^--"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2365 0 ;Existing comment at bol stays there.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2366 (let ((opoint (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2367 placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2368 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2369 (beginning-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2370 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2371 ;; CASE 1: use comment-column if previous line is a
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2372 ;; comment-only line indented to the left of comment-column
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2373 ((save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2374 (beginning-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2375 (and (not (bobp))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2376 (forward-line -1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2377 (skip-chars-forward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2378 (prog1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2379 (looking-at "--")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2380 (setq placeholder (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2381 (goto-char placeholder)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2382 (if (< (current-column) comment-column)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2383 comment-column
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2384 (current-column)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2385 ;; CASE 2: If comment-column is 0, and nothing but space
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2386 ;; before the comment, align it at 0 rather than 1.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2387 ((progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2388 (goto-char opoint)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2389 (skip-chars-backward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2390 (and (= comment-column 0) (bolp)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2391 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2392 ;; CASE 3: indent at comment column except leave at least one
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2393 ;; space.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2394 (t (max (1+ (current-column))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2395 comment-column))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2396 )))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2397
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2398 (defun vhdl-indent-line ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2399 ;; indent the current line as VHDL code. Returns the amount of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2400 ;; indentation change
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2401 (let* ((syntax (vhdl-get-syntactic-context))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2402 (pos (- (point-max) (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2403 (indent (apply '+ (mapcar 'vhdl-get-offset syntax)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2404 (shift-amt (- (current-indentation) indent)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2405 (and vhdl-echo-syntactic-information-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2406 (message "syntax: %s, indent= %d" syntax indent))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2407 (if (zerop shift-amt)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2408 nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2409 (delete-region (vhdl-point 'bol) (vhdl-point 'boi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2410 (beginning-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2411 (indent-to indent))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2412 (if (< (point) (vhdl-point 'boi))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2413 (back-to-indentation)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2414 ;; If initial point was within line's indentation, position after
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2415 ;; the indentation. Else stay at same point in text.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2416 (if (> (- (point-max) pos) (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2417 (goto-char (- (point-max) pos)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2418 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2419 (run-hooks 'vhdl-special-indent-hook)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2420 shift-amt))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2421
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2422 (defun vhdl-indent-command (&optional whole-exp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2423 "Indent current line as VHDL code, or in some cases insert a tab character.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2424
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2425 If `vhdl-tab-always-indent' is t, always just indent the current line.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2426 If nil, indent the current line only if point is at the left margin or
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2427 in the line's indentation; otherwise insert a tab. If other than nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2428 or t, then tab is inserted only within literals (comments and strings)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2429 and inside preprocessor directives, but line is always reindented.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2430
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2431 A numeric argument, regardless of its value, means indent rigidly all
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2432 the lines of the expression starting after point so that this line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2433 becomes properly indented. The relative indentation among the lines
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2434 of the expression are preserved."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2435 (interactive "P")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2436 (if whole-exp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2437 ;; If arg, always indent this line as VHDL
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2438 ;; and shift remaining lines of expression the same amount.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2439 (let ((shift-amt (vhdl-indent-line))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2440 beg end)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2441 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2442 (if (eq vhdl-tab-always-indent t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2443 (beginning-of-line))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2444 (setq beg (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2445 (forward-sexp)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2446 (setq end (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2447 (goto-char beg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2448 (forward-line 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2449 (setq beg (point)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2450 (if (> end beg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2451 (indent-code-rigidly beg end (- shift-amt))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2452 ;; No arg supplied, use vhdl-tab-always-indent to determine
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2453 ;; behavior
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2454 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2455 ;; CASE 1: indent when at column zero or in lines indentation,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2456 ;; otherwise insert a tab
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2457 ((not vhdl-tab-always-indent)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2458 (if (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2459 (skip-chars-backward " \t")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2460 (not (bolp)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2461 (insert-tab)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2462 (vhdl-indent-line)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2463 ;; CASE 2: just indent the line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2464 ((eq vhdl-tab-always-indent t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2465 (vhdl-indent-line))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2466 ;; CASE 3: if in a literal, insert a tab, but always indent the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2467 ;; line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2468 (t
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2469 (if (vhdl-in-literal (vhdl-point 'bod))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2470 (insert-tab))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2471 (vhdl-indent-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2472 ))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2473
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2474 (defun vhdl-indent-sexp (&optional endpos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2475 "Indent each line of the list starting just after point.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2476 If optional arg ENDPOS is given, indent each line, stopping when
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2477 ENDPOS is encountered. (interactive)"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2478 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2479 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2480 (let ((beg (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2481 (end (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2482 (vhdl-forward-sexp nil endpos)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2483 (point))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2484 (indent-region beg end nil))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2485
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2486 (defun vhdl-show-syntactic-information ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2487 "Show syntactic information for current line."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2488 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2489 (message "syntactic analysis: %s" (vhdl-get-syntactic-context))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2490 (vhdl-keep-region-active))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2491
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2492
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2493 ;; Verification and regression functions:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2494
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2495 (defun vhdl-regress-line (&optional arg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2496 "Check syntactic information for current line."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2497 (interactive "P")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2498 (let ((expected (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2499 (end-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2500 (if (search-backward " -- ((" (vhdl-point 'bol) t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2501 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2502 (forward-char 4)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2503 (read (current-buffer))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2504 (actual (vhdl-get-syntactic-context))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2505 (expurgated))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2506 ;; remove the library unit symbols
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2507 (mapcar
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2508 (function
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2509 (lambda (elt)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2510 (if (memq (car elt) '(entity configuration package
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2511 package-body architecture))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2512 nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2513 (setq expurgated (append expurgated (list elt))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2514 actual)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2515 (if (and (not arg) expected (listp expected))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2516 (if (not (equal expected expurgated))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2517 (error "Should be: %s, is: %s" expected expurgated))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2518 (save-excursion
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2519 (beginning-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2520 (if (not (looking-at "^\\s-*\\(--.*\\)?$"))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2521 (progn
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2522 (end-of-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2523 (if (search-backward " -- ((" (vhdl-point 'bol) t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2524 (kill-line))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2525 (insert " -- ")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2526 (insert (format "%s" expurgated)))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2527 (vhdl-keep-region-active))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2528
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2529 (defun test-vhdl-get-block-state ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2530 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2531 (let ((case-fold-search t)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2532 here vec (delay 0.5))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2533 (setq here (point))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2534 (message "%s" (prin1-to-string (setq vec (vhdl-get-block-state))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2535 (and (aref vec 0)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2536 (goto-char (aref vec 0))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2537 (sit-for delay))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2538 (and (aref vec 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2539 (goto-char (aref vec 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2540 (sit-for delay))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2541 (goto-char here)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2542 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2543
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2544 ;; Support for Barry Warsaw's elp (emacs lisp profiler) package:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2545
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2546 (setq elp-all-instrumented-list nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2547 (setq elp-function-list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2548 '(
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2549 vhdl-indent-command
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2550 vhdl-indent-line
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2551 vhdl-comment-indent
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2552 vhdl-lineup-statement-cont
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2553 vhdl-lineup-comment
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2554 vhdl-lineup-arglist-intro
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2555 vhdl-lineup-arglist
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2556 vhdl-get-syntactic-context
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2557 vhdl-skip-case-alternative
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2558 vhdl-get-block-state
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2559 vhdl-get-library-unit
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2560 vhdl-beginning-of-statement
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2561 vhdl-beginning-of-statement-1
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2562 vhdl-beginning-of-defun
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2563 vhdl-beginning-of-libunit
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2564 vhdl-backward-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2565 vhdl-forward-sexp
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2566 vhdl-backward-to-block
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2567 vhdl-statement-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2568 vhdl-end-of-leader
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2569 vhdl-corresponding-begin
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2570 vhdl-end-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2571 vhdl-corresponding-end
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2572 vhdl-corresponding-mid
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2573 vhdl-begin-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2574 vhdl-corresponding-defun
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2575 vhdl-defun-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2576 vhdl-libunit-p
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2577 vhdl-last-word
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2578 vhdl-first-word
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2579 vhdl-backward-syntactic-ws
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2580 vhdl-forward-syntactic-ws
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2581 vhdl-in-literal
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2582 vhdl-keep-region-active
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2583 ))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2584
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2585 ;; (elp-instrument-list elp-function-list)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2586
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2587 (defun vhdl-trace-all-functions ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2588 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2589 (let ((list elp-function-list))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2590 (while list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2591 (trace-function-background (car list))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2592 (setq list (cdr list)))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2593
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2594
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2595 ;; Defuns for submitting bug reports:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2596
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2597 (defconst vhdl-version "$Revision: 1.4 $"
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2598 "vhdl-mode version number.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2599 (defconst vhdl-mode-help-address "rwhitby@asc.corp.mot.com"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2600 "Address accepting submission of bug reports.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2601
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2602 (defun vhdl-version ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2603 "Echo the current version of vhdl-mode in the minibuffer."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2604 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2605 (message "Using vhdl-mode %s" vhdl-version)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2606 (vhdl-keep-region-active))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2607
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2608 ;; get reporter-submit-bug-report when byte-compiling
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2609 (and (fboundp 'eval-when-compile)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2610 (eval-when-compile
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2611 (require 'reporter)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2612
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2613 (defun vhdl-submit-bug-report ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2614 "Submit via mail a bug report on vhdl-mode."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2615 (interactive)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2616 ;; load in reporter
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2617 (and
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2618 (y-or-n-p "Do you want to submit a report on vhdl-mode? ")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2619 (require 'reporter)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2620 (reporter-submit-bug-report
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2621 vhdl-mode-help-address
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2622 (concat "vhdl-mode " vhdl-version)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2623 (list
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2624 ;; report only the vars that affect indentation
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2625 'vhdl-basic-offset
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2626 'vhdl-offsets-alist
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2627 'vhdl-comment-only-line-offset
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2628 'vhdl-tab-always-indent
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2629 'tab-width
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2630 )
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2631 (function
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2632 (lambda ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2633 (insert
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2634 (if vhdl-special-indent-hook
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2635 (concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2636 "vhdl-special-indent-hook is set to '"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2637 (format "%s" vhdl-special-indent-hook)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2638 ".\nPerhaps this is your problem?\n"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2639 "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2640 "\n")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2641 (format "vhdl-emacs-features: %s\n" vhdl-emacs-features)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2642 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2643 nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2644 "Dear Rod,"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2645 )))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2646
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2647 (provide 'vhdl-mode)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2648 ;;; vhdl-mode.el ends here