annotate lisp/modes/vhdl-mode.el @ 18:d95e72db5c07 r19-15b92

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