aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2007-12-16 05:08:49 +0000
committerMiles Bader2007-12-16 05:08:49 +0000
commitd29ee6b1a110cf5d170a10317a96acbbd4a1c68b (patch)
tree58f3c40766d8d56de7d2b026c29e198764d910aa
parent7e095e45a3f790e4608c88db9648d248e24901dc (diff)
parent47854a55680b5809811caf72f66ecbe8289c2855 (diff)
downloademacs-d29ee6b1a110cf5d170a10317a96acbbd4a1c68b.tar.gz
emacs-d29ee6b1a110cf5d170a10317a96acbbd4a1c68b.zip
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-300
-rw-r--r--ChangeLog4
-rw-r--r--admin/CPP-DEFINES46
-rw-r--r--admin/ChangeLog10
-rw-r--r--admin/FOR-RELEASE16
-rwxr-xr-xconfigure2
-rw-r--r--configure.in2
-rw-r--r--doc/lispref/ChangeLog7
-rw-r--r--doc/lispref/nonascii.texi18
-rw-r--r--doc/lispref/os.texi4
-rw-r--r--doc/misc/ChangeLog10
-rw-r--r--doc/misc/dbus.texi47
-rw-r--r--doc/misc/gnus.texi2
-rw-r--r--etc/ChangeLog35
-rw-r--r--etc/NEWS17
-rw-r--r--etc/NEWS.222
-rw-r--r--etc/TODO8
-rw-r--r--etc/emacs.desktop11
-rw-r--r--etc/images/icons/emacs16_mac.png1
-rw-r--r--etc/images/icons/emacs24_mac.png1
-rw-r--r--etc/images/icons/emacs256_mac.png1
-rw-r--r--etc/images/icons/emacs32_mac.png1
-rw-r--r--etc/images/icons/emacs48_mac.png1
-rw-r--r--etc/images/icons/emacs512_mac.png1
-rw-r--r--etc/images/icons/macemacs_16.pngbin1272 -> 0 bytes
-rw-r--r--etc/images/icons/macemacs_24.pngbin1795 -> 0 bytes
-rw-r--r--etc/images/icons/macemacs_256.pngbin58604 -> 0 bytes
-rw-r--r--etc/images/icons/macemacs_32.pngbin2454 -> 0 bytes
-rw-r--r--etc/images/icons/macemacs_48.pngbin4330 -> 0 bytes
-rw-r--r--etc/images/icons/macemacs_512.pngbin160704 -> 0 bytes
-rw-r--r--etc/schema/dbdyntbl.rnc2
-rw-r--r--etc/schema/docbk-dyntbl.rnc (renamed from etc/schema/docbook-dyntbl.rnc)0
-rw-r--r--etc/schema/docbk-soextbl.rnc (renamed from etc/schema/docbook-soextbl.rnc)0
-rw-r--r--etc/schema/xhtml-bform.rnc (renamed from etc/schema/xhtml-basic-form.rnc)0
-rw-r--r--etc/schema/xhtml-btable.rnc (renamed from etc/schema/xhtml-basic-table.rnc)0
-rw-r--r--etc/schema/xhtml-form.rnc2
-rw-r--r--etc/schema/xhtml-lst.rnc (renamed from etc/schema/xhtml-list.rnc)0
-rw-r--r--etc/schema/xhtml-table.rnc2
-rw-r--r--etc/schema/xhtml-tgt.rnc (renamed from etc/schema/xhtml-target.rnc)0
-rw-r--r--etc/schema/xhtml-xstyle.rnc (renamed from etc/schema/xhtml-style.rnc)0
-rw-r--r--etc/schema/xhtml.rnc10
-rw-r--r--leim/ChangeLog5
-rw-r--r--leim/quail/lao.el5
-rw-r--r--leim/quail/latin-post.el2
-rw-r--r--lib-src/ChangeLog2
-rw-r--r--lisp/ChangeLog319
-rw-r--r--lisp/bindings.el2
-rw-r--r--lisp/calc/calc-aent.el18
-rw-r--r--lisp/calc/calc-ext.el2
-rw-r--r--lisp/calc/calc-lang.el3
-rw-r--r--lisp/calc/calc-mode.el2
-rw-r--r--lisp/calc/calc.el8
-rw-r--r--lisp/calc/calcalg2.el4
-rw-r--r--lisp/calc/calcalg3.el2
-rw-r--r--lisp/calendar/calendar.el2
-rw-r--r--lisp/dired.el2
-rw-r--r--lisp/doc-view.el84
-rw-r--r--lisp/ediff-init.el4
-rw-r--r--lisp/emacs-lisp/check-declare.el6
-rw-r--r--lisp/emacs-lisp/checkdoc.el8
-rw-r--r--lisp/emacs-lisp/edebug.el4
-rw-r--r--lisp/emacs-lisp/lisp-mnt.el25
-rw-r--r--lisp/emulation/viper-init.el10
-rw-r--r--lisp/emulation/viper-util.el2
-rw-r--r--lisp/erc/ChangeLog34
-rw-r--r--lisp/erc/erc-backend.el12
-rw-r--r--lisp/erc/erc-lang.el2
-rw-r--r--lisp/erc/erc-match.el2
-rw-r--r--lisp/erc/erc-services.el83
-rw-r--r--lisp/erc/erc-stamp.el4
-rw-r--r--lisp/erc/erc.el1
-rw-r--r--lisp/files.el12
-rw-r--r--lisp/generic-x.el16
-rw-r--r--lisp/gnus/ChangeLog166
-rw-r--r--lisp/gnus/ecomplete.el2
-rw-r--r--lisp/gnus/gnus-art.el136
-rw-r--r--lisp/gnus/gnus-cache.el11
-rw-r--r--lisp/gnus/gnus-ems.el2
-rw-r--r--lisp/gnus/gnus-fun.el12
-rw-r--r--lisp/gnus/gnus-group.el6
-rw-r--r--lisp/gnus/gnus-int.el41
-rw-r--r--lisp/gnus/gnus-spec.el6
-rw-r--r--lisp/gnus/gnus-start.el8
-rw-r--r--lisp/gnus/gnus-sum.el25
-rw-r--r--lisp/gnus/gnus-util.el58
-rw-r--r--lisp/gnus/gnus-uu.el2
-rw-r--r--lisp/gnus/gnus.el6
-rw-r--r--lisp/gnus/mail-source.el9
-rw-r--r--lisp/gnus/message.el10
-rw-r--r--lisp/gnus/mm-bodies.el7
-rw-r--r--lisp/gnus/mm-decode.el43
-rw-r--r--lisp/gnus/mm-extern.el6
-rw-r--r--lisp/gnus/mm-util.el10
-rw-r--r--lisp/gnus/mm-uu.el2
-rw-r--r--lisp/gnus/mm-view.el12
-rw-r--r--lisp/gnus/mml-smime.el16
-rw-r--r--lisp/gnus/mml.el10
-rw-r--r--lisp/gnus/mml1991.el19
-rw-r--r--lisp/gnus/mml2015.el15
-rw-r--r--lisp/gnus/nndb.el11
-rw-r--r--lisp/gnus/nnfolder.el8
-rw-r--r--lisp/gnus/nnheader.el2
-rw-r--r--lisp/gnus/nnmail.el10
-rw-r--r--lisp/gnus/nnmaildir.el28
-rw-r--r--lisp/gnus/nnrss.el8
-rw-r--r--lisp/gnus/pop3.el2
-rw-r--r--lisp/gnus/rfc1843.el8
-rw-r--r--lisp/gnus/sieve-manage.el7
-rw-r--r--lisp/gnus/smime.el6
-rw-r--r--lisp/gnus/spam-stat.el2
-rw-r--r--lisp/gnus/spam.el15
-rw-r--r--lisp/help-fns.el3
-rw-r--r--lisp/ibuffer.el2
-rw-r--r--lisp/indent.el1
-rw-r--r--lisp/international/ja-dic-cnv.el2
-rw-r--r--lisp/international/latexenc.el3
-rw-r--r--lisp/isearch.el27
-rw-r--r--lisp/kmacro.el2
-rw-r--r--lisp/mail/feedmail.el2
-rw-r--r--lisp/mail/hashcash.el17
-rw-r--r--lisp/mail/reporter.el2
-rw-r--r--lisp/mail/rmailout.el2
-rw-r--r--lisp/mail/uce.el2
-rw-r--r--lisp/makefile.w32-in42
-rw-r--r--lisp/man.el4
-rw-r--r--lisp/mouse.el2
-rw-r--r--lisp/net/dbus.el142
-rw-r--r--lisp/net/imap.el13
-rw-r--r--lisp/net/rcirc.el14
-rw-r--r--lisp/net/trampver.el2
-rw-r--r--lisp/pgg-parse.el4
-rw-r--r--lisp/pgg.el33
-rw-r--r--lisp/play/mpuz.el2
-rw-r--r--lisp/progmodes/ada-xref.el14
-rw-r--r--lisp/progmodes/antlr-mode.el2
-rw-r--r--lisp/progmodes/cc-cmds.el7
-rw-r--r--lisp/progmodes/cc-vars.el59
-rw-r--r--lisp/progmodes/cperl-mode.el12
-rw-r--r--lisp/progmodes/ebrowse.el8
-rw-r--r--lisp/progmodes/idlw-shell.el4
-rw-r--r--lisp/progmodes/idlwave.el6
-rw-r--r--lisp/progmodes/perl-mode.el9
-rw-r--r--lisp/progmodes/verilog-mode.el10318
-rw-r--r--lisp/progmodes/vhdl-mode.el7
-rw-r--r--lisp/replace.el44
-rw-r--r--lisp/server.el8
-rw-r--r--lisp/startup.el2
-rw-r--r--lisp/term/mac-win.el2
-rw-r--r--lisp/textmodes/artist.el4
-rw-r--r--lisp/textmodes/org-publish.el4
-rw-r--r--lisp/textmodes/org.el29
-rw-r--r--lisp/textmodes/reftex-index.el2
-rw-r--r--lisp/textmodes/reftex-toc.el6
-rw-r--r--lisp/textmodes/reftex.el8
-rw-r--r--lisp/textmodes/texinfmt.el5
-rw-r--r--lisp/url/ChangeLog9
-rw-r--r--lisp/url/url-cookie.el25
-rw-r--r--lisp/url/url-history.el38
-rw-r--r--lisp/url/url-util.el22
-rw-r--r--lisp/url/url.el17
-rw-r--r--lisp/vc-cvs.el2
-rw-r--r--lisp/vc-mcvs.el2
-rw-r--r--lisp/vc.el14
-rw-r--r--lisp/wdired.el2
-rw-r--r--lisp/whitespace.el4
-rw-r--r--src/ChangeLog69
-rw-r--r--src/buffer.c58
-rw-r--r--src/dbusbind.c224
-rw-r--r--src/dispextern.h2
-rw-r--r--src/keyboard.c89
-rw-r--r--src/w32fns.c8
-rw-r--r--src/w32term.c2
171 files changed, 12404 insertions, 763 deletions
diff --git a/ChangeLog b/ChangeLog
index 4366e4a7a69..8280d712ab1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12007-12-09 Andreas Schwab <schwab@suse.de>
2
3 * configure.in: D-Bus is not enabled by default.
4
12007-12-06 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 52007-12-06 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2 6
3 * configure.in: Add AC_CONFIG_SRCDIR which was lost in the previous 7 * configure.in: Add AC_CONFIG_SRCDIR which was lost in the previous
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
new file mode 100644
index 00000000000..56693064c98
--- /dev/null
+++ b/admin/CPP-DEFINES
@@ -0,0 +1,46 @@
1Here are some of the cpp macros used, together with some short explanation
2of their use. Feel free to add more macros and more categories.
3
4** Distinguishing OSes **
5
6MAC_OS Compiling for some version of Mac OS?
7MAC_OS8 Compiling for Mac OS version 8. Requires MAC_OS?
8MAC_OSX Compiling for Mac OS X? Is that also valid for Darwin?
9MAC_OS_X ?? Apparently only used once in mac.c.
10CYGWIN Compiling the Cygwin port.
11__CYGWIN__ Ditto
12MSDOS Compiling the MS-DOS port.
13__MSDOS__ Ditto.
14__DJGPP__ Major version number of the DJGPP library for the DOS port.
15__DJGPP_MINOR__ Minor version number of the DJGPP library.
16__GO32__ Compiling the DOS port with DJGPP v1.x (obsolete).
17DOS_NT Compiling for either the MS-DOS or native MS-Windows port.
18WINDOWSNT Compiling the native MS-Windows (W32) port.
19__MINGW32__ Compiling the W32 port with the MinGW port of GCC.
20_MSC_VER Compiling the W32 port with the Microsoft C compiler.
21
22** Distinguishing GUIs **
23
24HAVE_NTGUI Use the native W32 GUI for windows, frames, menus&scrollbars.
25HAVE_CARBON Compile support for the Carbon GUI. Requires MAC_OS?
26HAVE_X11 Compile support for the X11 GUI.
27HAVE_X_WINDOWS Compile support for X Window system
28X11 ?? Makefile.in suggests it's equivalent to HAVE_X11
29USE_LUCID Use the Lucid toolkit for menus&scrollbars. Requires HAVE_X11.
30USE_MOTIF Use the Motif toolkit for menus&scrollbars. Requires HAVE_X11.
31USE_GTK Use the Gtk toolkit for menus&scrollbars. Requires HAVE_X11.
32
33** Frame types **
34
35FRAME_TERMCAP_P A tty (character terminal) frame.
36FRAME_X_P A frame on X Window system.
37FRAME_MSDOS_P An MS-DOS frame (used only by the DOS port).
38FRAME_MAC_P A Mac frame.
39FRAME_W32_P A frame using native MS-Windows GUI.
40FRAME_WINDOW_P A GUI frame (like X, w32, etc.)
41
42** Compile-time options **
43REL_ALLOC Compile in the relocatable memory allocator ralloc.c.
44SYSTEM_MALLOC Use the system library's malloc.
45
46# arch-tag: bc80061a-1168-4911-9766-46aaf2640250
diff --git a/admin/ChangeLog b/admin/ChangeLog
index c3252d3ff70..516cecfbb6d 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,13 @@
12007-12-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * CPP-DEFINES: New file.
4
52007-12-08 Reiner Steib <Reiner.Steib@gmx.de>
6
7 * FOR-RELEASE: Remove "window-system in face definition" [of
8 gnus-treat-emphasize]. Remove "Gnus archive groups". Add comment
9 on gnus-dired.el.
10
12007-12-05 Glenn Morris <rgm@gnu.org> 112007-12-05 Glenn Morris <rgm@gnu.org>
2 12
3 * admin.el (set-version): Handle configure.in. Adapt for doc/ 13 * admin.el (set-version): Handle configure.in. Adapt for doc/
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE
index 3ab61ba577c..f96da325b75 100644
--- a/admin/FOR-RELEASE
+++ b/admin/FOR-RELEASE
@@ -91,16 +91,8 @@ http://lists.gnu.org/archive/html/emacs-devel/2007-05/msg01339.html
91 91
92** rms: gnus-dired.el is a mistake. Those features should not 92** rms: gnus-dired.el is a mistake. Those features should not
93be part of Gnus. They should be moved to some other part of Emacs. 93be part of Gnus. They should be moved to some other part of Emacs.
94 94rsteib: Gnus dependencies in `gnus-dired.el' (and `mailcap.el') have been
95** sdl.web@gmail.com, 28 Oct: window-system in face definition 95minimized. I don't know what is left to do here.
96
97** Gnus archive groups are not shown at all if they are not at the default level.
98Fixed in Gnus CVS, but the patch has not been synched to Emacs yet:
99http://thread.gmane.org/gmane.emacs.gnus.general/65622/focus=65757
100
101** Extra question asked when doing a reply in Gnus
102Fixed in Gnus CVS, but the patch has not been synched to Emacs yet:
103http://thread.gmane.org/gmane.emacs.gnus.general/65627/65768
104 96
105** sdl.web@gmail.com, 30 Oct: ps-lpr-switches has no effect 97** sdl.web@gmail.com, 30 Oct: ps-lpr-switches has no effect
106 98
@@ -115,6 +107,10 @@ http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg02052.html
115** Fix or document the shortcoming of easymenu and :suffix. 107** Fix or document the shortcoming of easymenu and :suffix.
116http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01857.html 108http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01857.html
117 109
110** Fix problem with mode-name in SGML mode.
111If mode-name stays non-string, add NEWS entry and doc fix.
112http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg02048.html
113
118* DOCUMENTATION 114* DOCUMENTATION
119 115
120** Check the Emacs Tutorial. 116** Check the Emacs Tutorial.
diff --git a/configure b/configure
index 74ab9d542f9..0f3580be246 100755
--- a/configure
+++ b/configure
@@ -1370,7 +1370,7 @@ Optional Packages:
1370 --without-xaw3d don't use Xaw3d 1370 --without-xaw3d don't use Xaw3d
1371 --without-xim don't use X11 XIM 1371 --without-xim don't use X11 XIM
1372 --without-carbon don't use Carbon GUI on Mac OS X 1372 --without-carbon don't use Carbon GUI on Mac OS X
1373 --without-dbus don't use D-Bus 1373 --with-dbus use D-Bus
1374 --with-x use the X Window System 1374 --with-x use the X Window System
1375 1375
1376Some influential environment variables: 1376Some influential environment variables:
diff --git a/configure.in b/configure.in
index 76fd9a48173..ea68e2a6c2a 100644
--- a/configure.in
+++ b/configure.in
@@ -121,7 +121,7 @@ EMACS_ARG_N([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
121EMACS_ARG_N([xaw3d],[don't use Xaw3d]) 121EMACS_ARG_N([xaw3d],[don't use Xaw3d])
122EMACS_ARG_N([xim],[don't use X11 XIM]) 122EMACS_ARG_N([xim],[don't use X11 XIM])
123EMACS_ARG_N([carbon],[don't use Carbon GUI on Mac OS X]) 123EMACS_ARG_N([carbon],[don't use Carbon GUI on Mac OS X])
124EMACS_ARG_N([dbus],[don't use D-Bus]) 124EMACS_ARG_Y([dbus],[use D-Bus])
125 125
126AC_ARG_ENABLE(carbon-app, 126AC_ARG_ENABLE(carbon-app,
127[AS_HELP_STRING([--enable-carbon-app@<:@=DIR@:>@], 127[AS_HELP_STRING([--enable-carbon-app@<:@=DIR@:>@],
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 586f250bd06..bfeb88f7830 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,10 @@
12007-12-14 Martin Rudalics <rudalics@gmx.at>
2
3 * nonascii.texi (Encoding and I/O): Reword to avoid saying
4 "visit the current buffer".
5
6 * os.texi (System Interface): Fix typo.
7
12007-12-04 Richard Stallman <rms@gnu.org> 82007-12-04 Richard Stallman <rms@gnu.org>
2 9
3 * objects.texi (Symbol Type): Fix typo. 10 * objects.texi (Symbol Type): Fix typo.
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index 7c504aef2cd..16f70f57b9d 100644
--- a/doc/lispref/nonascii.texi
+++ b/doc/lispref/nonascii.texi
@@ -727,15 +727,15 @@ operation finishes the job of choosing a coding system. Very often
727you will want to find out afterwards which coding system was chosen. 727you will want to find out afterwards which coding system was chosen.
728 728
729@defvar buffer-file-coding-system 729@defvar buffer-file-coding-system
730This buffer-local variable records the coding system that was used to visit 730This buffer-local variable records the coding system used for saving the
731the current buffer. It is used for saving the buffer, and for writing part 731buffer and for writing part of the buffer with @code{write-region}. If
732of the buffer with @code{write-region}. If the text to be written 732the text to be written cannot be safely encoded using the coding system
733cannot be safely encoded using the coding system specified by this 733specified by this variable, these operations select an alternative
734variable, these operations select an alternative encoding by calling 734encoding by calling the function @code{select-safe-coding-system}
735the function @code{select-safe-coding-system} (@pxref{User-Chosen 735(@pxref{User-Chosen Coding Systems}). If selecting a different encoding
736Coding Systems}). If selecting a different encoding requires to ask 736requires to ask the user to specify a coding system,
737the user to specify a coding system, @code{buffer-file-coding-system} 737@code{buffer-file-coding-system} is updated to the newly selected coding
738is updated to the newly selected coding system. 738system.
739 739
740@code{buffer-file-coding-system} does @emph{not} affect sending text 740@code{buffer-file-coding-system} does @emph{not} affect sending text
741to a subprocess. 741to a subprocess.
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index bff759215da..6c237d83457 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -21,8 +21,8 @@ pertaining to the terminal and the screen.
21* System Environment:: Distinguish the name and kind of system. 21* System Environment:: Distinguish the name and kind of system.
22* User Identification:: Finding the name and user id of the user. 22* User Identification:: Finding the name and user id of the user.
23* Time of Day:: Getting the current time. 23* Time of Day:: Getting the current time.
24* Time Conversion:: Converting a time from numeric form 24* Time Conversion:: Converting a time from numeric form to
25 to calendrical data, and vice versa). 25 calendrical data and vice versa.
26* Time Parsing:: Converting a time from numeric form to text 26* Time Parsing:: Converting a time from numeric form to text
27 and vice versa. 27 and vice versa.
28* Processor Run Time:: Getting the run time used by Emacs. 28* Processor Run Time:: Getting the run time used by Emacs.
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 61fd28a0622..8e4eab56b15 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,13 @@
12007-12-14 Sven Joachim <svenjoac@gmx.de>
2
3 * gnus.texi (Score Variables): Fix typo.
4
52007-12-07 Michael Albinus <michael.albinus@gmx.de>
6
7 * dbus.texi (Synchronous Methods): Adapt dbus-call-method.
8 (Signals): Adapt dbus-send-signal and dbus-register-signal.
9 (Errors and Events): Adapt dbus-event.
10
12007-12-03 Lars Magne Ingebrigtsen <larsi@gnus.org> 112007-12-03 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 12
3 * gnus.texi (Other Files): Add the yenc command. 13 * gnus.texi (Other Files): Add the yenc command.
diff --git a/doc/misc/dbus.texi b/doc/misc/dbus.texi
index 14ceea37d1d..b5c8ce3efb1 100644
--- a/doc/misc/dbus.texi
+++ b/doc/misc/dbus.texi
@@ -318,7 +318,7 @@ which carries the input parameters to the object owning the method to
318be called, and a reply message returning the resulting output 318be called, and a reply message returning the resulting output
319parameters from the object. 319parameters from the object.
320 320
321@defun dbus-call-method bus method service path interface &rest args 321@defun dbus-call-method bus service path interface method &rest args
322This function calls @var{method} on the D-Bus @var{bus}. @var{bus} is 322This function calls @var{method} on the D-Bus @var{bus}. @var{bus} is
323either the symbol @code{:system} or the symbol @code{:session}. 323either the symbol @code{:system} or the symbol @code{:session}.
324 324
@@ -336,8 +336,8 @@ Lisp objects, according to the type conversion rules described in
336 336
337@example 337@example
338(dbus-call-method 338(dbus-call-method
339 :session "GetKeyField" "org.gnome.seahorse" 339 :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp"
340 "/org/gnome/seahorse/keys/openpgp" "org.gnome.seahorse.Keys" 340 "org.gnome.seahorse.Keys" "GetKeyField"
341 "openpgp:657984B8C7A966DD" "simple-name") 341 "openpgp:657984B8C7A966DD" "simple-name")
342 342
343@result{} (t ("Philip R. Zimmermann")) 343@result{} (t ("Philip R. Zimmermann"))
@@ -349,8 +349,9 @@ object. Example:
349 349
350@example 350@example
351(dbus-call-method 351(dbus-call-method
352 :system "GetPropertyString" "org.freedesktop.Hal" 352 :system "org.freedesktop.Hal"
353 "/org/freedesktop/Hal/devices/computer" "org.freedesktop.Hal.Device" 353 "/org/freedesktop/Hal/devices/computer"
354 "org.freedesktop.Hal.Device" "GetPropertyString"
354 "system.kernel.machine") 355 "system.kernel.machine")
355 356
356@result{} "i686" 357@result{} "i686"
@@ -368,14 +369,14 @@ emulate the @code{lshal} command on GNU/Linux systems:
368@example 369@example
369(dolist (device 370(dolist (device
370 (dbus-call-method 371 (dbus-call-method
371 :system "GetAllDevices" "org.freedesktop.Hal" 372 :system "org.freedesktop.Hal"
372 "/org/freedesktop/Hal/Manager" 373 "/org/freedesktop/Hal/Manager"
373 "org.freedesktop.Hal.Manager")) 374 "org.freedesktop.Hal.Manager" "GetAllDevices"))
374 (message "\nudi = %s" device) 375 (message "\nudi = %s" device)
375 (dolist (properties 376 (dolist (properties
376 (dbus-call-method 377 (dbus-call-method
377 :system "GetAllProperties" "org.freedesktop.Hal" 378 :system "org.freedesktop.Hal" device
378 device "org.freedesktop.Hal.Device")) 379 "org.freedesktop.Hal.Device" "GetAllProperties"))
379 (message " %s = %S" 380 (message " %s = %S"
380 (car properties) (or (caar (cdr properties)) "")))) 381 (car properties) (or (caar (cdr properties)) ""))))
381 382
@@ -406,7 +407,7 @@ emulate the @code{lshal} command on GNU/Linux systems:
406Signals are broadcast messages. They carry input parameters, which 407Signals are broadcast messages. They carry input parameters, which
407are received by all objects which have registered for such a signal. 408are received by all objects which have registered for such a signal.
408 409
409@defun dbus-send-signal bus signal service path interface &rest args 410@defun dbus-send-signal bus service path interface signal &rest args
410This function is similar to @code{dbus-call-method}. The difference 411This function is similar to @code{dbus-call-method}. The difference
411is, that there are no returning output parameters. 412is, that there are no returning output parameters.
412 413
@@ -425,12 +426,12 @@ Conversion}. Example:
425 426
426@example 427@example
427(dbus-send-signal 428(dbus-send-signal
428 :session "FileModified" "org.gnu.Emacs" "/org/gnu/Emacs" 429 :session "org.gnu.Emacs" "/org/gnu/Emacs"
429 "org.gnu.Emacs.FileManager" "/home/albinus/.emacs") 430 "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs")
430@end example 431@end example
431@end defun 432@end defun
432 433
433@defun dbus-register-signal bus signal service path interface handler 434@defun dbus-register-signal bus service path interface signal handler
434With this function, an application registers for @var{signal} on the 435With this function, an application registers for @var{signal} on the
435D-Bus @var{bus}. 436D-Bus @var{bus}.
436 437
@@ -461,13 +462,15 @@ received. It must accept as arguments the output parameters
461(defun my-dbus-signal-handler (device) 462(defun my-dbus-signal-handler (device)
462 (message "Device %s added" device)) 463 (message "Device %s added" device))
463 464
465@result{} my-dbus-signal-handler
466
464(dbus-register-signal 467(dbus-register-signal
465 :system "DeviceAdded" 468 :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager"
466 (dbus-get-name-owner :system "org.freedesktop.Hal") 469 "org.freedesktop.Hal.Manager" "DeviceAdded"
467 "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager"
468 'my-dbus-signal-handler) 470 'my-dbus-signal-handler)
469 471
470@result{} (:system "org.freedesktop.Hal.Manager" "DeviceAdded") 472@result{} (:system ":1.3" "/org/freedesktop/Hal/Manager"
473 "org.freedesktop.Hal.Manager" "DeviceAdded")
471@end example 474@end example
472 475
473As we know from the inspection data of interface 476As we know from the inspection data of interface
@@ -503,13 +506,9 @@ Incoming D-Bus messages are handled as Emacs events (see @pxref{Misc
503Events, , , elisp}). The generated event has this form: 506Events, , , elisp}). The generated event has this form:
504 507
505@example 508@example
506(dbus-event @var{handler} @var{bus} @var{service} @var{path} @var{interface} @var{member} &rest @var{args}) 509(dbus-event @var{bus} @var{service} @var{path} @var{interface} @var{member} @var{handler} &rest @var{args})
507@end example 510@end example
508 511
509@var{handler} is the callback function which has been registered for
510this signal (see @pxref{Signals}). When a @code{dbus-event} event
511arrives, @var{handler} is called with @var{args} as arguments.
512
513@var{bus} identifies the D-Bus the signal is coming from. It is 512@var{bus} identifies the D-Bus the signal is coming from. It is
514either the symbol @code{:system} or the symbol @code{:session}. 513either the symbol @code{:system} or the symbol @code{:session}.
515 514
@@ -517,6 +516,10 @@ either the symbol @code{:system} or the symbol @code{:session}.
517of the D-Bus object emitting the signal. @var{interface} and 516of the D-Bus object emitting the signal. @var{interface} and
518@var{member} denote the signal which has been sent. 517@var{member} denote the signal which has been sent.
519 518
519@var{handler} is the callback function which has been registered for
520this signal (see @pxref{Signals}). When a @code{dbus-event} event
521arrives, @var{handler} is called with @var{args} as arguments.
522
520In order to inspect the @code{dbus-event} data, you could extend the 523In order to inspect the @code{dbus-event} data, you could extend the
521definition of the callback function in @ref{Signals}: 524definition of the callback function in @ref{Signals}:
522 525
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 8ec39ce81fe..4a165c62b25 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -20529,7 +20529,7 @@ Suffix to add to the group name to arrive at the score file name
20529@vindex gnus-score-uncacheable-files 20529@vindex gnus-score-uncacheable-files
20530@cindex score cache 20530@cindex score cache
20531All score files are normally cached to avoid excessive re-loading of 20531All score files are normally cached to avoid excessive re-loading of
20532score files. However, if this might make your Emacs grow big and 20532score files. However, this might make your Emacs grow big and
20533bloated, so this regexp can be used to weed out score files unlikely 20533bloated, so this regexp can be used to weed out score files unlikely
20534to be needed again. It would be a bad idea to deny caching of 20534to be needed again. It would be a bad idea to deny caching of
20535@file{all.SCORE}, while it might be a good idea to not cache 20535@file{all.SCORE}, while it might be a good idea to not cache
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 0cd4f718b1a..19011436d3b 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,38 @@
12007-12-15 Eli Zaretskii <eliz@gnu.org>
2
3 The following files renamed to avoid file-name clashes in
4 8+3 (a.k.a. DOS) namespace:
5
6 * schema/xhtml-basic-form.rnc: Renamed to xhtml-bform.rnc.
7 * schema/xhtml-basic-table.rnc: Renamed to xhtml-btable.rnc.
8 * schema/xhtml-list.rnc: Renamed to xhtml-lst.rnc.
9 * schema/xhtml-target.rnc: Renamed to xhtml-tgt.rnc.
10 * schema/xhtml-style.rnc: Renamed to xhtml-xstyle.rnc.
11 * schema/xhtml-form.rnc, schema/xhtml-table.rnc, schema/xhtml.rnc:
12 Updated accordingly.
13
14 * schema/docbook-dyntbl.rnc, schema/docbook-dyntbl.rnc: Renamed to
15 docbk-dyntbl.rnc and docbk-soextbl.rnc, respectively.
16
17 * images/icons/macemacs_16.png, images/icons/macemacs_24.png:
18 * images/icons/macemacs_32.png, images/icons/macemacs_48.png:
19 * images/icons/macemacs_256.png, images/icons/macemacs_512.png:
20 Renamed to emacs16_mac.png, emacs24_mac.png, emacs32_mac.png,
21 emacs48_mac.png, emacs256_mac.png, and emacs512_mac.png,
22 respectively.
23
242007-12-08 Ulrich Mueller <ulm@gentoo.org> (tiny change)
25
26 * emacs.desktop (Exec, Icon, Categories): Fix entries.
27
282007-12-08 Reiner Steib <Reiner.Steib@gmx.de>
29
30 * NEWS: Add minimal Gnus item.
31
322007-12-08 Dan Nicolaescu <dann@ics.uci.edu>
33
34 * emacs.desktop: New file.
35
12007-11-30 Kentaro Ohkouchi <nanasess@fsm.ne.jp> 362007-11-30 Kentaro Ohkouchi <nanasess@fsm.ne.jp>
2 37
3 * images/icons/macemacs_16.png, images/icons/macemacs_24.png: 38 * images/icons/macemacs_16.png, images/icons/macemacs_24.png:
diff --git a/etc/NEWS b/etc/NEWS
index 5af239c8f4c..fb51744bab6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -55,7 +55,7 @@ testing for the `multi-tty' feature.
55OS-X-style icons (an application icon and a relevant document icon) 55OS-X-style icons (an application icon and a relevant document icon)
56were contributed by Kentaro Ohkouchi. 56were contributed by Kentaro Ohkouchi.
57Source files for these icons can be found in Emacs.app/Contents/Resources. 57Source files for these icons can be found in Emacs.app/Contents/Resources.
58PNG versions are available as etc/images/icons/macemacs_*.png. 58PNG versions are available as etc/images/icons/emacs*_mac.png.
59 59
60** Built-in functions (subr) can now have an interactive specification 60** Built-in functions (subr) can now have an interactive specification
61that is not a prompt string. If the `intspec' parameter of a `DEFUN' 61that is not a prompt string. If the `intspec' parameter of a `DEFUN'
@@ -234,7 +234,12 @@ position of point in help window (for example in `view-lossage').
234** view-remove-frame-by-deleting is now by default t 234** view-remove-frame-by-deleting is now by default t
235since users found iconification of view-mode frames distracting. 235since users found iconification of view-mode frames distracting.
236 236
237** isearch can now search through multiple ChangeLog files. 237** Isearch mode
238
239*** New command `isearch-occur' bound to `M-s o' in isearch mode
240runs `occur' with the current search string.
241
242*** isearch can now search through multiple ChangeLog files.
238When running isearch in a ChangeLog file, if the search fails, 243When running isearch in a ChangeLog file, if the search fails,
239then another C-s tries searching the previous ChangeLog, 244then another C-s tries searching the previous ChangeLog,
240if there is one (e.g. go from ChangeLog to ChangeLog.12). 245if there is one (e.g. go from ChangeLog to ChangeLog.12).
@@ -347,6 +352,14 @@ rather than fortran-indent-comment.
347+++ 352+++
348*** (The increasingly misnamed) F90 mode supports Fortran 2003 syntax. 353*** (The increasingly misnamed) F90 mode supports Fortran 2003 syntax.
349 354
355** Gnus package
356
357*** The Gnus package has been updated
358
359*** There are many news features, bug fixes and improvements.
360
361See the file GNUS-NEWS or the node "No Gnus" in the Gnus manual for details.
362
350** Miscellaneous 363** Miscellaneous
351 364
352*** comint-mode uses `start-file-process' now (see Lisp Changes). 365*** comint-mode uses `start-file-process' now (see Lisp Changes).
diff --git a/etc/NEWS.22 b/etc/NEWS.22
index d7368ac6f38..ccabf7d4faf 100644
--- a/etc/NEWS.22
+++ b/etc/NEWS.22
@@ -88,6 +88,8 @@ that the desktop being saved is not an update of the one on disk.
88 88
89** The new package vera-mode.el provides a major mode for editing Vera files. 89** The new package vera-mode.el provides a major mode for editing Vera files.
90 90
91** The new package verilog-mode.el provides a major mode for editing Verilog files.
92
91** The new package socks.el implements the SOCKS v5 protocol. 93** The new package socks.el implements the SOCKS v5 protocol.
92 94
93** VC 95** VC
diff --git a/etc/TODO b/etc/TODO
index a1b8659dfa3..495c4dbc536 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -25,10 +25,6 @@ I.e. mouse-set-font should use customize-face.
25 25
26** Compute the list of active keymaps *after* reading the first event. 26** Compute the list of active keymaps *after* reading the first event.
27 27
28** mouse-autoselect-window should wait to select the window until
29the mouse is put to rest or after a delay or both, so that moving over
30a window doesn't select it.
31
32** Distribute a bar cursor of width > 1 evenly between the two glyphs 28** Distribute a bar cursor of width > 1 evenly between the two glyphs
33 on each side of the bar (what to do at the edges?). 29 on each side of the bar (what to do at the edges?).
34 30
@@ -38,6 +34,8 @@ a window doesn't select it.
38** buffer-offer-save should be a permanent local. 34** buffer-offer-save should be a permanent local.
39 35
40** revert-buffer should eliminate overlays and the mark. 36** revert-buffer should eliminate overlays and the mark.
37 For related problems consult the thread starting with
38 http://lists.gnu.org/archive/html/emacs-devel/2005-11/msg01346.html
41 39
42** erase-buffer should perhaps disregard read-only properties of text. 40** erase-buffer should perhaps disregard read-only properties of text.
43 41
@@ -570,7 +568,7 @@ but which can also be used as a modifier).
570 a derived mode of sendmail.el. Or arrange for messages.el to be split 568 a derived mode of sendmail.el. Or arrange for messages.el to be split
571 into a small core and "the rest" so that we use less resources as long as 569 into a small core and "the rest" so that we use less resources as long as
572 we stick to the features provided in sendmail.el. 570 we stick to the features provided in sendmail.el.
573 571
574** Replace gmalloc.c with the modified Doug Lea code from the current 572** Replace gmalloc.c with the modified Doug Lea code from the current
575 GNU libc so that the special mmapping of buffers can be removed -- 573 GNU libc so that the special mmapping of buffers can be removed --
576 that apparently loses under Solaris, at least. [fx has mostly done 574 that apparently loses under Solaris, at least. [fx has mostly done
diff --git a/etc/emacs.desktop b/etc/emacs.desktop
new file mode 100644
index 00000000000..4e2603b32c8
--- /dev/null
+++ b/etc/emacs.desktop
@@ -0,0 +1,11 @@
1[Desktop Entry]
2Name=Emacs
3GenericName=Text Editor
4Comment=Edit text
5MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
6Exec=emacs %F
7Icon=emacs_32
8Type=Application
9Terminal=false
10Categories=Development;TextEditor;
11StartupWMClass=Emacs
diff --git a/etc/images/icons/emacs16_mac.png b/etc/images/icons/emacs16_mac.png
new file mode 100644
index 00000000000..f1ad7558e49
--- /dev/null
+++ b/etc/images/icons/emacs16_mac.png
@@ -0,0 +1 @@
‰PNG
diff --git a/etc/images/icons/emacs24_mac.png b/etc/images/icons/emacs24_mac.png
new file mode 100644
index 00000000000..f1ad7558e49
--- /dev/null
+++ b/etc/images/icons/emacs24_mac.png
@@ -0,0 +1 @@
‰PNG
diff --git a/etc/images/icons/emacs256_mac.png b/etc/images/icons/emacs256_mac.png
new file mode 100644
index 00000000000..f1ad7558e49
--- /dev/null
+++ b/etc/images/icons/emacs256_mac.png
@@ -0,0 +1 @@
‰PNG
diff --git a/etc/images/icons/emacs32_mac.png b/etc/images/icons/emacs32_mac.png
new file mode 100644
index 00000000000..f1ad7558e49
--- /dev/null
+++ b/etc/images/icons/emacs32_mac.png
@@ -0,0 +1 @@
‰PNG
diff --git a/etc/images/icons/emacs48_mac.png b/etc/images/icons/emacs48_mac.png
new file mode 100644
index 00000000000..f1ad7558e49
--- /dev/null
+++ b/etc/images/icons/emacs48_mac.png
@@ -0,0 +1 @@
‰PNG
diff --git a/etc/images/icons/emacs512_mac.png b/etc/images/icons/emacs512_mac.png
new file mode 100644
index 00000000000..f1ad7558e49
--- /dev/null
+++ b/etc/images/icons/emacs512_mac.png
@@ -0,0 +1 @@
‰PNG
diff --git a/etc/images/icons/macemacs_16.png b/etc/images/icons/macemacs_16.png
deleted file mode 100644
index 0f112d87185..00000000000
--- a/etc/images/icons/macemacs_16.png
+++ /dev/null
Binary files differ
diff --git a/etc/images/icons/macemacs_24.png b/etc/images/icons/macemacs_24.png
deleted file mode 100644
index 7666a1d1dea..00000000000
--- a/etc/images/icons/macemacs_24.png
+++ /dev/null
Binary files differ
diff --git a/etc/images/icons/macemacs_256.png b/etc/images/icons/macemacs_256.png
deleted file mode 100644
index 5529c75a4ee..00000000000
--- a/etc/images/icons/macemacs_256.png
+++ /dev/null
Binary files differ
diff --git a/etc/images/icons/macemacs_32.png b/etc/images/icons/macemacs_32.png
deleted file mode 100644
index 94bfe8893b6..00000000000
--- a/etc/images/icons/macemacs_32.png
+++ /dev/null
Binary files differ
diff --git a/etc/images/icons/macemacs_48.png b/etc/images/icons/macemacs_48.png
deleted file mode 100644
index ac3e703f820..00000000000
--- a/etc/images/icons/macemacs_48.png
+++ /dev/null
Binary files differ
diff --git a/etc/images/icons/macemacs_512.png b/etc/images/icons/macemacs_512.png
deleted file mode 100644
index b817081ad12..00000000000
--- a/etc/images/icons/macemacs_512.png
+++ /dev/null
Binary files differ
diff --git a/etc/schema/dbdyntbl.rnc b/etc/schema/dbdyntbl.rnc
index 8e859145fd0..4ade70bbe2e 100644
--- a/etc/schema/dbdyntbl.rnc
+++ b/etc/schema/dbdyntbl.rnc
@@ -2,7 +2,7 @@
2# allows the table model to be selected dynamically based on the 2# allows the table model to be selected dynamically based on the
3# definitions of cals.table.module and exchange.table.module. 3# definitions of cals.table.module and exchange.table.module.
4# 4#
5# To use this copy, docbook.rnc to docbook-dyntbl.rnc replacing 5# To use this, copy docbook.rnc to docbook-dyntbl.rnc replacing
6# "dbcalstbl.rnc" by "dbdyntbl.rnc". Then, you can override the 6# "dbcalstbl.rnc" by "dbdyntbl.rnc". Then, you can override the
7# choice of table model by doing 7# choice of table model by doing
8# 8#
diff --git a/etc/schema/docbook-dyntbl.rnc b/etc/schema/docbk-dyntbl.rnc
index 9bb997ff734..9bb997ff734 100644
--- a/etc/schema/docbook-dyntbl.rnc
+++ b/etc/schema/docbk-dyntbl.rnc
diff --git a/etc/schema/docbook-soextbl.rnc b/etc/schema/docbk-soextbl.rnc
index 945a6219dba..945a6219dba 100644
--- a/etc/schema/docbook-soextbl.rnc
+++ b/etc/schema/docbk-soextbl.rnc
diff --git a/etc/schema/xhtml-basic-form.rnc b/etc/schema/xhtml-bform.rnc
index c0a78a1d72e..c0a78a1d72e 100644
--- a/etc/schema/xhtml-basic-form.rnc
+++ b/etc/schema/xhtml-bform.rnc
diff --git a/etc/schema/xhtml-basic-table.rnc b/etc/schema/xhtml-btable.rnc
index 97e10a56743..97e10a56743 100644
--- a/etc/schema/xhtml-basic-table.rnc
+++ b/etc/schema/xhtml-btable.rnc
diff --git a/etc/schema/xhtml-form.rnc b/etc/schema/xhtml-form.rnc
index f5544190b01..99a0474afbe 100644
--- a/etc/schema/xhtml-form.rnc
+++ b/etc/schema/xhtml-form.rnc
@@ -2,7 +2,7 @@
2 2
3# Unlike the DTD implementation, this builds on the basic-form module 3# Unlike the DTD implementation, this builds on the basic-form module
4 4
5include "xhtml-basic-form.rnc" { 5include "xhtml-bform.rnc" {
6 select = element select { select.attlist, (option | optgroup)+ } 6 select = element select { select.attlist, (option | optgroup)+ }
7} 7}
8form.attlist &= 8form.attlist &=
diff --git a/etc/schema/xhtml-list.rnc b/etc/schema/xhtml-lst.rnc
index 8b994041eaa..8b994041eaa 100644
--- a/etc/schema/xhtml-list.rnc
+++ b/etc/schema/xhtml-lst.rnc
diff --git a/etc/schema/xhtml-table.rnc b/etc/schema/xhtml-table.rnc
index 70055b1598f..129d7b6742c 100644
--- a/etc/schema/xhtml-table.rnc
+++ b/etc/schema/xhtml-table.rnc
@@ -3,7 +3,7 @@
3# This builds on the basic tables module, unlike with the DTD 3# This builds on the basic tables module, unlike with the DTD
4# implementation. 4# implementation.
5 5
6include "xhtml-basic-table.rnc" { 6include "xhtml-btable.rnc" {
7 table = 7 table =
8 element table { 8 element table {
9 table.attlist, 9 table.attlist,
diff --git a/etc/schema/xhtml-target.rnc b/etc/schema/xhtml-tgt.rnc
index 505b37963a9..505b37963a9 100644
--- a/etc/schema/xhtml-target.rnc
+++ b/etc/schema/xhtml-tgt.rnc
diff --git a/etc/schema/xhtml-style.rnc b/etc/schema/xhtml-xstyle.rnc
index 93a52d5e2ad..93a52d5e2ad 100644
--- a/etc/schema/xhtml-style.rnc
+++ b/etc/schema/xhtml-xstyle.rnc
diff --git a/etc/schema/xhtml.rnc b/etc/schema/xhtml.rnc
index 3218cd71e5b..c85cb144e25 100644
--- a/etc/schema/xhtml.rnc
+++ b/etc/schema/xhtml.rnc
@@ -10,7 +10,7 @@ include "xhtml-attribs.rnc"
10include "xhtml-frames.rnc" 10include "xhtml-frames.rnc"
11include "xhtml-text.rnc" 11include "xhtml-text.rnc"
12include "xhtml-hypertext.rnc" 12include "xhtml-hypertext.rnc"
13include "xhtml-list.rnc" 13include "xhtml-lst.rnc"
14include "xhtml-image.rnc" 14include "xhtml-image.rnc"
15include "xhtml-ssismap.rnc" 15include "xhtml-ssismap.rnc"
16include "xhtml-base.rnc" 16include "xhtml-base.rnc"
@@ -22,16 +22,16 @@ include "xhtml-bdo.rnc"
22include "xhtml-pres.rnc" 22include "xhtml-pres.rnc"
23include "xhtml-edit.rnc" 23include "xhtml-edit.rnc"
24include "xhtml-applet.rnc" 24include "xhtml-applet.rnc"
25# include "xhtml-basic-form.rnc" 25# include "xhtml-bform.rnc"
26include "xhtml-form.rnc" 26include "xhtml-form.rnc"
27include "xhtml-style.rnc" 27include "xhtml-xstyle.rnc"
28include "xhtml-script.rnc" 28include "xhtml-script.rnc"
29# include "xhtml-basic-table.rnc" 29# include "xhtml-btable.rnc"
30include "xhtml-table.rnc" 30include "xhtml-table.rnc"
31include "xhtml-csismap.rnc" 31include "xhtml-csismap.rnc"
32include "xhtml-events.rnc" 32include "xhtml-events.rnc"
33include "xhtml-inlstyle.rnc" 33include "xhtml-inlstyle.rnc"
34include "xhtml-target.rnc" 34include "xhtml-tgt.rnc"
35include "xhtml-iframe.rnc" 35include "xhtml-iframe.rnc"
36include "xhtml-nameident.rnc" 36include "xhtml-nameident.rnc"
37include "xhtml-legacy.rnc" 37include "xhtml-legacy.rnc"
diff --git a/leim/ChangeLog b/leim/ChangeLog
index 69351db078b..1c14d412ec3 100644
--- a/leim/ChangeLog
+++ b/leim/ChangeLog
@@ -1,3 +1,8 @@
12007-12-07 Kenichi Handa <handa@ni.aist.go.jp>
2
3 * quail/lao.el (quail-map-from-table): Allow a tone just after a
4 consonant.
5
12007-11-17 Glenn Morris <rgm@gnu.org> 62007-11-17 Glenn Morris <rgm@gnu.org>
2 7
3 * Makefile.in (check-declare): New target. 8 * Makefile.in (check-declare): New target.
diff --git a/leim/quail/lao.el b/leim/quail/lao.el
index b9a2dd9bf9b..d6e1758b0dc 100644
--- a/leim/quail/lao.el
+++ b/leim/quail/lao.el
@@ -206,8 +206,9 @@ you need to re-load it to properly re-initialize related alists.")
206 lao-tone-key-alist 206 lao-tone-key-alist
207 lao-other-key-alist) 207 lao-other-key-alist)
208 (svt-state (lao-semivowel-key-alist . v-state) 208 (svt-state (lao-semivowel-key-alist . v-state)
209 (lao-vowel-key-alist . t-state) 209 (lao-vowel-key-alist . t-state)
210 lao-voweltone-key-alist) 210 lao-voweltone-key-alist
211 lao-tone-key-alist)
211 (v-state (lao-vowel-key-alist . t-state)) 212 (v-state (lao-vowel-key-alist . t-state))
212 (t-state lao-tone-key-alist)))) 213 (t-state lao-tone-key-alist))))
213 214
diff --git a/leim/quail/latin-post.el b/leim/quail/latin-post.el
index 73c08cee191..9d7b8ee4d71 100644
--- a/leim/quail/latin-post.el
+++ b/leim/quail/latin-post.el
@@ -1256,7 +1256,7 @@ Doubling the postfix separates the letter and postfix: e.g. aee -> ae
1256(quail-define-package 1256(quail-define-package
1257 "scandinavian-postfix" "Latin-1" "SC<" t 1257 "scandinavian-postfix" "Latin-1" "SC<" t
1258 "Scandinavian input method with postfix modifiers 1258 "Scandinavian input method with postfix modifiers
1259Supported languages are Swidish, Norwegian, Danish, and Finnish. 1259Supported languages are Swedish, Norwegian, Danish, and Finnish.
1260 1260
1261ae -> æ 1261ae -> æ
1262oe -> ø 1262oe -> ø
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 2cc37d49dd4..36929ebc24a 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -17,7 +17,7 @@
17 17
182007-11-22 Francesco Potort,Al(B <pot@gnu.org> 182007-11-22 Francesco Potort,Al(B <pot@gnu.org>
19 19
20 * etags.c (default_C_help) [CTAGS]: differentiate the help string, 20 * etags.c (default_C_help) [CTAGS]: Differentiate the help string,
21 as the defaults in ctags are different from etags. 21 as the defaults in ctags are different from etags.
22 22
232007-11-15 Francesco Potort,Al(B <pot@gnu.org> 232007-11-15 Francesco Potort,Al(B <pot@gnu.org>
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b1214e069bf..a9deefae96d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,306 @@
12007-12-12 Thien-Thi Nguyen <ttn@gnuvola.org>
2
3 * progmodes/cc-vars.el (defcustom-c-stylevar): Rewrite.
4
52007-12-11 Dan Nicolaescu <dann@ics.uci.edu>
6
7 * progmodes/verilog-mode.el (set-buffer-menubar): Remove unused
8 function.
9 (add-submenu): Only define for XEmacs.
10 (verilog-regexp-words): Revert previous change, keep the other
11 definition.
12
132007-12-09 Dan Nicolaescu <dann@ics.uci.edu>
14
15 * progmodes/perl-mode.el (perl-continued-statement-offset)
16 (perl-continued-brace-offset, perl-brace-offset)
17 (perl-brace-imaginary-offset, perl-label-offset):
18 * progmodes/cperl-mode.el (cperl-brace-offset)
19 (cperl-continued-brace-offset, cperl-label-offset)
20 (cperl-continued-statement-offset)
21 (cperl-extra-newline-before-brace, cperl-merge-trailing-else): Add
22 safe-local-variable properties.
23
242007-12-08 Dan Nicolaescu <dann@ics.uci.edu>
25
26 * progmodes/verilog-mode.el (verilog-mode-map)
27 (verilog-template-map, verilog-mode-mouse-map): Fix typos.
28 (verilog-colorize-include-files): Use only overlay functions so
29 that it can work on both emacs and XEmacs.
30 (set-extent-keymap): Remove unused defun.
31 (verilog-kill-existing-comment, verilog-insert-date)
32 (verilog-insert-year): Rename in order not to pollute the global
33 namespace from kill-existing-comment, insert-date and
34 insert-year, respectively.
35 (verilog-set-auto-endcomments, verilog-header): Update callers.
36
37 * files.el (auto-mode-alist): Recognize verilog files.
38
39 * progmodes/verilog-mode.el (verilog-string-replace-matches)
40 (verilog-string-remove-spaces, verilog-re-search-forward)
41 (verilog-re-search-backward, verilog-re-search-forward-quick)
42 (verilog-re-search-backward-quick, verilog-get-beg-of-line)
43 (verilog-get-end-of-line, verilog-within-string): Move definitions
44 before first use. No code changes.
45
462007-12-08 Dan Nicolaescu <dann@ics.uci.edu>
47
48 * progmodes/verilog-mode.el (verilog-mode-version)
49 (verilog-mode-release-date): Don't use expanding keywords.
50 (provide): Move to the end of file.
51 (fboundp): Don't check if eval-when-compile is bound, it is used
52 later in the file without checking.
53 (when, unless): Copy definitions from subr.el.
54 (char-before, defcustom, defface, customize-group)
55 (verilog-batch-error-wrapper): Don't use old style backquotes.
56 (verilog-regexp-opt): Avoid using the cl function case.
57 (verilog-regexp-words): Remove duplicated definition.
58 (verilog-mode-abbrev-table): Remove, duplicate.
59 (verilog-mode-map, verilog-template-map, verilog-mode-mouse-map):
60 Declare and initialize in one step.
61 (verilog-declaration-prefix-re, verilog-declaration-re)
62 (verilog-end-of-statement, verilog-indent-declaration)
63 (verilog-get-lineup-indent): Remove trailing whitespace.
64 (verilog-mode): Fix autoload cookie. Set
65 beginning-of-defun-function and end-of-defun-function. Use when
66 instead of if.
67 (verilog-emacs-features, verilog-auto-ascii-enum)
68 (verilog-insert-indices): Escape braces in doc strings.
69
702007-12-08 Michael McNamara <mac@verilog.com>
71 Wilson Snyder <wsnyder@wsnyder.org>
72
73 * progmodes/verilog-mode.el: New file.
74
752007-12-08 Eli Zaretskii <eliz@fencepost.gnu.org>
76
77 * international/latexenc.el (latexenc-find-file-coding-system): If
78 both coding-system-for-write and buffer-file-coding-system of
79 latex-main-file are nil, use `undecided'.
80
812007-12-06 Jason Rumney <jasonr@gnu.org>
82
83 * mouse.el (mouse-buffer-menu-alist): Keep buffer names left aligned.
84
852007-12-12 Yoni Rabkin Katzenell <yoni-r@actcom.com> (tiny change)
86
87 * files.el (revert-buffer): Docstring fix.
88
892007-12-11 Glenn Morris <rgm@gnu.org>
90
91 * emacs-lisp/check-declare.el (check-declare-verify): Handle deffoo.
92
932007-12-11 Jay Belanger <jay.p.belanger@gmail.com>
94
95 * calc/calc-aent.el (math-restore-underscores)
96 (math-string-restore-underscores): New functions.
97 (math-read-factor): Properly check variable names with underscores
98 for entries in `math-expr-variable-mapping'.
99
100 * calc/calc-lang.el (math-lang-name): New property name.
101
102 * calc/calc.el (calc-set-mode-line): Use `math-lang-name'
103 to set language name.
104
1052007-12-10 Katsumi Yamaoka <yamaoka@jpl.org>
106
107 * pgg.el (pgg-run-at-time, pgg-cancel-timer): Use eval-and-compile.
108
1092007-12-10 Stefan Monnier <monnier@iro.umontreal.ca>
110
111 * server.el (server-select-display): Fix important typo.
112 (server-process-filter): Turn a "" display into nil.
113
1142007-12-09 Juri Linkov <juri@jurta.org>
115
116 * replace.el (keep-lines, flush-lines, how-many): Doc fix.
117 Check search-upper-case before calling isearch-no-upper-case-p
118 to set case-fold-search.
119 (occur): Doc fix.
120 (occur-1, perform-replace): Check search-upper-case before calling
121 isearch-no-upper-case-p to set case-fold-search.
122
123 * isearch.el (search-upper-case): Doc fix.
124 (isearch-mode-map): Bind `M-s o' to isearch-occur.
125 (isearch-query-replace): Doc fix. Let-bind search-upper-case to nil.
126 (isearch-query-replace-regexp): Doc fix.
127 (isearch-occur): New function.
128
1292007-12-09 Reiner Steib <Reiner.Steib@gmx.de>
130
131 * pgg.el, pgg-parse.el (declare-function): Add new no-op macro for
132 backward compatibility.
133
134 * net/imap.el (imap-string-to-integer): New function.
135
1362007-12-09 David Kastrup <dak@gnu.org>
137
138 * emacs-lisp/lisp-mnt.el (lm-verify): Make it work with
139 directories. Not sure anybody uses this anymore, though.
140
1412007-12-09 Vinicius Jose Latorre <viniciusjl@ig.com.br>
142
143 * printing.el: Fix pr-interface-map initialization code.
144 (pr-version): New version 6.9.3.
145 (pr-f-set-keymap-parents): Replace by pr-set-keymap-parents.
146 (pr-f-set-keymap-name): Replace by pr-set-keymap-name.
147 (pr-f-read-string): Replace by pr-read-string.
148 (pr-set-keymap-parents, pr-set-keymap-name, pr-read-string): New fun
149 name.
150 (pr-interactive-n-up, pr-interactive-regexp): Code fix.
151
1522007-12-09 Glenn Morris <rgm@gnu.org>
153
154 * emulation/viper-init.el (top-level): Use dolist rather than mapc
155 in make-variable-frame-local call.
156
1572007-12-08 Dan Nicolaescu <dann@ics.uci.edu>
158
159 * mail/hashcash.el (declare-function):
160 * net/imap.el (declare-function): New no-op macro for backward
161 compatibility.
162
1632007-12-08 Eli Zaretskii <eliz@gnu.org>
164
165 Sync makefile.w32-in with Makefile.in.
166
167 * makefile.w32-in (check-declare): New target.
168 (BYTE_COMPILE_EXTRA_FLAGS): New variable.
169 (.el.elc, compile-CMD, compile-SH, compile-always-CMD)
170 (compile-always-SH, compile-calc-CMD, compile-calc-SH)
171 ($(lisp)/progmodes/cc-mode.elc): Use it.
172 ($(lisp)/progmodes/cc-mode.elc): New rule.
173
1742007-12-08 Reiner Steib <Reiner.Steib@gmx.de>
175
176 * indent.el (tab-stop-list): Mark as safe-local-variable.
177
178 * generic-x.el (etc-sudoers-generic-mode): New mode.
179 (generic-unix-modes): Add it.
180
1812007-12-08 Michael Albinus <michael.albinus@gmx.de>
182
183 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
184 apply wildcards in a hash table key; there is no usable hash code then.
185 (dbus-registered-functions-table): Use `equal' as test function.
186 (dbus-name-owner-changed-handler): Rewrite due to new hash table
187 structure.
188
1892007-12-08 Martin Rudalics <rudalics@gmx.at>
190
191 * progmodes/cc-cmds.el (c-mask-paragraph): Avoid invalid search
192 bound error in block comment branch.
193
1942007-12-08 David Kastrup <dak@gnu.org>
195
196 * textmodes/reftex.el (reftex-select-with-char):
197 * textmodes/reftex-toc.el (reftex-toc-do-promote)
198 (reftex-toc-visit-location, reftex-toc-find-section):
199 * textmodes/reftex-index.el (reftex-index-show-entry):
200 * textmodes/org.el (org-cycle-hide-archived-subtrees)
201 (org-table-rotate-recalc-marks, org-mark-ring-push)
202 (org-follow-info-link, org-mhe-get-message-folder-from-index)
203 (org-auto-repeat-maybe, org-store-log-note, org-delete-property)
204 (org-evaluate-time-range, org-edit-agenda-file-list):
205 * textmodes/artist.el (artist-select-next-op-in-list)
206 (artist-select-prev-op-in-list):
207 * term/mac-win.el (mac-service-insert-text):
208 * startup.el (fancy-about-screen):
209 * progmodes/vhdl-mode.el (vhdl-decision-query):
210 * progmodes/idlwave.el (idlwave-template)
211 (idlwave-scroll-completions, idlwave-display-completion-list):
212 * progmodes/ebrowse.el (ebrowse-show-progress):
213 * progmodes/cperl-mode.el (cperl-find-pods-heres):
214 * progmodes/antlr-mode.el (antlr-insert-option-do):
215 * play/mpuz.el (mpuz-close-game):
216 * net/rcirc.el (rcirc-next-active-buffer):
217 * mail/reporter.el (reporter-update-status):
218 * kmacro.el (kmacro-display):
219 * international/ja-dic-cnv.el (skkdic-set-okuri-nasi):
220 * emulation/viper-util.el (viper-save-setting):
221 * emacs-lisp/lisp-mnt.el (lm-verify):
222 * emacs-lisp/edebug.el (edebug-set-mode):
223 * emacs-lisp/checkdoc.el (checkdoc-rogue-spaces, checkdoc-defun):
224 * calendar/calendar.el (calendar-print-day-of-year):
225 * calc/calcalg3.el (calc-curve-fit):
226 * calc/calcalg2.el (math-integral):
227 * calc/calc.el (calc-read-key-sequence, calc-version):
228 * calc/calc-mode.el (calc-set-simplify-mode):
229 * calc/calc-ext.el (calc-fancy-prefix): Fix buggy call to `message'.
230
2312007-12-07 D. Goel <deego3@gmail.com>
232
233 * progmodes/idlw-shell.el (idlwave-shell-display-line)
234 * progmodes/ada-xref.el (ada-find-file, ada-get-all-references)
235 (ada-xref-find-in-modified-ali, ada-find-in-src-path)
236 * mail/uce.el (uce-reply-to-uce)
237 * progmodes/vhdl-mode.el (vhdl-template-modify)
238 * mail/feedmail.el (feedmail-dump-message-to-queue): Improve calls
239 to `error' (as suggested by RMS.)
240
2412007-12-07 Glenn Morris <rgm@gnu.org>
242
243 * allout.el (allout-write-file-hook-handler):
244 * textmodes/reftex.el (reftex-TeX-master-file):
245 * textmodes/reftex-parse.el (reftex-short-context):
246 Revert previous change.
247
2482007-12-07 Michael Albinus <michael.albinus@gmx.de>
249
250 * net/dbus.el (dbus-hash-table=): Fix for new hash table key structure.
251 (dbus-list-hash-table, dbus-name-owner-changed-handler): New defuns.
252 (dbus-check-event, dbus-handle-event, dbus-event-bus-name)
253 (dbus-event-service-name, dbus-event-path-name)
254 (dbus-event-interface-name, dbus-event-member-name): Fix for new
255 event structure.
256 (dbus-list-activatable-names, dbus-list-names)
257 (dbus-list-queued-owners, dbus-get-name-owner, dbus-introspect):
258 Reorder `dbus-call-method' arguments.
259
2602007-12-06 D. Goel <deego3@gmail.com>
261
262 * allout.el (allout-write-file-hook-handler):
263 * textmodes/reftex.el (reftex-TeX-master-file):
264 * textmodes/org.el (org-paste-subtree):
265 * progmodes/vhdl-mode.el (vhdl-template-modify):
266 * progmodes/idlw-shell.el (idlwave-shell-send-command)
267 (idlwave-shell-display-line):
268 * progmodes/ada-xref.el (ada-find-file, ada-get-all-references)
269 (ada-xref-find-in-modified-ali, ada-find-in-src-path):
270 * net/trampver.el (x):
271 * mail/uce.el (uce-reply-to-uce):
272 * mail/rmailout.el (rmail-output):
273 * mail/feedmail.el (feedmail-dump-message-to-queue):
274 * whitespace.el (whitespace-write-file-hook):
275 * wdired.el (wdired-check-kill-buffer):
276 * vc.el (vc-update):
277 * vc-mcvs.el (vc-mcvs-checkin):
278 * vc-cvs.el (vc-cvs-checkin):
279 * man.el (Man-bgproc-sentinel, Man-goto-see-also-section):
280 * ibuffer.el (ibuffer-current-buffer):
281 * dired.el (dired-move-to-end-of-filename):
282 * bindings.el (complete-symbol):
283 * textmodes/org-publish.el (org-publish-file):
284 (org-publish-current-project):
285 * textmodes/reftex-parse.el (reftex-short-context):
286 * textmodes/texinfmt.el: Fix buggy calls to `error'.
287
2882007-12-06 Stefan Monnier <monnier@iro.umontreal.ca>
289
290 * doc-view.el (doc-view-dvi->pdf-sentinel)
291 (doc-view-pdf/ps->png-sentinel, doc-view-pdf->txt-sentinel)
292 (doc-view-ps->pdf-sentinel, doc-view-display): Don't change buffer
293 within a sentinel or timer.
294 (doc-view-display): Don't try to display before the requested page
295 is available, unless told to do so explicitly.
296 (doc-view-pdf/ps->png-sentinel, doc-view-initiate-display):
297 Force display even if the requested page is not available.
298
2992007-12-06 Richard Stallman <rms@gnu.org>
300
301 * help-fns.el (describe-function-1): Call ad-get-advice-info
302 only on symbols.
303
12007-12-06 Glenn Morris <rgm@gnu.org> 3042007-12-06 Glenn Morris <rgm@gnu.org>
2 305
3 * progmodes/antlr-mode.el (antlr-keyword, antlr-syntax) 306 * progmodes/antlr-mode.el (antlr-keyword, antlr-syntax)
@@ -97,8 +400,8 @@
97 400
98 * eshell/esh-module.el (eshell-load-defgroups): Eval and compile. 401 * eshell/esh-module.el (eshell-load-defgroups): Eval and compile.
99 402
100 * eshell/esh-util.el (top-level): Don't require pp. Use 403 * eshell/esh-util.el (top-level): Don't require pp.
101 condition-case rather than ignore-errors. 404 Use condition-case rather than ignore-errors.
102 405
103 * eshell/eshell.el (eshell-buffer-name): Define for compiler. 406 * eshell/eshell.el (eshell-buffer-name): Define for compiler.
104 407
@@ -120,8 +423,8 @@
120 esh-maint. Collect any require statements. Leave provide at start. 423 esh-maint. Collect any require statements. Leave provide at start.
121 Move any commentary to start. 424 Move any commentary to start.
122 425
123 * emacs-lisp/bytecomp.el (byte-compile-declare-function): Remove 426 * emacs-lisp/bytecomp.el (byte-compile-declare-function):
124 declared function from byte-compile-noruntime-functions. 427 Remove declared function from byte-compile-noruntime-functions.
125 428
126 * ediff-util.el (ediff-version): 429 * ediff-util.el (ediff-version):
127 * progmodes/python.el (compilation-shell-minor-mode): 430 * progmodes/python.el (compilation-shell-minor-mode):
@@ -223,16 +526,16 @@
223 526
2242007-12-03 Richard Stallman <rms@gnu.org> 5272007-12-03 Richard Stallman <rms@gnu.org>
225 528
226 * subr.el (declare-function): Moved from byte-run.el. 529 * subr.el (declare-function): Move from byte-run.el.
227 530
228 * emacs-lisp/byte-run.el (declare-function): Moved to subr.el 531 * emacs-lisp/byte-run.el (declare-function): Move to subr.el
229 532
230 * window.el (recenter-top-bottom): Don't use `ecase'. 533 * window.el (recenter-top-bottom): Don't use `ecase'.
231 534
2322007-12-02 Karl Fogel <kfogel@red-bean.com> 5352007-12-02 Karl Fogel <kfogel@red-bean.com>
233 536
234 * saveplace.el (save-place-alist-to-file): Set 537 * saveplace.el (save-place-alist-to-file):
235 coding-system-for-write once and refer to it throughout. 538 Set coding-system-for-write once and refer to it throughout.
236 Suggested by David Reitter <dreitter{_AT_}inf.ed.ac.uk>. 539 Suggested by David Reitter <dreitter{_AT_}inf.ed.ac.uk>.
237 540
2382007-12-02 Karl Fogel <kfogel@red-bean.com> 5412007-12-02 Karl Fogel <kfogel@red-bean.com>
diff --git a/lisp/bindings.el b/lisp/bindings.el
index ead6ac51577..f0f85bbd8bd 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -616,7 +616,7 @@ language you are using."
616 (if (fboundp 'complete-tag) 616 (if (fboundp 'complete-tag)
617 (complete-tag) 617 (complete-tag)
618 ;; Don't autoload etags if we have no tags table. 618 ;; Don't autoload etags if we have no tags table.
619 (error (substitute-command-keys 619 (error "%s" (substitute-command-keys
620 "No tags table loaded; use \\[visit-tags-table] to load one"))))) 620 "No tags table loaded; use \\[visit-tags-table] to load one")))))
621 621
622;; Reduce total amount of space we must allocate during this function 622;; Reduce total amount of space we must allocate during this function
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el
index 697d510ac02..ee9c6e61e4c 100644
--- a/lisp/calc/calc-aent.el
+++ b/lisp/calc/calc-aent.el
@@ -1015,6 +1015,19 @@ in Calc algebraic input.")
1015 (concat (math-match-substring x 1) "-" (math-match-substring x 2))) 1015 (concat (math-match-substring x 1) "-" (math-match-substring x 2)))
1016 x)) 1016 x))
1017 1017
1018(defun math-restore-underscores (x)
1019 "Replace pound signs by underscores in the symbol x.
1020If the current Calc language does not allow underscores, return nil."
1021 (if (memq calc-language calc-lang-allow-underscores)
1022 (intern-soft (math-string-restore-underscores (symbol-name x)))))
1023
1024(defun math-string-restore-underscores (x)
1025 "Replace pound signs by underscores in the string x."
1026 (if (string-match "\\`\\(.*\\)#\\(.*\\)\\'" x)
1027 (math-string-restore-underscores
1028 (concat (math-match-substring x 1) "_" (math-match-substring x 2)))
1029 x))
1030
1018(defun math-read-if (cond op) 1031(defun math-read-if (cond op)
1019 (let ((then (math-read-expr-level 0))) 1032 (let ((then (math-read-expr-level 0)))
1020 (or (equal math-expr-data ":") 1033 (or (equal math-expr-data ":")
@@ -1116,7 +1129,10 @@ in Calc algebraic input.")
1116 sym 1129 sym
1117 (intern (concat "var-" 1130 (intern (concat "var-"
1118 (symbol-name sym))))))) 1131 (symbol-name sym)))))))
1119 (let ((v (assq (nth 1 val) math-expr-variable-mapping))) 1132 (let ((v (or
1133 (assq (nth 1 val) math-expr-variable-mapping)
1134 (assq (math-restore-underscores (nth 1 val))
1135 math-expr-variable-mapping))))
1120 (and v (setq val (if (consp (cdr v)) 1136 (and v (setq val (if (consp (cdr v))
1121 (funcall (car (cdr v)) v val) 1137 (funcall (car (cdr v)) v val)
1122 (list 'var 1138 (list 'var
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index 140335a3d02..56b95ef218e 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -1434,7 +1434,7 @@ calc-kill calc-kill-region calc-yank))))
1434 (calc-set-command-flag 'no-align) 1434 (calc-set-command-flag 'no-align)
1435 (setq prefix (set flag (not (symbol-value flag))) 1435 (setq prefix (set flag (not (symbol-value flag)))
1436 prefix-arg n) 1436 prefix-arg n)
1437 (message (if prefix msg ""))) 1437 (message "%s" (if prefix msg "")))
1438 (and prefix 1438 (and prefix
1439 (not calc-is-keypad-press) 1439 (not calc-is-keypad-press)
1440 (if (boundp 'overriding-terminal-local-map) 1440 (if (boundp 'overriding-terminal-local-map)
diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el
index 2ae23cd5aa9..6773049c391 100644
--- a/lisp/calc/calc-lang.el
+++ b/lisp/calc/calc-lang.el
@@ -408,6 +408,9 @@
408 (message 408 (message
409 "LaTeX language mode with \\func(\\text{var}) and multiline matrices"))))) 409 "LaTeX language mode with \\func(\\text{var}) and multiline matrices")))))
410 410
411(put 'tex 'math-lang-name "TeX")
412(put 'latex 'math-lang-name "LaTeX")
413
411(put 'tex 'math-oper-table 414(put 'tex 'math-oper-table
412 '( ( "\\hat" calcFunc-hat -1 950 ) 415 '( ( "\\hat" calcFunc-hat -1 950 )
413 ( "\\check" calcFunc-check -1 950 ) 416 ( "\\check" calcFunc-check -1 950 )
diff --git a/lisp/calc/calc-mode.el b/lisp/calc/calc-mode.el
index d7daf1bf997..85ae4d7b264 100644
--- a/lisp/calc/calc-mode.el
+++ b/lisp/calc/calc-mode.el
@@ -505,7 +505,7 @@
505 mode) 505 mode)
506 (and (not (eq calc-simplify-mode mode)) 506 (and (not (eq calc-simplify-mode mode))
507 mode))) 507 mode)))
508 (message (if (eq calc-simplify-mode mode) 508 (message "%s" (if (eq calc-simplify-mode mode)
509 msg 509 msg
510 "Default simplifications enabled"))) 510 "Default simplifications enabled")))
511 511
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index 69cacec2220..fa98b161567 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -1228,7 +1228,7 @@ If nil, selections displayed but ignored.")
1228 (let ((prompt2 (format "%s " (key-description (this-command-keys)))) 1228 (let ((prompt2 (format "%s " (key-description (this-command-keys))))
1229 (glob (current-global-map)) 1229 (glob (current-global-map))
1230 (loc (current-local-map))) 1230 (loc (current-local-map)))
1231 (or (input-pending-p) (message prompt)) 1231 (or (input-pending-p) (message "%s" prompt))
1232 (let ((key (calc-read-key t))) 1232 (let ((key (calc-read-key t)))
1233 (calc-unread-command (cdr key)) 1233 (calc-unread-command (cdr key))
1234 (unwind-protect 1234 (unwind-protect
@@ -1244,7 +1244,7 @@ If nil, selections displayed but ignored.")
1244(defun calc-version () 1244(defun calc-version ()
1245 "Return version of this version of Calc." 1245 "Return version of this version of Calc."
1246 (interactive) 1246 (interactive)
1247 (message (concat "Calc version " calc-version))) 1247 (message "Calc version %s" calc-version))
1248 1248
1249(defun calc-mode () 1249(defun calc-mode ()
1250 "Calculator major mode. 1250 "Calculator major mode.
@@ -1675,8 +1675,8 @@ See calc-keypad for details."
1675 (t (format "Radix%d " calc-number-radix))) 1675 (t (format "Radix%d " calc-number-radix)))
1676 (if calc-leading-zeros "Zero " "") 1676 (if calc-leading-zeros "Zero " "")
1677 (cond ((null calc-language) "") 1677 (cond ((null calc-language) "")
1678 ((eq calc-language 'tex) "TeX ") 1678 ((get calc-language 'math-lang-name)
1679 ((eq calc-language 'latex) "LaTeX ") 1679 (concat (get calc-language 'math-lang-name) " "))
1680 (t (concat 1680 (t (concat
1681 (capitalize (symbol-name calc-language)) 1681 (capitalize (symbol-name calc-language))
1682 " "))) 1682 " ")))
diff --git a/lisp/calc/calcalg2.el b/lisp/calc/calcalg2.el
index 4afed43d99c..1259642842a 100644
--- a/lisp/calc/calcalg2.el
+++ b/lisp/calc/calcalg2.el
@@ -746,7 +746,7 @@
746 (setq math-integ-msg (format 746 (setq math-integ-msg (format
747 "Working... Integrating %s" 747 "Working... Integrating %s"
748 (math-format-flat-expr expr 0))) 748 (math-format-flat-expr expr 0)))
749 (message math-integ-msg))) 749 (message "%s" math-integ-msg)))
750 (if math-cur-record 750 (if math-cur-record
751 (setcar (cdr math-cur-record) 751 (setcar (cdr math-cur-record)
752 (if same-as-above (vector simp) 'busy)) 752 (if same-as-above (vector simp) 'busy))
@@ -773,7 +773,7 @@
773 "simplification...\n") 773 "simplification...\n")
774 (setq val (math-integral simp 'no t)))))))) 774 (setq val (math-integral simp 'no t))))))))
775 (if (eq calc-display-working-message 'lots) 775 (if (eq calc-display-working-message 'lots)
776 (message math-integ-msg))) 776 (message "%s" math-integ-msg)))
777 (setcar (cdr math-cur-record) (or val 777 (setcar (cdr math-cur-record) (or val
778 (if (or math-enable-subst 778 (if (or math-enable-subst
779 (not math-any-substs)) 779 (not math-any-substs))
diff --git a/lisp/calc/calcalg3.el b/lisp/calc/calcalg3.el
index 374b0487cfe..77e8b1537f4 100644
--- a/lisp/calc/calcalg3.el
+++ b/lisp/calc/calcalg3.el
@@ -416,7 +416,7 @@
416 (calc-record (calc-normalize calc-fit-to-trail) "parm")))) 416 (calc-record (calc-normalize calc-fit-to-trail) "parm"))))
417 (when plot 417 (when plot
418 (if (stringp plot) 418 (if (stringp plot)
419 (message plot) 419 (message "%s" plot)
420 (let ((calc-graph-no-auto-view t)) 420 (let ((calc-graph-no-auto-view t))
421 (calc-graph-delete t) 421 (calc-graph-delete t)
422 (calc-graph-add-curve 422 (calc-graph-add-curve
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index d49667d2810..da87a1959fe 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -3154,7 +3154,7 @@ Defaults to today's date if DATE is not given."
3154(defun calendar-print-day-of-year () 3154(defun calendar-print-day-of-year ()
3155 "Show day number in year/days remaining in year for date under the cursor." 3155 "Show day number in year/days remaining in year for date under the cursor."
3156 (interactive) 3156 (interactive)
3157 (message (calendar-day-of-year-string (calendar-cursor-to-date t)))) 3157 (message "%s" (calendar-day-of-year-string (calendar-cursor-to-date t))))
3158 3158
3159(defun calendar-set-mode-line (str) 3159(defun calendar-set-mode-line (str)
3160 "Set mode line to STR, centered, surrounded by dashes." 3160 "Set mode line to STR, centered, surrounded by dashes."
diff --git a/lisp/dired.el b/lisp/dired.el
index ab56579e718..51067e46001 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2009,7 +2009,7 @@ Return the position of the beginning of the filename, or nil if none found."
2009 (forward-char -1)))) 2009 (forward-char -1))))
2010 (or no-error 2010 (or no-error
2011 (not (eq opoint (point))) 2011 (not (eq opoint (point)))
2012 (error (if hidden 2012 (error "%s" (if hidden
2013 (substitute-command-keys 2013 (substitute-command-keys
2014 "File line is hidden, type \\[dired-hide-subdir] to unhide") 2014 "File line is hidden, type \\[dired-hide-subdir] to unhide")
2015 "No file on this line"))) 2015 "No file on this line")))
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 0e336b12dd5..9073ce1536a 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -508,14 +508,14 @@ Should be invoked when the cached images aren't up-to-date."
508 "If DVI->PDF conversion was successful, convert the PDF to PNG now." 508 "If DVI->PDF conversion was successful, convert the PDF to PNG now."
509 (if (not (string-match "finished" event)) 509 (if (not (string-match "finished" event))
510 (message "DocView: dvi->pdf process changed status to %s." event) 510 (message "DocView: dvi->pdf process changed status to %s." event)
511 (set-buffer (process-get proc 'buffer)) 511 (with-current-buffer (process-get proc 'buffer)
512 (setq doc-view-current-converter-process nil 512 (setq doc-view-current-converter-process nil
513 mode-line-process nil) 513 mode-line-process nil)
514 ;; Now go on converting this PDF to a set of PNG files. 514 ;; Now go on converting this PDF to a set of PNG files.
515 (let* ((pdf (process-get proc 'pdf-file)) 515 (let* ((pdf (process-get proc 'pdf-file))
516 (png (expand-file-name "page-%d.png" 516 (png (expand-file-name "page-%d.png"
517 (doc-view-current-cache-dir)))) 517 (doc-view-current-cache-dir))))
518 (doc-view-pdf/ps->png pdf png)))) 518 (doc-view-pdf/ps->png pdf png)))))
519 519
520(defun doc-view-dvi->pdf (dvi pdf) 520(defun doc-view-dvi->pdf (dvi pdf)
521 "Convert DVI to PDF asynchronously." 521 "Convert DVI to PDF asynchronously."
@@ -533,14 +533,14 @@ Should be invoked when the cached images aren't up-to-date."
533 "If PDF/PS->PNG conversion was successful, update the display." 533 "If PDF/PS->PNG conversion was successful, update the display."
534 (if (not (string-match "finished" event)) 534 (if (not (string-match "finished" event))
535 (message "DocView: converter process changed status to %s." event) 535 (message "DocView: converter process changed status to %s." event)
536 (set-buffer (process-get proc 'buffer)) 536 (with-current-buffer (process-get proc 'buffer)
537 (setq doc-view-current-converter-process nil 537 (setq doc-view-current-converter-process nil
538 mode-line-process nil) 538 mode-line-process nil)
539 (when doc-view-current-timer 539 (when doc-view-current-timer
540 (cancel-timer doc-view-current-timer) 540 (cancel-timer doc-view-current-timer)
541 (setq doc-view-current-timer nil)) 541 (setq doc-view-current-timer nil))
542 ;; Yippie, finished. Update the display! 542 ;; Yippie, finished. Update the display!
543 (doc-view-display buffer-file-name))) 543 (doc-view-display buffer-file-name 'force))))
544 544
545(defun doc-view-pdf/ps->png (pdf-ps png) 545(defun doc-view-pdf/ps->png (pdf-ps png)
546 "Convert PDF-PS to PNG asynchronously." 546 "Convert PDF-PS to PNG asynchronously."
@@ -568,13 +568,13 @@ Should be invoked when the cached images aren't up-to-date."
568 (message "DocView: converter process changed status to %s." event) 568 (message "DocView: converter process changed status to %s." event)
569 (let ((current-buffer (current-buffer)) 569 (let ((current-buffer (current-buffer))
570 (proc-buffer (process-get proc 'buffer))) 570 (proc-buffer (process-get proc 'buffer)))
571 (set-buffer proc-buffer) 571 (with-current-buffer proc-buffer
572 (setq doc-view-current-converter-process nil 572 (setq doc-view-current-converter-process nil
573 mode-line-process nil) 573 mode-line-process nil)
574 ;; If the user looks at the DocView buffer where the conversion was 574 ;; If the user looks at the DocView buffer where the conversion was
575 ;; performed, search anew. This time it will be queried for a regexp. 575 ;; performed, search anew. This time it will be queried for a regexp.
576 (when (eq current-buffer proc-buffer) 576 (when (eq current-buffer proc-buffer)
577 (doc-view-search nil))))) 577 (doc-view-search nil))))))
578 578
579(defun doc-view-pdf->txt (pdf txt) 579(defun doc-view-pdf->txt (pdf txt)
580 "Convert PDF to TXT asynchronously." 580 "Convert PDF to TXT asynchronously."
@@ -590,13 +590,13 @@ Should be invoked when the cached images aren't up-to-date."
590(defun doc-view-ps->pdf-sentinel (proc event) 590(defun doc-view-ps->pdf-sentinel (proc event)
591 (if (not (string-match "finished" event)) 591 (if (not (string-match "finished" event))
592 (message "DocView: converter process changed status to %s." event) 592 (message "DocView: converter process changed status to %s." event)
593 (set-buffer (process-get proc 'buffer)) 593 (with-current-buffer (process-get proc 'buffer)
594 (setq doc-view-current-converter-process nil 594 (setq doc-view-current-converter-process nil
595 mode-line-process nil) 595 mode-line-process nil)
596 ;; Now we can transform to plain text. 596 ;; Now we can transform to plain text.
597 (doc-view-pdf->txt (process-get proc 'pdf-file) 597 (doc-view-pdf->txt (process-get proc 'pdf-file)
598 (expand-file-name "doc.txt" 598 (expand-file-name "doc.txt"
599 (doc-view-current-cache-dir))))) 599 (doc-view-current-cache-dir))))))
600 600
601(defun doc-view-ps->pdf (ps pdf) 601(defun doc-view-ps->pdf (ps pdf)
602 "Convert PS to PDF asynchronously." 602 "Convert PS to PDF asynchronously."
@@ -707,15 +707,19 @@ Predicate for sorting `doc-view-current-files'."
707 (and (= (length a) (length b)) 707 (and (= (length a) (length b))
708 (string< a b)))) 708 (string< a b))))
709 709
710(defun doc-view-display (doc) 710(defun doc-view-display (doc &optional force)
711 "Start viewing the document DOC." 711 "Start viewing the document DOC.
712 (set-buffer (get-file-buffer doc)) 712If FORCE is non-nil, start viewing even if the document does not
713 (setq doc-view-current-files 713have the page we want to view."
714 (sort (directory-files (doc-view-current-cache-dir) t 714 (with-current-buffer (get-file-buffer doc)
715 "page-[0-9]+\\.png" t) 715 (setq doc-view-current-files
716 'doc-view-sort)) 716 (sort (directory-files (doc-view-current-cache-dir) t
717 (when (> (length doc-view-current-files) 0) 717 "page-[0-9]+\\.png" t)
718 (doc-view-goto-page doc-view-current-page))) 718 'doc-view-sort))
719 (when (or force
720 (>= (length doc-view-current-files)
721 (or doc-view-current-page 1)))
722 (doc-view-goto-page doc-view-current-page))))
719 723
720(defun doc-view-buffer-message () 724(defun doc-view-buffer-message ()
721 ;; Only show this message initially, not when refreshing the buffer (in which 725 ;; Only show this message initially, not when refreshing the buffer (in which
@@ -898,7 +902,7 @@ If BACKWARD is non-nil, jump to the previous match."
898 (if (file-exists-p (doc-view-current-cache-dir)) 902 (if (file-exists-p (doc-view-current-cache-dir))
899 (progn 903 (progn
900 (message "DocView: using cached files!") 904 (message "DocView: using cached files!")
901 (doc-view-display buffer-file-name)) 905 (doc-view-display buffer-file-name 'force))
902 (doc-view-convert-current-doc)) 906 (doc-view-convert-current-doc))
903 (message 907 (message
904 "%s" 908 "%s"
diff --git a/lisp/ediff-init.el b/lisp/ediff-init.el
index b46562b5fde..91c8f41bb13 100644
--- a/lisp/ediff-init.el
+++ b/lisp/ediff-init.el
@@ -1576,7 +1576,7 @@ This default should work without changes."
1576 ) 1576 )
1577 ((ediff-key-press-event-p event) 1577 ((ediff-key-press-event-p event)
1578 (point)) 1578 (point))
1579 (t (error nil)))) 1579 (t (error "Error"))))
1580 1580
1581(defun ediff-event-buffer (event) 1581(defun ediff-event-buffer (event)
1582 (cond ((ediff-mouse-event-p event) 1582 (cond ((ediff-mouse-event-p event)
@@ -1587,7 +1587,7 @@ This default should work without changes."
1587 ) 1587 )
1588 ((ediff-key-press-event-p event) 1588 ((ediff-key-press-event-p event)
1589 (current-buffer)) 1589 (current-buffer))
1590 (t (error nil)))) 1590 (t (error "Error"))))
1591 1591
1592(defun ediff-event-key (event-or-key) 1592(defun ediff-event-key (event-or-key)
1593 (ediff-cond-compile-for-xemacs-or-emacs 1593 (ediff-cond-compile-for-xemacs-or-emacs
diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-declare.el
index 9fc8a9e61e7..fe7f774c7e9 100644
--- a/lisp/emacs-lisp/check-declare.el
+++ b/lisp/emacs-lisp/check-declare.el
@@ -34,6 +34,9 @@
34 34
35;;; TODO: 35;;; TODO:
36 36
37;; 1. Warn about functions marked as obsolete, eg
38;; password-read-and-add in smime.el.
39
37;;; Code: 40;;; Code:
38 41
39(defconst check-declare-warning-buffer "*Check Declarations Warnings*" 42(defconst check-declare-warning-buffer "*Check Declarations Warnings*"
@@ -141,7 +144,8 @@ is a string giving details of the error."
141 ;; defsubst's don't _have_ to be known at compile time. 144 ;; defsubst's don't _have_ to be known at compile time.
142 (setq re (format (if cflag 145 (setq re (format (if cflag
143 "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" 146 "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
144 "^[ \t]*(\\(fset[ \t]+'\\|def\\(?:un\\|subst\\|\ 147 "^[ \t]*(\\(fset[ \t]+'\\|\
148def\\(?:un\\|subst\\|foo\\|\
145ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\ 149ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\
146\\|\\(?:ine-obsolete-function-\\)?alias[ \t]+'\\)\\)\ 150\\|\\(?:ine-obsolete-function-\\)?alias[ \t]+'\\)\\)\
147\[ \t]*%s\\([ \t;]+\\|$\\)") 151\[ \t]*%s\\([ \t;]+\\|$\\)")
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 185df6fbe43..742e13412bb 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -978,7 +978,7 @@ Optional argument INTERACT permits more interactive fixing."
978 (if (not (interactive-p)) 978 (if (not (interactive-p))
979 e 979 e
980 (if e 980 (if e
981 (message (checkdoc-error-text e)) 981 (message "%s" (checkdoc-error-text e))
982 (checkdoc-show-diagnostics) 982 (checkdoc-show-diagnostics)
983 (message "Space Check: done."))))) 983 (message "Space Check: done.")))))
984 984
@@ -1038,15 +1038,15 @@ space at the end of each line."
1038 (end (save-excursion (end-of-defun) (point))) 1038 (end (save-excursion (end-of-defun) (point)))
1039 (msg (checkdoc-this-string-valid))) 1039 (msg (checkdoc-this-string-valid)))
1040 (if msg (if no-error 1040 (if msg (if no-error
1041 (message (checkdoc-error-text msg)) 1041 (message "%s" (checkdoc-error-text msg))
1042 (error "%s" (checkdoc-error-text msg))) 1042 (error "%s" (checkdoc-error-text msg)))
1043 (setq msg (checkdoc-message-text-search beg end)) 1043 (setq msg (checkdoc-message-text-search beg end))
1044 (if msg (if no-error 1044 (if msg (if no-error
1045 (message (checkdoc-error-text msg)) 1045 (message "%s" (checkdoc-error-text msg))
1046 (error "%s" (checkdoc-error-text msg))) 1046 (error "%s" (checkdoc-error-text msg)))
1047 (setq msg (checkdoc-rogue-space-check-engine beg end)) 1047 (setq msg (checkdoc-rogue-space-check-engine beg end))
1048 (if msg (if no-error 1048 (if msg (if no-error
1049 (message (checkdoc-error-text msg)) 1049 (message "%s" (checkdoc-error-text msg))
1050 (error "%s" (checkdoc-error-text msg)))))) 1050 (error "%s" (checkdoc-error-text msg))))))
1051 (if (interactive-p) (message "Checkdoc: done.")))))) 1051 (if (interactive-p) (message "Checkdoc: done."))))))
1052 1052
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index e3ade01a4a0..4dc7bdb3a73 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -3295,12 +3295,12 @@ With prefix argument, make it a temporary breakpoint."
3295 (if (eq (1+ edebug-recursion-depth) (recursion-depth)) 3295 (if (eq (1+ edebug-recursion-depth) (recursion-depth))
3296 (progn 3296 (progn
3297 (setq edebug-execution-mode mode) 3297 (setq edebug-execution-mode mode)
3298 (message shortmsg) 3298 (message "%s" shortmsg)
3299 ;; Continue execution 3299 ;; Continue execution
3300 (exit-recursive-edit)) 3300 (exit-recursive-edit))
3301 ;; This is not terribly useful!! 3301 ;; This is not terribly useful!!
3302 (setq edebug-next-execution-mode mode) 3302 (setq edebug-next-execution-mode mode)
3303 (message msg))) 3303 (message "%s" msg)))
3304 3304
3305 3305
3306(defalias 'edebug-step-through-mode 'edebug-step-mode) 3306(defalias 'edebug-step-through-mode 'edebug-step-mode)
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el
index ea6a96c6555..8d098a443fe 100644
--- a/lisp/emacs-lisp/lisp-mnt.el
+++ b/lisp/emacs-lisp/lisp-mnt.el
@@ -511,18 +511,17 @@ copyright notice is allowed."
511 (if (and file (file-directory-p file)) 511 (if (and file (file-directory-p file))
512 (setq ret 512 (setq ret
513 (with-temp-buffer 513 (with-temp-buffer
514 (mapcar 514 (dolist (f (directory-files file nil "\\.el\\'")
515 (lambda (f) 515 (buffer-string))
516 (if (string-match ".*\\.el\\'" f) 516 (when (file-regular-p f)
517 (let ((status (lm-verify f))) 517 (let ((status (lm-verify f)))
518 (insert f ":") 518 (insert f ":")
519 (if status 519 (if status
520 (lm-insert-at-column lm-comment-column status 520 (lm-insert-at-column lm-comment-column status
521 "\n") 521 "\n")
522 (if showok 522 (if showok
523 (lm-insert-at-column lm-comment-column 523 (lm-insert-at-column lm-comment-column
524 "OK\n")))))) 524 "OK\n"))))))))
525 (directory-files file))))
526 (lm-with-file file 525 (lm-with-file file
527 (setq name (lm-get-package-name)) 526 (setq name (lm-get-package-name))
528 (setq ret 527 (setq ret
@@ -562,7 +561,7 @@ copyright notice is allowed."
562 (t 561 (t
563 ret))))) 562 ret)))))
564 (if verbose 563 (if verbose
565 (message ret)) 564 (message "%s" ret))
566 ret)) 565 ret))
567 566
568(defun lm-synopsis (&optional file showall) 567(defun lm-synopsis (&optional file showall)
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index 539a561bb5b..c91886e0329 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -445,12 +445,10 @@ delete the text being replaced, as in standard Vi."
445(defvar viper-vi-state-cursor-color nil) 445(defvar viper-vi-state-cursor-color nil)
446 446
447(if (fboundp 'make-variable-frame-local) 447(if (fboundp 'make-variable-frame-local)
448 (mapc 'make-variable-frame-local 448 (dolist (v '(viper-replace-overlay-cursor-color
449 '(viper-replace-overlay-cursor-color 449 viper-insert-state-cursor-color viper-emacs-state-cursor-color
450 viper-insert-state-cursor-color 450 viper-vi-state-cursor-color))
451 viper-emacs-state-cursor-color 451 (make-variable-frame-local v)))
452 viper-vi-state-cursor-color)))
453
454 452
455(viper-deflocalvar viper-replace-overlay nil "") 453(viper-deflocalvar viper-replace-overlay nil "")
456(put 'viper-replace-overlay 'permanent-local t) 454(put 'viper-replace-overlay 'permanent-local t)
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index 87bf5235b81..78f54b3d63c 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -636,7 +636,7 @@
636 (regexp (format "^[^;]*%s[ \t\n]*[a-zA-Z---_']*[ \t\n)]" var-name)) 636 (regexp (format "^[^;]*%s[ \t\n]*[a-zA-Z---_']*[ \t\n)]" var-name))
637 (buf (find-file-noselect (substitute-in-file-name custom-file))) 637 (buf (find-file-noselect (substitute-in-file-name custom-file)))
638 ) 638 )
639 (message message) 639 (message "%s" (or message ""))
640 (save-excursion 640 (save-excursion
641 (set-buffer buf) 641 (set-buffer buf)
642 (goto-char (point-min)) 642 (goto-char (point-min))
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog
index bd20dfbed45..cdb64e87d0d 100644
--- a/lisp/erc/ChangeLog
+++ b/lisp/erc/ChangeLog
@@ -1,3 +1,37 @@
12007-12-09 Michael Olson <mwolson@gnu.org>
2
3 * erc-services.el (erc-nickserv-alist): Fix regexps for GRnet.
4
52007-12-09 Giorgos Keramidas <keramida@ceid.upatras.gr> (tiny change)
6
7 * erc-backend.el, erc.el:
8 Parse 275 (secure connection) responses.
9
10 * erc-services.el: Add identification hooks for GRnet, the Greek
11 IRC network <http://www.irc.gr>.
12
132007-12-08 David Kastrup <dak@gnu.org>
14
15 * erc-stamp.el (erc-echo-timestamp):
16 * erc-lang.el (language):
17 * erc-backend.el (erc-server-connect): Fix buggy call to `message'.
18
192007-12-07 Edward O'Connor <ted@oconnor.cx>
20
21 * erc-services.el: Provide a hook that runs when nickserv confirms
22 that the user has successfully identified.
23 (services, erc-nickserv-identify-mode): Add and remove
24 erc-nickserv-identification-autodetect from
25 erc-server-NOTICE-functions.
26 (erc-nickserv-alist): Add SUCCESS-REGEXP to each entry.
27 (erc-nickserv-alist-identified-regexp)
28 (erc-nickserv-identification-autodetect): New functions.
29 (erc-nickserv-identified-hook): New hook.
30
312007-12-06 D. Goel <deego3@gmail.com>
32
33 * erc-match.el (erc-add-entry-to-list): Fix buggy call to `error'.
34
12007-12-01 Glenn Morris <rgm@gnu.org> 352007-12-01 Glenn Morris <rgm@gnu.org>
2 36
3 * erc-backend.el (erc-server-send-ping): Move after definition of 37 * erc-backend.el (erc-server-send-ping): Move after definition of
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index c0f4205c012..5d94408ad4f 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -515,7 +515,7 @@ We will store server variables in the buffer given by BUFFER."
515 (set-process-filter process 'erc-server-filter-function) 515 (set-process-filter process 'erc-server-filter-function)
516 (set-process-buffer process buffer))) 516 (set-process-buffer process buffer)))
517 (erc-log "\n\n\n********************************************\n") 517 (erc-log "\n\n\n********************************************\n")
518 (message (erc-format-message 518 (message "%s" (erc-format-message
519 'login ?n 519 'login ?n
520 (with-current-buffer buffer (erc-current-nick)))) 520 (with-current-buffer buffer (erc-current-nick))))
521 ;; wait with script loading until we receive a confirmation (first 521 ;; wait with script loading until we receive a confirmation (first
@@ -1538,6 +1538,16 @@ A server may send more than one 005 message."
1538See `erc-display-server-message'." nil 1538See `erc-display-server-message'." nil
1539 (erc-display-server-message proc parsed)) 1539 (erc-display-server-message proc parsed))
1540 1540
1541(define-erc-response-handler (275)
1542 "Display secure connection message." nil
1543 (multiple-value-bind (nick user message)
1544 (cdr (erc-response.command-args parsed))
1545 (erc-display-message
1546 parsed 'notice 'active 's275
1547 ?n nick
1548 ?m (mapconcat 'identity (cddr (erc-response.command-args parsed))
1549 " "))))
1550
1541(define-erc-response-handler (290) 1551(define-erc-response-handler (290)
1542 "Handle dancer-ircd CAPAB messages." nil nil) 1552 "Handle dancer-ircd CAPAB messages." nil nil)
1543 1553
diff --git a/lisp/erc/erc-lang.el b/lisp/erc/erc-lang.el
index e61156f3d5a..b11721d227f 100644
--- a/lisp/erc/erc-lang.el
+++ b/lisp/erc/erc-lang.el
@@ -197,7 +197,7 @@ Normungsinstitut (ON), Postfach 130, A-1021 Vienna, Austria.")
197 "Return the language name for the ISO CODE." 197 "Return the language name for the ISO CODE."
198 (interactive (list (completing-read "ISO language code: " 198 (interactive (list (completing-read "ISO language code: "
199 iso-638-languages))) 199 iso-638-languages)))
200 (message (cdr (assoc code iso-638-languages)))) 200 (message "%s" (cdr (assoc code iso-638-languages))))
201 201
202(defun erc-cmd-LANG (language) 202(defun erc-cmd-LANG (language)
203 "Display the language name for the language code given by LANGUAGE." 203 "Display the language name for the language code given by LANGUAGE."
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el
index a4752588ebd..757ef66ea17 100644
--- a/lisp/erc/erc-match.el
+++ b/lisp/erc/erc-match.el
@@ -299,7 +299,7 @@ Completion is performed on the optional alist COMPLETIONS."
299 (lambda (x) 299 (lambda (x)
300 (not (erc-member-ignore-case (car x) (symbol-value list))))))) 300 (not (erc-member-ignore-case (car x) (symbol-value list)))))))
301 (if (erc-member-ignore-case entry (symbol-value list)) 301 (if (erc-member-ignore-case entry (symbol-value list))
302 (error (format "\"%s\" is already on the list" entry)) 302 (error "\"%s\" is already on the list" entry)
303 (set list (cons entry (symbol-value list)))))) 303 (set list (cons entry (symbol-value list))))))
304 304
305(defun erc-remove-entry-from-list (list prompt) 305(defun erc-remove-entry-from-list (list prompt)
diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el
index e6f6c40d7e8..099166bbc3f 100644
--- a/lisp/erc/erc-services.el
+++ b/lisp/erc/erc-services.el
@@ -29,9 +29,10 @@
29;; are made to test if NickServ is the real NickServ for a given network or 29;; are made to test if NickServ is the real NickServ for a given network or
30;; server. 30;; server.
31 31
32;; As a default, ERC has the data for the official nickname services on the 32;; As a default, ERC has the data for the official nickname services on
33;; networks Austnet, BrasNET, Dalnet, freenode, GalaxyNet, and Slashnet. 33;; the networks Austnet, BrasNET, Dalnet, freenode, GalaxyNet, GRnet,
34;; You can add more by using M-x customize-variable RET erc-nickserv-alist. 34;; and Slashnet. You can add more by using M-x customize-variable RET
35;; erc-nickserv-alist.
35 36
36;; Usage: 37;; Usage:
37;; 38;;
@@ -109,7 +110,9 @@ You can also use M-x erc-nickserv-identify-mode to change modes."
109 (remove-hook 'erc-after-connect 110 (remove-hook 'erc-after-connect
110 'erc-nickserv-identify-on-connect) 111 'erc-nickserv-identify-on-connect)
111 (remove-hook 'erc-nick-changed-functions 112 (remove-hook 'erc-nick-changed-functions
112 'erc-nickserv-identify-on-nick-change))) 113 'erc-nickserv-identify-on-nick-change)
114 (remove-hook 'erc-server-NOTICE-functions
115 'erc-nickserv-identification-autodetect)))
113 116
114;;;###autoload 117;;;###autoload
115(defun erc-nickserv-identify-mode (mode) 118(defun erc-nickserv-identify-mode (mode)
@@ -118,6 +121,8 @@ You can also use M-x erc-nickserv-identify-mode to change modes."
118 (list (intern (completing-read 121 (list (intern (completing-read
119 "Choose Nickserv identify mode (RET to disable): " 122 "Choose Nickserv identify mode (RET to disable): "
120 '(("autodetect") ("nick-change") ("both")) nil t)))) 123 '(("autodetect") ("nick-change") ("both")) nil t))))
124 (add-hook 'erc-server-NOTICE-functions
125 'erc-nickserv-identification-autodetect)
121 (cond ((eq mode 'autodetect) 126 (cond ((eq mode 'autodetect)
122 (setq erc-nickserv-identify-mode 'autodetect) 127 (setq erc-nickserv-identify-mode 'autodetect)
123 (add-hook 'erc-server-NOTICE-functions 128 (add-hook 'erc-server-NOTICE-functions
@@ -149,7 +154,9 @@ You can also use M-x erc-nickserv-identify-mode to change modes."
149 (remove-hook 'erc-after-connect 154 (remove-hook 'erc-after-connect
150 'erc-nickserv-identify-on-connect) 155 'erc-nickserv-identify-on-connect)
151 (remove-hook 'erc-nick-changed-functions 156 (remove-hook 'erc-nick-changed-functions
152 'erc-nickserv-identify-on-nick-change)))) 157 'erc-nickserv-identify-on-nick-change)
158 (remove-hook 'erc-server-NOTICE-functions
159 'erc-nickserv-identification-autodetect))))
153 160
154(defcustom erc-prompt-for-nickserv-password t 161(defcustom erc-prompt-for-nickserv-password t
155 "Ask for the password when identifying to NickServ." 162 "Ask for the password when identifying to NickServ."
@@ -176,6 +183,7 @@ Example of use:
176 (const DALnet) 183 (const DALnet)
177 (const freenode) 184 (const freenode)
178 (const GalaxyNet) 185 (const GalaxyNet)
186 (const GRnet)
179 (const iip) 187 (const iip)
180 (const OFTC) 188 (const OFTC)
181 (const QuakeNet) 189 (const QuakeNet)
@@ -192,63 +200,70 @@ Example of use:
192 '((Ars 200 '((Ars
193 nil nil 201 nil nil
194 "Census" 202 "Census"
195 "IDENTIFY" nil nil) 203 "IDENTIFY" nil nil nil)
196 (Austnet 204 (Austnet
197 "NickOP!service@austnet.org" 205 "NickOP!service@austnet.org"
198 "/msg\\s-NickOP@austnet.org\\s-identify\\s-<password>" 206 "/msg\\s-NickOP@austnet.org\\s-identify\\s-<password>"
199 "nickop@austnet.org" 207 "nickop@austnet.org"
200 "identify" nil nil) 208 "identify" nil nil nil)
201 (Azzurra 209 (Azzurra
202 "NickServ!service@azzurra.org" 210 "NickServ!service@azzurra.org"
203 "/ns\\s-IDENTIFY\\s-password" 211 "/ns\\s-IDENTIFY\\s-password"
204 "NickServ" 212 "NickServ"
205 "IDENTIFY" nil nil) 213 "IDENTIFY" nil nil nil)
206 (BitlBee 214 (BitlBee
207 nil nil 215 nil nil
208 "&bitlbee" 216 "&bitlbee"
209 "identify" nil nil) 217 "identify" nil nil nil)
210 (BRASnet 218 (BRASnet
211 "NickServ!services@brasnet.org" 219 "NickServ!services@brasnet.org"
212 "/NickServ\\s-IDENTIFY\\s-senha" 220 "/NickServ\\s-IDENTIFY\\s-senha"
213 "NickServ" 221 "NickServ"
214 "IDENTIFY" nil "") 222 "IDENTIFY" nil "" nil)
215 (DALnet 223 (DALnet
216 "NickServ!service@dal.net" 224 "NickServ!service@dal.net"
217 "/msg\\s-NickServ@services.dal.net\\s-IDENTIFY\\s-<password>" 225 "/msg\\s-NickServ@services.dal.net\\s-IDENTIFY\\s-<password>"
218 "NickServ@services.dal.net" 226 "NickServ@services.dal.net"
219 "IDENTIFY" nil nil) 227 "IDENTIFY" nil nil nil)
220 (freenode 228 (freenode
221 "NickServ!NickServ@services." 229 "NickServ!NickServ@services."
222 "/msg\\s-NickServ\\s-IDENTIFY\\s-<password>" 230 "/msg\\s-NickServ\\s-IDENTIFY\\s-<password>"
223 "NickServ" 231 "NickServ"
224 "IDENTIFY" nil nil) 232 "IDENTIFY" nil nil
233 "Password\\s-accepted\\s--\\s-you\\s-are\\s-now\\s-recognized")
225 (GalaxyNet 234 (GalaxyNet
226 "NS!nickserv@galaxynet.org" 235 "NS!nickserv@galaxynet.org"
227 "Please\\s-change\\s-nicks\\s-or\\s-authenticate." 236 "Please\\s-change\\s-nicks\\s-or\\s-authenticate."
228 "NS@services.galaxynet.org" 237 "NS@services.galaxynet.org"
229 "AUTH" t nil) 238 "AUTH" t nil nil)
239 (GRnet
240 "NickServ!service@irc.gr"
241 "This\\s-nickname\\s-is\\s-registered\\s-and\\s-protected."
242 "NickServ"
243 "IDENTIFY" nil nil
244 "Password\\s-accepted\\s--\\s-you\\s-are\\s-now\\s-recognized.")
230 (iip 245 (iip
231 "Trent@anon.iip" 246 "Trent@anon.iip"
232 "type\\s-/squery\\s-Trent\\s-identify\\s-<password>" 247 "type\\s-/squery\\s-Trent\\s-identify\\s-<password>"
233 "Trent@anon.iip" 248 "Trent@anon.iip"
234 "IDENTIFY" nil "SQUERY") 249 "IDENTIFY" nil "SQUERY" nil)
235 (OFTC 250 (OFTC
236 "NickServ!services@services.oftc.net" 251 "NickServ!services@services.oftc.net"
237 "type\\s-/msg\\s-NickServ\\s-IDENTIFY\\s-password." 252 "type\\s-/msg\\s-NickServ\\s-IDENTIFY\\s-password."
238 "NickServ" 253 "NickServ"
239 "IDENTIFY" nil nil) 254 "IDENTIFY" nil nil nil)
240 (QuakeNet 255 (QuakeNet
241 nil nil 256 nil nil
242 "Q@CServe.quakenet.org" 257 "Q@CServe.quakenet.org"
243 "auth" t nil) 258 "auth" t nil nil)
244 (SlashNET 259 (SlashNET
245 "NickServ!services@services.slashnet.org" 260 "NickServ!services@services.slashnet.org"
246 "/msg\\s-NickServ\\s-IDENTIFY\\s-password" 261 "/msg\\s-NickServ\\s-IDENTIFY\\s-password"
247 "NickServ@services.slashnet.org" 262 "NickServ@services.slashnet.org"
248 "IDENTIFY" nil nil)) 263 "IDENTIFY" nil nil nil))
249 "Alist of NickServer details, sorted by network. 264 "Alist of NickServer details, sorted by network.
250Every element in the list has the form 265Every element in the list has the form
251 \(SYMBOL NICKSERV REGEXP NICK KEYWORD USE-CURRENT ANSWER) 266 \(SYMBOL NICKSERV REGEXP NICK KEYWORD USE-CURRENT ANSWER SUCCESS-REGEXP)
252 267
253SYMBOL is a network identifier, a symbol, as used in `erc-networks-alist'. 268SYMBOL is a network identifier, a symbol, as used in `erc-networks-alist'.
254NICKSERV is the description of the nickserv in the form nick!user@host. 269NICKSERV is the description of the nickserv in the form nick!user@host.
@@ -258,7 +273,9 @@ KEYWORD is the keyword to use in the reply message to identify yourself.
258USE-CURRENT indicates whether the current nickname must be used when 273USE-CURRENT indicates whether the current nickname must be used when
259 identifying. 274 identifying.
260ANSWER is the command to use for the answer. The default is 'privmsg. 275ANSWER is the command to use for the answer. The default is 'privmsg.
261 This last element is optional." 276SUCCESS-REGEXP is a regular expression matching the message nickserv
277 sends when you've successfully identified.
278The last two elements are optional."
262 :group 'erc-services 279 :group 'erc-services
263 :type '(repeat 280 :type '(repeat
264 (list :tag "Nickserv data" 281 (list :tag "Nickserv data"
@@ -292,8 +309,36 @@ ANSWER is the command to use for the answer. The default is 'privmsg.
292(defsubst erc-nickserv-alist-ident-command (network &optional entry) 309(defsubst erc-nickserv-alist-ident-command (network &optional entry)
293 (nth 6 (or entry (assoc network erc-nickserv-alist)))) 310 (nth 6 (or entry (assoc network erc-nickserv-alist))))
294 311
312(defsubst erc-nickserv-alist-identified-regexp (network &optional entry)
313 (nth 7 (or entry (assoc network erc-nickserv-alist))))
314
295;; Functions: 315;; Functions:
296 316
317(defcustom erc-nickserv-identified-hook nil
318 "Run this hook when NickServ acknowledged successful identification.
319Hooks are called with arguments (NETWORK NICK)."
320 :group 'erc-services
321 :type 'hook)
322
323(defun erc-nickserv-identification-autodetect (proc parsed)
324 "Check for NickServ's successful identification notice.
325Make sure it is the real NickServ for this network and that it has
326specifically confirmed a successful identification attempt.
327If this is the case, run `erc-nickserv-identified-hook'."
328 (let* ((network (erc-network))
329 (sender (erc-nickserv-alist-sender network))
330 (success-regex (erc-nickserv-alist-identified-regexp network))
331 (sspec (erc-response.sender parsed))
332 (nick (car (erc-response.command-args parsed)))
333 (msg (erc-response.contents parsed)))
334 ;; continue only if we're sure it's the real nickserv for this network
335 ;; and it's told us we've successfully identified
336 (when (and sender (equal sspec sender)
337 (string-match success-regex msg))
338 (erc-log "NickServ IDENTIFY success notification detected")
339 (run-hook-with-args 'erc-nickserv-identified-hook network nick)
340 nil)))
341
297(defun erc-nickserv-identify-autodetect (proc parsed) 342(defun erc-nickserv-identify-autodetect (proc parsed)
298 "Check for a NickServ identify request everytime a notice is received. 343 "Check for a NickServ identify request everytime a notice is received.
299Make sure it is the real NickServ for this network and that it has 344Make sure it is the real NickServ for this network and that it has
diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el
index 64b04051d91..ae9bb51832a 100644
--- a/lisp/erc/erc-stamp.el
+++ b/lisp/erc/erc-stamp.el
@@ -412,8 +412,8 @@ NOW is position of point currently."
412 (when erc-echo-timestamps 412 (when erc-echo-timestamps
413 (let ((stamp (get-text-property now 'timestamp))) 413 (let ((stamp (get-text-property now 'timestamp)))
414 (when stamp 414 (when stamp
415 (message (format-time-string erc-echo-timestamp-format 415 (message "%s" (format-time-string erc-echo-timestamp-format
416 stamp)))))) 416 stamp))))))
417 417
418(provide 'erc-stamp) 418(provide 'erc-stamp)
419 419
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index e4e9268bfbe..cc9eb7a8f04 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -6213,6 +6213,7 @@ All windows are opened in the current frame."
6213 (s252 . "%i operator(s) online") 6213 (s252 . "%i operator(s) online")
6214 (s253 . "%i unknown connection(s)") 6214 (s253 . "%i unknown connection(s)")
6215 (s254 . "%i channels formed") 6215 (s254 . "%i channels formed")
6216 (s275 . "%n %m")
6216 (s301 . "%n is AWAY: %r") 6217 (s301 . "%n is AWAY: %r")
6217 (s303 . "Is online: %n") 6218 (s303 . "Is online: %n")
6218 (s305 . "%m") 6219 (s305 . "%m")
diff --git a/lisp/files.el b/lisp/files.el
index 8d5fcfda8c2..581864f6f46 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2054,6 +2054,8 @@ ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\)\\'" . archive-mode)
2054 ("\\.dtd\\'" . sgml-mode) 2054 ("\\.dtd\\'" . sgml-mode)
2055 ("\\.ds\\(ss\\)?l\\'" . dsssl-mode) 2055 ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
2056 ("\\.js\\'" . java-mode) ; javascript-mode would be better 2056 ("\\.js\\'" . java-mode) ; javascript-mode would be better
2057 ("\\.x[bp]m\\'" . c-mode)
2058 ("\\.d?v\\'" . verilog-mode)
2057 ;; .emacs or .gnus or .viper following a directory delimiter in 2059 ;; .emacs or .gnus or .viper following a directory delimiter in
2058 ;; Unix, MSDOG or VMS syntax. 2060 ;; Unix, MSDOG or VMS syntax.
2059 ("[]>:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode) 2061 ("[]>:/\\]\\..*\\(emacs\\|gnus\\|viper\\)\\'" . emacs-lisp-mode)
@@ -4204,10 +4206,12 @@ This undoes all changes since the file was visited or saved.
4204With a prefix argument, offer to revert from latest auto-save file, if 4206With a prefix argument, offer to revert from latest auto-save file, if
4205that is more recent than the visited file. 4207that is more recent than the visited file.
4206 4208
4207This command also works for special buffers that contain text which 4209This command also implements an interface for special buffers
4208doesn't come from a file, but reflects some other data base instead: 4210that contain text which doesn't come from a file, but reflects
4209for example, Dired buffers and `buffer-list' buffers. In these cases, 4211some other data instead (e.g. Dired buffers, `buffer-list'
4210it reconstructs the buffer contents from the appropriate data base. 4212buffers). This is done via the variable
4213`revert-buffer-function'. In these cases, it should reconstruct
4214the buffer contents from the appropriate data.
4211 4215
4212When called from Lisp, the first argument is IGNORE-AUTO; only offer 4216When called from Lisp, the first argument is IGNORE-AUTO; only offer
4213to revert from the auto-save file when this is nil. Note that the 4217to revert from the auto-save file when this is nil. Note that the
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index f400b299b9e..f9f3b923f26 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -221,6 +221,7 @@ This hook will be installed if the variable
221 etc-modules-conf-generic-mode 221 etc-modules-conf-generic-mode
222 etc-passwd-generic-mode 222 etc-passwd-generic-mode
223 etc-services-generic-mode 223 etc-services-generic-mode
224 etc-sudoers-generic-mode
224 fvwm-generic-mode 225 fvwm-generic-mode
225 inetd-conf-generic-mode 226 inetd-conf-generic-mode
226 mailagent-rules-generic-mode 227 mailagent-rules-generic-mode
@@ -1736,6 +1737,21 @@ like an INI file. You can add this hook to `find-file-hook'."
1736 (setq imenu-generic-expression 1737 (setq imenu-generic-expression
1737 '((nil "^\\([^# \t]+\\)\\s-+" 1)))))))) 1738 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1738 1739
1740;; /etc/sudoers
1741(when (memq 'etc-sudoers-generic-mode generic-extras-enable-list)
1742
1743(define-generic-mode etc-sudoers-generic-mode
1744 '(?#)
1745 '("User_Alias" "Runas_Alias" "Host_Alias" "Cmnd_Alias"
1746 "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
1747 "ALL")
1748 '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face)
1749 ("\\(\\*\\)" 1 font-lock-warning-face)
1750 ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face))
1751 '("/etc/sudoers\\'")
1752 nil
1753 "Generic mode for sudoers configuration files."))
1754
1739;; From Jacques Duthen <jacques.duthen@sncf.fr> 1755;; From Jacques Duthen <jacques.duthen@sncf.fr>
1740(when (memq 'show-tabs-generic-mode generic-extras-enable-list) 1756(when (memq 'show-tabs-generic-mode generic-extras-enable-list)
1741 1757
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index bb92d478277..d8bb4876269 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,169 @@
12007-12-15 Reiner Steib <Reiner.Steib@gmx.de>
2
3 * gnus-art.el (article-verify-x-pgp-sig): Add reference to X-PGP-Sig
4 format document.
5 (gnus-mime-delete-part): Don't write description line if empty.
6 (gnus-article-encrypt-body): Add confirmation for gnus-novice-user.
7
82007-12-14 Johan Bockg,Ae(Brd <bojohan@gnu.org>
9
10 * gnus-sum.el (gnus-summary-mark-unread-as-read)
11 (gnus-summary-mark-read-and-unread-as-read)
12 (gnus-summary-mark-current-read-and-unread-as-read)
13 (gnus-summary-mark-unread-as-ticked): Doc fix.
14 `gnus-mark-article-hook', not `gnus-summary-mark-article-hook'.
15
162007-12-14 Reiner Steib <Reiner.Steib@gmx.de>
17
18 * gnus-sum.el (gnus-summary-prev-article): Fix doc string. Reported by
19 Christoph Conrad <christoph.conrad@gmx.de>.
20
212007-12-14 Reiner Steib <Reiner.Steib@gmx.de>
22
23 * gnus-util.el (gnus-y-or-n-p, gnus-yes-or-no-p): Alias to y-or-n-p and
24 yes-or-no-p.
25
262007-12-11 Katsumi Yamaoka <yamaoka@jpl.org>
27
28 * mm-decode.el (mm-add-meta-html-tag): New function.
29 (mm-save-part-to-file, mm-pipe-part): Use it
30
31 * gnus-art.el (gnus-article-browse-delete-temp-files): Use
32 gnus-y-or-n-p instead of y-or-n-p.
33 (gnus-article-browse-html-parts): Work with message/external-body; use
34 mm-add-meta-html-tag.
35
362007-12-11 Glenn Morris <rgm@gnu.org>
37
38 * gnus-cache.el: Require gnus-sum not just when compiling.
39
40 * gnus-fun.el (gnus-display-x-face-in-from): Require gnus-art.
41
42 * gnus-int.el (gnus-server-opened, gnus-status-message): Move
43 definitions before use.
44
45 * mm-decode.el: Require gnus-util.
46 (mm-remove-part): Only call delete-annotation on XEmacs.
47
48 * mm-uu.el (gnus-original-article-buffer): Define for compiler.
49
50 * nnmail.el: Require gnus-int.
51
52 * spam.el: Move `require's before `eval-when-compile's.
53
54 * gnus-ems.el (gnus-alive-p):
55 * gnus-fun.el (message-goto-eoh):
56 * gnus-util.el (gnus-group-name-decode):
57 * mail-source.el (gnus-compress-sequence):
58 * message.el (Info-goto-node, format-spec):
59 * mm-bodies.el (message-options-get):
60 * mm-decode.el (mm-view-pkcs7):
61 * mm-util.el (gmm-write-region):
62 * mml-smime.el (mml-compute-boundary)
63 (gnus-completing-read-with-default):
64 * mml.el (widget-button-press, gnus-make-hashtable):
65 * mml1991.el (mm-decode-content-transfer-encoding)
66 (mm-encode-content-transfer-encoding)
67 (message-options-get, message-options-set):
68 * mml2015.el (gnus-buffer-live-p, gnus-get-buffer-create):
69 * nnfolder.el (gnus-request-group):
70 * nnheader.el (ietf-drums-unfold-fws):
71 * rfc1843.el (mail-header-parse-content-type, message-narrow-to-head):
72 * smime.el (gnus-run-mode-hooks):
73 * spam-stat.el (gnus-message): Autoload.
74
75 * gnus-cache.el, gnus-fun.el, gnus-group.el, gnus.el, mail-source.el:
76 * mm-bodies.el, mm-decode.el, mm-extern.el, mm-util.el:
77 * mml-smime.el, mml.el, mml1991.el, mml2015.el, nndb.el, nnfolder.el:
78 * nnmail.el, nnmaildir.el, nnrss.el, rfc1843.el, spam.el:
79 Add declare-function compatibility definition.
80
81 * gnus-cache.el (nnvirtual-find-group-art):
82 * gnus-fun.el (article-narrow-to-head, gnus-article-goto-header)
83 (gnus-add-image, gnus-add-wash-type):
84 * gnus-group.el (nnkiboze-score-file):
85 * gnus-sum.el (turn-on-gnus-mailing-list-mode)
86 (gnus-cache-write-active, mm-uu-dissect, idna-to-unicode):
87 * gnus-util.el (gnus-find-method-for-group, gnus-group-name-charset)
88 (message-tokenize-header, gnus-get-buffer-create)
89 (mm-enable-multibyte, gnus-put-text-property, gnus-overlay-put)
90 (gnus-make-overlay, mm-disable-multibyte, gnus-add-text-properties):
91 * gnus.el (gnus-group-decoded-name):
92 * mail-source.el (imap-capability):
93 * mm-bodies.el (message-options-set):
94 * mm-decode.el (gnus-configure-windows):
95 * mm-extern.el (message-goto-body):
96 * mm-util.el (mm-delete-duplicates, mm-detect-coding-region):
97 * mml-smime.el (epg-key-sub-key-list, epg-sub-key-capability)
98 (epg-sub-key-validity, message-options-set):
99 * mml.el (widget-event-point, gnus-configure-windows):
100 * mml1991.el (mc-encrypt-generic, gpg-sign-encrypt, gpg-encrypt):
101 * mml2015.el (epg-check-configuration, epg-configuration)
102 (message-options-set):
103 * nndb.el (nndb-request-article):
104 * nnfolder.el (gnus-request-create-group):
105 * nnmail.el (gnus-activate-group, gnus-group-mark-article-read):
106 * nnmaildir.el (gnus-group-mark-article-read):
107 * nnrss.el (w3-parse-buffer, gnus-group-make-rss-group):
108 * rfc1843.el (message-fetch-field):
109 * spam.el (gnus-extract-address-components):
110 Declare as functions.
111
1122007-12-10 Katsumi Yamaoka <yamaoka@jpl.org>
113
114 * gnus-art.el (gnus-article-browse-html-parts): Decode CTE.
115
1162007-12-09 Glenn Morris <rgm@gnu.org>
117
118 * gnus-uu.el (gnus-uu-yenc-article): Use insert-buffer-substring.
119
120 * gnus-art.el, gnus-spec.el, gnus-sum.el, gnus-util.el:
121 * message.el, mm-view.el, sieve-manage, smime.el:
122 Add declare-function compatibility definition.
123
124 * gnus-art.el (w3-region, w3m-region, Info-menu):
125 * gnus-spec.el (gnus-summary-from-or-to-or-newsgroups):
126 * gnus-sum.el (gnus-get-predicate):
127 * gnus-util.el (mm-append-to-file, w32-focus-frame):
128 * message.el (mail-abbrev-in-expansion-header-p):
129 * mm-view.el (w3-do-setup, w3-region, w3-prepare-buffer)
130 (w3m-detect-meta-charset, w3m-region):
131 * sieve-manage.el (password-read, password-cache-add)
132 (password-cache-remove):
133 * smime.el (password-read-and-add): Declare as functions.
134
1352007-12-08 David Kastrup <dak@gnu.org>
136
137 * gnus-sum.el (gnus-summary-simplify-subject-query):
138 * ecomplete.el (ecomplete-display-matches): Fix buggy call to
139 `message'.
140
1412007-12-07 Glenn Morris <rgm@gnu.org>
142
143 * gnus-art.el (article-make-date-line): Revert previous change.
144
1452007-12-06 Reiner Steib <Reiner.Steib@gmx.de>
146
147 * gnus-start.el (gnus-load): Rename local variable to avoid confusion.
148
1492007-12-06 Christian Plate <cplate@web.de> (tiny change)
150
151 * nnmaildir.el (nnmaildir-request-update-info): Improved performance.
152 Call gnus-add-to-range ranges only once with a prepared article-list.
153
1542007-12-06 Paul Jarc <prj@po.cwru.edu>
155
156 * nnmaildir.el (nnmaildir-request-list, nnmaildir-retrieve-groups,
157 nnmaildir-request-group, nnmaildir-retrieve-headers): Escape spaces in
158 group names with backslashes. Reported by Tassilo Horn
159 <tassilo@member.fsf.org>.
160
1612007-12-06 D. Goel <deego3@gmail.com>
162
163 * gnus-art.el (article-make-date-line):
164 * gnus-start.el (gnus-load):
165 * pop3.el (pop3-read-response): Fix buggy call to `error'.
166
12007-12-05 Katsumi Yamaoka <yamaoka@jpl.org> 1672007-12-05 Katsumi Yamaoka <yamaoka@jpl.org>
2 168
3 * gnus-art.el (gnus-use-idna) 169 * gnus-art.el (gnus-use-idna)
diff --git a/lisp/gnus/ecomplete.el b/lisp/gnus/ecomplete.el
index 42a75916277..285aca4270a 100644
--- a/lisp/gnus/ecomplete.el
+++ b/lisp/gnus/ecomplete.el
@@ -119,7 +119,7 @@
119 nil) 119 nil)
120 (if (not choose) 120 (if (not choose)
121 (progn 121 (progn
122 (message matches) 122 (message "%s" matches)
123 nil) 123 nil)
124 (setq highlight (ecomplete-highlight-match-line matches line)) 124 (setq highlight (ecomplete-highlight-match-line matches line))
125 (while (not (memq (setq command (read-event highlight)) '(? return))) 125 (while (not (memq (setq command (read-event highlight)) '(? return)))
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 4bb9ceb97ba..e984372543d 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -27,6 +27,9 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
30(eval-when-compile 33(eval-when-compile
31 (require 'cl)) 34 (require 'cl))
32(defvar tool-bar-map) 35(defvar tool-bar-map)
@@ -2705,6 +2708,9 @@ charset defined in `gnus-summary-show-article-charset-alist' is used."
2705 (t 2708 (t
2706 (apply (car func) (cdr func)))))))))) 2709 (apply (car func) (cdr func))))))))))
2707 2710
2711;; External.
2712(declare-function w3-region "ext:w3-display" (st nd))
2713
2708(defun gnus-article-wash-html-with-w3 () 2714(defun gnus-article-wash-html-with-w3 ()
2709 "Wash the current buffer with w3." 2715 "Wash the current buffer with w3."
2710 (mm-setup-w3) 2716 (mm-setup-w3)
@@ -2716,6 +2722,9 @@ charset defined in `gnus-summary-show-article-charset-alist' is used."
2716 (w3-region (point-min) (point-max)) 2722 (w3-region (point-min) (point-max))
2717 (error)))) 2723 (error))))
2718 2724
2725;; External.
2726(declare-function w3m-region "ext:w3m" (start end &optional url charset))
2727
2719(defun gnus-article-wash-html-with-w3m () 2728(defun gnus-article-wash-html-with-w3m ()
2720 "Wash the current buffer with emacs-w3m." 2729 "Wash the current buffer with emacs-w3m."
2721 (mm-setup-w3m) 2730 (mm-setup-w3m)
@@ -2773,9 +2782,9 @@ summary buffer."
2773 (or how 2782 (or how
2774 (setq how gnus-article-browse-delete-temp))) 2783 (setq how gnus-article-browse-delete-temp)))
2775 (when (and (eq how 'ask) 2784 (when (and (eq how 'ask)
2776 (y-or-n-p (format 2785 (gnus-y-or-n-p (format
2777 "Delete all %s temporary HTML file(s)? " 2786 "Delete all %s temporary HTML file(s)? "
2778 (length gnus-article-browse-html-temp-list))) 2787 (length gnus-article-browse-html-temp-list)))
2779 (setq how t))) 2788 (setq how t)))
2780 (dolist (file gnus-article-browse-html-temp-list) 2789 (dolist (file gnus-article-browse-html-temp-list)
2781 (when (and (file-exists-p file) 2790 (when (and (file-exists-p file)
@@ -2793,61 +2802,63 @@ summary buffer."
2793 "View all \"text/html\" parts from LIST. 2802 "View all \"text/html\" parts from LIST.
2794Recurse into multiparts." 2803Recurse into multiparts."
2795 ;; Internal function used by `gnus-article-browse-html-article'. 2804 ;; Internal function used by `gnus-article-browse-html-article'.
2796 (let ((showed)) 2805 (let (type file charset tmp-file showed)
2797 ;; Find and show the html-parts. 2806 ;; Find and show the html-parts.
2798 (dolist (handle list) 2807 (dolist (handle list)
2799 ;; If HTML, show it: 2808 ;; If HTML, show it:
2800 (when (listp handle) 2809 (cond ((not (listp handle)))
2801 (cond ((and (bufferp (car handle)) 2810 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2802 (string-match "text/html" (car (mm-handle-type handle)))) 2811 (and (equal (car type) "message/external-body")
2803 (let ((tmp-file (mm-make-temp-file 2812 (setq file (or (mail-content-type-get type 'name)
2804 ;; Do we need to care for 8.3 filenames? 2813 (mail-content-type-get
2805 "mm-" nil ".html")) 2814 (mm-handle-disposition handle)
2806 (charset (mail-content-type-get (mm-handle-type handle) 2815 'filename)))
2807 'charset))) 2816 (or (mm-handle-cache handle)
2808 (if charset 2817 (condition-case code
2809 ;; Add a meta html tag to specify charset. 2818 (progn (mm-extern-cache-contents handle) t)
2810 (mm-with-unibyte-buffer 2819 (error
2811 (insert (with-current-buffer (mm-handle-buffer handle) 2820 (gnus-message 3 "%s" (error-message-string code))
2812 (if (eq charset 'gnus-decoded) 2821 (when (>= gnus-verbose 3) (sit-for 2))
2813 (mm-encode-coding-string 2822 nil)))
2814 (buffer-string) 2823 (progn
2815 (setq charset 'utf-8)) 2824 (setq handle (mm-handle-cache handle)
2816 (buffer-string)))) 2825 type (mm-handle-type handle))
2817 (setq charset (format "\ 2826 (equal (car type) "text/html"))))
2818<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">" 2827 (when (or (setq charset (mail-content-type-get type 'charset))
2819 charset)) 2828 (not file))
2820 (goto-char (point-min)) 2829 (setq tmp-file (mm-make-temp-file
2821 (let ((case-fold-search t)) 2830 ;; Do we need to care for 8.3 filenames?
2822 (cond (;; Don't modify existing meta tag. 2831 "mm-" nil ".html")))
2823 (re-search-forward "\ 2832 (if charset
2824<meta[\t\n\r ]+http-equiv=\"content-type\"[^>]+>" 2833 ;; Add a meta html tag to specify charset.
2825 nil t)) 2834 (mm-with-unibyte-buffer
2826 ((re-search-forward "<head>[\t\n\r ]*" nil t) 2835 (insert (if (eq charset 'gnus-decoded)
2827 (insert charset "\n")) 2836 (mm-encode-coding-string (mm-get-part handle)
2828 (t 2837 (setq charset 'utf-8))
2829 (re-search-forward "\ 2838 (mm-get-part handle)))
2830<html\\(?:[\t\n\r ]+[^>]+\\|[\t\n\r ]*\\)>[\t\n\r ]*" 2839 (if (or (mm-add-meta-html-tag handle charset)
2831 nil t) 2840 (not file))
2832 (insert "<head>\n" charset "\n</head>\n"))))
2833 (mm-write-region (point-min) (point-max) 2841 (mm-write-region (point-min) (point-max)
2834 tmp-file nil nil nil 'binary t)) 2842 tmp-file nil nil nil 'binary t)
2835 (mm-save-part-to-file handle tmp-file)) 2843 (setq tmp-file nil)))
2836 (add-to-list 'gnus-article-browse-html-temp-list tmp-file) 2844 (when tmp-file
2837 (add-hook 'gnus-summary-prepare-exit-hook 2845 (mm-save-part-to-file handle tmp-file)))
2838 'gnus-article-browse-delete-temp-files) 2846 (when tmp-file
2839 (add-hook 'gnus-exit-gnus-hook 2847 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
2840 (lambda () 2848 (add-hook 'gnus-summary-prepare-exit-hook
2841 (gnus-article-browse-delete-temp-files t))) 2849 'gnus-article-browse-delete-temp-files)
2842 ;; FIXME: Warn if there's an <img> tag? 2850 (add-hook 'gnus-exit-gnus-hook
2843 (browse-url-of-file tmp-file) 2851 (lambda ()
2844 (setq showed t))) 2852 (gnus-article-browse-delete-temp-files t)))
2845 ;; If multipart, recurse 2853 ;; FIXME: Warn if there's an <img> tag?
2846 ((and (stringp (car handle)) 2854 (browse-url-of-file (or tmp-file (expand-file-name file)))
2847 (string-match "^multipart/" (car handle)) 2855 (setq showed t))
2848 (setq showed 2856 ;; If multipart, recurse
2849 (or showed 2857 ((and (stringp (car handle))
2850 (gnus-article-browse-html-parts handle)))))))) 2858 (string-match "^multipart/" (car handle))
2859 (setq showed
2860 (or showed
2861 (gnus-article-browse-html-parts handle)))))))
2851 showed)) 2862 showed))
2852 2863
2853;; FIXME: Documentation in texi/gnus.texi missing. 2864;; FIXME: Documentation in texi/gnus.texi missing.
@@ -3907,6 +3918,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is
3907 3918
3908(defun article-verify-x-pgp-sig () 3919(defun article-verify-x-pgp-sig ()
3909 "Verify X-PGP-Sig." 3920 "Verify X-PGP-Sig."
3921 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
3910 (interactive) 3922 (interactive)
3911 (if (gnus-buffer-live-p gnus-original-article-buffer) 3923 (if (gnus-buffer-live-p gnus-original-article-buffer)
3912 (let ((sig (with-current-buffer gnus-original-article-buffer 3924 (let ((sig (with-current-buffer gnus-original-article-buffer
@@ -4715,8 +4727,9 @@ Deleting parts may malfunction or destroy the article; continue? "))
4715 (handles gnus-article-mime-handles) 4727 (handles gnus-article-mime-handles)
4716 (none "(none)") 4728 (none "(none)")
4717 (description 4729 (description
4718 (mail-decode-encoded-word-string (or (mm-handle-description data) 4730 (let ((desc (mm-handle-description data)))
4719 none))) 4731 (when desc
4732 (mail-decode-encoded-word-string desc))))
4720 (filename 4733 (filename
4721 (or (mail-content-type-get (mm-handle-disposition data) 'filename) 4734 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4722 none)) 4735 none))
@@ -4734,7 +4747,8 @@ Deleting parts may malfunction or destroy the article; continue? "))
4734 "| Type: " type "\n" 4747 "| Type: " type "\n"
4735 "| Filename: " filename "\n" 4748 "| Filename: " filename "\n"
4736 "| Size (encoded): " bsize " Byte\n" 4749 "| Size (encoded): " bsize " Byte\n"
4737 "| Description: " description "\n" 4750 (when description
4751 (concat "| Description: " description "\n"))
4738 "`----\n")) 4752 "`----\n"))
4739 (setcdr data 4753 (setcdr data
4740 (cdr (mm-make-handle 4754 (cdr (mm-make-handle
@@ -7682,6 +7696,9 @@ url is put as the `gnus-button-url' overlay property on the button."
7682 "Fetch KDE style info URL." 7696 "Fetch KDE style info URL."
7683 (gnus-info-find-node (gnus-url-unhex-string url))) 7697 (gnus-info-find-node (gnus-url-unhex-string url)))
7684 7698
7699;; (info) will autoload info.el
7700(declare-function Info-menu "info" (menu-item &optional fork))
7701
7685(defun gnus-button-handle-info-keystrokes (url) 7702(defun gnus-button-handle-info-keystrokes (url)
7686 "Call `info' when pushing the corresponding URL button." 7703 "Call `info' when pushing the corresponding URL button."
7687 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'. 7704 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
@@ -7991,6 +8008,11 @@ For example:
7991 gnus-article-encrypt-protocol-alist 8008 gnus-article-encrypt-protocol-alist
7992 nil t)) 8009 nil t))
7993 current-prefix-arg)) 8010 current-prefix-arg))
8011 ;; User might hit `K E' instead of `K e', so prompt once.
8012 (when (and gnus-article-encrypt-protocol
8013 gnus-novice-user)
8014 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8015 (error "Encrypt aborted.")))
7994 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist)))) 8016 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7995 (unless func 8017 (unless func
7996 (error "Can't find the encrypt protocol %s" protocol)) 8018 (error "Can't find the encrypt protocol %s" protocol))
diff --git a/lisp/gnus/gnus-cache.el b/lisp/gnus/gnus-cache.el
index 4f61a0f2759..72c88600a5e 100644
--- a/lisp/gnus/gnus-cache.el
+++ b/lisp/gnus/gnus-cache.el
@@ -27,13 +27,18 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33
30(eval-when-compile (require 'cl)) 34(eval-when-compile (require 'cl))
31 35
32(require 'gnus) 36(require 'gnus)
37(require 'gnus-sum)
38
33(eval-when-compile 39(eval-when-compile
34 (unless (fboundp 'gnus-agent-load-alist) 40 (unless (fboundp 'gnus-agent-load-alist)
35 (defun gnus-agent-load-alist (group))) 41 (defun gnus-agent-load-alist (group))))
36 (require 'gnus-sum))
37 42
38(defcustom gnus-cache-active-file 43(defcustom gnus-cache-active-file
39 (expand-file-name "active" gnus-cache-directory) 44 (expand-file-name "active" gnus-cache-directory)
@@ -91,6 +96,8 @@ it's not cached."
91(defvar gnus-cache-active-altered nil) 96(defvar gnus-cache-active-altered nil)
92(defvar gnus-cache-total-fetched-hashtb nil) 97(defvar gnus-cache-total-fetched-hashtb nil)
93 98
99(declare-function nnvirtual-find-group-art "nnvirtual" (group article))
100
94(eval-and-compile 101(eval-and-compile
95 (autoload 'nnml-generate-nov-databases-directory "nnml") 102 (autoload 'nnml-generate-nov-databases-directory "nnml")
96 (autoload 'nnvirtual-find-group-art "nnvirtual")) 103 (autoload 'nnvirtual-find-group-art "nnvirtual"))
diff --git a/lisp/gnus/gnus-ems.el b/lisp/gnus/gnus-ems.el
index 79e513b5f05..a49d46a94d6 100644
--- a/lisp/gnus/gnus-ems.el
+++ b/lisp/gnus/gnus-ems.el
@@ -161,6 +161,8 @@
161 "Non-nil means the mark and region are currently active in this buffer." 161 "Non-nil means the mark and region are currently active in this buffer."
162 mark-active) ; aliased to region-exists-p in XEmacs. 162 mark-active) ; aliased to region-exists-p in XEmacs.
163 163
164(autoload 'gnus-alive-p "gnus-util")
165
164(defun gnus-x-splash () 166(defun gnus-x-splash ()
165 "Show a splash screen using a pixmap in the current buffer." 167 "Show a splash screen using a pixmap in the current buffer."
166 (interactive) 168 (interactive)
diff --git a/lisp/gnus/gnus-fun.el b/lisp/gnus/gnus-fun.el
index 05454960e38..e9c6d9fd816 100644
--- a/lisp/gnus/gnus-fun.el
+++ b/lisp/gnus/gnus-fun.el
@@ -26,6 +26,10 @@
26 26
27;;; Code: 27;;; Code:
28 28
29;; For Emacs < 22.2.
30(eval-and-compile
31 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
32
29(eval-when-compile 33(eval-when-compile
30 (require 'cl)) 34 (require 'cl))
31 35
@@ -105,6 +109,8 @@ Output to the current buffer, replace text, and don't mingle error."
105 (format gnus-convert-pbm-to-x-face-command 109 (format gnus-convert-pbm-to-x-face-command
106 (shell-quote-argument file))))))) 110 (shell-quote-argument file)))))))
107 111
112(autoload 'message-goto-eoh "message" nil t)
113
108;;;###autoload 114;;;###autoload
109(defun gnus-insert-random-x-face-header () 115(defun gnus-insert-random-x-face-header ()
110 "Insert a random X-Face header from `gnus-x-face-directory'." 116 "Insert a random X-Face header from `gnus-x-face-directory'."
@@ -203,8 +209,14 @@ The colors from this face are used as the foreground and background
203colors of the displayed X-Faces." 209colors of the displayed X-Faces."
204 :group 'gnus-article-headers) 210 :group 'gnus-article-headers)
205 211
212(declare-function article-narrow-to-head "gnus-art" ())
213(declare-function gnus-article-goto-header "gnus-art" (header))
214(declare-function gnus-add-image "gnus-art" (category image))
215(declare-function gnus-add-wash-type "gnus-art" (type))
216
206(defun gnus-display-x-face-in-from (data) 217(defun gnus-display-x-face-in-from (data)
207 "Display the X-Face DATA in the From header." 218 "Display the X-Face DATA in the From header."
219 (require 'gnus-art)
208 (let ((default-enable-multibyte-characters nil) 220 (let ((default-enable-multibyte-characters nil)
209 pbm) 221 pbm)
210 (when (or (gnus-image-type-available-p 'xface) 222 (when (or (gnus-image-type-available-p 'xface)
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index 5843214e48a..73d632591b5 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -27,6 +27,10 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33
30(eval-when-compile 34(eval-when-compile
31 (require 'cl)) 35 (require 'cl))
32(defvar tool-bar-mode) 36(defvar tool-bar-mode)
@@ -3004,6 +3008,8 @@ mail messages or news articles in files that have numeric names."
3004 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir))))) 3008 (list 'nndir (gnus-group-real-name group) (list 'nndir-directory dir)))))
3005 3009
3006(defvar nnkiboze-score-file) 3010(defvar nnkiboze-score-file)
3011(declare-function nnkiboze-score-file "nnkiboze" (group))
3012
3007(defun gnus-group-make-kiboze-group (group address scores) 3013(defun gnus-group-make-kiboze-group (group address scores)
3008 "Create an nnkiboze group. 3014 "Create an nnkiboze group.
3009The user will be prompted for a name, a regexp to match groups, and 3015The user will be prompted for a name, a regexp to match groups, and
diff --git a/lisp/gnus/gnus-int.el b/lisp/gnus/gnus-int.el
index ac2b7237866..5c48f70a6ad 100644
--- a/lisp/gnus/gnus-int.el
+++ b/lisp/gnus/gnus-int.el
@@ -58,6 +58,27 @@ server denied."
58(defvar gnus-internal-registry-spool-current-method nil 58(defvar gnus-internal-registry-spool-current-method nil
59 "The current method, for the registry.") 59 "The current method, for the registry.")
60 60
61
62(defun gnus-server-opened (gnus-command-method)
63 "Check whether a connection to GNUS-COMMAND-METHOD has been opened."
64 (unless (eq (gnus-server-status gnus-command-method)
65 'denied)
66 (when (stringp gnus-command-method)
67 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
68 (funcall (inline (gnus-get-function gnus-command-method 'server-opened))
69 (nth 1 gnus-command-method))))
70
71(defun gnus-status-message (gnus-command-method)
72 "Return the status message from GNUS-COMMAND-METHOD.
73If GNUS-COMMAND-METHOD is a string, it is interpreted as a group
74name. The method this group uses will be queried."
75 (let ((gnus-command-method
76 (if (stringp gnus-command-method)
77 (gnus-find-method-for-group gnus-command-method)
78 gnus-command-method)))
79 (funcall (gnus-get-function gnus-command-method 'status-message)
80 (nth 1 gnus-command-method))))
81
61;;; 82;;;
62;;; Server Communication 83;;; Server Communication
63;;; 84;;;
@@ -315,26 +336,6 @@ If it is down, start it up (again)."
315 (when func 336 (when func
316 (funcall func date (nth 1 gnus-command-method))))) 337 (funcall func date (nth 1 gnus-command-method)))))
317 338
318(defun gnus-server-opened (gnus-command-method)
319 "Check whether a connection to GNUS-COMMAND-METHOD has been opened."
320 (unless (eq (gnus-server-status gnus-command-method)
321 'denied)
322 (when (stringp gnus-command-method)
323 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
324 (funcall (inline (gnus-get-function gnus-command-method 'server-opened))
325 (nth 1 gnus-command-method))))
326
327(defun gnus-status-message (gnus-command-method)
328 "Return the status message from GNUS-COMMAND-METHOD.
329If GNUS-COMMAND-METHOD is a string, it is interpreted as a group
330name. The method this group uses will be queried."
331 (let ((gnus-command-method
332 (if (stringp gnus-command-method)
333 (gnus-find-method-for-group gnus-command-method)
334 gnus-command-method)))
335 (funcall (gnus-get-function gnus-command-method 'status-message)
336 (nth 1 gnus-command-method))))
337
338(defun gnus-request-regenerate (gnus-command-method) 339(defun gnus-request-regenerate (gnus-command-method)
339 "Request a data generation from GNUS-COMMAND-METHOD." 340 "Request a data generation from GNUS-COMMAND-METHOD."
340 (when (stringp gnus-command-method) 341 (when (stringp gnus-command-method)
diff --git a/lisp/gnus/gnus-spec.el b/lisp/gnus/gnus-spec.el
index f87377cb1ed..5b8bf92ffdb 100644
--- a/lisp/gnus/gnus-spec.el
+++ b/lisp/gnus/gnus-spec.el
@@ -27,6 +27,9 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
30(eval-when-compile (require 'cl)) 33(eval-when-compile (require 'cl))
31(defvar gnus-newsrc-file-version) 34(defvar gnus-newsrc-file-version)
32 35
@@ -87,6 +90,9 @@ text properties. This is only needed on XEmacs, as FSF Emacs does this anyway."
87(defvar gnus-tmp-header) 90(defvar gnus-tmp-header)
88(defvar gnus-tmp-from) 91(defvar gnus-tmp-from)
89 92
93(declare-function gnus-summary-from-or-to-or-newsgroups "gnus-sum"
94 (header gnus-tmp-from))
95
90(defun gnus-summary-line-format-spec () 96(defun gnus-summary-line-format-spec ()
91 (insert gnus-tmp-unread gnus-tmp-replied 97 (insert gnus-tmp-unread gnus-tmp-replied
92 gnus-tmp-score-char gnus-tmp-indentation) 98 gnus-tmp-score-char gnus-tmp-indentation)
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index 2c1b6677949..bd0e4efafad 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -2394,11 +2394,11 @@ If FORCE is non-nil, the .newsrc file is read."
2394 (eval form)) 2394 (eval form))
2395 (error 2395 (error
2396 (unless (eq (car type) 'end-of-file) 2396 (unless (eq (car type) 'end-of-file)
2397 (let ((error (format "Error in %s line %d" file 2397 (let ((errmsg (format "Error in %s line %d" file
2398 (count-lines (point-min) (point))))) 2398 (count-lines (point-min) (point)))))
2399 (ding) 2399 (ding)
2400 (unless (gnus-yes-or-no-p (concat error "; continue? ")) 2400 (unless (gnus-yes-or-no-p (concat errmsg "; continue? "))
2401 (error "%s" error))))))))) 2401 (error "%s" errmsg)))))))))
2402 2402
2403(defun gnus-read-newsrc-el-file (file) 2403(defun gnus-read-newsrc-el-file (file)
2404 (let ((ding-file (concat file "d"))) 2404 (let ((ding-file (concat file "d")))
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index b082a8b152e..62068d85a80 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -27,6 +27,9 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
30(eval-when-compile 33(eval-when-compile
31 (require 'cl)) 34 (require 'cl))
32 35
@@ -2959,6 +2962,9 @@ When FORCE, rebuild the tool bar."
2959 (setq headers (cdr headers))) 2962 (setq headers (cdr headers)))
2960 (list (nreverse outh)))))))) 2963 (list (nreverse outh))))))))
2961 2964
2965
2966(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
2967
2962 2968
2963 2969
2964(defun gnus-summary-mode (&optional group) 2970(defun gnus-summary-mode (&optional group)
@@ -4028,7 +4034,7 @@ If NO-DISPLAY, don't generate a summary buffer."
4028 "Query where the respool algorithm would put this article." 4034 "Query where the respool algorithm would put this article."
4029 (interactive) 4035 (interactive)
4030 (gnus-summary-select-article) 4036 (gnus-summary-select-article)
4031 (message (gnus-general-simplify-subject (gnus-summary-article-subject)))) 4037 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4032 4038
4033(defun gnus-gather-threads-by-subject (threads) 4039(defun gnus-gather-threads-by-subject (threads)
4034 "Gather threads by looking at Subject headers." 4040 "Gather threads by looking at Subject headers."
@@ -5576,6 +5582,8 @@ If SELECT-ARTICLES, only select those articles from GROUP."
5576 (gnus-inverse-list-range-intersection 5582 (gnus-inverse-list-range-intersection
5577 gnus-newsgroup-articles gnus-newsgroup-seen)))) 5583 gnus-newsgroup-articles gnus-newsgroup-seen))))
5578 5584
5585(declare-function gnus-get-predicate "gnus-agent" (predicate))
5586
5579(defun gnus-summary-display-make-predicate (display) 5587(defun gnus-summary-display-make-predicate (display)
5580 (require 'gnus-agent) 5588 (require 'gnus-agent)
5581 (when (= (length display) 1) 5589 (when (= (length display) 1)
@@ -6946,6 +6954,8 @@ If FORCE (the prefix), also save the .newsrc file(s)."
6946 (gnus-save-newsrc-file) 6954 (gnus-save-newsrc-file)
6947 (gnus-dribble-save))) 6955 (gnus-dribble-save)))
6948 6956
6957(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
6958
6949(defun gnus-summary-exit (&optional temporary leave-hidden) 6959(defun gnus-summary-exit (&optional temporary leave-hidden)
6950 "Exit reading current newsgroup, and then return to group selection mode. 6960 "Exit reading current newsgroup, and then return to group selection mode.
6951`gnus-exit-group-hook' is called with no arguments if that value is non-nil." 6961`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
@@ -7648,7 +7658,7 @@ If BACKWARD, the previous article is selected instead of the next."
7648 (gnus-summary-article-subject)))) 7658 (gnus-summary-article-subject))))
7649 7659
7650(defun gnus-summary-prev-article (&optional unread subject) 7660(defun gnus-summary-prev-article (&optional unread subject)
7651 "Select the article after the current one. 7661 "Select the article before the current one.
7652If UNREAD is non-nil, only unread articles are selected." 7662If UNREAD is non-nil, only unread articles are selected."
7653 (interactive "P") 7663 (interactive "P")
7654 (gnus-summary-next-article unread subject t)) 7664 (gnus-summary-next-article unread subject t))
@@ -9437,6 +9447,8 @@ prefix specifies how many places to rotate each letter forward."
9437 ;; Create buttons and stuff... 9447 ;; Create buttons and stuff...
9438 (gnus-treat-article nil)) 9448 (gnus-treat-article nil))
9439 9449
9450(declare-function idna-to-unicode "ext:idna" (str))
9451
9440(defun gnus-summary-idna-message (&optional arg) 9452(defun gnus-summary-idna-message (&optional arg)
9441 "Decode IDNA encoded domain names in the current articles. 9453 "Decode IDNA encoded domain names in the current articles.
9442IDNA encoded domain names looks like `xn--bar'. If a string 9454IDNA encoded domain names looks like `xn--bar'. If a string
@@ -10818,12 +10830,12 @@ The difference between N and the number of marks cleared is returned."
10818 (gnus-summary-mark-forward (- n) gnus-unread-mark)) 10830 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10819 10831
10820(defun gnus-summary-mark-unread-as-read () 10832(defun gnus-summary-mark-unread-as-read ()
10821 "Intended to be used by `gnus-summary-mark-article-hook'." 10833 "Intended to be used by `gnus-mark-article-hook'."
10822 (when (memq gnus-current-article gnus-newsgroup-unreads) 10834 (when (memq gnus-current-article gnus-newsgroup-unreads)
10823 (gnus-summary-mark-article gnus-current-article gnus-read-mark))) 10835 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10824 10836
10825(defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark) 10837(defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10826 "Intended to be used by `gnus-summary-mark-article-hook'." 10838 "Intended to be used by `gnus-mark-article-hook'."
10827 (let ((mark (gnus-summary-article-mark))) 10839 (let ((mark (gnus-summary-article-mark)))
10828 (when (or (gnus-unread-mark-p mark) 10840 (when (or (gnus-unread-mark-p mark)
10829 (gnus-read-mark-p mark)) 10841 (gnus-read-mark-p mark))
@@ -10831,7 +10843,7 @@ The difference between N and the number of marks cleared is returned."
10831 (or new-mark gnus-read-mark))))) 10843 (or new-mark gnus-read-mark)))))
10832 10844
10833(defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark) 10845(defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10834 "Intended to be used by `gnus-summary-mark-article-hook'." 10846 "Intended to be used by `gnus-mark-article-hook'."
10835 (let ((mark (gnus-summary-article-mark))) 10847 (let ((mark (gnus-summary-article-mark)))
10836 (when (or (gnus-unread-mark-p mark) 10848 (when (or (gnus-unread-mark-p mark)
10837 (gnus-read-mark-p mark)) 10849 (gnus-read-mark-p mark))
@@ -10839,7 +10851,7 @@ The difference between N and the number of marks cleared is returned."
10839 (or new-mark gnus-read-mark))))) 10851 (or new-mark gnus-read-mark)))))
10840 10852
10841(defun gnus-summary-mark-unread-as-ticked () 10853(defun gnus-summary-mark-unread-as-ticked ()
10842 "Intended to be used by `gnus-summary-mark-article-hook'." 10854 "Intended to be used by `gnus-mark-article-hook'."
10843 (when (memq gnus-current-article gnus-newsgroup-unreads) 10855 (when (memq gnus-current-article gnus-newsgroup-unreads)
10844 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark))) 10856 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10845 10857
@@ -11792,6 +11804,7 @@ save those articles instead."
11792 encoded))) 11804 encoded)))
11793 11805
11794(defvar gnus-summary-save-parts-counter) 11806(defvar gnus-summary-save-parts-counter)
11807(declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
11795 11808
11796(defun gnus-summary-save-parts (type dir n &optional reverse) 11809(defun gnus-summary-save-parts (type dir n &optional reverse)
11797 "Save parts matching TYPE to DIR. 11810 "Save parts matching TYPE to DIR.
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index de01fb2db11..56aacf0d5a6 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -35,6 +35,9 @@
35 35
36;;; Code: 36;;; Code:
37 37
38;; For Emacs < 22.2.
39(eval-and-compile
40 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
38(eval-when-compile 41(eval-when-compile
39 (require 'cl)) 42 (require 'cl))
40;; Fixme: this should be a gnus variable, not nnmail-. 43;; Fixme: this should be a gnus variable, not nnmail-.
@@ -214,6 +217,13 @@ is slower."
214 (search-forward ":" eol t) 217 (search-forward ":" eol t)
215 (point))))) 218 (point)))))
216 219
220(declare-function gnus-find-method-for-group "gnus" (group &optional info))
221(autoload 'gnus-group-name-decode "gnus-group")
222(declare-function gnus-group-name-charset "gnus-group" (method group))
223;; gnus-group requires gnus-int which requires message.
224(declare-function message-tokenize-header "message"
225 (header &optional separator))
226
217(defun gnus-decode-newsgroups (newsgroups group &optional method) 227(defun gnus-decode-newsgroups (newsgroups group &optional method)
218 (let ((method (or method (gnus-find-method-for-group group)))) 228 (let ((method (or method (gnus-find-method-for-group group))))
219 (mapconcat (lambda (group) 229 (mapconcat (lambda (group)
@@ -327,15 +337,23 @@ Symbols are also allowed; their print names are used instead."
327 337
328;; Two silly functions to ensure that all `y-or-n-p' questions clear 338;; Two silly functions to ensure that all `y-or-n-p' questions clear
329;; the echo area. 339;; the echo area.
330(defun gnus-y-or-n-p (prompt) 340;;
331 (prog1 341;; Do we really need these aliases? Workarounds for bugs in the corresponding
332 (y-or-n-p prompt) 342;; Emacs functions? Maybe these bug are no longer present in any supported
333 (message ""))) 343;; (X)Emacs version? Alias them to the original functions and see if anyone
334 344;; reports a problem. If not, replace with original functions. --rsteib
335(defun gnus-yes-or-no-p (prompt) 345;;
336 (prog1 346;; (defun gnus-y-or-n-p (prompt)
337 (yes-or-no-p prompt) 347;; (prog1
338 (message ""))) 348;; (y-or-n-p prompt)
349;; (message "")))
350;; (defun gnus-yes-or-no-p (prompt)
351;; (prog1
352;; (yes-or-no-p prompt)
353;; (message "")))
354
355(defalias 'gnus-y-or-n-p 'y-or-n-p)
356(defalias 'gnus-yes-or-no-p 'yes-or-no-p)
339 357
340;; By Frank Schmitt <ich@Frank-Schmitt.net>. Allows to have 358;; By Frank Schmitt <ich@Frank-Schmitt.net>. Allows to have
341;; age-depending date representations. (e.g. just the time if it's 359;; age-depending date representations. (e.g. just the time if it's
@@ -654,6 +672,10 @@ If N, return the Nth ancestor instead."
654 672
655(defvar gnus-work-buffer " *gnus work*") 673(defvar gnus-work-buffer " *gnus work*")
656 674
675(declare-function gnus-get-buffer-create "gnus" (name))
676;; gnus.el requires mm-util.
677(declare-function mm-enable-multibyte "mm-util")
678
657(defun gnus-set-work-buffer () 679(defun gnus-set-work-buffer ()
658 "Put point in the empty Gnus work buffer." 680 "Put point in the empty Gnus work buffer."
659 (if (get-buffer gnus-work-buffer) 681 (if (get-buffer gnus-work-buffer)
@@ -838,6 +860,9 @@ If there's no subdirectory, delete DIRECTORY as well."
838 (setq string (replace-match "" t t string))) 860 (setq string (replace-match "" t t string)))
839 string) 861 string)
840 862
863(declare-function gnus-put-text-property "gnus"
864 (start end property value &optional object))
865
841(defsubst gnus-put-text-property-excluding-newlines (beg end prop val) 866(defsubst gnus-put-text-property-excluding-newlines (beg end prop val)
842 "The same as `put-text-property', but don't put this prop on any newlines in the region." 867 "The same as `put-text-property', but don't put this prop on any newlines in the region."
843 (save-match-data 868 (save-match-data
@@ -849,6 +874,10 @@ If there's no subdirectory, delete DIRECTORY as well."
849 (setq beg (point))) 874 (setq beg (point)))
850 (gnus-put-text-property beg (point) prop val))))) 875 (gnus-put-text-property beg (point) prop val)))))
851 876
877(declare-function gnus-overlay-put "gnus" (overlay prop value))
878(declare-function gnus-make-overlay "gnus"
879 (beg end &optional buffer front-advance rear-advance))
880
852(defsubst gnus-put-overlay-excluding-newlines (beg end prop val) 881(defsubst gnus-put-overlay-excluding-newlines (beg end prop val)
853 "The same as `put-text-property', but don't put this prop on any newlines in the region." 882 "The same as `put-text-property', but don't put this prop on any newlines in the region."
854 (save-match-data 883 (save-match-data
@@ -987,6 +1016,9 @@ with potentially long computations."
987(defvar rmail-default-rmail-file) 1016(defvar rmail-default-rmail-file)
988(defvar mm-text-coding-system) 1017(defvar mm-text-coding-system)
989 1018
1019(declare-function mm-append-to-file "mm-util"
1020 (start end filename &optional codesys inhibit))
1021
990(defun gnus-output-to-rmail (filename &optional ask) 1022(defun gnus-output-to-rmail (filename &optional ask)
991 "Append the current article to an Rmail file named FILENAME." 1023 "Append the current article to an Rmail file named FILENAME."
992 (require 'rmail) 1024 (require 'rmail)
@@ -1199,6 +1231,9 @@ Return the modified alist."
1199 (throw 'found nil))) 1231 (throw 'found nil)))
1200 t)) 1232 t))
1201 1233
1234;; gnus.el requires mm-util.
1235(declare-function mm-disable-multibyte "mm-util")
1236
1202(defun gnus-write-active-file (file hashtb &optional full-names) 1237(defun gnus-write-active-file (file hashtb &optional full-names)
1203 ;; `coding-system-for-write' should be `raw-text' or equivalent. 1238 ;; `coding-system-for-write' should be `raw-text' or equivalent.
1204 (let ((coding-system-for-write nnmail-active-file-coding-system)) 1239 (let ((coding-system-for-write nnmail-active-file-coding-system))
@@ -1266,6 +1301,9 @@ Return the modified alist."
1266 (pop l2)) 1301 (pop l2))
1267 l1)))) 1302 l1))))
1268 1303
1304(declare-function gnus-add-text-properties "gnus"
1305 (start end properties &optional object))
1306
1269(defun gnus-add-text-properties-when 1307(defun gnus-add-text-properties-when
1270 (property value start end properties &optional object) 1308 (property value start end properties &optional object)
1271 "Like `gnus-add-text-properties', only applied on where PROPERTY is VALUE." 1309 "Like `gnus-add-text-properties', only applied on where PROPERTY is VALUE."
@@ -1515,6 +1553,8 @@ CHOICE is a list of the choice char and help message at IDX."
1515 (kill-buffer buf)) 1553 (kill-buffer buf))
1516 tchar)) 1554 tchar))
1517 1555
1556(declare-function w32-focus-frame "../term/w32-win" (frame))
1557
1518(defun gnus-select-frame-set-input-focus (frame) 1558(defun gnus-select-frame-set-input-focus (frame)
1519 "Select FRAME, raise it, and set input focus, if possible." 1559 "Select FRAME, raise it, and set input focus, if possible."
1520 (cond ((featurep 'xemacs) 1560 (cond ((featurep 'xemacs)
diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el
index 3a045c2c234..82a423ba3eb 100644
--- a/lisp/gnus/gnus-uu.el
+++ b/lisp/gnus/gnus-uu.el
@@ -1051,7 +1051,7 @@ When called interactively, prompt for REGEXP."
1051 (unless state 1051 (unless state
1052 (push 'middle state)) 1052 (push 'middle state))
1053 (mm-with-unibyte-buffer 1053 (mm-with-unibyte-buffer
1054 (insert-buffer gnus-original-article-buffer) 1054 (insert-buffer-substring gnus-original-article-buffer)
1055 (yenc-decode-region (point-min) (point-max)) 1055 (yenc-decode-region (point-min) (point-max))
1056 (when (and (member 'begin state) 1056 (when (and (member 'begin state)
1057 (file-exists-p gnus-uu-yenc-article-name)) 1057 (file-exists-p gnus-uu-yenc-article-name))
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index bd96e52d65f..fc76fce86d7 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -30,6 +30,10 @@
30 30
31(eval '(run-hooks 'gnus-load-hook)) 31(eval '(run-hooks 'gnus-load-hook))
32 32
33;; For Emacs < 22.2.
34(eval-and-compile
35 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
36
33(eval-when-compile (require 'cl)) 37(eval-when-compile (require 'cl))
34(require 'wid-edit) 38(require 'wid-edit)
35(require 'mm-util) 39(require 'mm-util)
@@ -3736,6 +3740,8 @@ server is native)."
3736 "Return the prefix of the current group name." 3740 "Return the prefix of the current group name."
3737 (< 0 (length (gnus-group-real-prefix group)))) 3741 (< 0 (length (gnus-group-real-prefix group))))
3738 3742
3743(declare-function gnus-group-decoded-name "gnus-group" (string))
3744
3739(defun gnus-summary-buffer-name (group) 3745(defun gnus-summary-buffer-name (group)
3740 "Return the summary buffer name of GROUP." 3746 "Return the summary buffer name of GROUP."
3741 (concat "*Summary " (gnus-group-decoded-name group) "*")) 3747 (concat "*Summary " (gnus-group-decoded-name group) "*"))
diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el
index 39595b767ad..a3721430819 100644
--- a/lisp/gnus/mail-source.el
+++ b/lisp/gnus/mail-source.el
@@ -27,6 +27,10 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33
30(require 'format-spec) 34(require 'format-spec)
31(eval-when-compile 35(eval-when-compile
32 (require 'cl) 36 (require 'cl)
@@ -997,9 +1001,14 @@ This only works when `display-time' is enabled."
997 (autoload 'imap-range-to-message-set "imap") 1001 (autoload 'imap-range-to-message-set "imap")
998 (autoload 'nnheader-ms-strip-cr "nnheader")) 1002 (autoload 'nnheader-ms-strip-cr "nnheader"))
999 1003
1004(autoload 'gnus-compress-sequence "gnus-range")
1005
1000(defvar mail-source-imap-file-coding-system 'binary 1006(defvar mail-source-imap-file-coding-system 'binary
1001 "Coding system for the crashbox made by `mail-source-fetch-imap'.") 1007 "Coding system for the crashbox made by `mail-source-fetch-imap'.")
1002 1008
1009;; Autoloads will bring in imap before this is called.
1010(declare-function imap-capability "imap" (&optional identifier buffer))
1011
1003(defun mail-source-fetch-imap (source callback) 1012(defun mail-source-fetch-imap (source callback)
1004 "Fetcher for imap sources." 1013 "Fetcher for imap sources."
1005 (mail-source-bind (imap source) 1014 (mail-source-bind (imap source)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 3aaa8c25745..4fba4fd630e 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -31,9 +31,11 @@
31 31
32;;; Code: 32;;; Code:
33 33
34(eval-and-compile
35 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
34(eval-when-compile 36(eval-when-compile
35 (require 'cl)) 37 (require 'cl))
36 38
37(require 'hashcash) 39(require 'hashcash)
38(require 'canlock) 40(require 'canlock)
39(require 'mailheader) 41(require 'mailheader)
@@ -2469,6 +2471,8 @@ Point is left at the beginning of the narrowed-to region."
2469 (kill-region start (point)))) 2471 (kill-region start (point))))
2470 2472
2471 2473
2474(autoload 'Info-goto-node "info")
2475
2472(defun message-info (&optional arg) 2476(defun message-info (&optional arg)
2473 "Display the Message manual. 2477 "Display the Message manual.
2474 2478
@@ -3696,6 +3700,8 @@ This function uses `mail-citation-hook' if that is non-nil."
3696 3700
3697(defvar gnus-extract-address-components) 3701(defvar gnus-extract-address-components)
3698 3702
3703(autoload 'format-spec "format-spec")
3704
3699(defun message-insert-formatted-citation-line (&optional from date) 3705(defun message-insert-formatted-citation-line (&optional from date)
3700 "Function that inserts a formatted citation line. 3706 "Function that inserts a formatted citation line.
3701 3707
@@ -7474,6 +7480,8 @@ If nil, the function bound in `text-mode-map' or `global-map' is executed."
7474 :type '(choice (const nil) 7480 :type '(choice (const nil)
7475 function)) 7481 function))
7476 7482
7483(declare-function mail-abbrev-in-expansion-header-p "mailabbrev" ())
7484
7477(defun message-tab () 7485(defun message-tab ()
7478 "Complete names according to `message-completion-alist'. 7486 "Complete names according to `message-completion-alist'.
7479Execute function specified by `message-tab-body-function' when not in 7487Execute function specified by `message-tab-body-function' when not in
diff --git a/lisp/gnus/mm-bodies.el b/lisp/gnus/mm-bodies.el
index 0560c51ba41..758925b5c8b 100644
--- a/lisp/gnus/mm-bodies.el
+++ b/lisp/gnus/mm-bodies.el
@@ -26,6 +26,10 @@
26 26
27;;; Code: 27;;; Code:
28 28
29;; For Emacs < 22.2.
30(eval-and-compile
31 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
32
29(require 'mm-util) 33(require 'mm-util)
30(require 'rfc2047) 34(require 'rfc2047)
31(require 'mm-encode) 35(require 'mm-encode)
@@ -67,6 +71,9 @@ Valid encodings are `7bit', `8bit', `quoted-printable' and `base64'."
67 (const base64)))) 71 (const base64))))
68 :group 'mime) 72 :group 'mime)
69 73
74(autoload 'message-options-get "message")
75(declare-function message-options-set "message" (symbol value))
76
70(defun mm-encode-body (&optional charset) 77(defun mm-encode-body (&optional charset)
71 "Encode a body. 78 "Encode a body.
72Should be called narrowed to the body that is to be encoded. 79Should be called narrowed to the body that is to be encoded.
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 71ef9bcdf55..e2c23d9db5a 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -26,9 +26,14 @@
26 26
27;;; Code: 27;;; Code:
28 28
29;; For Emacs < 22.2.
30(eval-and-compile
31 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
32
29(require 'mail-parse) 33(require 'mail-parse)
30(require 'mailcap) 34(require 'mailcap)
31(require 'mm-bodies) 35(require 'mm-bodies)
36(require 'gnus-util)
32(eval-when-compile (require 'cl) 37(eval-when-compile (require 'cl)
33 (require 'term)) 38 (require 'term))
34 39
@@ -733,6 +738,8 @@ external if displayed external."
733 (mm-display-external 738 (mm-display-external
734 handle 'mailcap-save-binary-file))))))))) 739 handle 'mailcap-save-binary-file)))))))))
735 740
741(declare-function gnus-configure-windows "gnus-win" (setting &optional force))
742
736(defun mm-display-external (handle method) 743(defun mm-display-external (handle method)
737 "Display HANDLE using METHOD." 744 "Display HANDLE using METHOD."
738 (let ((outbuf (current-buffer))) 745 (let ((outbuf (current-buffer)))
@@ -990,7 +997,8 @@ external if displayed external."
990 (cond 997 (cond
991 ;; Internally displayed part. 998 ;; Internally displayed part.
992 ((mm-annotationp object) 999 ((mm-annotationp object)
993 (delete-annotation object)) 1000 (if (featurep 'xemacs)
1001 (delete-annotation object)))
994 ((or (functionp object) 1002 ((or (functionp object)
995 (and (listp object) 1003 (and (listp object)
996 (eq (car object) 'lambda))) 1004 (eq (car object) 'lambda)))
@@ -1231,9 +1239,39 @@ PROMPT overrides the default one used to ask user for a file name."
1231 (mm-save-part-to-file handle file) 1239 (mm-save-part-to-file handle file)
1232 file)))) 1240 file))))
1233 1241
1242(defun mm-add-meta-html-tag (handle &optional charset)
1243 "Add meta html tag to specify CHARSET of HANDLE in the current buffer.
1244CHARSET defaults to the one HANDLE specifies. Existing meta tag that
1245specifies charset will not be modified. Return t if meta tag is added
1246or replaced."
1247 (when (equal (mm-handle-media-type handle) "text/html")
1248 (when (or charset
1249 (setq charset (mail-content-type-get (mm-handle-type handle)
1250 'charset)))
1251 (setq charset (format "\
1252<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">" charset))
1253 (let ((case-fold-search t))
1254 (goto-char (point-min))
1255 (if (re-search-forward "\
1256<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']\
1257text/\\(\\sw+\\)\\(?:\;\\s-*charset=\\(.+?\\)\\)?[\"'][^>]*>" nil t)
1258 (if (and (match-beginning 2)
1259 (string-match "\\`html\\'" (match-string 1)))
1260 ;; Don't modify existing meta tag.
1261 nil
1262 ;; Replace it with the one specifying charset.
1263 (replace-match charset)
1264 t)
1265 (if (re-search-forward "<head>\\s-*" nil t)
1266 (insert charset "\n")
1267 (re-search-forward "<html\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
1268 (insert "<head>\n" charset "\n</head>\n"))
1269 t)))))
1270
1234(defun mm-save-part-to-file (handle file) 1271(defun mm-save-part-to-file (handle file)
1235 (mm-with-unibyte-buffer 1272 (mm-with-unibyte-buffer
1236 (mm-insert-part handle) 1273 (mm-insert-part handle)
1274 (mm-add-meta-html-tag handle)
1237 (let ((current-file-modes (default-file-modes))) 1275 (let ((current-file-modes (default-file-modes)))
1238 (set-default-file-modes mm-attachment-file-modes) 1276 (set-default-file-modes mm-attachment-file-modes)
1239 (unwind-protect 1277 (unwind-protect
@@ -1250,6 +1288,7 @@ PROMPT overrides the default one used to ask user for a file name."
1250 (read-string "Shell command on MIME part: " mm-last-shell-command))) 1288 (read-string "Shell command on MIME part: " mm-last-shell-command)))
1251 (mm-with-unibyte-buffer 1289 (mm-with-unibyte-buffer
1252 (mm-insert-part handle) 1290 (mm-insert-part handle)
1291 (mm-add-meta-html-tag handle)
1253 (let ((coding-system-for-write 'binary)) 1292 (let ((coding-system-for-write 'binary))
1254 (shell-command-on-region (point-min) (point-max) command nil))))) 1293 (shell-command-on-region (point-min) (point-max) command nil)))))
1255 1294
@@ -1490,6 +1529,8 @@ If RECURSIVE, search recursively."
1490 (put-text-property 0 (length (car handle)) parameter value 1529 (put-text-property 0 (length (car handle)) parameter value
1491 (car handle)))) 1530 (car handle))))
1492 1531
1532(autoload 'mm-view-pkcs7 "mm-view")
1533
1493(defun mm-possibly-verify-or-decrypt (parts ctl) 1534(defun mm-possibly-verify-or-decrypt (parts ctl)
1494 (let ((type (car ctl)) 1535 (let ((type (car ctl))
1495 (subtype (cadr (split-string (car ctl) "/"))) 1536 (subtype (cadr (split-string (car ctl) "/")))
diff --git a/lisp/gnus/mm-extern.el b/lisp/gnus/mm-extern.el
index 14e4c77dbed..784ea8c9297 100644
--- a/lisp/gnus/mm-extern.el
+++ b/lisp/gnus/mm-extern.el
@@ -27,6 +27,10 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33
30(eval-when-compile (require 'cl)) 34(eval-when-compile (require 'cl))
31 35
32(require 'mm-util) 36(require 'mm-util)
@@ -90,6 +94,8 @@
90 (let (mm-extern-anonymous) 94 (let (mm-extern-anonymous)
91 (mm-extern-anon-ftp handle))) 95 (mm-extern-anon-ftp handle)))
92 96
97(declare-function message-goto-body "message" (&optional interactivep))
98
93(defun mm-extern-mail-server (handle) 99(defun mm-extern-mail-server (handle)
94 (require 'message) 100 (require 'message)
95 (let* ((params (cdr (mm-handle-type handle))) 101 (let* ((params (cdr (mm-handle-type handle)))
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index edb7521dbf3..e6e5ea95d18 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -26,6 +26,10 @@
26 26
27;;; Code: 27;;; Code:
28 28
29;; For Emacs < 22.2.
30(eval-and-compile
31 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
32
29(eval-when-compile (require 'cl)) 33(eval-when-compile (require 'cl))
30(require 'mail-prsvr) 34(require 'mail-prsvr)
31 35
@@ -913,6 +917,8 @@ But this is very much a corner case, so don't worry about it."
913 (when (featurep 'xemacs) 917 (when (featurep 'xemacs)
914 `(and (featurep 'mule) (mm-xemacs-find-mime-charset-1 ,begin ,end)))) 918 `(and (featurep 'mule) (mm-xemacs-find-mime-charset-1 ,begin ,end))))
915 919
920(declare-function mm-delete-duplicates "mm-util" (list))
921
916(defun mm-find-mime-charset-region (b e &optional hack-charsets) 922(defun mm-find-mime-charset-region (b e &optional hack-charsets)
917 "Return the MIME charsets needed to encode the region between B and E. 923 "Return the MIME charsets needed to encode the region between B and E.
918nil means ASCII, a single-element list represents an appropriate MIME 924nil means ASCII, a single-element list represents an appropriate MIME
@@ -1145,6 +1151,8 @@ If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'."
1145 inhibit-file-name-handlers))) 1151 inhibit-file-name-handlers)))
1146 (write-region start end filename append visit lockname))) 1152 (write-region start end filename append visit lockname)))
1147 1153
1154(autoload 'gmm-write-region "gmm-utils")
1155
1148;; It is not a MIME function, but some MIME functions use it. 1156;; It is not a MIME function, but some MIME functions use it.
1149(if (and (fboundp 'make-temp-file) 1157(if (and (fboundp 'make-temp-file)
1150 (ignore-errors 1158 (ignore-errors
@@ -1236,6 +1244,8 @@ If SUFFIX is non-nil, add that at the end of the file name."
1236 (if (eq (point) end) 'ascii (mm-guess-charset)) 1244 (if (eq (point) end) 'ascii (mm-guess-charset))
1237 (goto-char point))))) 1245 (goto-char point)))))
1238 1246
1247(declare-function mm-detect-coding-region "mm-util" (start end))
1248
1239(if (fboundp 'coding-system-get) 1249(if (fboundp 'coding-system-get)
1240 (defun mm-detect-mime-charset-region (start end) 1250 (defun mm-detect-mime-charset-region (start end)
1241 "Detect MIME charset of the text in the region between START and END." 1251 "Detect MIME charset of the text in the region between START and END."
diff --git a/lisp/gnus/mm-uu.el b/lisp/gnus/mm-uu.el
index 52d47b728ef..610f53002c6 100644
--- a/lisp/gnus/mm-uu.el
+++ b/lisp/gnus/mm-uu.el
@@ -427,6 +427,8 @@ apply the face `mm-uu-extract'."
427 (list mm-dissect-disposition 427 (list mm-dissect-disposition
428 (cons 'filename file-name))))) 428 (cons 'filename file-name)))))
429 429
430(defvar gnus-original-article-buffer) ; gnus.el
431
430(defun mm-uu-yenc-extract () 432(defun mm-uu-yenc-extract ()
431 ;; This might not be exactly correct, but we sure can't get the 433 ;; This might not be exactly correct, but we sure can't get the
432 ;; binary data from the article buffer, since that's already in a 434 ;; binary data from the article buffer, since that's already in a
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index cb4f42dabcf..04e72dffa27 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -24,7 +24,8 @@
24;;; Commentary: 24;;; Commentary:
25 25
26;;; Code: 26;;; Code:
27 27(eval-and-compile
28 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
28(eval-when-compile (require 'cl)) 29(eval-when-compile (require 'cl))
29(require 'mail-parse) 30(require 'mail-parse)
30(require 'mailcap) 31(require 'mailcap)
@@ -117,6 +118,11 @@
117 (defalias 'mm-inline-image 'mm-inline-image-xemacs) 118 (defalias 'mm-inline-image 'mm-inline-image-xemacs)
118 (defalias 'mm-inline-image 'mm-inline-image-emacs))) 119 (defalias 'mm-inline-image 'mm-inline-image-emacs)))
119 120
121;; External.
122(declare-function w3-do-setup "ext:w3" ())
123(declare-function w3-region "ext:w3-display" (st nd))
124(declare-function w3-prepare-buffer "ext:w3-display" (&rest args))
125
120(defvar mm-w3-setup nil) 126(defvar mm-w3-setup nil)
121(defun mm-setup-w3 () 127(defun mm-setup-w3 ()
122 (unless mm-w3-setup 128 (unless mm-w3-setup
@@ -201,6 +207,10 @@
201(defvar mm-w3m-setup nil 207(defvar mm-w3m-setup nil
202 "Whether gnus-article-mode has been setup to use emacs-w3m.") 208 "Whether gnus-article-mode has been setup to use emacs-w3m.")
203 209
210;; External.
211(declare-function w3m-detect-meta-charset "ext:w3m" ())
212(declare-function w3m-region "ext:w3m" (start end &optional url charset))
213
204(defun mm-setup-w3m () 214(defun mm-setup-w3m ()
205 "Setup gnus-article-mode to use emacs-w3m." 215 "Setup gnus-article-mode to use emacs-w3m."
206 (unless mm-w3m-setup 216 (unless mm-w3m-setup
diff --git a/lisp/gnus/mml-smime.el b/lisp/gnus/mml-smime.el
index 07dc1ab4ccb..cbd70cb2adb 100644
--- a/lisp/gnus/mml-smime.el
+++ b/lisp/gnus/mml-smime.el
@@ -27,6 +27,10 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33
30(eval-when-compile (require 'cl)) 34(eval-when-compile (require 'cl))
31 35
32(require 'smime) 36(require 'smime)
@@ -216,6 +220,8 @@ Whether the passphrase is cached at all is controlled by
216 (quit)) 220 (quit))
217 result)) 221 result))
218 222
223(autoload 'gnus-completing-read-with-default "gnus-util")
224
219(defun mml-smime-openssl-encrypt-query () 225(defun mml-smime-openssl-encrypt-query ()
220 ;; todo: try dns/ldap automatically first, before prompting user 226 ;; todo: try dns/ldap automatically first, before prompting user
221 (let (certs done) 227 (let (certs done)
@@ -346,6 +352,10 @@ Whether the passphrase is cached at all is controlled by
346 (cons key-id mml-smime-epg-secret-key-id-list)) 352 (cons key-id mml-smime-epg-secret-key-id-list))
347 (copy-sequence passphrase))))) 353 (copy-sequence passphrase)))))
348 354
355(declare-function epg-key-sub-key-list "ext:epg" (key))
356(declare-function epg-sub-key-capability "ext:epg" (sub-key))
357(declare-function epg-sub-key-validity "ext:epg" (sub-key))
358
349(defun mml-smime-epg-find-usable-key (keys usage) 359(defun mml-smime-epg-find-usable-key (keys usage)
350 (catch 'found 360 (catch 'found
351 (while keys 361 (while keys
@@ -358,6 +368,12 @@ Whether the passphrase is cached at all is controlled by
358 (setq pointer (cdr pointer)))) 368 (setq pointer (cdr pointer))))
359 (setq keys (cdr keys))))) 369 (setq keys (cdr keys)))))
360 370
371(autoload 'mml-compute-boundary "mml")
372
373;; We require mm-decode, which requires mm-bodies, which autoloads
374;; message-options-get (!).
375(declare-function message-options-set "message" (symbol value))
376
361(defun mml-smime-epg-sign (cont) 377(defun mml-smime-epg-sign (cont)
362 (let* ((inhibit-redisplay t) 378 (let* ((inhibit-redisplay t)
363 (context (epg-make-context 'CMS)) 379 (context (epg-make-context 'CMS))
diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el
index c5b7796ffaf..14dc90940cd 100644
--- a/lisp/gnus/mml.el
+++ b/lisp/gnus/mml.el
@@ -25,6 +25,10 @@
25 25
26;;; Code: 26;;; Code:
27 27
28;; For Emacs < 22.2.
29(eval-and-compile
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
31
28(require 'mm-util) 32(require 'mm-util)
29(require 'mm-bodies) 33(require 'mm-bodies)
30(require 'mm-encode) 34(require 'mm-encode)
@@ -1315,6 +1319,12 @@ Should be adopted if code in `message-send-mail' is changed."
1315 1319
1316(defvar mml-preview-buffer nil) 1320(defvar mml-preview-buffer nil)
1317 1321
1322(autoload 'gnus-make-hashtable "gnus-util")
1323(autoload 'widget-button-press "wid-edit" nil t)
1324(declare-function widget-event-point "wid-edit" (event))
1325;; If gnus-buffer-configuration is bound this is loaded.
1326(declare-function gnus-configure-windows "gnus-win" (setting &optional force))
1327
1318(defun mml-preview (&optional raw) 1328(defun mml-preview (&optional raw)
1319 "Display current buffer with Gnus, in a new buffer. 1329 "Display current buffer with Gnus, in a new buffer.
1320If RAW, display a raw encoded MIME message. 1330If RAW, display a raw encoded MIME message.
diff --git a/lisp/gnus/mml1991.el b/lisp/gnus/mml1991.el
index be9981676e6..44efe6da668 100644
--- a/lisp/gnus/mml1991.el
+++ b/lisp/gnus/mml1991.el
@@ -28,6 +28,10 @@
28 28
29;;; Code: 29;;; Code:
30 30
31;; For Emacs < 22.2.
32(eval-and-compile
33 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
34
31(eval-when-compile 35(eval-when-compile
32 (require 'cl) 36 (require 'cl)
33 (require 'mm-util)) 37 (require 'mm-util))
@@ -39,6 +43,11 @@
39(autoload 'quoted-printable-decode-region "qp") 43(autoload 'quoted-printable-decode-region "qp")
40(autoload 'quoted-printable-encode-region "qp") 44(autoload 'quoted-printable-encode-region "qp")
41 45
46(autoload 'mm-decode-content-transfer-encoding "mm-bodies")
47(autoload 'mm-encode-content-transfer-encoding "mm-bodies")
48(autoload 'message-options-get "message")
49(autoload 'message-options-set "message")
50
42(defvar mml1991-use mml2015-use 51(defvar mml1991-use mml2015-use
43 "The package used for PGP.") 52 "The package used for PGP.")
44 53
@@ -111,6 +120,9 @@ Whether the passphrase is cached at all is controlled by
111 (insert-buffer-substring signature) 120 (insert-buffer-substring signature)
112 (goto-char (point-max))))) 121 (goto-char (point-max)))))
113 122
123(declare-function mc-encrypt-generic "ext:mc-toplev"
124 (&optional recipients scheme start end from sign))
125
114(defun mml1991-mailcrypt-encrypt (cont &optional sign) 126(defun mml1991-mailcrypt-encrypt (cont &optional sign)
115 (let ((text (current-buffer)) 127 (let ((text (current-buffer))
116 (mc-pgp-always-sign 128 (mc-pgp-always-sign
@@ -161,6 +173,13 @@ Whether the passphrase is cached at all is controlled by
161(eval-and-compile 173(eval-and-compile
162 (autoload 'gpg-sign-cleartext "gpg")) 174 (autoload 'gpg-sign-cleartext "gpg"))
163 175
176(declare-function gpg-sign-encrypt "ext:gpg"
177 (plaintext ciphertext result recipients &optional
178 passphrase sign-with-key armor textmode))
179(declare-function gpg-encrypt "ext:gpg"
180 (plaintext ciphertext result recipients &optional
181 passphrase armor textmode))
182
164(defun mml1991-gpg-sign (cont) 183(defun mml1991-gpg-sign (cont)
165 (let ((text (current-buffer)) 184 (let ((text (current-buffer))
166 headers signature 185 headers signature
diff --git a/lisp/gnus/mml2015.el b/lisp/gnus/mml2015.el
index 28d1929399e..95d119282ae 100644
--- a/lisp/gnus/mml2015.el
+++ b/lisp/gnus/mml2015.el
@@ -30,6 +30,10 @@
30 30
31;;; Code: 31;;; Code:
32 32
33;; For Emacs < 22.2.
34(eval-and-compile
35 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
36
33(eval-when-compile (require 'cl)) 37(eval-when-compile (require 'cl))
34(require 'mm-decode) 38(require 'mm-decode)
35(require 'mm-util) 39(require 'mm-util)
@@ -38,6 +42,10 @@
38 42
39(defvar mc-pgp-always-sign) 43(defvar mc-pgp-always-sign)
40 44
45(declare-function epg-check-configuration "ext:epg-config"
46 (config &optional minimum-version))
47(declare-function epg-configuration "ext:epg-config" ())
48
41(defvar mml2015-use (or 49(defvar mml2015-use (or
42 (condition-case nil 50 (condition-case nil
43 (progn 51 (progn
@@ -396,6 +404,10 @@ Whether the passphrase is cached at all is controlled by
396 (insert (format "--%s--\n" boundary)) 404 (insert (format "--%s--\n" boundary))
397 (goto-char (point-max)))) 405 (goto-char (point-max))))
398 406
407;; We require mm-decode, which requires mm-bodies, which autoloads
408;; message-options-get (!).
409(declare-function message-options-set "message" (symbol value))
410
399(defun mml2015-mailcrypt-encrypt (cont &optional sign) 411(defun mml2015-mailcrypt-encrypt (cont &optional sign)
400 (let ((mc-pgp-always-sign 412 (let ((mc-pgp-always-sign
401 (or mc-pgp-always-sign 413 (or mc-pgp-always-sign
@@ -1329,6 +1341,9 @@ If no one is selected, default secret key is used. "
1329 1341
1330;;; General wrapper 1342;;; General wrapper
1331 1343
1344(autoload 'gnus-buffer-live-p "gnus-util")
1345(autoload 'gnus-get-buffer-create "gnus")
1346
1332(defun mml2015-clean-buffer () 1347(defun mml2015-clean-buffer ()
1333 (if (gnus-buffer-live-p mml2015-result-buffer) 1348 (if (gnus-buffer-live-p mml2015-result-buffer)
1334 (with-current-buffer mml2015-result-buffer 1349 (with-current-buffer mml2015-result-buffer
diff --git a/lisp/gnus/nndb.el b/lisp/gnus/nndb.el
index 70d395ba986..9e1bd3623dc 100644
--- a/lisp/gnus/nndb.el
+++ b/lisp/gnus/nndb.el
@@ -48,6 +48,12 @@
48;; * make the backend TOUCH an article when marked as expireable (will 48;; * make the backend TOUCH an article when marked as expireable (will
49;; make article expire 'expiry' days after that moment). 49;; make article expire 'expiry' days after that moment).
50 50
51;;; Code:
52
53;; For Emacs < 22.2.
54(eval-and-compile
55 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
56
51;;- 57;;-
52;; Register nndb with known select methods. 58;; Register nndb with known select methods.
53 59
@@ -55,8 +61,6 @@
55(unless (assoc "nndb" gnus-valid-select-methods) 61(unless (assoc "nndb" gnus-valid-select-methods)
56 (gnus-declare-backend "nndb" 'mail 'respool 'address 'prompt-address)) 62 (gnus-declare-backend "nndb" 'mail 'respool 'address 'prompt-address))
57 63
58;;; Code:
59
60(require 'nnmail) 64(require 'nnmail)
61(require 'nnheader) 65(require 'nnheader)
62(require 'nntp) 66(require 'nntp)
@@ -240,6 +244,9 @@ expiry mechanism."
240 (nndb-request-expire-articles-remote articles group server force) 244 (nndb-request-expire-articles-remote articles group server force)
241 (nndb-request-expire-articles-local articles group server force))) 245 (nndb-request-expire-articles-local articles group server force)))
242 246
247;; _Something_ defines it...
248(declare-function nndb-request-article "nndb" t t)
249
243(deffoo nndb-request-move-article 250(deffoo nndb-request-move-article
244 (article group server accept-form &optional last move-is-internal) 251 (article group server accept-form &optional last move-is-internal)
245 "Move ARTICLE (a number) from GROUP on SERVER. 252 "Move ARTICLE (a number) from GROUP on SERVER.
diff --git a/lisp/gnus/nnfolder.el b/lisp/gnus/nnfolder.el
index bf82791fea6..8dc28a3eaf6 100644
--- a/lisp/gnus/nnfolder.el
+++ b/lisp/gnus/nnfolder.el
@@ -31,6 +31,10 @@
31 31
32;;; Code: 32;;; Code:
33 33
34;; For Emacs < 22.2.
35(eval-and-compile
36 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
37
34(require 'nnheader) 38(require 'nnheader)
35(require 'message) 39(require 'message)
36(require 'nnmail) 40(require 'nnmail)
@@ -429,6 +433,10 @@ the group. Then the marks file will be regenerated properly by Gnus.")
429 ;; The article numbers are increasing, so this result is sorted. 433 ;; The article numbers are increasing, so this result is sorted.
430 (nreverse numbers))))) 434 (nreverse numbers)))))
431 435
436(autoload 'gnus-request-group "gnus-int")
437(declare-function gnus-request-create-group "gnus-int"
438 (group &optional gnus-command-method args))
439
432(deffoo nnfolder-request-expire-articles (articles newsgroup 440(deffoo nnfolder-request-expire-articles (articles newsgroup
433 &optional server force) 441 &optional server force)
434 (nnfolder-possibly-change-group newsgroup server) 442 (nnfolder-possibly-change-group newsgroup server)
diff --git a/lisp/gnus/nnheader.el b/lisp/gnus/nnheader.el
index 11cb4bff55c..79783f535c3 100644
--- a/lisp/gnus/nnheader.el
+++ b/lisp/gnus/nnheader.el
@@ -251,6 +251,8 @@ on your system, you could say something like:
251 (skip-chars-forward " \t") 251 (skip-chars-forward " \t")
252 (buffer-substring (point) (point-at-eol))) 252 (buffer-substring (point) (point-at-eol)))
253 253
254(autoload 'ietf-drums-unfold-fws "ietf-drums")
255
254(defun nnheader-parse-naked-head (&optional number) 256(defun nnheader-parse-naked-head (&optional number)
255 ;; This function unfolds continuation lines in this buffer 257 ;; This function unfolds continuation lines in this buffer
256 ;; destructively. When this side effect is unwanted, use 258 ;; destructively. When this side effect is unwanted, use
diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el
index e05c286b1ab..06e6db5f792 100644
--- a/lisp/gnus/nnmail.el
+++ b/lisp/gnus/nnmail.el
@@ -27,6 +27,10 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33
30(eval-when-compile (require 'cl)) 34(eval-when-compile (require 'cl))
31 35
32(require 'gnus) ; for macro gnus-kill-buffer, at least 36(require 'gnus) ; for macro gnus-kill-buffer, at least
@@ -35,6 +39,7 @@
35(require 'gnus-util) 39(require 'gnus-util)
36(require 'mail-source) 40(require 'mail-source)
37(require 'mm-util) 41(require 'mm-util)
42(require 'gnus-int)
38 43
39(eval-and-compile 44(eval-and-compile
40 (autoload 'gnus-add-buffer "gnus") 45 (autoload 'gnus-add-buffer "gnus")
@@ -1315,6 +1320,9 @@ Eudora has a broken References line, but an OK In-Reply-To."
1315 1320
1316;;; Utility functions 1321;;; Utility functions
1317 1322
1323(declare-function gnus-activate-group "gnus-start"
1324 (group &optional scan dont-check method))
1325
1318(defun nnmail-do-request-post (accept-func &optional server) 1326(defun nnmail-do-request-post (accept-func &optional server)
1319 "Utility function to directly post a message to an nnmail-derived group. 1327 "Utility function to directly post a message to an nnmail-derived group.
1320Calls ACCEPT-FUNC (which should be `nnchoke-request-accept-article') 1328Calls ACCEPT-FUNC (which should be `nnchoke-request-accept-article')
@@ -1854,6 +1862,8 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
1854 ;; Compare the time with the current time. 1862 ;; Compare the time with the current time.
1855 (ignore-errors (time-less-p days (time-since time)))))))) 1863 (ignore-errors (time-less-p days (time-since time))))))))
1856 1864
1865(declare-function gnus-group-mark-article-read "gnus-group" (group article))
1866
1857(defun nnmail-expiry-target-group (target group) 1867(defun nnmail-expiry-target-group (target group)
1858 ;; Do not invoke this from nntp-server-buffer! At least nnfolder clears 1868 ;; Do not invoke this from nntp-server-buffer! At least nnfolder clears
1859 ;; that buffer if the nnfolder group isn't selected. 1869 ;; that buffer if the nnfolder group isn't selected.
diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el
index e7674168484..05c19c27ee1 100644
--- a/lisp/gnus/nnmaildir.el
+++ b/lisp/gnus/nnmaildir.el
@@ -61,6 +61,10 @@
61 ) 61 )
62] 62]
63 63
64;; For Emacs < 22.2.
65(eval-and-compile
66 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
67
64(eval-and-compile 68(eval-and-compile
65 (require 'nnheader) 69 (require 'nnheader)
66 (require 'gnus) 70 (require 'gnus)
@@ -884,7 +888,9 @@ by nnmaildir-request-article.")
884 pgname (nnmaildir--pgname nnmaildir--cur-server pgname) 888 pgname (nnmaildir--pgname nnmaildir--cur-server pgname)
885 group (symbol-value group) 889 group (symbol-value group)
886 ro (nnmaildir--param pgname 'read-only)) 890 ro (nnmaildir--param pgname 'read-only))
887 (insert (nnmaildir--grp-name group) " ") 891 (insert (gnus-replace-in-string
892 (nnmaildir--grp-name group) " " "\\ " t)
893 " ")
888 (princ (nnmaildir--group-maxnum nnmaildir--cur-server group) 894 (princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
889 nntp-server-buffer) 895 nntp-server-buffer)
890 (insert " ") 896 (insert " ")
@@ -911,14 +917,17 @@ by nnmaildir-request-article.")
911 (insert " ") 917 (insert " ")
912 (princ (nnmaildir--group-maxnum nnmaildir--cur-server group) 918 (princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
913 nntp-server-buffer) 919 nntp-server-buffer)
914 (insert " " gname "\n"))))) 920 (insert " "
921 (gnus-replace-in-string gname " " "\\ " t)
922 "\n")))))
915 'group) 923 'group)
916 924
917(defun nnmaildir-request-update-info (gname info &optional server) 925(defun nnmaildir-request-update-info (gname info &optional server)
918 (let ((group (nnmaildir--prepare server gname)) 926 (let ((group (nnmaildir--prepare server gname))
919 pgname flist always-marks never-marks old-marks dotfile num dir 927 pgname flist always-marks never-marks old-marks dotfile num dir
920 markdirs marks mark ranges markdir article read end new-marks ls 928 markdirs marks mark ranges markdir article read end new-marks ls
921 old-mmth new-mmth mtime mark-sym existing missing deactivate-mark) 929 old-mmth new-mmth mtime mark-sym existing missing deactivate-mark
930 article-list)
922 (catch 'return 931 (catch 'return
923 (unless group 932 (unless group
924 (setf (nnmaildir--srv-error nnmaildir--cur-server) 933 (setf (nnmaildir--srv-error nnmaildir--cur-server)
@@ -966,12 +975,13 @@ by nnmaildir-request-article.")
966 (setq ranges (assq mark-sym old-marks)) 975 (setq ranges (assq mark-sym old-marks))
967 (if ranges (setq ranges (cdr ranges))) 976 (if ranges (setq ranges (cdr ranges)))
968 (throw 'got-ranges nil)) 977 (throw 'got-ranges nil))
978 (setq article-list nil)
969 (dolist (prefix (funcall ls markdir nil "\\`[^.]" 'nosort)) 979 (dolist (prefix (funcall ls markdir nil "\\`[^.]" 'nosort))
970 (setq article (nnmaildir--flist-art flist prefix)) 980 (setq article (nnmaildir--flist-art flist prefix))
971 (if article 981 (if article
972 (setq ranges 982 (setq article-list
973 (gnus-add-to-range ranges 983 (cons (nnmaildir--art-num article) article-list))))
974 `(,(nnmaildir--art-num article))))))) 984 (setq ranges (gnus-add-to-range ranges (sort article-list '<))))
975 (if (eq mark-sym 'read) (setq read ranges) 985 (if (eq mark-sym 'read) (setq read ranges)
976 (if ranges (setq marks (cons (cons mark-sym ranges) marks))))) 986 (if ranges (setq marks (cons (cons mark-sym ranges) marks)))))
977 (gnus-info-set-read info (gnus-range-add read missing)) 987 (gnus-info-set-read info (gnus-range-add read missing))
@@ -999,7 +1009,7 @@ by nnmaildir-request-article.")
999 (insert " ") 1009 (insert " ")
1000 (princ (nnmaildir--group-maxnum nnmaildir--cur-server group) 1010 (princ (nnmaildir--group-maxnum nnmaildir--cur-server group)
1001 nntp-server-buffer) 1011 nntp-server-buffer)
1002 (insert " " gname "\n") 1012 (insert " " (gnus-replace-in-string gname " " "\\ " t) "\n")
1003 t)))) 1013 t))))
1004 1014
1005(defun nnmaildir-request-create-group (gname &optional server args) 1015(defun nnmaildir-request-create-group (gname &optional server args)
@@ -1161,7 +1171,7 @@ by nnmaildir-request-article.")
1161 (insert "\t" (nnmaildir--nov-get-beg nov) "\t" 1171 (insert "\t" (nnmaildir--nov-get-beg nov) "\t"
1162 (nnmaildir--art-msgid article) "\t" 1172 (nnmaildir--art-msgid article) "\t"
1163 (nnmaildir--nov-get-mid nov) "\tXref: nnmaildir " 1173 (nnmaildir--nov-get-mid nov) "\tXref: nnmaildir "
1164 gname ":") 1174 (gnus-replace-in-string gname " " "\\ " t) ":")
1165 (princ num nntp-server-buffer) 1175 (princ num nntp-server-buffer)
1166 (insert "\t" (nnmaildir--nov-get-end nov) "\n")))) 1176 (insert "\t" (nnmaildir--nov-get-end nov) "\n"))))
1167 (catch 'return 1177 (catch 'return
@@ -1433,6 +1443,8 @@ by nnmaildir-request-article.")
1433(defun nnmaildir-active-number (gname) 1443(defun nnmaildir-active-number (gname)
1434 0) 1444 0)
1435 1445
1446(declare-function gnus-group-mark-article-read "gnus-group" (group article))
1447
1436(defun nnmaildir-request-expire-articles (ranges &optional gname server force) 1448(defun nnmaildir-request-expire-articles (ranges &optional gname server force)
1437 (let ((no-force (not force)) 1449 (let ((no-force (not force))
1438 (group (nnmaildir--prepare server gname)) 1450 (group (nnmaildir--prepare server gname))
diff --git a/lisp/gnus/nnrss.el b/lisp/gnus/nnrss.el
index f72166b0455..4a02690a3c5 100644
--- a/lisp/gnus/nnrss.el
+++ b/lisp/gnus/nnrss.el
@@ -27,6 +27,10 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33
30(eval-when-compile (require 'cl)) 34(eval-when-compile (require 'cl))
31 35
32(require 'gnus) 36(require 'gnus)
@@ -418,6 +422,8 @@ otherwise return nil."
418 nnrss-compatible-encoding-alist))))) 422 nnrss-compatible-encoding-alist)))))
419 (mm-coding-system-p 'utf-8))) 423 (mm-coding-system-p 'utf-8)))
420 424
425(declare-function w3-parse-buffer "ext:w3-parse" (&optional buff))
426
421(defun nnrss-fetch (url &optional local) 427(defun nnrss-fetch (url &optional local)
422 "Fetch URL and put it in a the expected Lisp structure." 428 "Fetch URL and put it in a the expected Lisp structure."
423 (mm-with-unibyte-buffer 429 (mm-with-unibyte-buffer
@@ -784,6 +790,8 @@ which RSS 2.0 allows."
784 (push (list group nnrss-group-max) nnrss-server-data))) 790 (push (list group nnrss-group-max) nnrss-server-data)))
785 (nnrss-save-server-data server)))) 791 (nnrss-save-server-data server))))
786 792
793(declare-function gnus-group-make-rss-group "gnus-group" (&optional url))
794
787(defun nnrss-opml-import (opml-file) 795(defun nnrss-opml-import (opml-file)
788 "OPML subscriptions import. 796 "OPML subscriptions import.
789Read the file and attempt to subscribe to each Feed in the file." 797Read the file and attempt to subscribe to each Feed in the file."
diff --git a/lisp/gnus/pop3.el b/lisp/gnus/pop3.el
index d152c2480ad..a48e8bc6cfe 100644
--- a/lisp/gnus/pop3.el
+++ b/lisp/gnus/pop3.el
@@ -314,7 +314,7 @@ Return the response string if optional second argument is non-nil."
314 (setq match-end (point)) 314 (setq match-end (point))
315 (goto-char pop3-read-point) 315 (goto-char pop3-read-point)
316 (if (looking-at "-ERR") 316 (if (looking-at "-ERR")
317 (error (buffer-substring (point) (- match-end 2))) 317 (error "%s" (buffer-substring (point) (- match-end 2)))
318 (if (not (looking-at "+OK")) 318 (if (not (looking-at "+OK"))
319 (progn (setq pop3-read-point match-end) nil) 319 (progn (setq pop3-read-point match-end) nil)
320 (setq pop3-read-point match-end) 320 (setq pop3-read-point match-end)
diff --git a/lisp/gnus/rfc1843.el b/lisp/gnus/rfc1843.el
index f27825b6d74..4820184d21a 100644
--- a/lisp/gnus/rfc1843.el
+++ b/lisp/gnus/rfc1843.el
@@ -34,6 +34,10 @@
34 34
35;;; Code: 35;;; Code:
36 36
37;; For Emacs < 22.2.
38(eval-and-compile
39 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
40
37(eval-when-compile (require 'cl)) 41(eval-when-compile (require 'cl))
38(require 'mm-util) 42(require 'mm-util)
39 43
@@ -139,6 +143,10 @@ ftp://ftp.math.psu.edu/pub/simpson/chinese/hzp/hzp.doc"
139 (aset s (incf i) (+ v (if (< v 63) 64 98)))))) 143 (aset s (incf i) (+ v (if (< v 63) 64 98))))))
140 s)) 144 s))
141 145
146(autoload 'mail-header-parse-content-type "mail-parse")
147(autoload 'message-narrow-to-head "message")
148(declare-function message-fetch-field "message" (header &optional not-all))
149
142(defun rfc1843-decode-article-body () 150(defun rfc1843-decode-article-body ()
143 "Decode HZ encoded text in the article body." 151 "Decode HZ encoded text in the article body."
144 (if (string-match (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") 152 (if (string-match (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>")
diff --git a/lisp/gnus/sieve-manage.el b/lisp/gnus/sieve-manage.el
index 5cf14f7eb32..a4b763650c8 100644
--- a/lisp/gnus/sieve-manage.el
+++ b/lisp/gnus/sieve-manage.el
@@ -76,6 +76,9 @@
76 76
77;;; Code: 77;;; Code:
78 78
79;; For Emacs < 22.2.
80(eval-and-compile
81 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
79(or (require 'password-cache nil t) 82(or (require 'password-cache nil t)
80 (require 'password)) 83 (require 'password))
81(eval-when-compile 84(eval-when-compile
@@ -193,6 +196,10 @@ Valid states are `closed', `initial', `nonauth', and `auth'.")
193 (when (fboundp 'set-buffer-multibyte) 196 (when (fboundp 'set-buffer-multibyte)
194 (set-buffer-multibyte nil))) 197 (set-buffer-multibyte nil)))
195 198
199(declare-function password-read "password-cache" (prompt &optional key))
200(declare-function password-cache-add "password-cache" (key password))
201(declare-function password-cache-remove "password-cache" (key))
202
196;; Uses the dynamically bound `reason' variable. 203;; Uses the dynamically bound `reason' variable.
197(defvar reason) 204(defvar reason)
198(defun sieve-manage-interactive-login (buffer loginfunc) 205(defun sieve-manage-interactive-login (buffer loginfunc)
diff --git a/lisp/gnus/smime.el b/lisp/gnus/smime.el
index 31545c16044..105cadff081 100644
--- a/lisp/gnus/smime.el
+++ b/lisp/gnus/smime.el
@@ -121,6 +121,9 @@
121 121
122;;; Code: 122;;; Code:
123 123
124;; For Emacs < 22.2.
125(eval-and-compile
126 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
124(require 'dig) 127(require 'dig)
125(or (require 'password-cache nil t) 128(or (require 'password-cache nil t)
126 (require 'password)) 129 (require 'password))
@@ -257,6 +260,7 @@ must be set in `ldap-host-parameters-alist'."
257 temporary-file-directory)))))) 260 temporary-file-directory))))))
258 261
259;; Password dialog function 262;; Password dialog function
263(declare-function password-read-and-add "password-cache" (prompt &optional key))
260 264
261(defun smime-ask-passphrase (&optional cache-key) 265(defun smime-ask-passphrase (&optional cache-key)
262 "Asks the passphrase to unlock the secret key. 266 "Asks the passphrase to unlock the secret key.
@@ -654,6 +658,8 @@ A string or a list of strings is returned."
654 (define-key smime-mode-map "q" 'smime-exit) 658 (define-key smime-mode-map "q" 'smime-exit)
655 (define-key smime-mode-map "f" 'smime-certificate-info)) 659 (define-key smime-mode-map "f" 'smime-certificate-info))
656 660
661(autoload 'gnus-run-mode-hooks "gnus-util")
662
657(defun smime-mode () 663(defun smime-mode ()
658 "Major mode for browsing, viewing and fetching certificates. 664 "Major mode for browsing, viewing and fetching certificates.
659 665
diff --git a/lisp/gnus/spam-stat.el b/lisp/gnus/spam-stat.el
index 5b57f376cf8..bba1c2a70e8 100644
--- a/lisp/gnus/spam-stat.el
+++ b/lisp/gnus/spam-stat.el
@@ -377,6 +377,8 @@ Use `spam-stat-ngood', `spam-stat-nbad', `spam-stat-good',
377 (spam-stat-buffer-words)) 377 (spam-stat-buffer-words))
378 (setq spam-stat-dirty t)) 378 (setq spam-stat-dirty t))
379 379
380(autoload 'gnus-message "gnus-util")
381
380(defun spam-stat-buffer-change-to-spam () 382(defun spam-stat-buffer-change-to-spam ()
381 "Consider current buffer no longer normal mail but spam." 383 "Consider current buffer no longer normal mail but spam."
382 (setq spam-stat-nbad (1+ spam-stat-nbad) 384 (setq spam-stat-nbad (1+ spam-stat-nbad)
diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el
index fddebb1d290..f2c18e71d0c 100644
--- a/lisp/gnus/spam.el
+++ b/lisp/gnus/spam.el
@@ -40,16 +40,20 @@
40 40
41;;{{{ compilation directives and autoloads/requires 41;;{{{ compilation directives and autoloads/requires
42 42
43;; For Emacs < 22.2.
44(eval-and-compile
45 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
46
43(eval-when-compile (require 'cl)) 47(eval-when-compile (require 'cl))
44(eval-when-compile (require 'spam-report))
45(eval-when-compile (require 'hashcash))
46 48
49(require 'message) ;for the message-fetch-field functions
47(require 'gnus-sum) 50(require 'gnus-sum)
48
49(require 'gnus-uu) ; because of key prefix issues 51(require 'gnus-uu) ; because of key prefix issues
50;;; for the definitions of group content classification and spam processors 52;;; for the definitions of group content classification and spam processors
51(require 'gnus) 53(require 'gnus)
52(require 'message) ;for the message-fetch-field functions 54
55(eval-when-compile (require 'spam-report))
56(eval-when-compile (require 'hashcash))
53 57
54;; for nnimap-split-download-body-default 58;; for nnimap-split-download-body-default
55(eval-when-compile (require 'nnimap)) 59(eval-when-compile (require 'nnimap))
@@ -2066,6 +2070,9 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
2066 (autoload 'bbdb-create-internal "bbdb") 2070 (autoload 'bbdb-create-internal "bbdb")
2067 (autoload 'bbdb-search-simple "bbdb")) 2071 (autoload 'bbdb-search-simple "bbdb"))
2068 2072
2073;; Autoloaded in message, which we require.
2074(declare-function gnus-extract-address-components "gnus-util" (from))
2075
2069(eval-and-compile 2076(eval-and-compile
2070 (when (condition-case nil 2077 (when (condition-case nil
2071 (progn 2078 (progn
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 5aa8860ae9d..a8350bf0445 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -252,7 +252,8 @@ face (according to `face-differs-from-default-p')."
252 252
253;;;###autoload 253;;;###autoload
254(defun describe-function-1 (function) 254(defun describe-function-1 (function)
255 (let* ((advised (and (featurep 'advice) (ad-get-advice-info function))) 255 (let* ((advised (and (symbolp function) (featurep 'advice)
256 (ad-get-advice-info function)))
256 ;; If the function is advised, use the symbol that has the 257 ;; If the function is advised, use the symbol that has the
257 ;; real definition, if that symbol is already set up. 258 ;; real definition, if that symbol is already set up.
258 (real-function 259 (real-function
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index b09a3e26979..aa436a96971 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -1392,7 +1392,7 @@ If point is on a group name, this function operates on that group."
1392 (when must-be-live 1392 (when must-be-live
1393 (if (bufferp buf) 1393 (if (bufferp buf)
1394 (unless (buffer-live-p buf) 1394 (unless (buffer-live-p buf)
1395 (error (substitute-command-keys "Buffer %s has been killed; use `\\[ibuffer-update]' to update") buf)) 1395 (error "Buffer %s has been killed; %s" buf (substitute-command-keys "use `\\[ibuffer-update]' to update")))
1396 (error "No buffer on this line"))) 1396 (error "No buffer on this line")))
1397 buf)) 1397 buf))
1398 1398
diff --git a/lisp/indent.el b/lisp/indent.el
index 30ba4ec2b88..225395dcc80 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -454,6 +454,7 @@ See also `indent-relative-maybe'."
454This should be a list of integers, ordered from smallest to largest." 454This should be a list of integers, ordered from smallest to largest."
455 :group 'indent 455 :group 'indent
456 :type '(repeat integer)) 456 :type '(repeat integer))
457(put 'tab-stop-list 'safe-local-variable 'listp)
457 458
458(defvar edit-tab-stops-map 459(defvar edit-tab-stops-map
459 (let ((map (make-sparse-keymap))) 460 (let ((map (make-sparse-keymap)))
diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el
index 9daa00410c3..4d15f05f936 100644
--- a/lisp/international/ja-dic-cnv.el
+++ b/lisp/international/ja-dic-cnv.el
@@ -559,7 +559,7 @@ To get complete usage, invoke:
559 (while l 559 (while l
560 (setq count (1+ count)) 560 (setq count (1+ count))
561 (if (= (% count 10000) 0) 561 (if (= (% count 10000) 0)
562 (message (format "%d entries" count))) 562 (message "%d entries" count))
563 (setq entry (skkdic-extract-conversion-data (car l))) 563 (setq entry (skkdic-extract-conversion-data (car l)))
564 (set-nested-alist (car entry) (cdr entry) map) 564 (set-nested-alist (car entry) (cdr entry) map)
565 (setq l (cdr l))) 565 (setq l (cdr l)))
diff --git a/lisp/international/latexenc.el b/lisp/international/latexenc.el
index 57013b59538..cc52eb4cbdf 100644
--- a/lisp/international/latexenc.el
+++ b/lisp/international/latexenc.el
@@ -181,7 +181,8 @@ coding system names is determined from `latex-inputenc-coding-alist'."
181 (find-file-noselect latexenc-main-file t))) 181 (find-file-noselect latexenc-main-file t)))
182 (coding-system-base ;Disregard the EOL part of the CS. 182 (coding-system-base ;Disregard the EOL part of the CS.
183 (with-current-buffer latexenc-main-buffer 183 (with-current-buffer latexenc-main-buffer
184 (or coding-system-for-write buffer-file-coding-system)))) 184 (or coding-system-for-write buffer-file-coding-system
185 'undecided))))
185 'undecided)))) 186 'undecided))))
186 'undecided)) 187 'undecided))
187 188
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 22fa28e70ef..6920345576c 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -96,7 +96,8 @@ that the search has reached."
96That is, upper and lower case chars must match exactly. 96That is, upper and lower case chars must match exactly.
97This applies no matter where the chars come from, but does not 97This applies no matter where the chars come from, but does not
98apply to chars in regexps that are prefixed with `\\'. 98apply to chars in regexps that are prefixed with `\\'.
99If this value is `not-yanks', yanked text is always downcased." 99If this value is `not-yanks', text yanked into the search string
100in Isearch mode is always downcased."
100 :type '(choice (const :tag "off" nil) 101 :type '(choice (const :tag "off" nil)
101 (const not-yanks) 102 (const not-yanks)
102 (other :tag "on" t)) 103 (other :tag "on" t))
@@ -407,6 +408,7 @@ A value of nil means highlight all matches."
407 408
408 (define-key map [?\M-%] 'isearch-query-replace) 409 (define-key map [?\M-%] 'isearch-query-replace)
409 (define-key map [?\C-\M-%] 'isearch-query-replace-regexp) 410 (define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
411 (define-key map "\M-so" 'isearch-occur)
410 412
411 map) 413 map)
412 "Keymap for `isearch-mode'.") 414 "Keymap for `isearch-mode'.")
@@ -1226,11 +1228,14 @@ Use `isearch-exit' to quit without signaling."
1226 (isearch-update)) 1228 (isearch-update))
1227 1229
1228(defun isearch-query-replace (&optional regexp-flag) 1230(defun isearch-query-replace (&optional regexp-flag)
1229 "Start query-replace with string to replace from last search string." 1231 "Start `query-replace' with string to replace from last search string."
1230 (interactive) 1232 (interactive)
1231 (barf-if-buffer-read-only) 1233 (barf-if-buffer-read-only)
1232 (if regexp-flag (setq isearch-regexp t)) 1234 (if regexp-flag (setq isearch-regexp t))
1233 (let ((case-fold-search isearch-case-fold-search)) 1235 (let ((case-fold-search isearch-case-fold-search)
1236 ;; set `search-upper-case' to nil to not call
1237 ;; `isearch-no-upper-case-p' in `perform-replace'
1238 (search-upper-case nil))
1234 (isearch-done) 1239 (isearch-done)
1235 (isearch-clean-overlays) 1240 (isearch-clean-overlays)
1236 (if (and isearch-other-end 1241 (if (and isearch-other-end
@@ -1252,10 +1257,24 @@ Use `isearch-exit' to quit without signaling."
1252 (if (and transient-mark-mode mark-active) (region-end))))) 1257 (if (and transient-mark-mode mark-active) (region-end)))))
1253 1258
1254(defun isearch-query-replace-regexp () 1259(defun isearch-query-replace-regexp ()
1255 "Start query-replace-regexp with string to replace from last search string." 1260 "Start `query-replace-regexp' with string to replace from last search string."
1256 (interactive) 1261 (interactive)
1257 (isearch-query-replace t)) 1262 (isearch-query-replace t))
1258 1263
1264(defun isearch-occur (regexp &optional nlines)
1265 "Run `occur' with regexp to search from the current search string.
1266Interactively, REGEXP is the current search regexp or a quoted search
1267string. NLINES has the same meaning as in `occur'."
1268 (interactive
1269 (list
1270 (if isearch-regexp isearch-string (regexp-quote isearch-string))
1271 (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
1272 (let ((case-fold-search isearch-case-fold-search)
1273 ;; set `search-upper-case' to nil to not call
1274 ;; `isearch-no-upper-case-p' in `occur-1'
1275 (search-upper-case nil))
1276 (occur regexp nlines)))
1277
1259 1278
1260(defun isearch-delete-char () 1279(defun isearch-delete-char ()
1261 "Discard last input item and move point back. 1280 "Discard last input item and move point back.
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index 096d35bebbd..ebb3a4a419f 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -404,7 +404,7 @@ Optional arg EMPTY is message to print if no macros are defined."
404 (format " [%s]" 404 (format " [%s]"
405 (format kmacro-counter-format-start kmacro-counter))) 405 (format kmacro-counter-format-start kmacro-counter)))
406 (if z (substring m 0 (1- x)) m) (if z "..." ""))) 406 (if z (substring m 0 (1- x)) m) (if z "..." "")))
407 (message (or empty "No keyboard macros defined")))) 407 (message "%s" (or empty "No keyboard macros defined"))))
408 408
409 409
410(defun kmacro-repeat-on-last-key (keys) 410(defun kmacro-repeat-on-last-key (keys)
diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el
index e75387f48ac..ab8611424db 100644
--- a/lisp/mail/feedmail.el
+++ b/lisp/mail/feedmail.el
@@ -1922,7 +1922,7 @@ mapped to mostly alphanumerics for safety."
1922 ;; progn to get nil result no matter what 1922 ;; progn to get nil result no matter what
1923 (progn (make-directory queue-directory t) nil) 1923 (progn (make-directory queue-directory t) nil)
1924 (file-accessible-directory-p queue-directory) 1924 (file-accessible-directory-p queue-directory)
1925 (error (concat "FQM: Message not queued; trouble with directory " queue-directory))) 1925 (error "FQM: Message not queued; trouble with directory %s" queue-directory))
1926 (let ((filename) 1926 (let ((filename)
1927 (is-fqm) 1927 (is-fqm)
1928 (is-in-this-dir) 1928 (is-in-this-dir)
diff --git a/lisp/mail/hashcash.el b/lisp/mail/hashcash.el
index 22005ce957e..36cd17fe6fc 100644
--- a/lisp/mail/hashcash.el
+++ b/lisp/mail/hashcash.el
@@ -49,6 +49,9 @@
49 49
50;;; Code: 50;;; Code:
51 51
52(eval-and-compile
53 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
54
52(defgroup hashcash nil 55(defgroup hashcash nil
53 "Hashcash configuration." 56 "Hashcash configuration."
54 :group 'mail) 57 :group 'mail)
@@ -112,13 +115,15 @@ For example, you may want to set this to '(\"-Z2\") to reduce header length."
112(require 'mail-utils) 115(require 'mail-utils)
113 116
114(eval-and-compile 117(eval-and-compile
115 (if (fboundp 'point-at-bol) 118 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
116 (defalias 'hashcash-point-at-bol 'point-at-bol) 119
117 (defalias 'hashcash-point-at-bol 'line-beginning-position)) 120 (if (fboundp 'point-at-bol)
121 (defalias 'hashcash-point-at-bol 'point-at-bol)
122 (defalias 'hashcash-point-at-bol 'line-beginning-position))
118 123
119 (if (fboundp 'point-at-eol) 124 (if (fboundp 'point-at-eol)
120 (defalias 'hashcash-point-at-eol 'point-at-eol) 125 (defalias 'hashcash-point-at-eol 'point-at-eol)
121 (defalias 'hashcash-point-at-eol 'line-end-position))) 126 (defalias 'hashcash-point-at-eol 'line-end-position)))
122 127
123(defun hashcash-strip-quoted-names (addr) 128(defun hashcash-strip-quoted-names (addr)
124 (setq addr (mail-strip-quoted-names addr)) 129 (setq addr (mail-strip-quoted-names addr))
diff --git a/lisp/mail/reporter.el b/lisp/mail/reporter.el
index 24dd9ab0c35..0777c60a2b9 100644
--- a/lisp/mail/reporter.el
+++ b/lisp/mail/reporter.el
@@ -118,7 +118,7 @@ composed.")
118 "Periodically output a status message." 118 "Periodically output a status message."
119 (if (zerop (% reporter-status-count 10)) 119 (if (zerop (% reporter-status-count 10))
120 (progn 120 (progn
121 (message reporter-status-message) 121 (message "%s" reporter-status-message)
122 (setq reporter-status-message (concat reporter-status-message ".")))) 122 (setq reporter-status-message (concat reporter-status-message "."))))
123 (setq reporter-status-count (1+ reporter-status-count))) 123 (setq reporter-status-count (1+ reporter-status-count)))
124 124
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el
index 1e9f8379b7b..234277320ad 100644
--- a/lisp/mail/rmailout.el
+++ b/lisp/mail/rmailout.el
@@ -380,7 +380,7 @@ The optional fourth argument FROM-GNUS is set when called from GNUS."
380 (rmail-toggle-header)) 380 (rmail-toggle-header))
381 (if (and (> count 0) (not next-message-p)) 381 (if (and (> count 0) (not next-message-p))
382 (progn 382 (progn
383 (error 383 (error "%s"
384 (save-excursion 384 (save-excursion
385 (set-buffer rmailbuf) 385 (set-buffer rmailbuf)
386 (format "Only %d message%s appended" num-appended 386 (format "Only %d message%s appended" num-appended
diff --git a/lisp/mail/uce.el b/lisp/mail/uce.el
index 5a4e01ae9fc..094cb03f861 100644
--- a/lisp/mail/uce.el
+++ b/lisp/mail/uce.el
@@ -239,7 +239,7 @@ address, and postmaster of the mail relay used."
239 (full-header-p (and (eq uce-mail-reader 'rmail) 239 (full-header-p (and (eq uce-mail-reader 'rmail)
240 (not (rmail-msg-is-pruned))))) 240 (not (rmail-msg-is-pruned)))))
241 (or (get-buffer message-buffer) 241 (or (get-buffer message-buffer)
242 (error (concat "No buffer " message-buffer ", cannot find UCE"))) 242 (error "No buffer %s, cannot find UCE" message-buffer))
243 (switch-to-buffer message-buffer) 243 (switch-to-buffer message-buffer)
244 ;; We need the message with headers pruned. 244 ;; We need the message with headers pruned.
245 (if full-header-p 245 (if full-header-p
diff --git a/lisp/makefile.w32-in b/lisp/makefile.w32-in
index 1998dc6d590..ae9a5170140 100644
--- a/lisp/makefile.w32-in
+++ b/lisp/makefile.w32-in
@@ -40,6 +40,12 @@ EMACS = $(THISDIR)/../bin/emacs.exe
40 40
41EMACSOPT = -batch --no-init-file --no-site-file --multibyte 41EMACSOPT = -batch --no-init-file --no-site-file --multibyte
42 42
43# Extra flags to pass to the byte compiler
44BYTE_COMPILE_EXTRA_FLAGS =
45# For example to not display the undefined function warnings you can use this:
46# BYTE_COMPILE_EXTRA_FLAGS = --eval '(setq byte-compile-warnings (quote (not unresolved)))'
47# The example above is just for developers, it should not be used by default.
48
43# Set EMACSLOADPATH correctly (already defined in environment). 49# Set EMACSLOADPATH correctly (already defined in environment).
44EMACSLOADPATH=$(lisp) 50EMACSLOADPATH=$(lisp)
45 51
@@ -201,7 +207,7 @@ TAGS-LISP: $(lisptagsfiles1) $(lisptagsfiles2)
201.SUFFIXES: .elc .el 207.SUFFIXES: .elc .el
202 208
203.el.elc: 209.el.elc:
204 -$(emacs) -f batch-byte-compile $< 210 -$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $<
205 211
206# Compile all Lisp files, but don't recompile those that are up to 212# Compile all Lisp files, but don't recompile those that are up to
207# date. Some files don't actually get compiled because they set the 213# date. Some files don't actually get compiled because they set the
@@ -221,22 +227,22 @@ compile: $(lisp)/subdirs.el mh-autoloads compile-$(SHELLTYPE) doit
221compile-CMD: 227compile-CMD:
222# -for %%f in ($(lisp) $(WINS)) do for %%g in (%%f\*.elc) do @attrib -r %%g 228# -for %%f in ($(lisp) $(WINS)) do for %%g in (%%f\*.elc) do @attrib -r %%g
223 for %%f in ($(COMPILE_FIRST)) do \ 229 for %%f in ($(COMPILE_FIRST)) do \
224 $(emacs) -l loaddefs -f batch-byte-compile-if-not-done %%f 230 $(emacs) -l loaddefs $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile-if-not-done %%f
225 for %%f in (. $(WINS)) do for %%g in (%%f/*.el) do \ 231 for %%f in (. $(WINS)) do for %%g in (%%f/*.el) do \
226 $(emacs) -l loaddefs -f batch-byte-compile-if-not-done %%f/%%g 232 $(emacs) -l loaddefs $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile-if-not-done %%f/%%g
227 233
228compile-SH: 234compile-SH:
229# for elc in $(lisp)/*.elc $(lisp)/*/*.elc; do attrib -r $$elc; done 235# for elc in $(lisp)/*.elc $(lisp)/*/*.elc; do attrib -r $$elc; done
230 for el in $(COMPILE_FIRST); do \ 236 for el in $(COMPILE_FIRST); do \
231 echo Compiling $$el; \ 237 echo Compiling $$el; \
232 $(emacs) -l loaddefs -f batch-byte-compile-if-not-done $$el; \ 238 $(emacs) -l loaddefs $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile-if-not-done $$el; \
233 done 239 done
234 for dir in $(lisp) $(WINS); do \ 240 for dir in $(lisp) $(WINS); do \
235 for el in $$dir/*.el; do \ 241 for el in $$dir/*.el; do \
236 if test -f $$el; \ 242 if test -f $$el; \
237 then \ 243 then \
238 echo Compiling $$el; \ 244 echo Compiling $$el; \
239 $(emacs) -l loaddefs -f batch-byte-compile-if-not-done $$el; \ 245 $(emacs) -l loaddefs $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile-if-not-done $$el; \
240 fi \ 246 fi \
241 done; \ 247 done; \
242 done 248 done
@@ -249,31 +255,31 @@ compile-always: $(lisp)/subdirs.el compile-always-$(SHELLTYPE) doit
249 255
250compile-always-CMD: 256compile-always-CMD:
251# -for %%f in ($(lisp) $(WINS)) do for %%g in (%%f\*.elc) do @attrib -r %%g 257# -for %%f in ($(lisp) $(WINS)) do for %%g in (%%f\*.elc) do @attrib -r %%g
252 for %%f in ($(COMPILE_FIRST)) do $(emacs) -f batch-byte-compile %%f 258 for %%f in ($(COMPILE_FIRST)) do $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile %%f
253 for %%f in (. $(WINS)) do for %%g in (%%f/*.el) do $(emacs) -f batch-byte-compile %%f/%%g 259 for %%f in (. $(WINS)) do for %%g in (%%f/*.el) do $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile %%f/%%g
254 260
255compile-always-SH: 261compile-always-SH:
256# for elc in $(lisp)/*.elc $(lisp)/*/*.elc; do attrib -r $$elc; done 262# for elc in $(lisp)/*.elc $(lisp)/*/*.elc; do attrib -r $$elc; done
257 for el in $(COMPILE_FIRST); do \ 263 for el in $(COMPILE_FIRST); do \
258 echo Compiling $$el; \ 264 echo Compiling $$el; \
259 $(emacs) -f batch-byte-compile $$el || exit 1; \ 265 $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $$el || exit 1; \
260 done 266 done
261 for dir in $(lisp) $(WINS); do \ 267 for dir in $(lisp) $(WINS); do \
262 for el in $$dir/*.el; do \ 268 for el in $$dir/*.el; do \
263 echo Compiling $$el; \ 269 echo Compiling $$el; \
264 $(emacs) -f batch-byte-compile $$el || exit 1; \ 270 $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $$el || exit 1; \
265 done; \ 271 done; \
266 done 272 done
267 273
268compile-calc: compile-calc-$(SHELLTYPE) 274compile-calc: compile-calc-$(SHELLTYPE)
269 275
270compile-calc-CMD: 276compile-calc-CMD:
271 for %%f in ($(lisp)/calc/*.el) do $(emacs) -f batch-byte-compile %%f 277 for %%f in ($(lisp)/calc/*.el) do $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile %%f
272 278
273compile-calc-SH: 279compile-calc-SH:
274 for el in $(lisp)/calc/*.el; do \ 280 for el in $(lisp)/calc/*.el; do \
275 echo Compiling $$el; \ 281 echo Compiling $$el; \
276 $(emacs) -f batch-byte-compile $$el || exit 1; \ 282 $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $$el || exit 1; \
277 done 283 done
278 284
279# Backup compiled Lisp files in elc.tar.gz. If that file already 285# Backup compiled Lisp files in elc.tar.gz. If that file already
@@ -295,6 +301,15 @@ compile-after-backup: backup-compiled-files compile-always
295recompile: mh-autoloads doit $(lisp)/progmodes/cc-mode.elc 301recompile: mh-autoloads doit $(lisp)/progmodes/cc-mode.elc
296 $(emacs) --eval $(ARGQUOTE)(batch-byte-recompile-directory 0)$(ARGQUOTE) $(lisp) 302 $(emacs) --eval $(ARGQUOTE)(batch-byte-recompile-directory 0)$(ARGQUOTE) $(lisp)
297 303
304# CC Mode uses a compile time macro system which causes a compile time
305# dependency in cc-mode.elc on the macros in cc-langs.el and the
306# version string in cc-defs.el.
307$(lisp)/progmodes/cc-mode.elc: \
308 $(lisp)/progmodes/cc-mode.el \
309 $(lisp)/progmodes/cc-langs.el \
310 $(lisp)/progmodes/cc-defs.el
311 $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $(lisp)/progmodes/cc-mode.el
312
298# Update MH-E internal autoloads. These are not to be confused with 313# Update MH-E internal autoloads. These are not to be confused with
299# the autoloads for the MH-E entry points, which are already in 314# the autoloads for the MH-E entry points, which are already in
300# loaddefs.el. 315# loaddefs.el.
@@ -443,6 +458,11 @@ install-lisp-CMD:
443 for %%f in ($(WINS)) do cp -f %%f/*.el "$(INSTALL_DIR)/lisp/%%f" 458 for %%f in ($(WINS)) do cp -f %%f/*.el "$(INSTALL_DIR)/lisp/%%f"
444 for %%f in (. $(WINS)) do cp -f %%f/*.elc "$(INSTALL_DIR)/lisp/%%f" 459 for %%f in (. $(WINS)) do cp -f %%f/*.elc "$(INSTALL_DIR)/lisp/%%f"
445 460
461# WARNING: Do NOT split the part inside $(ARGQUOTE)s into multiple lines as
462# this can break with GNU Make 3.81 and later if sh.exe is used.
463check-declare:
464 $(emacs) -l $(lisp)/emacs-lisp/check-declare --eval $(ARGQUOTE)(check-declare-directory $(DQUOTE)$(lisp)$(DQUOTE))$(ARGQUOTE)
465
446# 466#
447# Maintenance 467# Maintenance
448# 468#
diff --git a/lisp/man.el b/lisp/man.el
index 41f1d37bb18..c3621be1c97 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1077,7 +1077,7 @@ manpage command."
1077 (Man-notify-when-ready Man-buffer)) 1077 (Man-notify-when-ready Man-buffer))
1078 1078
1079 (if err-mess 1079 (if err-mess
1080 (error err-mess)) 1080 (error "%s" err-mess))
1081 )))) 1081 ))))
1082 1082
1083 1083
@@ -1338,7 +1338,7 @@ Returns t if section is found, nil otherwise."
1338Actually the section moved to is described by `Man-see-also-regexp'." 1338Actually the section moved to is described by `Man-see-also-regexp'."
1339 (interactive) 1339 (interactive)
1340 (if (not (Man-find-section Man-see-also-regexp)) 1340 (if (not (Man-find-section Man-see-also-regexp))
1341 (error (concat "No " Man-see-also-regexp 1341 (error "%s" (concat "No " Man-see-also-regexp
1342 " section found in the current manpage")))) 1342 " section found in the current manpage"))))
1343 1343
1344(defun Man-possibly-hyphenated-word () 1344(defun Man-possibly-hyphenated-word ()
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 82d12ccbdd0..39882ca33c0 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1933,7 +1933,7 @@ and selects that window."
1933 (cons 1933 (cons
1934 (cons 1934 (cons
1935 (format 1935 (format
1936 (format "%%%ds %%s%%s %%s" maxlen) 1936 (format "%%-%ds %%s%%s %%s" maxlen)
1937 (buffer-name elt) 1937 (buffer-name elt)
1938 (if (buffer-modified-p elt) "*" " ") 1938 (if (buffer-modified-p elt) "*" " ")
1939 (save-excursion 1939 (save-excursion
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el
index 9221c52a082..83d0f7fa3ec 100644
--- a/lisp/net/dbus.el
+++ b/lisp/net/dbus.el
@@ -49,32 +49,63 @@
49 49
50;;; Hash table of registered functions. 50;;; Hash table of registered functions.
51 51
52(defun dbus-hash-table= (x y) 52;; We create it here. So we have a simple test in dbusbind.c, whether
53 "Compares keys X and Y in the hash table of registered functions for D-Bus. 53;; the Lisp code has been loaded.
54See `dbus-registered-functions-table' for a description of the hash table." 54(setq dbus-registered-functions-table (make-hash-table :test 'equal))
55 (and 55
56 (listp x) (listp y) 56(defun dbus-list-hash-table ()
57 ;; Bus symbol, either :system or :session. 57 "Returns all registered signal registrations to D-Bus.
58 (symbolp (car x)) (symbolp (car y)) (equal (car x) (car y)) 58The return value is a list, with elements of kind (KEY . VALUE).
59 ;; Interface. 59See `dbus-registered-functions-table' for a description of the
60 (or 60hash table."
61 (null (cadr x)) (null (cadr y)) ; wildcard 61 (let (result)
62 (and 62 (maphash
63 (stringp (cadr x)) (stringp (cadr y)) (string-equal (cadr x) (cadr y)))) 63 '(lambda (key value) (add-to-list 'result (cons key value) 'append))
64 ;; Member. 64 dbus-registered-functions-table)
65 (or 65 result))
66 (null (caddr x)) (null (caddr y)) ; wildcard 66
67 (and 67(defun dbus-name-owner-changed-handler (service old-owner new-owner)
68 (stringp (caddr x)) (stringp (caddr y)) 68 "Reapplies all signal registrations to D-Bus.
69 (string-equal (caddr x) (caddr y)))))) 69This handler is applied when a \"NameOwnerChanged\" signal has
70 70arrived. SERVICE is the object name for which the name owner has
71(define-hash-table-test 'dbus-hash-table-test 'dbus-hash-table= 'sxhash) 71been changed. OLD-OWNER is the previous owner of SERVICE, or the
72 72empty string if SERVICE was not owned yet. NEW-OWNER is the new
73;; When we assume that interface and and member are always strings in 73owner of SERVICE, or the empty string if SERVICE looses any name owner."
74;; the key, we could use `equal' as test function. But we want to 74 (save-match-data
75;; have also `nil' there, being a wildcard. 75 ;; Check whether SERVICE is a known name.
76(setq dbus-registered-functions-table 76 (when (and (stringp service) (not (string-match "^:" service))
77 (make-hash-table :test 'dbus-hash-table-test)) 77 (stringp old-owner) (stringp new-owner))
78 (maphash
79 '(lambda (key value)
80 (dolist (elt value)
81 ;; key has the structure (BUS INTERFACE SIGNAL).
82 ;; elt has the structure (SERVICE UNAME PATH HANDLER).
83 (when (string-equal old-owner (cadr elt))
84 ;; Remove old key, and add new entry with changed name.
85 (when dbus-debug (message "Remove rule for %s %s" key elt))
86 ;(dbus-unregister-signal key)
87 (setcar (cdr elt) new-owner)
88 (when dbus-debug (message "Add rule for %s %s" key elt))
89 ;; Maybe we could arrange the lists a little bit better
90 ;; that we don't need to extract every single element?
91 (when (not (zerop (length new-owner)))
92 (dbus-register-signal
93 ;; BUS SERVICE PATH
94 (nth 0 key) (nth 0 elt) (nth 2 elt)
95 ;; INTERFACE SIGNAL HANDLER
96 (nth 1 key) (nth 2 key) (nth 3 elt))))))
97 (copy-hash-table dbus-registered-functions-table)))))
98
99;; Register the handler.
100(condition-case nil
101 (progn
102 (dbus-register-signal
103 :system dbus-service-dbus dbus-path-dbus dbus-interface-dbus
104 "NameOwnerChanged" 'dbus-name-owner-changed-handler)
105 (dbus-register-signal
106 :session dbus-service-dbus dbus-path-dbus dbus-interface-dbus
107 "NameOwnerChanged" 'dbus-name-owner-changed-handler))
108 (dbus-error))
78 109
79 110
80;;; D-Bus events. 111;;; D-Bus events.
@@ -83,33 +114,34 @@ See `dbus-registered-functions-table' for a description of the hash table."
83 "Checks whether EVENT is a well formed D-Bus event. 114 "Checks whether EVENT is a well formed D-Bus event.
84EVENT is a list which starts with symbol `dbus-event': 115EVENT is a list which starts with symbol `dbus-event':
85 116
86 (dbus-event HANDLER BUS SERVICE PATH INTERFACE MEMBER &rest ARGS) 117 (dbus-event BUS SERVICE PATH INTERFACE MEMBER HANDLER &rest ARGS)
87 118
88HANDLER is the function which has been registered for this 119BUS identifies the D-Bus the signal is coming from. It is either
89signal. BUS identifies the D-Bus the signal is coming from. It 120the symbol `:system' or the symbol `:session'. SERVICE and PATH
90is either the symbol `:system' or the symbol `:session'. SERVICE 121are the unique name and the object path of the D-Bus object
91and PATH are the name and the object path of the D-Bus object
92emitting the signal. INTERFACE and MEMBER denote the signal 122emitting the signal. INTERFACE and MEMBER denote the signal
93which has been sent. ARGS are the arguments passed to HANDLER, 123which has been sent. HANDLER is the function which has been
94when it is called during event handling in `dbus-handle-event'. 124registered for this signal. ARGS are the arguments passed to
125HANDLER, when it is called during event handling in
126`dbus-handle-event'.
95 127
96This function raises a `dbus-error' signal in case the event is 128This function raises a `dbus-error' signal in case the event is
97not well formed." 129not well formed."
98 (when dbus-debug (message "DBus-Event %s" event)) 130 (when dbus-debug (message "DBus-Event %s" event))
99 (unless (and (listp event) 131 (unless (and (listp event)
100 (eq (car event) 'dbus-event) 132 (eq (car event) 'dbus-event)
101 ;; Handler.
102 (functionp (nth 1 event))
103 ;; Bus symbol. 133 ;; Bus symbol.
104 (symbolp (nth 2 event)) 134 (symbolp (nth 1 event))
105 ;; Service. 135 ;; Service.
106 (stringp (nth 3 event)) 136 (stringp (nth 2 event))
107 ;; Object path. 137 ;; Object path.
108 (stringp (nth 4 event)) 138 (stringp (nth 3 event))
109 ;; Interface. 139 ;; Interface.
110 (stringp (nth 5 event)) 140 (stringp (nth 4 event))
111 ;; Member. 141 ;; Member.
112 (stringp (nth 6 event))) 142 (stringp (nth 5 event))
143 ;; Handler.
144 (functionp (nth 6 event)))
113 (signal 'dbus-error (list "Not a valid D-Bus event" event)))) 145 (signal 'dbus-error (list "Not a valid D-Bus event" event))))
114 146
115;;;###autoload 147;;;###autoload
@@ -123,7 +155,7 @@ part of the event, is called with arguments ARGS."
123 (condition-case nil 155 (condition-case nil
124 (progn 156 (progn
125 (dbus-check-event event) 157 (dbus-check-event event)
126 (apply (cadr event) (nthcdr 7 event))) 158 (apply (nth 6 event) (nthcdr 7 event)))
127 (dbus-error))) 159 (dbus-error)))
128 160
129(defun dbus-event-bus-name (event) 161(defun dbus-event-bus-name (event)
@@ -133,7 +165,7 @@ EVENT is a D-Bus event, see `dbus-check-event'. This function
133raises a `dbus-error' signal in case the event is not well 165raises a `dbus-error' signal in case the event is not well
134formed." 166formed."
135 (dbus-check-event event) 167 (dbus-check-event event)
136 (nth 2 event)) 168 (nth 1 event))
137 169
138(defun dbus-event-service-name (event) 170(defun dbus-event-service-name (event)
139 "Return the name of the D-Bus object the event is coming from. 171 "Return the name of the D-Bus object the event is coming from.
@@ -141,7 +173,7 @@ The result is a string. EVENT is a D-Bus event, see `dbus-check-event'.
141This function raises a `dbus-error' signal in case the event is 173This function raises a `dbus-error' signal in case the event is
142not well formed." 174not well formed."
143 (dbus-check-event event) 175 (dbus-check-event event)
144 (nth 3 event)) 176 (nth 2 event))
145 177
146(defun dbus-event-path-name (event) 178(defun dbus-event-path-name (event)
147 "Return the object path of the D-Bus object the event is coming from. 179 "Return the object path of the D-Bus object the event is coming from.
@@ -149,7 +181,7 @@ The result is a string. EVENT is a D-Bus event, see `dbus-check-event'.
149This function raises a `dbus-error' signal in case the event is 181This function raises a `dbus-error' signal in case the event is
150not well formed." 182not well formed."
151 (dbus-check-event event) 183 (dbus-check-event event)
152 (nth 4 event)) 184 (nth 3 event))
153 185
154(defun dbus-event-interface-name (event) 186(defun dbus-event-interface-name (event)
155 "Return the interface name of the D-Bus object the event is coming from. 187 "Return the interface name of the D-Bus object the event is coming from.
@@ -157,7 +189,7 @@ The result is a string. EVENT is a D-Bus event, see `dbus-check-event'.
157This function raises a `dbus-error' signal in case the event is 189This function raises a `dbus-error' signal in case the event is
158not well formed." 190not well formed."
159 (dbus-check-event event) 191 (dbus-check-event event)
160 (nth 5 event)) 192 (nth 4 event))
161 193
162(defun dbus-event-member-name (event) 194(defun dbus-event-member-name (event)
163 "Return the member name the event is coming from. 195 "Return the member name the event is coming from.
@@ -166,7 +198,7 @@ string. EVENT is a D-Bus event, see `dbus-check-event'. This
166function raises a `dbus-error' signal in case the event is not 198function raises a `dbus-error' signal in case the event is not
167well formed." 199well formed."
168 (dbus-check-event event) 200 (dbus-check-event event)
169 (nth 6 event)) 201 (nth 5 event))
170 202
171 203
172;;; D-Bus registered names. 204;;; D-Bus registered names.
@@ -177,8 +209,8 @@ The result is a list of strings, which is nil when there are no
177activatable service names at all." 209activatable service names at all."
178 (condition-case nil 210 (condition-case nil
179 (dbus-call-method 211 (dbus-call-method
180 :system "ListActivatableNames" dbus-service-dbus 212 :system dbus-service-dbus
181 dbus-path-dbus dbus-interface-dbus) 213 dbus-path-dbus dbus-interface-dbus "ListActivatableNames")
182 (dbus-error))) 214 (dbus-error)))
183 215
184(defun dbus-list-names (bus) 216(defun dbus-list-names (bus)
@@ -189,7 +221,7 @@ registered service names at all. Well known names are strings like
189for services." 221for services."
190 (condition-case nil 222 (condition-case nil
191 (dbus-call-method 223 (dbus-call-method
192 bus "ListNames" dbus-service-dbus dbus-path-dbus dbus-interface-dbus) 224 bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus "ListNames")
193 (dbus-error))) 225 (dbus-error)))
194 226
195(defun dbus-list-known-names (bus) 227(defun dbus-list-known-names (bus)
@@ -206,8 +238,8 @@ The result is a list of strings, or nil when there are no queued name
206owners service names at all." 238owners service names at all."
207 (condition-case nil 239 (condition-case nil
208 (dbus-call-method 240 (dbus-call-method
209 bus "ListQueuedOwners" dbus-service-dbus 241 bus dbus-service-dbus dbus-path-dbus
210 dbus-path-dbus dbus-interface-dbus service) 242 dbus-interface-dbus "ListQueuedOwners" service)
211 (dbus-error))) 243 (dbus-error)))
212 244
213(defun dbus-get-name-owner (bus service) 245(defun dbus-get-name-owner (bus service)
@@ -215,8 +247,8 @@ owners service names at all."
215The result is either a string, or nil if there is no name owner." 247The result is either a string, or nil if there is no name owner."
216 (condition-case nil 248 (condition-case nil
217 (dbus-call-method 249 (dbus-call-method
218 bus "GetNameOwner" dbus-service-dbus 250 bus dbus-service-dbus dbus-path-dbus
219 dbus-path-dbus dbus-interface-dbus service) 251 dbus-interface-dbus "GetNameOwner" service)
220 (dbus-error))) 252 (dbus-error)))
221 253
222(defun dbus-introspect (bus service path) 254(defun dbus-introspect (bus service path)
@@ -227,10 +259,10 @@ Example:
227 259
228\(dbus-introspect 260\(dbus-introspect
229 :system \"org.freedesktop.Hal\" 261 :system \"org.freedesktop.Hal\"
230 \"/org/freedesktop/Hal/devices/computer\"))" 262 \"/org/freedesktop/Hal/devices/computer\")"
231 (condition-case nil 263 (condition-case nil
232 (dbus-call-method 264 (dbus-call-method
233 bus "Introspect" service path dbus-interface-introspectable) 265 bus service path dbus-interface-introspectable "Introspect")
234 (dbus-error))) 266 (dbus-error)))
235 267
236(if nil ;; Must be reworked. Shall we offer D-Bus signatures at all? 268(if nil ;; Must be reworked. Shall we offer D-Bus signatures at all?
diff --git a/lisp/net/imap.el b/lisp/net/imap.el
index 8e41c68720b..40e41d79de7 100644
--- a/lisp/net/imap.el
+++ b/lisp/net/imap.el
@@ -140,6 +140,7 @@
140 140
141(eval-when-compile (require 'cl)) 141(eval-when-compile (require 'cl))
142(eval-and-compile 142(eval-and-compile
143 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
143 (autoload 'starttls-open-stream "starttls") 144 (autoload 'starttls-open-stream "starttls")
144 (autoload 'starttls-negotiate "starttls") 145 (autoload 'starttls-negotiate "starttls")
145 (autoload 'sasl-find-mechanism "sasl") 146 (autoload 'sasl-find-mechanism "sasl")
@@ -1734,6 +1735,18 @@ is non-nil return these properties."
1734 (concat "UID STORE " articles 1735 (concat "UID STORE " articles
1735 " +FLAGS" (if silent ".SILENT") " (" flags ")")))))) 1736 " +FLAGS" (if silent ".SILENT") " (" flags ")"))))))
1736 1737
1738;; Cf. http://thread.gmane.org/gmane.emacs.gnus.general/65317/focus=65343
1739;; Signal an error if we'd get an integer overflow.
1740;;
1741;; FIXME: Identify relevant calls to `string-to-number' and replace them with
1742;; `imap-string-to-integer'.
1743(defun imap-string-to-integer (string &optional base)
1744 (let ((number (string-to-number string base)))
1745 (if (> number most-positive-fixnum)
1746 (error
1747 (format "String %s cannot be converted to a lisp integer" number))
1748 number)))
1749
1737(defun imap-message-copyuid-1 (mailbox) 1750(defun imap-message-copyuid-1 (mailbox)
1738 (if (imap-capability 'UIDPLUS) 1751 (if (imap-capability 'UIDPLUS)
1739 (list (nth 0 (imap-mailbox-get-1 'copyuid mailbox)) 1752 (list (nth 0 (imap-mailbox-get-1 'copyuid mailbox))
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index ef24de44e50..a1a0e0ca8e9 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -1708,13 +1708,13 @@ With prefix ARG, go to the next low priority buffer with activity."
1708 (recenter -1))) 1708 (recenter -1)))
1709 (if (eq major-mode 'rcirc-mode) 1709 (if (eq major-mode 'rcirc-mode)
1710 (switch-to-buffer (rcirc-non-irc-buffer)) 1710 (switch-to-buffer (rcirc-non-irc-buffer))
1711 (message (concat 1711 (message "%s" (concat
1712 "No IRC activity." 1712 "No IRC activity."
1713 (when lopri 1713 (when lopri
1714 (concat 1714 (concat
1715 " Type C-u " 1715 " Type C-u "
1716 (key-description (this-command-keys)) 1716 (key-description (this-command-keys))
1717 " for low priority activity.")))))))) 1717 " for low priority activity."))))))))
1718 1718
1719(defvar rcirc-activity-hooks nil 1719(defvar rcirc-activity-hooks nil
1720 "Hook to be run when there is channel activity. 1720 "Hook to be run when there is channel activity.
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index 58ae73d8cd3..0639210a1be 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -38,7 +38,7 @@
38 38
39;; Check for (X)Emacs version. 39;; Check for (X)Emacs version.
40(let ((x (if (or (< emacs-major-version 21) (and (featurep 'xemacs) (< emacs-minor-version 4))) (format "Tramp 2.1.12-pre is not fit for %s" (when (string-match "^.*$" (emacs-version)) (match-string 0 (emacs-version)))) "ok"))) 40(let ((x (if (or (< emacs-major-version 21) (and (featurep 'xemacs) (< emacs-minor-version 4))) (format "Tramp 2.1.12-pre is not fit for %s" (when (string-match "^.*$" (emacs-version)) (match-string 0 (emacs-version)))) "ok")))
41 (unless (string-match "\\`ok\\'" x) (error x))) 41 (unless (string-match "\\`ok\\'" x) (error "%s" x)))
42 42
43(provide 'trampver) 43(provide 'trampver)
44 44
diff --git a/lisp/pgg-parse.el b/lisp/pgg-parse.el
index 336c492efde..87bafc08fd4 100644
--- a/lisp/pgg-parse.el
+++ b/lisp/pgg-parse.el
@@ -36,7 +36,9 @@
36 36
37;;; Code: 37;;; Code:
38 38
39(eval-when-compile (require 'cl)) 39(eval-when-compile
40 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
41 (require 'cl))
40 42
41(defgroup pgg-parse () 43(defgroup pgg-parse ()
42 "OpenPGP packet parsing." 44 "OpenPGP packet parsing."
diff --git a/lisp/pgg.el b/lisp/pgg.el
index 6e4a2a874ec..26911974ea6 100644
--- a/lisp/pgg.el
+++ b/lisp/pgg.el
@@ -35,18 +35,17 @@
35 35
36;; Don't merge these two `eval-when-compile's. 36;; Don't merge these two `eval-when-compile's.
37(eval-when-compile 37(eval-when-compile
38 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
38 (require 'cl)) 39 (require 'cl))
39 40
40;;; @ utility functions 41;;; @ utility functions
41;;; 42;;;
42 43
43(eval-when-compile 44(eval-when-compile
44 (unless (featurep 'xemacs) 45 ;; Define it as a null macro for Emacs in order to suppress a byte
45 (defalias 'pgg-run-at-time 'run-at-time) 46 ;; compile warning that Emacs 21 issues.
46 (defalias 'pgg-cancel-timer 'cancel-timer)) 47 (defmacro pgg-run-at-time-1 (time repeat function args)
47 48 (when (featurep 'xemacs)
48 (when (featurep 'xemacs)
49 (defmacro pgg-run-at-time-1 (time repeat function args)
50 (if (condition-case nil 49 (if (condition-case nil
51 (let ((delete-itimer 'delete-itimer) 50 (let ((delete-itimer 'delete-itimer)
52 (itimer-driver-start 'itimer-driver-start) 51 (itimer-driver-start 'itimer-driver-start)
@@ -104,19 +103,23 @@
104 itimer 103 itimer
105 (append (list itimer function) args))))) 104 (append (list itimer function) args)))))
106 1e-9 (if time (max time 1e-9) 1e-9) 105 1e-9 (if time (max time 1e-9) 1e-9)
107 nil t itimers ,repeat ,function ,args)))) 106 nil t itimers ,repeat ,function ,args))))))
108 107
109 (defun pgg-run-at-time (time repeat function &rest args) 108(eval-and-compile
110 "Emulating function run as `run-at-time'. 109 (if (featurep 'xemacs)
110 (progn
111 (defun pgg-run-at-time (time repeat function &rest args)
112 "Emulating function run as `run-at-time'.
111TIME should be nil meaning now, or a number of seconds from now. 113TIME should be nil meaning now, or a number of seconds from now.
112Return an itimer object which can be used in either `delete-itimer' 114Return an itimer object which can be used in either `delete-itimer'
113or `cancel-timer'." 115or `cancel-timer'."
114 (pgg-run-at-time-1 time repeat function args)) 116 (pgg-run-at-time-1 time repeat function args))
115 (defun pgg-cancel-timer (timer) 117 (defun pgg-cancel-timer (timer)
116 "Emulate cancel-timer for xemacs." 118 "Emulate cancel-timer for xemacs."
117 (let ((delete-itimer 'delete-itimer)) 119 (let ((delete-itimer 'delete-itimer))
118 (funcall delete-itimer timer))) 120 (funcall delete-itimer timer))))
119 )) 121 (defalias 'pgg-run-at-time 'run-at-time)
122 (defalias 'pgg-cancel-timer 'cancel-timer)))
120 123
121(defun pgg-invoke (func scheme &rest args) 124(defun pgg-invoke (func scheme &rest args)
122 (progn 125 (progn
diff --git a/lisp/play/mpuz.el b/lisp/play/mpuz.el
index 4cd3bd673ff..8b40b4187c6 100644
--- a/lisp/play/mpuz.el
+++ b/lisp/play/mpuz.el
@@ -489,7 +489,7 @@ You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]."
489 ((< mpuz-nb-errors 10) "bad!") 489 ((< mpuz-nb-errors 10) "bad!")
490 ((< mpuz-nb-errors 15) "awful.") 490 ((< mpuz-nb-errors 15) "awful.")
491 (t "not serious."))))) 491 (t "not serious.")))))
492 (message message) 492 (message "%s" message)
493 (sit-for 4) 493 (sit-for 4)
494 (if (y-or-n-p (concat message " Start a new game? ")) 494 (if (y-or-n-p (concat message " Start a new game? "))
495 (mpuz-start-new-game) 495 (mpuz-start-new-game)
diff --git a/lisp/progmodes/ada-xref.el b/lisp/progmodes/ada-xref.el
index ddea4c293df..00be89553a7 100644
--- a/lisp/progmodes/ada-xref.el
+++ b/lisp/progmodes/ada-xref.el
@@ -564,7 +564,7 @@ Completion is available."
564 (let ((file (ada-find-src-file-in-dir filename))) 564 (let ((file (ada-find-src-file-in-dir filename)))
565 (if file 565 (if file
566 (find-file file) 566 (find-file file)
567 (error (concat filename " not found in src_dir"))))) 567 (error "%s not found in src_dir" filename))))
568 568
569 569
570;; ----- Utilities ------------------------------------------------- 570;; ----- Utilities -------------------------------------------------
@@ -1722,8 +1722,8 @@ Information is extracted from the ali file."
1722 ;; No more idea to find the declaration. Give up 1722 ;; No more idea to find the declaration. Give up
1723 (progn 1723 (progn
1724 (kill-buffer ali-buffer) 1724 (kill-buffer ali-buffer)
1725 (error (concat "No declaration of " (ada-name-of identlist) 1725
1726 " found.")) 1726 (error "No declaration of %s found." (ada-name-of identlist))
1727 ))) 1727 )))
1728 ) 1728 )
1729 1729
@@ -1808,10 +1808,8 @@ This function is disabled for operators, and only works for identifiers."
1808 ;; none => error 1808 ;; none => error
1809 ((= len 0) 1809 ((= len 0)
1810 (kill-buffer (current-buffer)) 1810 (kill-buffer (current-buffer))
1811 (error (concat "No declaration of " 1811 (error "No declaration of %s recorded in .ali file"
1812 (ada-name-of identlist) 1812 (ada-name-of identlist)))
1813 " recorded in .ali file")))
1814
1815 ;; one => should be the right one 1813 ;; one => should be the right one
1816 ((= len 1) 1814 ((= len 1)
1817 (goto-line (caar declist))) 1815 (goto-line (caar declist)))
@@ -2011,7 +2009,7 @@ the declaration and documentation of the subprograms one is using."
2011 (string-to-number (nth 2 (car list))) 2009 (string-to-number (nth 2 (car list)))
2012 identlist 2010 identlist
2013 other-frame) 2011 other-frame)
2014 (error (concat (caar list) " not found in src_dir"))) 2012 (error "%s not found in src_dir" (caar list)))
2015 (message "This is only a (good) guess at the cross-reference.") 2013 (message "This is only a (good) guess at the cross-reference.")
2016 ) 2014 )
2017 2015
diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el
index 9f6e70dcce5..d7e2ff3574e 100644
--- a/lisp/progmodes/antlr-mode.el
+++ b/lisp/progmodes/antlr-mode.el
@@ -1875,7 +1875,7 @@ cell where the two values determine the area inside the braces."
1875 (read initial) 1875 (read initial)
1876 initial)) 1876 initial))
1877 (cdr value)))) 1877 (cdr value))))
1878 (message (cadr value)) 1878 (message "%s" (or (cadr value) ""))
1879 (setq value nil))) 1879 (setq value nil)))
1880 ;; insert value ---------------------------------------------------------- 1880 ;; insert value ----------------------------------------------------------
1881 (if (consp old) 1881 (if (consp old)
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index db052c4b8f5..06c0946290b 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -3864,7 +3864,12 @@ command to conveniently insert and align the necessary backslashes."
3864 (save-excursion 3864 (save-excursion
3865 (goto-char (cdr c-lit-limits)) 3865 (goto-char (cdr c-lit-limits))
3866 (beginning-of-line) 3866 (beginning-of-line)
3867 (and (search-forward-regexp 3867 ;; The following conjunct was added to avoid an
3868 ;; "Invalid search bound (wrong side of point)"
3869 ;; error in the subsequent re-search. Maybe
3870 ;; another fix would be needed (2007-12-08).
3871 (and (> (- (cdr c-lit-limits) 2) (point))
3872 (search-forward-regexp
3868 (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)") 3873 (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
3869 (- (cdr c-lit-limits) 2) t) 3874 (- (cdr c-lit-limits) 2) t)
3870 (not (search-forward-regexp 3875 (not (search-forward-regexp
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el
index 76b0e5a898c..fcfdbc53bb4 100644
--- a/lisp/progmodes/cc-vars.el
+++ b/lisp/progmodes/cc-vars.el
@@ -156,34 +156,45 @@ Useful as last item in a `choice' widget."
156 (setq c-fallback-style (cons (cons name val) c-fallback-style))) 156 (setq c-fallback-style (cons (cons name val) c-fallback-style)))
157 157
158(defmacro defcustom-c-stylevar (name val doc &rest args) 158(defmacro defcustom-c-stylevar (name val doc &rest args)
159 "Defines a style variable." 159 "Define a style variable NAME with VAL and DOC.
160 `(let ((-value- ,val)) 160More precisely, convert the given `:type FOO', mined out of ARGS,
161 (c-set-stylevar-fallback ',name -value-) 161to an aggregate `:type (radio STYLE (PREAMBLE FOO))', append some
162 (custom-declare-variable 162some boilerplate documentation to DOC, arrange for the fallback
163 ',name ''set-from-style 163value of NAME to be VAL, and call `custom-declare-variable' to
164 ,(concat doc " 164do the rest of the work.
165
166STYLE stands for the choice where the value is taken from some
167style setting. PREAMBLE is optionally prepended to FOO; that is,
168if FOO contains :tag or :value, the respective two-element list
169component is ignored."
170 (declare (debug (symbolp form stringp &rest)))
171 (let* ((expanded-doc (concat doc "
165 172
166This is a style variable. Apart from the valid values described 173This is a style variable. Apart from the valid values described
167above, it can be set to the symbol `set-from-style'. In that case, it 174above, it can be set to the symbol `set-from-style'. In that case,
168takes its value from the style system (see `c-default-style' and 175it takes its value from the style system (see `c-default-style' and
169`c-style-alist') when a CC Mode buffer is initialized. Otherwise, 176`c-style-alist') when a CC Mode buffer is initialized. Otherwise,
170the value set here overrides the style system (there is a variable 177the value set here overrides the style system (there is a variable
171`c-old-style-variable-behavior' that changes this, though).") 178`c-old-style-variable-behavior' that changes this, though)."))
172 ,@(plist-put 179 (typ (eval (plist-get args :type)))
173 args ':type 180 (type (if (consp typ) typ (list typ)))
174 `(` (radio 181 (head (car type))
175 (const :tag "Use style settings" 182 (tail (cdr type))
176 set-from-style) 183 (newt (append (unless (plist-get tail :tag)
177 ,(, (let ((type (eval (plist-get args ':type)))) 184 '(:tag "Override style settings"))
178 (unless (consp type) 185 (unless (plist-get tail :value)
179 (setq type (list type))) 186 `(:value ,val))
180 (unless (c-safe (plist-get (cdr type) ':value)) 187 tail))
181 (setcdr type (append '(:value (, -value-)) 188 (aggregate `'(radio
182 (cdr type)))) 189 (const :tag "Use style settings" set-from-style)
183 (unless (c-safe (plist-get (cdr type) ':tag)) 190 ,(cons head newt))))
184 (setcdr type (append '(:tag "Override style settings") 191 (message "aggregate: %S" aggregate)
185 (cdr type)))) 192 `(progn
186 (bq-process type))))))))) 193 (c-set-stylevar-fallback ',name ,val)
194 (custom-declare-variable
195 ',name ''set-from-style
196 ,expanded-doc
197 ,@(plist-put args :type aggregate)))))
187 198
188(defun c-valid-offset (offset) 199(defun c-valid-offset (offset)
189 "Return non-nil if OFFSET is a valid offset for a syntactic symbol. 200 "Return non-nil if OFFSET is a valid offset for a syntactic symbol.
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 4a397a9d012..29376579c1c 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -231,12 +231,18 @@ for constructs with multiline if/unless/while/until/for/foreach condition."
231 :type 'integer 231 :type 'integer
232 :group 'cperl-indentation-details) 232 :group 'cperl-indentation-details)
233 233
234;; Is is not unusual to put both perl-indent-level and 234;; Is is not unusual to put both things like perl-indent-level and
235;; cperl-indent-level in the local variable section of a file. If only 235;; cperl-indent-level in the local variable section of a file. If only
236;; one of perl-mode and cperl-mode is in use, a warning will be issued 236;; one of perl-mode and cperl-mode is in use, a warning will be issued
237;; about the variable. Autoload this here, so that no warning is 237;; about the variable. Autoload these here, so that no warning is
238;; issued when using either perl-mode or cperl-mode. 238;; issued when using either perl-mode or cperl-mode.
239;;;###autoload(put 'cperl-indent-level 'safe-local-variable 'integerp) 239;;;###autoload(put 'cperl-indent-level 'safe-local-variable 'integerp)
240;;;###autoload(put 'cperl-brace-offset 'safe-local-variable 'integerp)
241;;;###autoload(put 'cperl-continued-brace-offset 'safe-local-variable 'integerp)
242;;;###autoload(put 'cperl-label-offset 'safe-local-variable 'integerp)
243;;;###autoload(put 'cperl-continued-statement-offset 'safe-local-variable 'integerp)
244;;;###autoload(put 'cperl-extra-newline-before-brace 'safe-local-variable 'booleanp)
245;;;###autoload(put 'cperl-merge-trailing-else 'safe-local-variable 'booleanp)
240 246
241(defcustom cperl-lineup-step nil 247(defcustom cperl-lineup-step nil
242 "*`cperl-lineup' will always lineup at multiple of this number. 248 "*`cperl-lineup' will always lineup at multiple of this number.
@@ -4581,7 +4587,7 @@ the sections using `cperl-pod-head-face', `cperl-pod-face',
4581 (setq qtag "Can't find })"))) 4587 (setq qtag "Can't find })")))
4582 (progn 4588 (progn
4583 (goto-char (1- e)) 4589 (goto-char (1- e))
4584 (message qtag)) 4590 (message "%s" qtag))
4585 (cperl-postpone-fontification 4591 (cperl-postpone-fontification
4586 (1- tag) (1- (point)) 4592 (1- tag) (1- (point))
4587 'face font-lock-variable-name-face) 4593 'face font-lock-variable-name-face)
diff --git a/lisp/progmodes/ebrowse.el b/lisp/progmodes/ebrowse.el
index 5acbe70a074..3fe83d9ead5 100644
--- a/lisp/progmodes/ebrowse.el
+++ b/lisp/progmodes/ebrowse.el
@@ -896,10 +896,10 @@ this is the first progress message displayed."
896 (let (message-log-max) 896 (let (message-log-max)
897 (when start (setq ebrowse-n-boxes 0)) 897 (when start (setq ebrowse-n-boxes 0))
898 (setq ebrowse-n-boxes (mod (1+ ebrowse-n-boxes) ebrowse-max-boxes)) 898 (setq ebrowse-n-boxes (mod (1+ ebrowse-n-boxes) ebrowse-max-boxes))
899 (message (concat title ": " 899 (message "%s: %s" title
900 (propertize (make-string ebrowse-n-boxes 900 (propertize (make-string ebrowse-n-boxes
901 (if (display-color-p) ?\ ?+)) 901 (if (display-color-p) ?\ ?+))
902 'face 'ebrowse-progress))))) 902 'face 'ebrowse-progress))))
903 903
904 904
905;;; Reading a tree from disk 905;;; Reading a tree from disk
diff --git a/lisp/progmodes/idlw-shell.el b/lisp/progmodes/idlw-shell.el
index eebfd377a7e..1f184ea157d 100644
--- a/lisp/progmodes/idlw-shell.el
+++ b/lisp/progmodes/idlw-shell.el
@@ -1322,7 +1322,7 @@ message, independent of what HIDE is set to."
1322 (if (or (not (setq buf (get-buffer (idlwave-shell-buffer)))) 1322 (if (or (not (setq buf (get-buffer (idlwave-shell-buffer))))
1323 (not (setq proc (get-buffer-process buf)))) 1323 (not (setq proc (get-buffer-process buf))))
1324 (if (not idlwave-shell-automatic-start) 1324 (if (not idlwave-shell-automatic-start)
1325 (error 1325 (error "%s"
1326 (substitute-command-keys 1326 (substitute-command-keys
1327 "You need to first start an IDL shell with \\[idlwave-shell]")) 1327 "You need to first start an IDL shell with \\[idlwave-shell]"))
1328 (idlwave-shell-recenter-shell-window) 1328 (idlwave-shell-recenter-shell-window)
@@ -2375,7 +2375,7 @@ matter what the settings of that variable."
2375 (if (not (idlwave-shell-valid-frame frame)) 2375 (if (not (idlwave-shell-valid-frame frame))
2376 ;; fixme: errors are dangerous in shell filters. but i think i 2376 ;; fixme: errors are dangerous in shell filters. but i think i
2377 ;; have never encountered this one. 2377 ;; have never encountered this one.
2378 (error (concat "invalid frame - unable to access file: " (car frame))) 2378 (error "invalid frame - unable to access file: %s" (car frame))
2379;;; 2379;;;
2380;;; buffer : the buffer to display a line in. 2380;;; buffer : the buffer to display a line in.
2381;;; select-shell: current buffer is the shell. 2381;;; select-shell: current buffer is the shell.
diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el
index 9648494adc4..49e88597665 100644
--- a/lisp/progmodes/idlwave.el
+++ b/lisp/progmodes/idlwave.el
@@ -3799,7 +3799,7 @@ unless the optional second argument NOINDENT is non-nil."
3799 (if (not noindent) 3799 (if (not noindent)
3800 (indent-region beg end nil)) 3800 (indent-region beg end nil))
3801 (if (stringp prompt) 3801 (if (stringp prompt)
3802 (message prompt))))) 3802 (message "%s" prompt)))))
3803 3803
3804(defun idlwave-rw-case (string) 3804(defun idlwave-rw-case (string)
3805 "Make STRING have the case required by `idlwave-reserved-word-upcase'." 3805 "Make STRING have the case required by `idlwave-reserved-word-upcase'."
@@ -7038,7 +7038,7 @@ sort the list before displaying"
7038 (select-window win) 7038 (select-window win)
7039 (eval idlwave-complete-after-success-form)) 7039 (eval idlwave-complete-after-success-form))
7040 (set-window-start cwin (point-min))))) 7040 (set-window-start cwin (point-min)))))
7041 (and message (message message))) 7041 (and message (message "%s" message)))
7042 (select-window win)))) 7042 (select-window win))))
7043 7043
7044(defun idlwave-display-completion-list (list &optional message beg complete) 7044(defun idlwave-display-completion-list (list &optional message beg complete)
@@ -7069,7 +7069,7 @@ sort the list before displaying"
7069 (run-hooks 'idlwave-completion-setup-hook) 7069 (run-hooks 'idlwave-completion-setup-hook)
7070 7070
7071 ;; Display the message 7071 ;; Display the message
7072 (message (or message "Making completion list...done"))) 7072 (message "%s" (or message "Making completion list...done")))
7073 7073
7074(defun idlwave-choose (function &rest args) 7074(defun idlwave-choose (function &rest args)
7075 "Call FUNCTION as a completion chooser and pass ARGS to it." 7075 "Call FUNCTION as a completion chooser and pass ARGS to it."
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index af456f98284..6c91fb1811b 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -402,12 +402,17 @@ The expansion is entirely correct because it uses the C preprocessor."
402 :type 'integer 402 :type 'integer
403 :group 'perl) 403 :group 'perl)
404 404
405;; Is is not unusual to put both perl-indent-level and 405;; Is is not unusual to put both things like perl-indent-level and
406;; cperl-indent-level in the local variable section of a file. If only 406;; cperl-indent-level in the local variable section of a file. If only
407;; one of perl-mode and cperl-mode is in use, a warning will be issued 407;; one of perl-mode and cperl-mode is in use, a warning will be issued
408;; about the variable. Autoload this here, so that no warning is 408;; about the variable. Autoload these here, so that no warning is
409;; issued when using either perl-mode or cperl-mode. 409;; issued when using either perl-mode or cperl-mode.
410;;;###autoload(put 'perl-indent-level 'safe-local-variable 'integerp) 410;;;###autoload(put 'perl-indent-level 'safe-local-variable 'integerp)
411;;;###autoload(put 'perl-continued-statement-offset 'safe-local-variable 'integerp)
412;;;###autoload(put 'perl-continued-brace-offset 'safe-local-variable 'integerp)
413;;;###autoload(put 'perl-brace-offset 'safe-local-variable 'integerp)
414;;;###autoload(put 'perl-brace-imaginary-offset 'safe-local-variable 'integerp)
415;;;###autoload(put 'perl-label-offset 'safe-local-variable 'integerp)
411 416
412(defcustom perl-continued-statement-offset 4 417(defcustom perl-continued-statement-offset 4
413 "*Extra indent for lines not starting new statements." 418 "*Extra indent for lines not starting new statements."
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
new file mode 100644
index 00000000000..2d34d9d599a
--- /dev/null
+++ b/lisp/progmodes/verilog-mode.el
@@ -0,0 +1,10318 @@
1;; verilog-mode.el --- major mode for editing verilog source in Emacs
2
3;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4;; 2005, 2006, 2007 Free Software Foundation, Inc.
5
6;; Author: Michael McNamara (mac@verilog.com)
7;; http://www.verilog.com
8;;
9;; AUTO features, signal, modsig; by: Wilson Snyder
10;; (wsnyder@wsnyder.org)
11;; http://www.veripool.com
12;; Keywords: languages
13
14;; This file is part of GNU Emacs.
15
16;; GNU Emacs is free software; you can redistribute it and/or modify
17;; it under the terms of the GNU General Public License as published by
18;; the Free Software Foundation; either version 3, or (at your option)
19;; any later version.
20
21;; GNU Emacs is distributed in the hope that it will be useful,
22;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;; GNU General Public License for more details.
25
26;; You should have received a copy of the GNU General Public License
27;; along with GNU Emacs; see the file COPYING. If not, write to the
28;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29;; Boston, MA 02110-1301, USA.
30
31;;; Commentary:
32
33;; This mode borrows heavily from the Pascal-mode and the cc-mode of emacs
34
35;; USAGE
36;; =====
37
38;; A major mode for editing Verilog HDL source code. When you have
39;; entered Verilog mode, you may get more info by pressing C-h m. You
40;; may also get online help describing various functions by: C-h f
41;; <Name of function you want described>
42
43;; KNOWN BUGS / BUG REPORTS
44;; =======================
45
46;; Verilog is a rapidly evolving language, and hence this mode is
47;; under continuous development. Hence this is beta code, and likely
48;; has bugs. Please report any and all bugs to me at mac@verilog.com.
49;; Please use verilog-submit-bug-report to submit a report; type C-c
50;; C-b to invoke this and as a result I will have a much easier time
51;; of reproducing the bug you find, and hence fixing it.
52
53;; INSTALLING THE MODE
54;; ===================
55
56;; An older version of this mode may be already installed as a part of
57;; your environment, and one method of updating would be to update
58;; your emacs environment. Sometimes this is difficult for local
59;; political/control reasons, and hence you can always install a
60;; private copy (or even a shared copy) which overrides the system
61;; default.
62
63;; You can get step by step help in installing this file by going to
64;; <http://www.verilog.com/emacs_install.html>
65
66;; The short list of installation instructions are: To set up
67;; automatic verilog mode, put this file in your load path, and put
68;; the following in code (please un comment it first!) in your
69;; .emacs, or in your site's site-load.el
70
71; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
72; (setq auto-mode-alist (cons '("\\.v\\'" . verilog-mode) auto-mode-alist))
73; (setq auto-mode-alist (cons '("\\.dv\\'" . verilog-mode) auto-mode-alist))
74
75;; If you want to customize Verilog mode to fit your needs better,
76;; you may add these lines (the values of the variables presented
77;; here are the defaults). Note also that if you use an emacs that
78;; supports custom, it's probably better to use the custom menu to
79;; edit these.
80;;
81;; Be sure to examine at the help for verilog-auto, and the other
82;; verilog-auto-* functions for some major coding time savers.
83;;
84; ;; User customization for Verilog mode
85; (setq verilog-indent-level 3
86; verilog-indent-level-module 3
87; verilog-indent-level-declaration 3
88; verilog-indent-level-behavioral 3
89; verilog-indent-level-directive 1
90; verilog-case-indent 2
91; verilog-auto-newline t
92; verilog-auto-indent-on-newline t
93; verilog-tab-always-indent t
94; verilog-auto-endcomments t
95; verilog-minimum-comment-distance 40
96; verilog-indent-begin-after-if t
97; verilog-auto-lineup '(all)
98; verilog-highlight-p1800-keywords nil
99; verilog-linter "my_lint_shell_command"
100; )
101
102;;
103
104;;; History:
105;;
106;;
107;;; Code:
108
109;; This variable will always hold the version number of the mode
110(defconst verilog-mode-version "377"
111 "Version of this verilog mode.")
112(defconst verilog-mode-release-date "2007-12-07"
113 "Version of this verilog mode.")
114
115(defun verilog-version ()
116 "Inform caller of the version of this file."
117 (interactive)
118 (message (concat "Using verilog-mode version " verilog-mode-version) ))
119
120;; Insure we have certain packages, and deal with it if we don't
121(eval-when-compile
122 (condition-case nil
123 (require 'imenu)
124 (error nil))
125 (condition-case nil
126 (require 'reporter)
127 (error nil))
128 (condition-case nil
129 (require 'easymenu)
130 (error nil))
131 (condition-case nil
132 (require 'regexp-opt)
133 (error nil))
134 (condition-case nil
135 (load "skeleton") ;; bug in 19.28 through 19.30 skeleton.el, not provided.
136 (error nil))
137 (condition-case nil
138 (require 'vc)
139 (error nil))
140 (condition-case nil
141 (if (fboundp 'when)
142 nil ;; fab
143 (defmacro when (cond &rest body)
144 (list 'if cond (cons 'progn body))))
145 (error nil))
146 (condition-case nil
147 (if (fboundp 'unless)
148 nil ;; fab
149 (defmacro unless (cond &rest body)
150 (cons 'if (cons cond (cons nil body)))))
151 (error nil))
152 (condition-case nil
153 (if (fboundp 'store-match-data)
154 nil ;; fab
155 (defmacro store-match-data (&rest args) nil))
156 (error nil))
157 (if (featurep 'xemacs)
158 (condition-case nil
159 (if (boundp 'current-menubar)
160 nil ;; great
161 (progn
162 (defmacro add-submenu (&rest args) nil))
163 )
164 (error nil)))
165 (condition-case nil
166 (if (fboundp 'zmacs-activate-region)
167 nil ;; great
168 (defmacro zmacs-activate-region (&rest args) nil))
169 (error nil))
170 (condition-case nil
171 (if (fboundp 'char-before)
172 nil ;; great
173 (defmacro char-before (&rest body)
174 (char-after (1- (point)))))
175 (error nil))
176 ;; Requires to define variables that would be "free" warnings
177 (condition-case nil
178 (require 'font-lock)
179 (error nil))
180 (condition-case nil
181 (require 'compile)
182 (error nil))
183 (condition-case nil
184 (require 'custom)
185 (error nil))
186 (condition-case nil
187 (require 'dinotrace)
188 (error nil))
189 (condition-case nil
190 (if (fboundp 'dinotrace-unannotate-all)
191 nil ;; great
192 (defun dinotrace-unannotate-all (&rest args) nil))
193 (error nil))
194 (condition-case nil
195 (if (fboundp 'customize-apropos)
196 nil ;; great
197 (defun customize-apropos (&rest args) nil))
198 (error nil))
199 (condition-case nil
200 (if (fboundp 'match-string-no-properties)
201 nil ;; great
202 (defsubst match-string-no-properties (num &optional string)
203 "Return string of text matched by last search, without text properties.
204NUM specifies which parenthesized expression in the last regexp.
205 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
206Zero means the entire text matched by the whole regexp or whole string.
207STRING should be given if the last search was by `string-match' on STRING."
208 (if (match-beginning num)
209 (if string
210 (let ((result
211 (substring string (match-beginning num) (match-end num))))
212 (set-text-properties 0 (length result) nil result)
213 result)
214 (buffer-substring-no-properties (match-beginning num)
215 (match-end num)
216 (current-buffer)
217 )))))
218 (error nil))
219 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
220 nil ;; We've got what we needed
221 ;; We have the old custom-library, hack around it!
222 (defmacro defgroup (&rest args) nil)
223 (defmacro customize (&rest args)
224 (message "Sorry, Customize is not available with this version of emacs"))
225 (defmacro defcustom (var value doc &rest args)
226 `(defvar ,var ,value ,doc))
227 )
228 (if (fboundp 'defface)
229 nil ; great!
230 (defmacro defface (var values doc &rest args)
231 `(make-face ,var))
232 )
233
234 (if (and (featurep 'custom) (fboundp 'customize-group))
235 nil ;; We've got what we needed
236 ;; We have an intermediate custom-library, hack around it!
237 (defmacro customize-group (var &rest args)
238 `(customize ,var))
239 )
240
241 )
242;; Provide a regular expression optimization routine, using regexp-opt
243;; if provided by the user's elisp libraries
244(eval-and-compile
245 (if (fboundp 'regexp-opt)
246 ;; regexp-opt is defined, does it take 3 or 2 arguments?
247 (if (fboundp 'function-max-args)
248 (let ((args (function-max-args `regexp-opt)))
249 (cond
250 ((eq args 3) ;; It takes 3
251 (condition-case nil ; Hide this defun from emacses
252 ;with just a two input regexp
253 (defun verilog-regexp-opt (a b)
254 "Deal with differing number of required arguments for `regexp-opt'.
255 Call 'regexp-opt' on A and B."
256 (regexp-opt a b 't)
257 )
258 (error nil))
259 )
260 ((eq args 2) ;; It takes 2
261 (defun verilog-regexp-opt (a b)
262 "Call 'regexp-opt' on A and B."
263 (regexp-opt a b))
264 )
265 (t nil)))
266 ;; We can't tell; assume it takes 2
267 (defun verilog-regexp-opt (a b)
268 "Call 'regexp-opt' on A and B."
269 (regexp-opt a b))
270 )
271 ;; There is no regexp-opt, provide our own
272 (defun verilog-regexp-opt (strings &optional paren shy)
273 (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
274 (concat open (mapconcat 'regexp-quote strings "\\|") close)))
275 ))
276
277(eval-when-compile
278 (defun verilog-regexp-words (a)
279 "Call 'regexp-opt' with word delimiters for the words A."
280 (concat "\\<" (verilog-regexp-opt a t) "\\>")))
281
282(defun verilog-customize ()
283 "Link to customize screen for Verilog."
284 (interactive)
285 (customize-group 'verilog-mode))
286
287(defun verilog-font-customize ()
288 "Link to customize fonts used for Verilog."
289 (interactive)
290 (customize-apropos "font-lock-*" 'faces))
291
292(defgroup verilog-mode nil
293 "Facilitates easy editing of Verilog source text"
294 :group 'languages)
295
296; (defgroup verilog-mode-fonts nil
297; "Facilitates easy customization fonts used in Verilog source text"
298; :link '(customize-apropos "font-lock-*" 'faces)
299; :group 'verilog-mode)
300
301(defgroup verilog-mode-indent nil
302 "Customize indentation and highlighting of verilog source text"
303 :group 'verilog-mode)
304
305(defgroup verilog-mode-actions nil
306 "Customize actions on verilog source text"
307 :group 'verilog-mode)
308
309(defgroup verilog-mode-auto nil
310 "Customize AUTO actions when expanding verilog source text"
311 :group 'verilog-mode)
312
313(defcustom verilog-linter
314 "echo 'No verilog-linter set, see \"M-x describe-variable verilog-linter\"'"
315 "*Unix program and arguments to call to run a lint checker on verilog source.
316Depending on the `verilog-set-compile-command', this may be invoked when
317you type \\[compile]. When the compile completes, \\[next-error] will take
318you to the next lint error."
319 :type 'string
320 :group 'verilog-mode-actions)
321
322(defcustom verilog-coverage
323 "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'"
324 "*Program and arguments to use to annotate for coverage verilog source.
325Depending on the `verilog-set-compile-command', this may be invoked when
326you type \\[compile]. When the compile completes, \\[next-error] will take
327you to the next lint error."
328 :type 'string
329 :group 'verilog-mode-actions)
330
331(defcustom verilog-simulator
332 "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'"
333 "*Program and arguments to use to interpret verilog source.
334Depending on the `verilog-set-compile-command', this may be invoked when
335you type \\[compile]. When the compile completes, \\[next-error] will take
336you to the next lint error."
337 :type 'string
338 :group 'verilog-mode-actions)
339
340(defcustom verilog-compiler
341 "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'"
342 "*Program and arguments to use to compile verilog source.
343Depending on the `verilog-set-compile-command', this may be invoked when
344you type \\[compile]. When the compile completes, \\[next-error] will take
345you to the next lint error."
346 :type 'string
347 :group 'verilog-mode-actions)
348
349(defvar verilog-tool 'verilog-linter
350 "Which tool to use for building compiler-command.
351Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or
352`verilog-compiler. Alternatively use the \"Choose Compilation Action\"
353menu. See `verilog-set-compile-command' for more information.")
354
355(defcustom verilog-highlight-translate-off nil
356 "*Non-nil means background-highlight code excluded from translation.
357That is, all code between \"// synopsys translate_off\" and
358\"// synopsys translate_on\" is highlighted using a different background color
359\(face `verilog-font-lock-translate-off-face').
360
361Note: This will slow down on-the-fly fontification (and thus editing).
362
363Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu
364entry \"Fontify Buffer\"). XEmacs: turn off and on font locking."
365 :type 'boolean
366 :group 'verilog-mode-indent)
367
368(defcustom verilog-indent-level 3
369 "*Indentation of Verilog statements with respect to containing block."
370 :group 'verilog-mode-indent
371 :type 'integer)
372
373(defcustom verilog-indent-level-module 3
374 "*Indentation of Module level Verilog statements. (eg always, initial)
375Set to 0 to get initial and always statements lined up on the left side of
376your screen."
377 :group 'verilog-mode-indent
378 :type 'integer)
379
380(defcustom verilog-indent-level-declaration 3
381 "*Indentation of declarations with respect to containing block.
382Set to 0 to get them list right under containing block."
383 :group 'verilog-mode-indent
384 :type 'integer)
385
386(defcustom verilog-indent-declaration-macros nil
387 "*How to treat macro expansions in a declaration.
388If nil, indent as:
389 input [31:0] a;
390 input `CP;
391 output c;
392If non nil, treat as:
393 input [31:0] a;
394 input `CP ;
395 output c;"
396 :group 'verilog-mode-indent
397 :type 'boolean)
398
399(defcustom verilog-indent-lists t
400 "*How to treat indenting items in a list.
401If t (the default), indent as:
402 always @( posedge a or
403 reset ) begin
404
405If nil, treat as:
406 always @( posedge a or
407 reset ) begin"
408 :group 'verilog-mode-indent
409 :type 'boolean)
410
411(defcustom verilog-indent-level-behavioral 3
412 "*Absolute indentation of first begin in a task or function block.
413Set to 0 to get such code to start at the left side of the screen."
414 :group 'verilog-mode-indent
415 :type 'integer)
416
417(defcustom verilog-indent-level-directive 1
418 "*Indentation to add to each level of `ifdef declarations.
419Set to 0 to have all directives start at the left side of the screen."
420 :group 'verilog-mode-indent
421 :type 'integer)
422
423(defcustom verilog-cexp-indent 2
424 "*Indentation of Verilog statements split across lines."
425 :group 'verilog-mode-indent
426 :type 'integer)
427
428(defcustom verilog-case-indent 2
429 "*Indentation for case statements."
430 :group 'verilog-mode-indent
431 :type 'integer)
432
433(defcustom verilog-auto-newline t
434 "*True means automatically newline after semicolons."
435 :group 'verilog-mode-indent
436 :type 'boolean)
437
438(defcustom verilog-auto-indent-on-newline t
439 "*True means automatically indent line after newline."
440 :group 'verilog-mode-indent
441 :type 'boolean)
442
443(defcustom verilog-tab-always-indent t
444 "*True means TAB should always re-indent the current line.
445Nil means TAB will only reindent when at the beginning of the line."
446 :group 'verilog-mode-indent
447 :type 'boolean)
448
449(defcustom verilog-tab-to-comment nil
450 "*True means TAB moves to the right hand column in preparation for a comment."
451 :group 'verilog-mode-actions
452 :type 'boolean)
453
454(defcustom verilog-indent-begin-after-if t
455 "*If true, indent begin statements following if, else, while, for and repeat.
456Otherwise, line them up."
457 :group 'verilog-mode-indent
458 :type 'boolean )
459
460
461(defcustom verilog-align-ifelse nil
462 "*If true, align `else' under matching `if'.
463Otherwise else is lined up with first character on line holding matching if."
464 :group 'verilog-mode-indent
465 :type 'boolean )
466
467(defcustom verilog-minimum-comment-distance 10
468 "*Minimum distance (in lines) between begin and end required before a comment.
469Setting this variable to zero results in every end acquiring a comment; the
470default avoids too many redundant comments in tight quarters"
471 :group 'verilog-mode-indent
472 :type 'integer)
473
474(defcustom verilog-auto-lineup '(declaration)
475 "*Algorithm for lining up statements on multiple lines.
476
477If this list contains the symbol 'all', then all line ups described below
478are done.
479
480If this list contains the symbol 'declaration', then declarations are lined up
481with any preceding declarations, taking into account widths and the like, so
482for example the code:
483 reg [31:0] a;
484 reg b;
485would become
486 reg [31:0] a;
487 reg b;
488
489If this list contains the symbol 'assignment', then assignments are lined up
490with any preceding assignments, so for example the code
491 a_long_variable = b + c;
492 d = e + f;
493would become
494 a_long_variable = b + c;
495 d = e + f;"
496
497;; The following is not implemented:
498;If this list contains the symbol 'case', then case items are lined up
499;with any preceding case items, so for example the code
500; case (a) begin
501; a_long_state : a = 3;
502; b: a = 4;
503; endcase
504;would become
505; case (a) begin
506; a_long_state : a = 3;
507; b : a = 4;
508; endcase
509;
510
511 :group 'verilog-mode-indent
512 :type 'list )
513
514(defcustom verilog-highlight-p1800-keywords nil
515 "*If true highlight words newly reserved by IEEE-1800 in
516verilog-font-lock-p1800-face in order to gently suggest changing where
517these words are used as variables to something else. Nil means highlight
518these words as appropriate for the SystemVerilog IEEE-1800 standard. Note
519that changing this will require restarting emacs to see the effect as font
520color choices are cached by emacs"
521 :group 'verilog-mode-indent
522 :type 'boolean)
523
524(defcustom verilog-auto-endcomments t
525 "*True means insert a comment /* ... */ after 'end's.
526The name of the function or case will be set between the braces."
527 :group 'verilog-mode-actions
528 :type 'boolean )
529
530(defcustom verilog-auto-read-includes nil
531 "*True means to automatically read includes before AUTOs.
532This will do a `verilog-read-defines' and `verilog-read-includes' before
533each AUTO expansion. This makes it easier to embed defines and includes,
534but can result in very slow reading times if there are many or large
535include files."
536 :group 'verilog-mode-actions
537 :type 'boolean )
538
539(defcustom verilog-auto-save-policy nil
540 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs.
541A value of `force' will always do a \\[verilog-auto] automatically if
542needed on every save. A value of `detect' will do \\[verilog-auto]
543automatically when it thinks necessary. A value of `ask' will query the
544user when it thinks updating is needed.
545
546You should not rely on the 'ask or 'detect policies, they are safeguards
547only. They do not detect when AUTOINSTs need to be updated because a
548sub-module's port list has changed."
549 :group 'verilog-mode-actions
550 :type '(choice (const nil) (const ask) (const detect) (const force)))
551
552(defcustom verilog-auto-star-expand t
553 "*Non-nil indicates to expand a SystemVerilog .* instance ports.
554They will be expanded in the same way as if there was a AUTOINST in the
555instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'."
556 :group 'verilog-mode-actions
557 :type 'boolean)
558
559(defcustom verilog-auto-star-save nil
560 "*Non-nil indicates to save to disk SystemVerilog .* instance expansions.
561Nil indicates direct connections will be removed before saving. Only
562meaningful to those created due to `verilog-auto-star-expand' being set.
563
564Instead of setting this, you may want to use /*AUTOINST*/, which will
565always be saved."
566 :group 'verilog-mode-actions
567 :type 'boolean)
568
569(defvar verilog-auto-update-tick nil
570 "Modification tick at which autos were last performed.")
571
572(defvar verilog-auto-last-file-locals nil
573 "Text from file-local-variables during last evaluation.")
574
575(defvar verilog-error-regexp-add-didit nil)
576(defvar verilog-error-regexp nil)
577(setq verilog-error-regexp-add-didit nil
578 verilog-error-regexp
579 '(
580 ; SureLint
581;; ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2)
582 ; Most SureFire tools
583 ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\), \\(line \\|\\)\\([0-9]+\\):" 2 4 )
584 ("\
585\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
586:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
587 ; xsim
588 ; Error! in file /homes/mac/Axis/Xsim/test.v at line 13 [OBJ_NOT_DECLARED]
589 ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3)
590 ; vcs
591 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3)
592 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2)
593 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3)
594 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2)
595 ; Verilator
596 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
597 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
598 ; vxl
599 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3)
600 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2) ; vxl
601 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2)
602 ; nc-verilog
603 (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2)
604 ; Leda
605 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2)
606 )
607; "*List of regexps for verilog compilers, like verilint. See compilation-error-regexp-alist for the formatting."
608)
609
610(defvar verilog-error-font-lock-keywords
611 '(
612 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t)
613 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t)
614
615 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t)
616 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t)
617
618 ("\
619\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
620:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t)
621 ("\
622\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
623:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t)
624
625 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 bold t)
626 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 3 bold t)
627
628 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t)
629 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t)
630
631 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t)
632 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t)
633
634 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
635 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 3 bold t)
636
637 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t)
638 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
639 ; vxl
640 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
641 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
642
643 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 bold t)
644 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 2 bold t)
645
646 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 bold t)
647 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 2 bold t)
648 ; nc-verilog
649 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 bold t)
650 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t)
651 ; Leda
652 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t)
653 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t)
654 )
655 "*Keywords to also highlight in Verilog *compilation* buffers."
656 )
657
658(defcustom verilog-library-flags '("")
659 "*List of standard Verilog arguments to use for /*AUTOINST*/.
660These arguments are used to find files for `verilog-auto', and match
661the flags accepted by a standard Verilog-XL simulator.
662
663 -f filename Reads more `verilog-library-flags' from the filename.
664 +incdir+dir Adds the directory to `verilog-library-directories'.
665 -Idir Adds the directory to `verilog-library-directories'.
666 -y dir Adds the directory to `verilog-library-directories'.
667 +libext+.v Adds the extensions to `verilog-library-extensions'.
668 -v filename Adds the filename to `verilog-library-files'.
669
670 filename Adds the filename to `verilog-library-files'.
671 This is not recommended, -v is a better choice.
672
673You might want these defined in each file; put at the *END* of your file
674something like:
675
676 // Local Variables:
677 // verilog-library-flags:(\"-y dir -y otherdir\")
678 // End:
679
680Verilog-mode attempts to detect changes to this local variable, but they
681are only insured to be correct when the file is first visited. Thus if you
682have problems, use \\[find-alternate-file] RET to have these take effect.
683
684See also the variables mentioned above."
685 :group 'verilog-mode-auto
686 :type '(repeat string))
687
688(defcustom verilog-library-directories '(".")
689 "*List of directories when looking for files for /*AUTOINST*/.
690The directory may be relative to the current file, or absolute.
691Environment variables are also expanded in the directory names.
692Having at least the current directory is a good idea.
693
694You might want these defined in each file; put at the *END* of your file
695something like:
696
697 // Local Variables:
698 // verilog-library-directories:(\".\" \"subdir\" \"subdir2\")
699 // End:
700
701Verilog-mode attempts to detect changes to this local variable, but they
702are only insured to be correct when the file is first visited. Thus if you
703have problems, use \\[find-alternate-file] RET to have these take effect.
704
705See also `verilog-library-flags', `verilog-library-files'
706and `verilog-library-extensions'."
707 :group 'verilog-mode-auto
708 :type '(repeat file))
709
710(defcustom verilog-library-files '()
711 "*List of files to search for modules when looking for AUTOINST files.
712This is a complete path, usually to a technology file with many standard
713cells defined in it.
714
715You might want these defined in each file; put at the *END* of your file
716something like:
717
718 // Local Variables:
719 // verilog-library-files:(\"/some/path/technology.v\" \"/some/path/tech2.v\")
720 // End:
721
722Verilog-mode attempts to detect changes to this local variable, but they
723are only insured to be correct when the file is first visited. Thus if you
724have problems, use \\[find-alternate-file] RET to have these take effect.
725
726See also `verilog-library-flags', `verilog-library-directories'."
727 :group 'verilog-mode-auto
728 :type '(repeat directory))
729
730(defcustom verilog-library-extensions '(".v")
731 "*List of extensions to use when looking for files for /*AUTOINST*/.
732See also `verilog-library-flags', `verilog-library-directories'."
733 :type '(repeat string)
734 :group 'verilog-mode-auto)
735
736(defcustom verilog-active-low-regexp nil
737 "*If set, treat signals matching this regexp as active low.
738This is used for AUTORESET and AUTOTIEOFF. For proper behavior,
739you will probably also need `verilog-auto-reset-widths' set."
740 :group 'verilog-mode-auto
741 :type 'string)
742
743(defcustom verilog-auto-sense-include-inputs nil
744 "*If true, AUTOSENSE should include all inputs.
745If nil, only inputs that are NOT output signals in the same block are
746included."
747 :type 'boolean
748 :group 'verilog-mode-auto)
749
750(defcustom verilog-auto-sense-defines-constant nil
751 "*If true, AUTOSENSE should assume all defines represent constants.
752When true, the defines will not be included in sensitivity lists. To
753maintain compatibility with other sites, this should be set at the bottom
754of each verilog file that requires it, rather than being set globally."
755 :type 'boolean
756 :group 'verilog-mode-auto)
757
758(defcustom verilog-auto-reset-widths t
759 "*If true, AUTORESET should determine the width of signals.
760This is then used to set the width of the zero (32'h0 for example). This
761is required by some lint tools that aren't smart enough to ignore widths of
762the constant zero. This may result in ugly code when parameters determine
763the MSB or LSB of a signal inside a AUTORESET."
764 :type 'boolean
765 :group 'verilog-mode-auto)
766
767(defcustom verilog-assignment-delay ""
768 "*Text used for delays in delayed assignments. Add a trailing space if set."
769 :type 'string
770 :group 'verilog-mode-auto)
771
772(defcustom verilog-auto-inst-vector t
773 "*If true, when creating default ports with AUTOINST, use bus subscripts.
774If nil, skip the subscript when it matches the entire bus as declared in
775the module (AUTOWIRE signals always are subscripted, you must manually
776declare the wire to have the subscripts removed.) Nil may speed up some
777simulators, but is less general and harder to read, so avoid."
778 :group 'verilog-mode-auto
779 :type 'boolean )
780
781(defcustom verilog-auto-inst-template-numbers nil
782 "*If true, when creating templated ports with AUTOINST, add a comment.
783The comment will add the line number of the template that was used for that
784port declaration. Setting this aids in debugging, but nil is suggested for
785regular use to prevent large numbers of merge conflicts."
786 :group 'verilog-mode-auto
787 :type 'boolean )
788
789(defvar verilog-auto-inst-column 40
790 "Column number for first part of auto-inst.")
791
792(defcustom verilog-auto-input-ignore-regexp nil
793 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp.
794See the \\[verilog-faq] for examples on using this."
795 :group 'verilog-mode-auto
796 :type 'string )
797
798(defcustom verilog-auto-inout-ignore-regexp nil
799 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp.
800See the \\[verilog-faq] for examples on using this."
801 :group 'verilog-mode-auto
802 :type 'string )
803
804(defcustom verilog-auto-output-ignore-regexp nil
805 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp.
806See the \\[verilog-faq] for examples on using this."
807 :group 'verilog-mode-auto
808 :type 'string )
809
810(defcustom verilog-auto-unused-ignore-regexp nil
811 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp.
812See the \\[verilog-faq] for examples on using this."
813 :group 'verilog-mode-auto
814 :type 'string )
815
816(defcustom verilog-typedef-regexp nil
817 "*If non-nil, regular expression that matches Verilog-2001 typedef names.
818For example, \"_t$\" matches typedefs named with _t, as in the C language."
819 :group 'verilog-mode-auto
820 :type 'string )
821
822(defcustom verilog-mode-hook 'verilog-set-compile-command
823 "*Hook (List of functions) run after verilog mode is loaded."
824 :type 'hook
825 :group 'verilog-mode)
826
827(defcustom verilog-auto-hook nil
828 "*Hook run after `verilog-mode' updates AUTOs."
829 :type 'hook
830 :group 'verilog-mode-auto)
831
832(defcustom verilog-before-auto-hook nil
833 "*Hook run before `verilog-mode' updates AUTOs."
834 :type 'hook
835 :group 'verilog-mode-auto)
836
837(defcustom verilog-delete-auto-hook nil
838 "*Hook run after `verilog-mode' deletes AUTOs."
839 :type 'hook
840 :group 'verilog-mode-auto)
841
842(defcustom verilog-before-delete-auto-hook nil
843 "*Hook run before `verilog-mode' deletes AUTOs."
844 :type 'hook
845 :group 'verilog-mode-auto)
846
847(defcustom verilog-getopt-flags-hook nil
848 "*Hook run after `verilog-getopt-flags' determines the Verilog option lists."
849 :type 'hook
850 :group 'verilog-mode-auto)
851
852(defcustom verilog-before-getopt-flags-hook nil
853 "*Hook run before `verilog-getopt-flags' determines the Verilog option lists."
854 :type 'hook
855 :group 'verilog-mode-auto)
856
857(defvar verilog-imenu-generic-expression
858 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4)
859 ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3))
860 "Imenu expression for Verilog-mode. See `imenu-generic-expression'.")
861
862;;
863;; provide a verilog-header function.
864;; Customization variables:
865;;
866(defvar verilog-date-scientific-format nil
867 "*If non-nil, dates are written in scientific format (e.g. 1997/09/17).
868If nil, in European format (e.g. 17.09.1997). The brain-dead American
869format (e.g. 09/17/1997) is not supported.")
870
871(defvar verilog-company nil
872 "*Default name of Company for verilog header.
873If set will become buffer local.")
874
875(defvar verilog-project nil
876 "*Default name of Project for verilog header.
877If set will become buffer local.")
878
879(defvar verilog-mode-map
880 (let ((map (make-sparse-keymap)))
881 (define-key map ";" 'electric-verilog-semi)
882 (define-key map [(control 59)] 'electric-verilog-semi-with-comment)
883 (define-key map ":" 'electric-verilog-colon)
884 ;;(define-key map "=" 'electric-verilog-equal)
885 (define-key map "\`" 'electric-verilog-tick)
886 (define-key map "\t" 'electric-verilog-tab)
887 (define-key map "\r" 'electric-verilog-terminate-line)
888 ;; backspace/delete key bindings
889 (define-key map [backspace] 'backward-delete-char-untabify)
890 (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable
891 (define-key map [delete] 'delete-char)
892 (define-key map [(meta delete)] 'kill-word))
893 (define-key map "\M-\C-b" 'electric-verilog-backward-sexp)
894 (define-key map "\M-\C-f" 'electric-verilog-forward-sexp)
895 (define-key map "\M-\r" `electric-verilog-terminate-and-indent)
896 (define-key map "\M-\t" 'verilog-complete-word)
897 (define-key map "\M-?" 'verilog-show-completions)
898 (define-key map [(meta control h)] 'verilog-mark-defun)
899 (define-key map "\C-c\`" 'verilog-lint-off)
900 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit)
901 (define-key map "\C-c\C-r" 'verilog-label-be)
902 (define-key map "\C-c\C-i" 'verilog-pretty-declarations)
903 (define-key map "\C-c=" 'verilog-pretty-expr)
904 (define-key map "\C-c\C-b" 'verilog-submit-bug-report)
905 (define-key map "\M-*" 'verilog-star-comment)
906 (define-key map "\C-c\C-c" 'verilog-comment-region)
907 (define-key map "\C-c\C-u" 'verilog-uncomment-region)
908 (define-key map "\M-\C-a" 'verilog-beg-of-defun)
909 (define-key map "\M-\C-e" 'verilog-end-of-defun)
910 (define-key map "\C-c\C-d" 'verilog-goto-defun)
911 (define-key map "\C-c\C-k" 'verilog-delete-auto)
912 (define-key map "\C-c\C-a" 'verilog-auto)
913 (define-key map "\C-c\C-s" 'verilog-auto-save-compile)
914 (define-key map "\C-c\C-z" 'verilog-inject-auto)
915 (define-key map "\C-c\C-e" 'verilog-expand-vector)
916 (define-key map "\C-c\C-h" 'verilog-header)
917 map)
918 "Keymap used in Verilog mode.")
919
920;; menus
921(defvar verilog-xemacs-menu
922 '("Verilog"
923 ("Choose Compilation Action"
924 ["None"
925 (progn
926 (setq verilog-tool nil)
927 (verilog-set-compile-command))
928 :style radio
929 :selected (equal verilog-tool nil)]
930 ["Lint"
931 (progn
932 (setq verilog-tool 'verilog-linter)
933 (verilog-set-compile-command))
934 :style radio
935 :selected (equal verilog-tool `verilog-linter)]
936 ["Coverage"
937 (progn
938 (setq verilog-tool 'verilog-coverage)
939 (verilog-set-compile-command))
940 :style radio
941 :selected (equal verilog-tool `verilog-coverage)]
942 ["Simulator"
943 (progn
944 (setq verilog-tool 'verilog-simulator)
945 (verilog-set-compile-command))
946 :style radio
947 :selected (equal verilog-tool `verilog-simulator)]
948 ["Compiler"
949 (progn
950 (setq verilog-tool 'verilog-compiler)
951 (verilog-set-compile-command))
952 :style radio
953 :selected (equal verilog-tool `verilog-compiler)]
954 )
955 ("Move"
956 ["Beginning of function" verilog-beg-of-defun t]
957 ["End of function" verilog-end-of-defun t]
958 ["Mark function" verilog-mark-defun t]
959 ["Goto function/module" verilog-goto-defun t]
960 ["Move to beginning of block" electric-verilog-backward-sexp t]
961 ["Move to end of block" electric-verilog-forward-sexp t]
962 )
963 ("Comments"
964 ["Comment Region" verilog-comment-region t]
965 ["UnComment Region" verilog-uncomment-region t]
966 ["Multi-line comment insert" verilog-star-comment t]
967 ["Lint error to comment" verilog-lint-off t]
968 )
969 "----"
970 ["Compile" compile t]
971 ["AUTO, Save, Compile" verilog-auto-save-compile t]
972 ["Next Compile Error" next-error t]
973 ["Ignore Lint Warning at point" verilog-lint-off t]
974 "----"
975 ["Line up declarations around point" verilog-pretty-declarations t]
976 ["Line up equations around point" verilog-pretty-expr t]
977 ["Redo/insert comments on every end" verilog-label-be t]
978 ["Expand [x:y] vector line" verilog-expand-vector t]
979 ["Insert begin-end block" verilog-insert-block t]
980 ["Complete word" verilog-complete-word t]
981 "----"
982 ["Recompute AUTOs" verilog-auto t]
983 ["Kill AUTOs" verilog-delete-auto t]
984 ["Inject AUTOs" verilog-inject-auto t]
985 ("AUTO Help..."
986 ["AUTO General" (describe-function 'verilog-auto) t]
987 ["AUTO Library Flags" (describe-variable 'verilog-library-flags) t]
988 ["AUTO Library Path" (describe-variable 'verilog-library-directories) t]
989 ["AUTO Library Files" (describe-variable 'verilog-library-files) t]
990 ["AUTO Library Extensions" (describe-variable 'verilog-library-extensions) t]
991 ["AUTO `define Reading" (describe-function 'verilog-read-defines) t]
992 ["AUTO `include Reading" (describe-function 'verilog-read-includes) t]
993 ["AUTOARG" (describe-function 'verilog-auto-arg) t]
994 ["AUTOASCIIENUM" (describe-function 'verilog-auto-ascii-enum) t]
995 ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module) t]
996 ["AUTOINOUT" (describe-function 'verilog-auto-inout) t]
997 ["AUTOINPUT" (describe-function 'verilog-auto-input) t]
998 ["AUTOINST" (describe-function 'verilog-auto-inst) t]
999 ["AUTOINST (.*)" (describe-function 'verilog-auto-star) t]
1000 ["AUTOINSTPARAM" (describe-function 'verilog-auto-inst-param) t]
1001 ["AUTOOUTPUT" (describe-function 'verilog-auto-output) t]
1002 ["AUTOOUTPUTEVERY" (describe-function 'verilog-auto-output-every) t]
1003 ["AUTOREG" (describe-function 'verilog-auto-reg) t]
1004 ["AUTOREGINPUT" (describe-function 'verilog-auto-reg-input) t]
1005 ["AUTORESET" (describe-function 'verilog-auto-reset) t]
1006 ["AUTOSENSE" (describe-function 'verilog-auto-sense) t]
1007 ["AUTOTIEOFF" (describe-function 'verilog-auto-tieoff) t]
1008 ["AUTOUNUSED" (describe-function 'verilog-auto-unused) t]
1009 ["AUTOWIRE" (describe-function 'verilog-auto-wire) t]
1010 )
1011 "----"
1012 ["Submit bug report" verilog-submit-bug-report t]
1013 ["Version and FAQ" verilog-faq t]
1014 ["Customize Verilog Mode..." verilog-customize t]
1015 ["Customize Verilog Fonts & Colors" verilog-font-customize t]
1016 )
1017 "Emacs menu for VERILOG mode."
1018 )
1019(defvar verilog-statement-menu
1020 '("Statements"
1021 ["Header" verilog-sk-header t]
1022 ["Comment" verilog-sk-comment t]
1023 "----"
1024 ["Module" verilog-sk-module t]
1025 ["Primitive" verilog-sk-primitive t]
1026 "----"
1027 ["Input" verilog-sk-input t]
1028 ["Output" verilog-sk-output t]
1029 ["Inout" verilog-sk-inout t]
1030 ["Wire" verilog-sk-wire t]
1031 ["Reg" verilog-sk-reg t]
1032 ["Define thing under point as a register" verilog-sk-define-signal t]
1033 "----"
1034 ["Initial" verilog-sk-initial t]
1035 ["Always" verilog-sk-always t]
1036 ["Function" verilog-sk-function t]
1037 ["Task" verilog-sk-task t]
1038 ["Specify" verilog-sk-specify t]
1039 ["Generate" verilog-sk-generate t]
1040 "----"
1041 ["Begin" verilog-sk-begin t]
1042 ["If" verilog-sk-if t]
1043 ["(if) else" verilog-sk-else-if t]
1044 ["For" verilog-sk-for t]
1045 ["While" verilog-sk-while t]
1046 ["Fork" verilog-sk-fork t]
1047 ["Repeat" verilog-sk-repeat t]
1048 ["Case" verilog-sk-case t]
1049 ["Casex" verilog-sk-casex t]
1050 ["Casez" verilog-sk-casez t]
1051 )
1052 "Menu for statement templates in Verilog."
1053 )
1054
1055(easy-menu-define verilog-menu verilog-mode-map "Menu for Verilog mode"
1056 verilog-xemacs-menu)
1057(easy-menu-define verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog."
1058 verilog-statement-menu)
1059
1060(defvar verilog-mode-abbrev-table nil
1061 "Abbrev table in use in Verilog-mode buffers.")
1062
1063(define-abbrev-table 'verilog-mode-abbrev-table ())
1064
1065;;
1066;; Macros
1067;;
1068
1069(defsubst verilog-string-replace-matches (from-string to-string fixedcase literal string)
1070 "Replace occurrences of FROM-STRING with TO-STRING.
1071FIXEDCASE and LITERAL as in `replace-match`. STRING is what to replace.
1072The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\")
1073will break, as the o's continuously replace. xa -> x works ok though."
1074 ;; Hopefully soon to a emacs built-in
1075 (let ((start 0))
1076 (while (string-match from-string string start)
1077 (setq string (replace-match to-string fixedcase literal string)
1078 start (min (length string) (match-end 0))))
1079 string))
1080
1081(defsubst verilog-string-remove-spaces (string)
1082 "Remove spaces surrounding STRING."
1083 (save-match-data
1084 (setq string (verilog-string-replace-matches "^\\s-+" "" nil nil string))
1085 (setq string (verilog-string-replace-matches "\\s-+$" "" nil nil string))
1086 string))
1087
1088(defsubst verilog-re-search-forward (REGEXP BOUND NOERROR)
1089 ; checkdoc-params: (REGEXP BOUND NOERROR)
1090 "Like `re-search-forward', but skips over match in comments or strings."
1091 (store-match-data '(nil nil))
1092 (while (and
1093 (re-search-forward REGEXP BOUND NOERROR)
1094 (and (verilog-skip-forward-comment-or-string)
1095 (progn
1096 (store-match-data '(nil nil))
1097 (if BOUND
1098 (< (point) BOUND)
1099 t)
1100 ))))
1101 (match-end 0))
1102
1103(defsubst verilog-re-search-backward (REGEXP BOUND NOERROR)
1104 ; checkdoc-params: (REGEXP BOUND NOERROR)
1105 "Like `re-search-backward', but skips over match in comments or strings."
1106 (store-match-data '(nil nil))
1107 (while (and
1108 (re-search-backward REGEXP BOUND NOERROR)
1109 (and (verilog-skip-backward-comment-or-string)
1110 (progn
1111 (store-match-data '(nil nil))
1112 (if BOUND
1113 (> (point) BOUND)
1114 t)
1115 ))))
1116 (match-end 0))
1117
1118(defsubst verilog-re-search-forward-quick (regexp bound noerror)
1119 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR,
1120but trashes match data and is faster for REGEXP that doesn't match often.
1121This may at some point use text properties to ignore comments,
1122so there may be a large up front penalty for the first search."
1123 (let (pt)
1124 (while (and (not pt)
1125 (re-search-forward regexp bound noerror))
1126 (if (not (verilog-inside-comment-p))
1127 (setq pt (match-end 0))))
1128 pt))
1129
1130(defsubst verilog-re-search-backward-quick (regexp bound noerror)
1131 ; checkdoc-params: (REGEXP BOUND NOERROR)
1132 "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR,
1133but trashes match data and is faster for REGEXP that doesn't match often.
1134This may at some point use text properties to ignore comments,
1135so there may be a large up front penalty for the first search."
1136 (let (pt)
1137 (while (and (not pt)
1138 (re-search-backward regexp bound noerror))
1139 (if (not (verilog-inside-comment-p))
1140 (setq pt (match-end 0))))
1141 pt))
1142
1143(defsubst verilog-get-beg-of-line (&optional arg)
1144 (save-excursion
1145 (beginning-of-line arg)
1146 (point)))
1147
1148(defsubst verilog-get-end-of-line (&optional arg)
1149 (save-excursion
1150 (end-of-line arg)
1151 (point)))
1152
1153(defsubst verilog-within-string ()
1154 (save-excursion
1155 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point)))))
1156
1157;; compilation program
1158(defun verilog-set-compile-command ()
1159 "Function to compute shell command to compile verilog.
1160
1161This reads `verilog-tool' and sets `compile-command'. This specifies the
1162program that executes when you type \\[compile] or
1163\\[verilog-auto-save-compile].
1164
1165By default `verilog-tool' uses a Makefile if one exists in the current
1166directory. If not, it is set to the `verilog-linter', `verilog-coverage',
1167`verilog-simulator', or `verilog-compiler' variables, as selected with the
1168Verilog -> \"Choose Compilation Action\" menu.
1169
1170You should set `verilog-tool' or the other variables to the path and
1171arguments for your Verilog simulator. For example:
1172 \"vcs -p123 -O\"
1173or a string like:
1174 \"(cd /tmp; surecov %s)\".
1175
1176In the former case, the path to the current buffer is concat'ed to the
1177value of `verilog-tool'; in the later, the path to the current buffer is
1178substituted for the %s.
1179
1180Where __FILE__ appears in the string, the buffer-file-name of the current
1181buffer, without the directory portion, will be substituted."
1182 (interactive)
1183 (cond
1184 ((or (file-exists-p "makefile") ;If there is a makefile, use it
1185 (file-exists-p "Makefile"))
1186 (make-local-variable 'compile-command)
1187 (setq compile-command "make "))
1188 (t
1189 (make-local-variable 'compile-command)
1190 (setq compile-command
1191 (if verilog-tool
1192 (if (string-match "%s" (eval verilog-tool))
1193 (format (eval verilog-tool) (or buffer-file-name ""))
1194 (concat (eval verilog-tool) " " (or buffer-file-name "")))
1195 ""))))
1196 (verilog-modify-compile-command))
1197
1198(defun verilog-modify-compile-command ()
1199 "Replace meta-information in `compile-command'.
1200Where __FILE__ appears in the string, the current buffer's file-name,
1201without the directory portion, will be substituted."
1202 (when (and
1203 (stringp compile-command)
1204 (string-match "\\b__FILE__\\b" compile-command))
1205 (make-local-variable 'compile-command)
1206 (setq compile-command
1207 (verilog-string-replace-matches
1208 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name))
1209 t t compile-command))))
1210
1211(defun verilog-error-regexp-add ()
1212 "Add the messages to the `compilation-error-regexp-alist'.
1213Called by `compilation-mode-hook'. This allows \\[next-error] to find the errors."
1214 (if (not verilog-error-regexp-add-didit)
1215 (progn
1216 (setq verilog-error-regexp-add-didit t)
1217 (setq-default compilation-error-regexp-alist
1218 (append verilog-error-regexp
1219 (default-value 'compilation-error-regexp-alist)))
1220 ;; Could be buffer local at this point; maybe also in let; change all three
1221 (setq compilation-error-regexp-alist (default-value 'compilation-error-regexp-alist))
1222 (set (make-local-variable 'compilation-error-regexp-alist)
1223 (default-value 'compilation-error-regexp-alist))
1224 )))
1225
1226(add-hook 'compilation-mode-hook 'verilog-error-regexp-add)
1227
1228(defconst verilog-directive-re
1229 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif"
1230 ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef"
1231 ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale"
1232 ;; "`time_scale" "`undef" "`while"
1233 "\\<`\\(case\\|def\\(ault\\|ine\\(\\)?\\)\\|e\\(lse\\|nd\\(for\\|if\\|protect\\|switch\\|while\\)\\)\\|for\\(mat\\)?\\|i\\(f\\(def\\|ndef\\)?\\|nclude\\)\\|let\\|protect\\|switch\\|time\\(_scale\\|scale\\)\\|undef\\|while\\)\\>")
1234
1235(defconst verilog-directive-begin
1236 "\\<`\\(for\\|i\\(f\\|fdef\\|fndef\\)\\|switch\\|while\\)\\>")
1237
1238(defconst verilog-directive-middle
1239 "\\<`\\(else\\|default\\|case\\)\\>")
1240
1241(defconst verilog-directive-end
1242 "`\\(endfor\\|endif\\|endswitch\\|endwhile\\)\\>")
1243
1244(defconst verilog-directive-re-1
1245 (concat "[ \t]*" verilog-directive-re))
1246
1247;;
1248;; Regular expressions used to calculate indent, etc.
1249;;
1250(defconst verilog-symbol-re "\\<[a-zA-Z_][a-zA-Z_0-9.]*\\>")
1251(defconst verilog-case-re "\\(\\<case[xz]?\\>\\|\\<randcase\\>\\)")
1252;; Want to match
1253;; aa :
1254;; aa,bb :
1255;; a[34:32] :
1256;; a,
1257;; b :
1258
1259(defconst verilog-no-indent-begin-re
1260 "\\<\\(if\\|else\\|while\\|for\\|repeat\\|always\\|always_comb\\|always_ff\\|always_latch\\)\\>")
1261
1262(defconst verilog-ends-re
1263 ;; Parenthesis indicate type of keyword found
1264 (concat
1265 "\\(\\<else\\>\\)\\|" ; 1
1266 "\\(\\<if\\>\\)\\|" ; 2
1267 "\\(\\<end\\>\\)\\|" ; 3
1268 "\\(\\<endcase\\>\\)\\|" ; 4
1269 "\\(\\<endfunction\\>\\)\\|" ; 5
1270 "\\(\\<endtask\\>\\)\\|" ; 6
1271 "\\(\\<endspecify\\>\\)\\|" ; 7
1272 "\\(\\<endtable\\>\\)\\|" ; 8
1273 "\\(\\<endgenerate\\>\\)\\|" ; 9
1274 "\\(\\<join\\(_any\\|_none\\)?\\>\\)\\|" ; 10
1275 "\\(\\<endclass\\>\\)\\|" ; 11
1276 "\\(\\<endgroup\\>\\)" ; 12
1277 ))
1278
1279(defconst verilog-auto-end-comment-lines-re
1280 ;; Matches to names in this list cause auto-end-commentation
1281 (concat "\\("
1282 verilog-directive-re "\\)\\|\\("
1283 (eval-when-compile
1284 (verilog-regexp-words
1285 `( "begin"
1286 "else"
1287 "end"
1288 "endcase"
1289 "endclass"
1290 "endclocking"
1291 "endgroup"
1292 "endfunction"
1293 "endmodule"
1294 "endprogram"
1295 "endprimitive"
1296 "endinterface"
1297 "endpackage"
1298 "endsequence"
1299 "endspecify"
1300 "endtable"
1301 "endtask"
1302 "join"
1303 "join_any"
1304 "join_none"
1305 "module"
1306 "macromodule"
1307 "primitive"
1308 "interface"
1309 "package")))
1310 "\\)"))
1311
1312;;; NOTE: verilog-leap-to-head expects that verilog-end-block-re and
1313;;; verilog-end-block-ordered-re matches exactly the same strings.
1314(defconst verilog-end-block-ordered-re
1315 ;; Parenthesis indicate type of keyword found
1316 (concat "\\(\\<endcase\\>\\)\\|" ; 1
1317 "\\(\\<end\\>\\)\\|" ; 2
1318 "\\(\\<end" ; 3, but not used
1319 "\\(" ; 4, but not used
1320 "\\(function\\)\\|" ; 5
1321 "\\(task\\)\\|" ; 6
1322 "\\(module\\)\\|" ; 7
1323 "\\(primitive\\)\\|" ; 8
1324 "\\(interface\\)\\|" ; 9
1325 "\\(package\\)\\|" ; 10
1326 "\\(class\\)\\|" ; 11
1327 "\\(group\\)\\|" ; 12
1328 "\\(program\\)\\|" ; 13
1329 "\\(sequence\\)\\|" ; 14
1330 "\\(clocking\\)\\|" ; 15
1331 "\\)\\>\\)"))
1332(defconst verilog-end-block-re
1333 (eval-when-compile
1334 (verilog-regexp-words
1335
1336 `("end" ;; closes begin
1337 "endcase" ;; closes any of case, casex casez or randcase
1338 "join" "join_any" "join_none" ;; closes fork
1339 "endclass"
1340 "endtable"
1341 "endspecify"
1342 "endfunction"
1343 "endgenerate"
1344 "endtask"
1345 "endgroup"
1346 "endproperty"
1347 "endinterface"
1348 "endpackage"
1349 "endprogram"
1350 "endsequence"
1351 "endclocking"
1352 )
1353 )))
1354
1355
1356(defconst verilog-endcomment-reason-re
1357 ;; Parenthesis indicate type of keyword found
1358 (concat
1359 "\\(\\<fork\\>\\)\\|"
1360 "\\(\\<begin\\>\\)\\|"
1361 "\\(\\<if\\>\\)\\|"
1362 "\\(\\<clocking\\>\\)\\|"
1363 "\\(\\<else\\>\\)\\|"
1364 "\\(\\<end\\>.*\\<else\\>\\)\\|"
1365 "\\(\\<task\\>\\)\\|"
1366 "\\(\\<function\\>\\)\\|"
1367 "\\(\\<initial\\>\\)\\|"
1368 "\\(\\<interface\\>\\)\\|"
1369 "\\(\\<package\\>\\)\\|"
1370 "\\(\\<final\\>\\)\\|"
1371 "\\(\\<always\\>\\(\[ \t\]*@\\)?\\)\\|"
1372 "\\(\\<always_comb\\>\\(\[ \t\]*@\\)?\\)\\|"
1373 "\\(\\<always_ff\\>\\(\[ \t\]*@\\)?\\)\\|"
1374 "\\(\\<always_latch\\>\\(\[ \t\]*@\\)?\\)\\|"
1375 "\\(@\\)\\|"
1376 "\\(\\<while\\>\\)\\|"
1377 "\\(\\<for\\(ever\\|each\\)?\\>\\)\\|"
1378 "\\(\\<repeat\\>\\)\\|\\(\\<wait\\>\\)\\|"
1379 "#"))
1380
1381(defconst verilog-named-block-re "begin[ \t]*:")
1382
1383;; These words begin a block which can occur inside a module which should be indented,
1384;; and closed with the respective word from the end-block list
1385
1386(defconst verilog-beg-block-re
1387 (eval-when-compile
1388 (verilog-regexp-words
1389 `("begin"
1390 "case" "casex" "casez" "randcase"
1391 "clocking"
1392 "generate"
1393 "fork"
1394 "function"
1395 "property"
1396 "specify"
1397 "table"
1398 "task"
1399 ))))
1400;; These are the same words, in a specific order in the regular
1401;; expression so that matching will work nicely for
1402;; verilog-forward-sexp and verilog-calc-indent
1403
1404(defconst verilog-beg-block-re-ordered
1405 ( concat "\\<"
1406 "\\(begin\\)" ;1
1407 "\\|\\(randcase\\|\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?\\)" ; 2
1408;; "\\|\\(randcase\\|case[xz]?\\)" ; 2
1409 "\\|\\(fork\\)" ;3
1410 "\\|\\(class\\)" ;4
1411 "\\|\\(table\\)" ;5
1412 "\\|\\(specify\\)" ;6
1413 "\\|\\(function\\)" ;7
1414 "\\|\\(task\\)" ;8
1415 "\\|\\(generate\\)" ;9
1416 "\\|\\(covergroup\\)" ;10
1417 "\\|\\(property\\)" ;11
1418 "\\|\\(\\(rand\\)?sequence\\)" ;12
1419 "\\|\\(clocking\\)" ;13
1420 "\\>"))
1421
1422(defconst verilog-end-block-ordered-rry
1423 [ "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)"
1424 "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)"
1425 "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)"
1426 "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)"
1427 "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)"
1428 "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)"
1429 "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)"
1430 "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)"
1431 "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)"
1432 "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)"
1433 "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)"
1434 "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)"
1435 "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)"
1436 ] )
1437
1438(defconst verilog-nameable-item-re
1439 (eval-when-compile
1440 (verilog-regexp-words
1441 `("begin"
1442 "fork"
1443 "join" "join_any" "join_none"
1444 "end"
1445 "endcase"
1446 "endconfig"
1447 "endclass"
1448 "endclocking"
1449 "endfunction"
1450 "endgenerate"
1451 "endmodule"
1452 "endprimative"
1453 "endinterface"
1454 "endpackage"
1455 "endspecify"
1456 "endtable"
1457 "endtask" )
1458 )))
1459
1460(defconst verilog-declaration-opener
1461 (eval-when-compile
1462 (verilog-regexp-words
1463 `("module" "begin" "task" "function"))))
1464
1465(defconst verilog-declaration-prefix-re
1466 (eval-when-compile
1467 (verilog-regexp-words
1468 `(
1469 ;; port direction
1470 "inout" "input" "output" "ref"
1471 ;; changeableness
1472 "const" "static" "protected" "local"
1473 ;; parameters
1474 "localparam" "parameter" "var"
1475 ;; type creation
1476 "typedef"
1477 ))))
1478(defconst verilog-declaration-core-re
1479 (eval-when-compile
1480 (verilog-regexp-words
1481 `(
1482 ;; integer_atom_type
1483 "byte" "shortint" "int" "longint" "integer" "time"
1484 ;; integer_vector_type
1485 "bit" "logic" "reg"
1486 ;; non_integer_type
1487 "shortreal" "real" "realtime"
1488 ;; net_type
1489 "supply0" "supply1" "tri" "triand" "trior" "trireg" "tri0" "tri1" "uwire" "wire" "wand" "wor"
1490 ;; misc
1491 "string" "event" "chandle" "virtual" "enum" "genvar"
1492 "struct" "union"
1493 ;; builtin classes
1494 "mailbox" "semaphore"
1495 ))))
1496(defconst verilog-declaration-re
1497 (concat "\\(" verilog-declaration-prefix-re "\\s-*\\)?" verilog-declaration-core-re))
1498(defconst verilog-range-re "\\(\\[[^]]*\\]\\s-*\\)+")
1499(defconst verilog-optional-signed-re "\\s-*\\(signed\\)?")
1500(defconst verilog-optional-signed-range-re
1501 (concat
1502 "\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<signed\\>\\s-*\\)?\\(" verilog-range-re "\\)?"))
1503(defconst verilog-macroexp-re "`\\sw+")
1504
1505(defconst verilog-delay-re "#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)")
1506(defconst verilog-declaration-re-2-no-macro
1507 (concat "\\s-*" verilog-declaration-re
1508 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)"
1509 "\\)?"))
1510(defconst verilog-declaration-re-2-macro
1511 (concat "\\s-*" verilog-declaration-re
1512 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)"
1513 "\\|\\(" verilog-macroexp-re "\\)"
1514 "\\)?"))
1515(defconst verilog-declaration-re-1-macro
1516 (concat "^" verilog-declaration-re-2-macro))
1517
1518(defconst verilog-declaration-re-1-no-macro (concat "^" verilog-declaration-re-2-no-macro))
1519
1520(defconst verilog-defun-re
1521 (eval-when-compile (verilog-regexp-words `("macromodule" "module" "class" "program" "interface" "package" "primitive" "config"))))
1522(defconst verilog-end-defun-re
1523 (eval-when-compile (verilog-regexp-words `("endmodule" "endclass" "endprogram" "endinterface" "endpackage" "endprimitive" "endconfig"))))
1524(defconst verilog-zero-indent-re
1525 (concat verilog-defun-re "\\|" verilog-end-defun-re))
1526
1527(defconst verilog-behavioral-block-beg-re
1528 (concat "\\(\\<initial\\>\\|\\<final\\>\\|\\<always\\>\\|\\<always_comb\\>\\|\\<always_ff\\>\\|"
1529 "\\<always_latch\\>\\|\\<function\\>\\|\\<task\\>\\)"))
1530
1531(defconst verilog-indent-re
1532 (eval-when-compile
1533 (verilog-regexp-words
1534 `(
1535 "{"
1536 "always" "always_latch" "always_ff" "always_comb"
1537 "begin" "end"
1538; "unique" "priority"
1539 "case" "casex" "casez" "randcase" "endcase"
1540 "class" "endclass"
1541 "clocking" "endclocking"
1542 "config" "endconfig"
1543 "covergroup" "endgroup"
1544 "fork" "join" "join_any" "join_none"
1545 "function" "endfunction"
1546 "final"
1547 "generate" "endgenerate"
1548 "initial"
1549 "interface" "endinterface"
1550 "module" "macromodule" "endmodule"
1551 "package" "endpackage"
1552 "primitive" "endprimative"
1553 "program" "endprogram"
1554 "property" "endproperty"
1555 "sequence" "randsequence" "endsequence"
1556 "specify" "endspecify"
1557 "table" "endtable"
1558 "task" "endtask"
1559 "`case"
1560 "`default"
1561 "`define" "`undef"
1562 "`if" "`ifdef" "`ifndef" "`else" "`endif"
1563 "`while" "`endwhile"
1564 "`for" "`endfor"
1565 "`format"
1566 "`include"
1567 "`let"
1568 "`protect" "`endprotect"
1569 "`switch" "`endswitch"
1570 "`timescale"
1571 "`time_scale"
1572 ))))
1573
1574(defconst verilog-defun-level-re
1575 (eval-when-compile
1576 (verilog-regexp-words
1577 `(
1578 "module" "macromodule" "primitive" "class" "program" "initial" "final" "always" "always_comb"
1579 "always_ff" "always_latch" "endtask" "endfunction" "interface" "package"
1580 "config"))))
1581
1582(defconst verilog-defun-level-not-generate-re
1583 (eval-when-compile
1584 (verilog-regexp-words
1585 `(
1586 "module" "macromodule" "primitive" "class" "program" "interface" "package" "config"))))
1587
1588(defconst verilog-cpp-level-re
1589 (eval-when-compile
1590 (verilog-regexp-words
1591 `(
1592 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass"
1593 ))))
1594(defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?")
1595(defconst verilog-extended-complete-re
1596 (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)"
1597 "\\|\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)"
1598 "\\|" verilog-extended-case-re ))
1599(defconst verilog-basic-complete-re
1600 (eval-when-compile
1601 (verilog-regexp-words
1602 `(
1603 "always" "assign" "always_latch" "always_ff" "always_comb" "constraint"
1604 "import" "initial" "final" "module" "macromodule" "repeat" "randcase" "while"
1605 "if" "for" "forever" "foreach" "else" "parameter" "do"
1606 ))))
1607(defconst verilog-complete-reg
1608 (concat
1609 verilog-extended-complete-re
1610 "\\|"
1611 verilog-basic-complete-re))
1612
1613(defconst verilog-end-statement-re
1614 (concat "\\(" verilog-beg-block-re "\\)\\|\\("
1615 verilog-end-block-re "\\)"))
1616
1617(defconst verilog-endcase-re
1618 (concat verilog-case-re "\\|"
1619 "\\(endcase\\)\\|"
1620 verilog-defun-re
1621 ))
1622
1623(defconst verilog-exclude-str-start "/* -----\\/----- EXCLUDED -----\\/-----"
1624 "String used to mark beginning of excluded text.")
1625(defconst verilog-exclude-str-end " -----/\\----- EXCLUDED -----/\\----- */"
1626 "String used to mark end of excluded text.")
1627(defconst verilog-preprocessor-re
1628 (eval-when-compile
1629 (verilog-regexp-words
1630 `(
1631 "`define" "`include" "`ifdef" "`ifndef" "`if" "`endif" "`else"
1632 ))))
1633
1634(defconst verilog-keywords
1635 '( "`case" "`default" "`define" "`else" "`endfor" "`endif"
1636 "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef"
1637 "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale"
1638 "`time_scale" "`undef" "`while"
1639
1640 "after" "alias" "always" "always_comb" "always_ff" "always_latch" "and"
1641 "assert" "assign" "assume" "automatic" "before" "begin" "bind"
1642 "bins" "binsof" "bit" "break" "buf" "bufif0" "bufif1" "byte"
1643 "case" "casex" "casez" "cell" "chandle" "class" "clocking" "cmos"
1644 "config" "const" "constraint" "context" "continue" "cover"
1645 "covergroup" "coverpoint" "cross" "deassign" "default" "defparam"
1646 "design" "disable" "dist" "do" "edge" "else" "end" "endcase"
1647 "endclass" "endclocking" "endconfig" "endfunction" "endgenerate"
1648 "endgroup" "endinterface" "endmodule" "endpackage" "endprimitive"
1649 "endprogram" "endproperty" "endspecify" "endsequence" "endtable"
1650 "endtask" "enum" "event" "expect" "export" "extends" "extern"
1651 "final" "first_match" "for" "force" "foreach" "forever" "fork"
1652 "forkjoin" "function" "generate" "genvar" "highz0" "highz1" "if"
1653 "iff" "ifnone" "ignore_bins" "illegal_bins" "import" "incdir"
1654 "include" "initial" "inout" "input" "inside" "instance" "int"
1655 "integer" "interface" "intersect" "join" "join_any" "join_none"
1656 "large" "liblist" "library" "local" "localparam" "logic"
1657 "longint" "macromodule" "mailbox" "matches" "medium" "modport" "module"
1658 "nand" "negedge" "new" "nmos" "nor" "noshowcancelled" "not"
1659 "notif0" "notif1" "null" "or" "output" "package" "packed"
1660 "parameter" "pmos" "posedge" "primitive" "priority" "program"
1661 "property" "protected" "pull0" "pull1" "pulldown" "pullup"
1662 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc"
1663 "randcase" "randsequence" "rcmos" "real" "realtime" "ref" "reg"
1664 "release" "repeat" "return" "rnmos" "rpmos" "rtran" "rtranif0"
1665 "rtranif1" "scalared" "semaphore" "sequence" "shortint" "shortreal"
1666 "showcancelled" "signed" "small" "solve" "specify" "specparam"
1667 "static" "string" "strong0" "strong1" "struct" "super" "supply0"
1668 "supply1" "table" "tagged" "task" "this" "throughout" "time"
1669 "timeprecision" "timeunit" "tran" "tranif0" "tranif1" "tri"
1670 "tri0" "tri1" "triand" "trior" "trireg" "type" "typedef" "union"
1671 "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void"
1672 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard"
1673 "wire" "with" "within" "wor" "xnor" "xor"
1674 )
1675 "List of Verilog keywords.")
1676
1677
1678(defconst verilog-emacs-features
1679 ;; Documentation at the bottom
1680 (let ((major (and (boundp 'emacs-major-version)
1681 emacs-major-version))
1682 (minor (and (boundp 'emacs-minor-version)
1683 emacs-minor-version))
1684 flavor comments flock-syntax)
1685 ;; figure out version numbers if not already discovered
1686 (and (or (not major) (not minor))
1687 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
1688 (setq major (string-to-int (substring emacs-version
1689 (match-beginning 1)
1690 (match-end 1)))
1691 minor (string-to-int (substring emacs-version
1692 (match-beginning 2)
1693 (match-end 2)))))
1694 (if (not (and major minor))
1695 (error "Cannot figure out the major and minor version numbers"))
1696 ;; calculate the major version
1697 (cond
1698 ((= major 4) (setq major 'v18)) ;Epoch 4
1699 ((= major 18) (setq major 'v18)) ;Emacs 18
1700 ((= major 19) (setq major 'v19 ;Emacs 19
1701 flavor (if (or (string-match "Lucid" emacs-version)
1702 (string-match "XEmacs" emacs-version))
1703 'XEmacs 'FSF)))
1704 ((> major 19) (setq major 'v20
1705 flavor (if (or (string-match "Lucid" emacs-version)
1706 (string-match "XEmacs" emacs-version))
1707 'XEmacs 'FSF)))
1708 ;; I don't know
1709 (t (error "Cannot recognize major version number: %s" major)))
1710 ;; XEmacs 19 uses 8-bit modify-syntax-entry flags, as do all
1711 ;; patched Emacs 19, Emacs 18, Epoch 4's. Only Emacs 19 uses a
1712 ;; 1-bit flag. Let's be as smart as we can about figuring this
1713 ;; out.
1714 (if (or (eq major 'v20) (eq major 'v19))
1715 (let ((table (copy-syntax-table)))
1716 (modify-syntax-entry ?a ". 12345678" table)
1717 (cond
1718 ;; XEmacs pre 20 and Emacs pre 19.30 use vectors for syntax tables.
1719 ((vectorp table)
1720 (if (= (logand (lsh (aref table ?a) -16) 255) 255)
1721 (setq comments '8-bit)
1722 (setq comments '1-bit)))
1723 ;; XEmacs 20 is known to be 8-bit
1724 ((eq flavor 'XEmacs) (setq comments '8-bit))
1725 ;; Emacs 19.30 and beyond are known to be 1-bit
1726 ((eq flavor 'FSF) (setq comments '1-bit))
1727 ;; Don't know what this is
1728 (t (error "Couldn't figure out syntax table format"))
1729 ))
1730 ;; Emacs 18 has no support for dual comments
1731 (setq comments 'no-dual-comments))
1732 ;; determine whether to use old or new font lock syntax
1733 ;; We can assume 8-bit syntax table emacsen support new syntax, otherwise
1734 ;; look for version > 19.30
1735 (setq flock-syntax
1736 (if (or (equal comments '8-bit)
1737 (equal major 'v20)
1738 (and (equal major 'v19) (> minor 30)))
1739 'flock-syntax-after-1930
1740 'flock-syntax-before-1930))
1741 ;; lets do some minimal sanity checking.
1742 (if (or
1743 ;; Emacs before 19.6 had bugs
1744 (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6))
1745 ;; Emacs 19 before 19.21 has known bugs
1746 (and (eq major 'v19) (eq flavor 'FSF) (< minor 21))
1747 )
1748 (with-output-to-temp-buffer "*verilog-mode warnings*"
1749 (print (format
1750 "The version of Emacs that you are running, %s,
1751has known bugs in its syntax parsing routines which will affect the
1752performance of verilog-mode. You should strongly consider upgrading to the
1753latest available version. verilog-mode may continue to work, after a
1754fashion, but strange indentation errors could be encountered."
1755 emacs-version))))
1756 ;; Emacs 18, with no patch is not too good
1757 (if (and (eq major 'v18) (eq comments 'no-dual-comments))
1758 (with-output-to-temp-buffer "*verilog-mode warnings*"
1759 (print (format
1760 "The version of Emacs 18 you are running, %s,
1761has known deficiencies in its ability to handle the dual verilog
1762\(and C++) comments, (e.g. the // and /* */ comments). This will
1763not be much of a problem for you if you only use the /* */ comments,
1764but you really should strongly consider upgrading to one of the latest
1765Emacs 19's. In Emacs 18, you may also experience performance degradations.
1766Emacs 19 has some new built-in routines which will speed things up for you.
1767Because of these inherent problems, verilog-mode is not supported
1768on emacs-18."
1769 emacs-version))))
1770 ;; Emacs 18 with the syntax patches are no longer supported
1771 (if (and (eq major 'v18) (not (eq comments 'no-dual-comments)))
1772 (with-output-to-temp-buffer "*verilog-mode warnings*"
1773 (print (format
1774 "You are running a syntax patched Emacs 18 variant. While this should
1775work for you, you may want to consider upgrading to Emacs 19.
1776The syntax patches are no longer supported either for verilog-mode."))))
1777 (list major comments flock-syntax))
1778 "A list of features extant in the Emacs you are using.
1779There are many flavors of Emacs out there, each with different
1780features supporting those needed by `verilog-mode'. Here's the current
1781supported list, along with the values for this variable:
1782
1783 Vanilla Emacs 18/Epoch 4: (v18 no-dual-comments flock-syntax-before-1930)
1784 Emacs 18/Epoch 4 (patch2): (v18 8-bit flock-syntax-after-1930)
1785 XEmacs (formerly Lucid) 19: (v19 8-bit flock-syntax-after-1930)
1786 XEmacs 20: (v20 8-bit flock-syntax-after-1930)
1787 Emacs 19.1-19.30: (v19 8-bit flock-syntax-before-1930)
1788 Emacs 19.31-19.xx: (v19 8-bit flock-syntax-after-1930)
1789 Emacs20 : (v20 1-bit flock-syntax-after-1930).")
1790
1791(defconst verilog-comment-start-regexp "//\\|/\\*"
1792 "Dual comment value for `comment-start-regexp'.")
1793
1794(defun verilog-populate-syntax-table (table)
1795 "Populate the syntax TABLE."
1796 (modify-syntax-entry ?\\ "\\" table)
1797 (modify-syntax-entry ?+ "." table)
1798 (modify-syntax-entry ?- "." table)
1799 (modify-syntax-entry ?= "." table)
1800 (modify-syntax-entry ?% "." table)
1801 (modify-syntax-entry ?< "." table)
1802 (modify-syntax-entry ?> "." table)
1803 (modify-syntax-entry ?& "." table)
1804 (modify-syntax-entry ?| "." table)
1805 (modify-syntax-entry ?` "w" table)
1806 (modify-syntax-entry ?_ "w" table)
1807 (modify-syntax-entry ?\' "." table)
1808)
1809
1810(defun verilog-setup-dual-comments (table)
1811 "Set up TABLE to handle block and line style comments."
1812 (cond
1813 ((memq '8-bit verilog-emacs-features)
1814 ;; XEmacs (formerly Lucid) has the best implementation
1815 (modify-syntax-entry ?/ ". 1456" table)
1816 (modify-syntax-entry ?* ". 23" table)
1817 (modify-syntax-entry ?\n "> b" table)
1818 )
1819 ((memq '1-bit verilog-emacs-features)
1820 ;; Emacs 19 does things differently, but we can work with it
1821 (modify-syntax-entry ?/ ". 124b" table)
1822 (modify-syntax-entry ?* ". 23" table)
1823 (modify-syntax-entry ?\n "> b" table)
1824 )
1825 ))
1826
1827(defvar verilog-mode-syntax-table nil
1828 "Syntax table used in `verilog-mode' buffers.")
1829
1830(defconst verilog-font-lock-keywords nil
1831 "Default highlighting for Verilog mode.")
1832
1833(defconst verilog-font-lock-keywords-1 nil
1834 "Subdued level highlighting for Verilog mode.")
1835
1836(defconst verilog-font-lock-keywords-2 nil
1837 "Medium level highlighting for Verilog mode.
1838See also `verilog-font-lock-extra-types'.")
1839
1840(defconst verilog-font-lock-keywords-3 nil
1841 "Gaudy level highlighting for Verilog mode.
1842See also `verilog-font-lock-extra-types'.")
1843(defvar verilog-font-lock-translate-off-face
1844 'verilog-font-lock-translate-off-face
1845 "Font to use for translated off regions.")
1846(defface verilog-font-lock-translate-off-face
1847 '((((class color)
1848 (background light))
1849 (:background "gray90" :italic t ))
1850 (((class color)
1851 (background dark))
1852 (:background "gray10" :italic t ))
1853 (((class grayscale) (background light))
1854 (:foreground "DimGray" :italic t))
1855 (((class grayscale) (background dark))
1856 (:foreground "LightGray" :italic t))
1857 (t (:italis t)))
1858 "Font lock mode face used to background highlight translate-off regions."
1859 :group 'font-lock-highlighting-faces)
1860
1861(defvar verilog-font-lock-p1800-face
1862 'verilog-font-lock-p1800-face
1863 "Font to use for p1800 keywords.")
1864(defface verilog-font-lock-p1800-face
1865 '((((class color)
1866 (background light))
1867 (:foreground "DarkOrange3" :bold t ))
1868 (((class color)
1869 (background dark))
1870 (:foreground "orange1" :bold t ))
1871 (t (:italic t)))
1872 "Font lock mode face used to highlight P1800 keywords."
1873 :group 'font-lock-highlighting-faces)
1874
1875(defvar verilog-font-lock-ams-face
1876 'verilog-font-lock-ams-face
1877 "Font to use for Analog/Mixed Signal keywords.")
1878(defface verilog-font-lock-ams-face
1879 '((((class color)
1880 (background light))
1881 (:foreground "Purple" :bold t ))
1882 (((class color)
1883 (background dark))
1884 (:foreground "orange1" :bold t ))
1885 (t (:italic t)))
1886 "Font lock mode face used to highlight AMS keywords."
1887 :group 'font-lock-highlighting-faces)
1888
1889(let* ((verilog-type-font-keywords
1890 (eval-when-compile
1891 (verilog-regexp-opt
1892 '(
1893 "and" "bit" "buf" "bufif0" "bufif1" "cmos" "defparam"
1894 "event" "genvar" "inout" "input" "integer" "localparam"
1895 "logic" "mailbox" "nand" "nmos" "not" "notif0" "notif1" "or"
1896 "output" "parameter" "pmos" "pull0" "pull1" "pullup"
1897 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran"
1898 "rtranif0" "rtranif1" "semaphore" "signed" "struct" "supply"
1899 "supply0" "supply1" "time" "tran" "tranif0" "tranif1"
1900 "tri" "tri0" "tri1" "triand" "trior" "trireg" "typedef"
1901 "uwire" "vectored" "wand" "wire" "wor" "xnor" "xor"
1902 ) nil )))
1903
1904 (verilog-pragma-keywords
1905 (eval-when-compile
1906 (verilog-regexp-opt
1907 '("surefire" "synopsys" "rtl_synthesis" "verilint" ) nil
1908 )))
1909
1910 (verilog-p1800-keywords
1911 (eval-when-compile
1912 (verilog-regexp-opt
1913 '("alias" "assert" "assume" "automatic" "before" "bind"
1914 "bins" "binsof" "break" "byte" "cell" "chandle" "class"
1915 "clocking" "config" "const" "constraint" "context" "continue"
1916 "cover" "covergroup" "coverpoint" "cross" "deassign" "design"
1917 "dist" "do" "edge" "endclass" "endclocking" "endconfig"
1918 "endgroup" "endprogram" "endproperty" "endsequence" "enum"
1919 "expect" "export" "extends" "extern" "first_match" "foreach"
1920 "forkjoin" "genvar" "highz0" "highz1" "ifnone" "ignore_bins"
1921 "illegal_bins" "import" "incdir" "include" "inside" "instance"
1922 "int" "intersect" "large" "liblist" "library" "local" "longint"
1923 "matches" "medium" "modport" "new" "noshowcancelled" "null"
1924 "packed" "program" "property" "protected" "pull0" "pull1"
1925 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc"
1926 "randcase" "randsequence" "ref" "release" "return" "scalared"
1927 "sequence" "shortint" "shortreal" "showcancelled" "small" "solve"
1928 "specparam" "static" "string" "strong0" "strong1" "struct"
1929 "super" "tagged" "this" "throughout" "timeprecision" "timeunit"
1930 "type" "union" "unsigned" "use" "var" "virtual" "void"
1931 "wait_order" "weak0" "weak1" "wildcard" "with" "within"
1932 ) nil )))
1933
1934 (verilog-ams-keywords
1935 (eval-when-compile
1936 (verilog-regexp-opt
1937 '("above" "abs" "absdelay" "acos" "acosh" "ac_stim"
1938 "aliasparam" "analog" "analysis" "asin" "asinh" "atan" "atan2" "atanh"
1939 "branch" "ceil" "connectmodule" "connectrules" "cos" "cosh" "ddt"
1940 "ddx" "discipline" "driver_update" "enddiscipline" "endconnectrules"
1941 "endnature" "endparamset" "exclude" "exp" "final_step" "flicker_noise"
1942 "floor" "flow" "from" "ground" "hypot" "idt" "idtmod" "inf"
1943 "initial_step" "laplace_nd" "laplace_np" "laplace_zd" "laplace_zp"
1944 "last_crossing" "limexp" "ln" "log" "max" "min" "nature"
1945 "net_resolution" "noise_table" "paramset" "potential" "pow" "sin"
1946 "sinh" "slew" "sqrt" "tan" "tanh" "timer" "transition" "white_noise"
1947 "wreal" "zi_nd" "zi_np" "zi_zd" ) nil )))
1948
1949 (verilog-font-keywords
1950 (eval-when-compile
1951 (verilog-regexp-opt
1952 '(
1953 "assign" "begin" "case" "casex" "casez" "randcase" "deassign"
1954 "default" "disable" "else" "end" "endcase" "endfunction"
1955 "endgenerate" "endinterface" "endmodule" "endprimitive"
1956 "endspecify" "endtable" "endtask" "final" "for" "force" "return" "break"
1957 "continue" "forever" "fork" "function" "generate" "if" "iff" "initial"
1958 "interface" "join" "join_any" "join_none" "macromodule" "module" "negedge"
1959 "package" "endpackage" "always" "always_comb" "always_ff"
1960 "always_latch" "posedge" "primitive" "priority" "release"
1961 "repeat" "specify" "table" "task" "unique" "wait" "while"
1962 "class" "program" "endclass" "endprogram"
1963 ) nil ))))
1964
1965 (setq verilog-font-lock-keywords
1966 (list
1967 ;; Fontify all builtin keywords
1968 (concat "\\<\\(" verilog-font-keywords "\\|"
1969 ;; And user/system tasks and functions
1970 "\\$[a-zA-Z][a-zA-Z0-9_\\$]*"
1971 "\\)\\>")
1972 ;; Fontify all types
1973 (cons (concat "\\<\\(" verilog-type-font-keywords "\\)\\>")
1974 'font-lock-type-face)
1975 ;; Fontify IEEE-P1800 keywords appropriately
1976 (if verilog-highlight-p1800-keywords
1977 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>")
1978 'verilog-font-lock-p1800-face)
1979 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>")
1980 'font-lock-type-face))
1981 ;; Fontify Verilog-AMS keywords
1982 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>")
1983 'verilog-font-lock-ams-face)
1984 ))
1985
1986 (setq verilog-font-lock-keywords-1
1987 (append verilog-font-lock-keywords
1988 (list
1989 ;; Fontify module definitions
1990 (list
1991 "\\<\\(\\(macro\\)?module\\|primitive\\|class\\|program\\|interface\\|package\\|task\\)\\>\\s-*\\(\\sw+\\)"
1992 '(1 font-lock-keyword-face)
1993 '(3 font-lock-function-name-face 'prepend))
1994 ;; Fontify function definitions
1995 (list
1996 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" )
1997 '(1 font-lock-keyword-face)
1998 '(3 font-lock-reference-face prepend)
1999 )
2000 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)"
2001 (1 font-lock-keyword-face)
2002 (2 font-lock-reference-face append)
2003 )
2004 '("\\<function\\>\\s-+\\(\\sw+\\)"
2005 1 'font-lock-reference-face append)
2006 )))
2007
2008 (setq verilog-font-lock-keywords-2
2009 (append verilog-font-lock-keywords-1
2010 (list
2011 ;; Fontify pragmas
2012 (concat "\\(//\\s-*" verilog-pragma-keywords "\\s-.*\\)")
2013 ;; Fontify escaped names
2014 '("\\(\\\\\\S-*\\s-\\)" 0 font-lock-function-name-face)
2015 ;; Fontify macro definitions/ uses
2016 '("`\\s-*[A-Za-z][A-Za-z0-9_]*" 0 (if (boundp 'font-lock-preprocessor-face)
2017 'font-lock-preprocessor-face
2018 'font-lock-type-face))
2019 ;; Fontify delays/numbers
2020 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)"
2021 0 font-lock-type-face append)
2022 ;; Fontify instantiation names
2023 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face)
2024
2025 )))
2026
2027 (setq verilog-font-lock-keywords-3
2028 (append verilog-font-lock-keywords-2
2029 (when verilog-highlight-translate-off
2030 (list
2031 ;; Fontify things in translate off regions
2032 '(verilog-match-translate-off (0 'verilog-font-lock-translate-off-face prepend))
2033 )))
2034 )
2035 )
2036
2037
2038
2039(defun verilog-inside-comment-p ()
2040 "Check if point inside a nested comment."
2041 (save-excursion
2042 (let ((st-point (point)) hitbeg)
2043 (or (search-backward "//" (verilog-get-beg-of-line) t)
2044 (if (progn
2045 ;; This is for tricky case //*, we keep searching if /* is proceeded by // on same line
2046 (while (and (setq hitbeg (search-backward "/*" nil t))
2047 (progn (forward-char 1) (search-backward "//" (verilog-get-beg-of-line) t))))
2048 hitbeg)
2049 (not (search-forward "*/" st-point t)))))))
2050
2051(defun verilog-declaration-end ()
2052 (search-forward ";"))
2053
2054(defun verilog-point-text (&optional pointnum)
2055 "Return text describing where POINTNUM or current point is (for errors).
2056Use filename, if current buffer being edited shorten to just buffer name."
2057 (concat (or (and (equal (window-buffer (selected-window)) (current-buffer))
2058 (buffer-name))
2059 buffer-file-name
2060 (buffer-name))
2061 ":" (int-to-string (count-lines (point-min) (or pointnum (point))))))
2062
2063(defun electric-verilog-backward-sexp ()
2064 "Move backward over a sexp."
2065 (interactive)
2066 ;; before that see if we are in a comment
2067 (verilog-backward-sexp)
2068)
2069(defun electric-verilog-forward-sexp ()
2070 "Move backward over a sexp."
2071 (interactive)
2072 ;; before that see if we are in a comment
2073 (verilog-forward-sexp)
2074)
2075;;;used by hs-minor-mode
2076(defun verilog-forward-sexp-function (arg)
2077 (if (< arg 0)
2078 (verilog-backward-sexp)
2079 (verilog-forward-sexp)))
2080
2081
2082(defun verilog-backward-sexp ()
2083 (let ((reg)
2084 (elsec 1)
2085 (found nil)
2086 (st (point))
2087 )
2088 (if (not (looking-at "\\<"))
2089 (forward-word -1))
2090 (cond
2091 ((verilog-skip-backward-comment-or-string)
2092 )
2093 ((looking-at "\\<else\\>")
2094 (setq reg (concat
2095 verilog-end-block-re
2096 "\\|\\(\\<else\\>\\)"
2097 "\\|\\(\\<if\\>\\)"
2098 ))
2099 (while (and (not found)
2100 (verilog-re-search-backward reg nil 'move))
2101 (cond
2102 ((match-end 1) ; matched verilog-end-block-re
2103 ; try to leap back to matching outward block by striding across
2104 ; indent level changing tokens then immediately
2105 ; previous line governs indentation.
2106 (verilog-leap-to-head))
2107 ((match-end 2) ; else, we're in deep
2108 (setq elsec (1+ elsec)))
2109 ((match-end 3) ; found it
2110 (setq elsec (1- elsec))
2111 (if (= 0 elsec)
2112 ;; Now previous line describes syntax
2113 (setq found 't)
2114 ))
2115 )
2116 )
2117 )
2118 ((looking-at verilog-end-block-re)
2119 (verilog-leap-to-head))
2120 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)")
2121 (cond
2122 ((match-end 1)
2123 (verilog-re-search-backward "\\<\\(macro\\)?module\\>" nil 'move))
2124 ((match-end 2)
2125 (verilog-re-search-backward "\\<primitive\\>" nil 'move))
2126 ((match-end 3)
2127 (verilog-re-search-backward "\\<class\\>" nil 'move))
2128 ((match-end 4)
2129 (verilog-re-search-backward "\\<program\\>" nil 'move))
2130 ((match-end 5)
2131 (verilog-re-search-backward "\\<interface\\>" nil 'move))
2132 ((match-end 6)
2133 (verilog-re-search-backward "\\<package\\>" nil 'move))
2134 (t
2135 (goto-char st)
2136 (backward-sexp 1))))
2137 (t
2138 (goto-char st)
2139 (backward-sexp))
2140 ) ;; cond
2141 ))
2142
2143(defun verilog-forward-sexp ()
2144 (let ((reg)
2145 (md 2)
2146 (st (point)))
2147 (if (not (looking-at "\\<"))
2148 (forward-word -1))
2149 (cond
2150 ((verilog-skip-forward-comment-or-string)
2151 (verilog-forward-syntactic-ws)
2152 )
2153 ((looking-at verilog-beg-block-re-ordered);; begin|case|fork|class|table|specify|function|task|generate|covergroup|property|sequence|clocking
2154 (cond
2155 ((match-end 1) ; end
2156 ;; Search forward for matching begin
2157 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" ))
2158 ((match-end 2) ; endcase
2159 ;; Search forward for matching case
2160 (setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )
2161 )
2162 ((match-end 3) ; join
2163 ;; Search forward for matching fork
2164 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))
2165 ((match-end 4) ; endclass
2166 ;; Search forward for matching class
2167 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
2168 ((match-end 5) ; endtable
2169 ;; Search forward for matching table
2170 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" ))
2171 ((match-end 6) ; endspecify
2172 ;; Search forward for matching specify
2173 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" ))
2174 ((match-end 7) ; endfunction
2175 ;; Search forward for matching function
2176 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" ))
2177 ((match-end 8) ; endtask
2178 ;; Search forward for matching task
2179 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" ))
2180 ((match-end 9) ; endgenerate
2181 ;; Search forward for matching generate
2182 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" ))
2183 ((match-end 10) ; endgroup
2184 ;; Search forward for matching covergroup
2185 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))
2186 ((match-end 11) ; endproperty
2187 ;; Search forward for matching property
2188 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" ))
2189 ((match-end 12) ; endsequence
2190 ;; Search forward for matching sequence
2191 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )
2192 (setq md 3) ; 3 to get to endsequence in the reg above
2193 )
2194 ((match-end 13) ; endclocking
2195 ;; Search forward for matching clocking
2196 (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" ))
2197 )
2198 (if (forward-word 1)
2199 (catch 'skip
2200 (let ((nest 1))
2201 (while (verilog-re-search-forward reg nil 'move)
2202 (cond
2203 ((match-end md) ; the closer in reg, so we are climbing out
2204 (setq nest (1- nest))
2205 (if (= 0 nest) ; we are out!
2206 (throw 'skip 1)))
2207 ((match-end 1) ; the opener in reg, so we are deeper now
2208 (setq nest (1+ nest)))))
2209 )))
2210 )
2211 ((looking-at (concat
2212 "\\(\\<\\(macro\\)?module\\>\\)\\|"
2213 "\\(\\<primitive\\>\\)\\|"
2214 "\\(\\<class\\>\\)\\|"
2215 "\\(\\<program\\>\\)\\|"
2216 "\\(\\<interface\\>\\)\\|"
2217 "\\(\\<package\\>\\)"))
2218 (cond
2219 ((match-end 1)
2220 (verilog-re-search-forward "\\<endmodule\\>" nil 'move))
2221 ((match-end 2)
2222 (verilog-re-search-forward "\\<endprimitive\\>" nil 'move))
2223 ((match-end 3)
2224 (verilog-re-search-forward "\\<endclass\\>" nil 'move))
2225 ((match-end 4)
2226 (verilog-re-search-forward "\\<endprogram\\>" nil 'move))
2227 ((match-end 5)
2228 (verilog-re-search-forward "\\<endinterface\\>" nil 'move))
2229 ((match-end 6)
2230 (verilog-re-search-forward "\\<endpackage\\>" nil 'move))
2231 (t
2232 (goto-char st)
2233 (if (= (following-char) ?\) )
2234 (forward-char 1)
2235 (forward-sexp 1)))))
2236 (t
2237 (goto-char st)
2238 (if (= (following-char) ?\) )
2239 (forward-char 1)
2240 (forward-sexp 1)))
2241 ) ;; cond
2242 ))
2243
2244(defun verilog-declaration-beg ()
2245 (verilog-re-search-backward verilog-declaration-re (bobp) t))
2246
2247(require 'font-lock)
2248(defvar verilog-need-fld 1)
2249(defvar font-lock-defaults-alist nil) ;In case we are XEmacs
2250
2251(defun verilog-font-lock-init ()
2252 "Initialize fontification."
2253 ;; highlight keywords and standardized types, attributes, enumeration
2254 ;; values, and subprograms
2255 (setq verilog-font-lock-keywords-3
2256 (append verilog-font-lock-keywords-2
2257 (when verilog-highlight-translate-off
2258 (list
2259 ;; Fontify things in translate off regions
2260 '(verilog-match-translate-off (0 'verilog-font-lock-translate-off-face prepend))
2261 ))
2262 )
2263 )
2264 (put 'verilog-mode 'font-lock-defaults
2265 '((verilog-font-lock-keywords
2266 verilog-font-lock-keywords-1
2267 verilog-font-lock-keywords-2
2268 verilog-font-lock-keywords-3
2269 )
2270 nil ;; nil means highlight strings & comments as well as keywords
2271 nil ;; nil means keywords must match case
2272 nil ;; syntax table handled elsewhere
2273 verilog-beg-of-defun ;; function to move to beginning of reasonable region to highlight
2274 ))
2275 (if verilog-need-fld
2276 (let ((verilog-mode-defaults
2277 '((verilog-font-lock-keywords
2278 verilog-font-lock-keywords-1
2279 verilog-font-lock-keywords-2
2280 verilog-font-lock-keywords-3
2281 )
2282 nil ;; nil means highlight strings & comments as well as keywords
2283 nil ;; nil means keywords must match case
2284 nil ;; syntax table handled elsewhere
2285 verilog-beg-of-defun ;; function to move to beginning of reasonable region to highlight
2286 )))
2287 (setq font-lock-defaults-alist
2288 (append
2289 font-lock-defaults-alist
2290 (list (cons 'verilog-mode verilog-mode-defaults))))
2291 (setq verilog-need-fld 0))))
2292
2293;; initialize fontification for Verilog Mode
2294(verilog-font-lock-init)
2295;; start up message
2296(defconst verilog-startup-message-lines
2297 '("Please use \\[verilog-submit-bug-report] to report bugs."
2298 "Visit http://www.verilog.com to check for updates"
2299 ))
2300(defconst verilog-startup-message-displayed t)
2301(defun verilog-display-startup-message ()
2302 (if (not verilog-startup-message-displayed)
2303 (if (sit-for 5)
2304 (let ((lines verilog-startup-message-lines))
2305 (message "verilog-mode version %s, released %s; type \\[describe-mode] for help"
2306 verilog-mode-version verilog-mode-release-date)
2307 (setq verilog-startup-message-displayed t)
2308 (while (and (sit-for 4) lines)
2309 (message (substitute-command-keys (car lines)))
2310 (setq lines (cdr lines)))))
2311 (message "")))
2312;;
2313;;
2314;; Mode
2315;;
2316(defvar verilog-which-tool 1)
2317;;;###autoload
2318(defun verilog-mode ()
2319 "Major mode for editing Verilog code.
2320\\<verilog-mode-map>
2321See \\[describe-function] verilog-auto (\\[verilog-auto]) for details on how
2322AUTOs can improve coding efficiency.
2323
2324Use \\[verilog-faq] for a pointer to frequently asked questions.
2325
2326NEWLINE, TAB indents for Verilog code.
2327Delete converts tabs to spaces as it moves back.
2328
2329Supports highlighting.
2330
2331Turning on Verilog mode calls the value of the variable `verilog-mode-hook'
2332with no args, if that value is non-nil.
2333
2334Variables controlling indentation/edit style:
2335
2336 variable `verilog-indent-level' (default 3)
2337 Indentation of Verilog statements with respect to containing block.
2338 `verilog-indent-level-module' (default 3)
2339 Absolute indentation of Module level Verilog statements.
2340 Set to 0 to get initial and always statements lined up
2341 on the left side of your screen.
2342 `verilog-indent-level-declaration' (default 3)
2343 Indentation of declarations with respect to containing block.
2344 Set to 0 to get them list right under containing block.
2345 `verilog-indent-level-behavioral' (default 3)
2346 Indentation of first begin in a task or function block
2347 Set to 0 to get such code to lined up underneath the task or function keyword
2348 `verilog-indent-level-directive' (default 1)
2349 Indentation of `ifdef/`endif blocks
2350 `verilog-cexp-indent' (default 1)
2351 Indentation of Verilog statements broken across lines i.e.:
2352 if (a)
2353 begin
2354 `verilog-case-indent' (default 2)
2355 Indentation for case statements.
2356 `verilog-auto-newline' (default nil)
2357 Non-nil means automatically newline after semicolons and the punctuation
2358 mark after an end.
2359 `verilog-auto-indent-on-newline' (default t)
2360 Non-nil means automatically indent line after newline
2361 `verilog-tab-always-indent' (default t)
2362 Non-nil means TAB in Verilog mode should always reindent the current line,
2363 regardless of where in the line point is when the TAB command is used.
2364 `verilog-indent-begin-after-if' (default t)
2365 Non-nil means to indent begin statements following a preceding
2366 if, else, while, for and repeat statements, if any. otherwise,
2367 the begin is lined up with the preceding token. If t, you get:
2368 if (a)
2369 begin // amount of indent based on `verilog-cexp-indent'
2370 otherwise you get:
2371 if (a)
2372 begin
2373 `verilog-auto-endcomments' (default t)
2374 Non-nil means a comment /* ... */ is set after the ends which ends
2375 cases, tasks, functions and modules.
2376 The type and name of the object will be set between the braces.
2377 `verilog-minimum-comment-distance' (default 10)
2378 Minimum distance (in lines) between begin and end required before a comment
2379 will be inserted. Setting this variable to zero results in every
2380 end acquiring a comment; the default avoids too many redundant
2381 comments in tight quarters.
2382 `verilog-auto-lineup' (default `(all))
2383 List of contexts where auto lineup of code should be done.
2384
2385Variables controlling other actions:
2386
2387 `verilog-linter' (default surelint)
2388 Unix program to call to run the lint checker. This is the default
2389 command for \\[compile-command] and \\[verilog-auto-save-compile].
2390
2391See \\[customize] for the complete list of variables.
2392
2393AUTO expansion functions are, in part:
2394
2395 \\[verilog-auto] Expand AUTO statements.
2396 \\[verilog-delete-auto] Remove the AUTOs.
2397 \\[verilog-inject-auto] Insert AUTOs for the first time.
2398
2399Some other functions are:
2400
2401 \\[verilog-complete-word] Complete word with appropriate possibilities.
2402 \\[verilog-mark-defun] Mark function.
2403 \\[verilog-beg-of-defun] Move to beginning of current function.
2404 \\[verilog-end-of-defun] Move to end of current function.
2405 \\[verilog-label-be] Label matching begin ... end, fork ... join, etc statements.
2406
2407 \\[verilog-comment-region] Put marked area in a comment.
2408 \\[verilog-uncomment-region] Uncomment an area commented with \\[verilog-comment-region].
2409 \\[verilog-insert-block] Insert begin ... end;.
2410 \\[verilog-star-comment] Insert /* ... */.
2411
2412 \\[verilog-sk-always] Insert a always @(AS) begin .. end block.
2413 \\[verilog-sk-begin] Insert a begin .. end block.
2414 \\[verilog-sk-case] Insert a case block, prompting for details.
2415 \\[verilog-sk-for] Insert a for (...) begin .. end block, prompting for details.
2416 \\[verilog-sk-generate] Insert a generate .. endgenerate block.
2417 \\[verilog-sk-header] Insert a nice header block at the top of file.
2418 \\[verilog-sk-initial] Insert an initial begin .. end block.
2419 \\[verilog-sk-fork] Insert a fork begin .. end .. join block.
2420 \\[verilog-sk-module] Insert a module .. (/*AUTOARG*/);.. endmodule block.
2421 \\[verilog-sk-primitive] Insert a primitive .. (.. );.. endprimitive block.
2422 \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block.
2423 \\[verilog-sk-specify] Insert a specify .. endspecify block.
2424 \\[verilog-sk-task] Insert a task .. begin .. end endtask block.
2425 \\[verilog-sk-while] Insert a while (...) begin .. end block, prompting for details.
2426 \\[verilog-sk-casex] Insert a casex (...) item: begin.. end endcase block, prompting for details.
2427 \\[verilog-sk-casez] Insert a casez (...) item: begin.. end endcase block, prompting for details.
2428 \\[verilog-sk-if] Insert an if (..) begin .. end block.
2429 \\[verilog-sk-else-if] Insert an else if (..) begin .. end block.
2430 \\[verilog-sk-comment] Insert a comment block.
2431 \\[verilog-sk-assign] Insert an assign .. = ..; statement.
2432 \\[verilog-sk-function] Insert a function .. begin .. end endfunction block.
2433 \\[verilog-sk-input] Insert an input declaration, prompting for details.
2434 \\[verilog-sk-output] Insert an output declaration, prompting for details.
2435 \\[verilog-sk-state-machine] Insert a state machine definition, prompting for details.
2436 \\[verilog-sk-inout] Insert an inout declaration, prompting for details.
2437 \\[verilog-sk-wire] Insert a wire declaration, prompting for details.
2438 \\[verilog-sk-reg] Insert a register declaration, prompting for details.
2439 \\[verilog-sk-define-signal] Define signal under point as a register at the top of the module.
2440
2441All key bindings can be seen in a Verilog-buffer with \\[describe-bindings].
2442Key bindings specific to `verilog-mode-map' are:
2443
2444\\{verilog-mode-map}"
2445 (interactive)
2446 (kill-all-local-variables)
2447 (use-local-map verilog-mode-map)
2448 (setq major-mode 'verilog-mode)
2449 (setq mode-name "Verilog")
2450 (setq local-abbrev-table verilog-mode-abbrev-table)
2451 (setq verilog-mode-syntax-table (make-syntax-table))
2452 (verilog-populate-syntax-table verilog-mode-syntax-table)
2453 (set (make-local-variable 'beginning-of-defun-function)
2454 'verilog-beg-of-defun)
2455 (set (make-local-variable 'end-of-defun-function)
2456 'verilog-end-of-defun)
2457 ;; add extra comment syntax
2458 (verilog-setup-dual-comments verilog-mode-syntax-table)
2459 (set-syntax-table verilog-mode-syntax-table)
2460 (make-local-variable 'indent-line-function)
2461 (setq indent-line-function 'verilog-indent-line-relative)
2462 (setq comment-indent-function 'verilog-comment-indent)
2463 (make-local-variable 'parse-sexp-ignore-comments)
2464 (setq parse-sexp-ignore-comments nil)
2465 (make-local-variable 'comment-start)
2466 (make-local-variable 'comment-end)
2467 (make-local-variable 'comment-multi-line)
2468 (make-local-variable 'comment-start-skip)
2469 (setq comment-start "// "
2470 comment-end ""
2471 comment-start-skip "/\\*+ *\\|// *"
2472 comment-multi-line nil)
2473 ;; Set up for compilation
2474 (setq verilog-which-tool 1)
2475 (setq verilog-tool 'verilog-linter)
2476 (verilog-set-compile-command)
2477 (when (boundp 'hack-local-variables-hook) ;; Also modify any file-local-variables
2478 (add-hook 'hack-local-variables-hook 'verilog-modify-compile-command t))
2479
2480 ;; Setting up menus
2481 (when (featurep 'xemacs)
2482 (when (and current-menubar
2483 (not (assoc "Verilog" current-menubar)))
2484 ;; (set-buffer-menubar (copy-sequence current-menubar))
2485 (add-submenu nil verilog-xemacs-menu)
2486 (add-submenu nil verilog-stmt-menu)
2487 ))
2488 ;; Stuff for GNU emacs
2489 (make-local-variable 'font-lock-defaults)
2490 ;;------------------------------------------------------------
2491 ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el)
2492 ;; all buffer local:
2493 (make-local-hook 'font-lock-mode-hook)
2494 (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20
2495 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t)
2496 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20
2497 (make-local-hook 'after-change-functions)
2498 (add-hook 'after-change-functions 'verilog-colorize-include-files t t)
2499
2500 ;; Tell imenu how to handle verilog.
2501 (make-local-variable 'imenu-generic-expression)
2502 (setq imenu-generic-expression verilog-imenu-generic-expression)
2503 ;; hideshow support
2504 (unless (assq 'verilog-mode hs-special-modes-alist)
2505 (setq hs-special-modes-alist
2506 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil
2507 verilog-forward-sexp-function)
2508 hs-special-modes-alist)))
2509 ;; Display version splash information.
2510 (verilog-display-startup-message)
2511
2512 ;; Stuff for autos
2513 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local
2514;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them
2515;; (verilog-getopt-flags)
2516 (run-hooks 'verilog-mode-hook))
2517
2518
2519;;
2520;; Electric functions
2521;;
2522(defun electric-verilog-terminate-line (&optional arg)
2523 "Terminate line and indent next line.
2524With optional ARG, remove existing end of line comments."
2525 (interactive)
2526 ;; before that see if we are in a comment
2527 (let ((state
2528 (save-excursion
2529 (parse-partial-sexp (point-min) (point)))))
2530 (cond
2531 ((nth 7 state) ; Inside // comment
2532 (if (eolp)
2533 (progn
2534 (delete-horizontal-space)
2535 (newline))
2536 (progn
2537 (newline)
2538 (insert-string "// ")
2539 (beginning-of-line)))
2540 (verilog-indent-line))
2541 ((nth 4 state) ; Inside any comment (hence /**/)
2542 (newline)
2543 (verilog-more-comment))
2544 ((eolp)
2545 ;; First, check if current line should be indented
2546 (if (save-excursion
2547 (delete-horizontal-space)
2548 (beginning-of-line)
2549 (skip-chars-forward " \t")
2550 (if (looking-at verilog-auto-end-comment-lines-re)
2551 (let ((indent-str (verilog-indent-line)))
2552 ;; Maybe we should set some endcomments
2553 (if verilog-auto-endcomments
2554 (verilog-set-auto-endcomments indent-str arg))
2555 (end-of-line)
2556 (delete-horizontal-space)
2557 (if arg
2558 ()
2559 (newline))
2560 nil)
2561 (progn
2562 (end-of-line)
2563 (delete-horizontal-space)
2564 't
2565 )
2566 )
2567 )
2568 ;; see if we should line up assignments
2569 (progn
2570 (if (or (memq 'all verilog-auto-lineup)
2571 (memq 'assignments verilog-auto-lineup))
2572 (verilog-pretty-expr)
2573 )
2574 (newline)
2575 )
2576 (forward-line 1)
2577 )
2578 ;; Indent next line
2579 (if verilog-auto-indent-on-newline
2580 (verilog-indent-line))
2581 )
2582 (t
2583 (newline))
2584 )))
2585
2586(defun electric-verilog-terminate-and-indent ()
2587 "Insert a newline and indent for the next statement."
2588 (interactive)
2589 (electric-verilog-terminate-line 1))
2590
2591(defun electric-verilog-semi ()
2592 "Insert `;' character and reindent the line."
2593 (interactive)
2594 (insert last-command-char)
2595
2596 (if (or (verilog-in-comment-or-string-p)
2597 (verilog-in-escaped-name-p))
2598 ()
2599 (save-excursion
2600 (beginning-of-line)
2601 (verilog-forward-ws&directives)
2602 (verilog-indent-line)
2603 )
2604 (if (and verilog-auto-newline
2605 (not (verilog-parenthesis-depth)))
2606 (electric-verilog-terminate-line))))
2607
2608(defun electric-verilog-semi-with-comment ()
2609 "Insert `;' character, reindent the line and indent for comment."
2610 (interactive)
2611 (insert "\;")
2612 (save-excursion
2613 (beginning-of-line)
2614 (verilog-indent-line))
2615 (indent-for-comment))
2616
2617(defun electric-verilog-colon ()
2618 "Insert `:' and do all indentations except line indent on this line."
2619 (interactive)
2620 (insert last-command-char)
2621 ;; Do nothing if within string.
2622 (if (or
2623 (verilog-within-string)
2624 (not (verilog-in-case-region-p)))
2625 ()
2626 (save-excursion
2627 (let ((p (point))
2628 (lim (progn (verilog-beg-of-statement) (point))))
2629 (goto-char p)
2630 (verilog-backward-case-item lim)
2631 (verilog-indent-line)))
2632;; (let ((verilog-tab-always-indent nil))
2633;; (verilog-indent-line))
2634 ))
2635
2636;;(defun electric-verilog-equal ()
2637;; "Insert `=', and do indentation if within block."
2638;; (interactive)
2639;; (insert last-command-char)
2640;; Could auto line up expressions, but not yet
2641;; (if (eq (car (verilog-calculate-indent)) 'block)
2642;; (let ((verilog-tab-always-indent nil))
2643;; (verilog-indent-command)))
2644;; )
2645
2646(defun electric-verilog-tick ()
2647 "Insert back-tick, and indent to column 0 if this is a CPP directive."
2648 (interactive)
2649 (insert last-command-char)
2650 (save-excursion
2651 (if (progn
2652 (beginning-of-line)
2653 (looking-at verilog-directive-re-1))
2654 (verilog-indent-line))))
2655
2656(defun electric-verilog-tab ()
2657 "Function called when TAB is pressed in Verilog mode."
2658 (interactive)
2659 ;; If verilog-tab-always-indent, indent the beginning of the line.
2660 (if (or verilog-tab-always-indent
2661 (save-excursion
2662 (skip-chars-backward " \t")
2663 (bolp)))
2664 (let* ((oldpnt (point))
2665 (boi-point
2666 (save-excursion
2667 (beginning-of-line)
2668 (skip-chars-forward " \t")
2669 (verilog-indent-line)
2670 (back-to-indentation)
2671 (point))))
2672 (if (< (point) boi-point)
2673 (back-to-indentation)
2674 (cond ((not verilog-tab-to-comment))
2675 ((not (eolp))
2676 (end-of-line))
2677 (t
2678 (indent-for-comment)
2679 (when (and (eolp) (= oldpnt (point)))
2680 ; kill existing comment
2681 (beginning-of-line)
2682 (re-search-forward comment-start-skip oldpnt 'move)
2683 (goto-char (match-beginning 0))
2684 (skip-chars-backward " \t")
2685 (kill-region (point) oldpnt)
2686 ))))
2687 )
2688 (progn (insert "\t"))))
2689
2690
2691
2692;;
2693;; Interactive functions
2694;;
2695
2696(defun verilog-indent-buffer ()
2697 "Indent-region the entire buffer as Verilog code.
2698To call this from the command line, see \\[verilog-batch-indent]."
2699 (interactive)
2700 (verilog-mode)
2701 (indent-region (point-min) (point-max) nil))
2702
2703(defun verilog-insert-block ()
2704 "Insert Verilog begin ... end; block in the code with right indentation."
2705 (interactive)
2706 (verilog-indent-line)
2707 (insert "begin")
2708 (electric-verilog-terminate-line)
2709 (save-excursion
2710 (electric-verilog-terminate-line)
2711 (insert "end")
2712 (beginning-of-line)
2713 (verilog-indent-line)))
2714
2715(defun verilog-star-comment ()
2716 "Insert Verilog star comment at point."
2717 (interactive)
2718 (verilog-indent-line)
2719 (insert "/*")
2720 (save-excursion
2721 (newline)
2722 (insert " */"))
2723 (newline)
2724 (insert " * "))
2725
2726(defun verilog-insert-indices (MAX)
2727 "Insert a set of indices at into the rectangle.
2728The upper left corner is defined by the current point. Indices always
2729begin with 0 and extend to the MAX - 1. If no prefix arg is given, the
2730user is prompted for a value. The indices are surrounded by square brackets
2731\[]. For example, the following code with the point located after the first
2732'a' gives:
2733
2734 a = b a[ 0] = b
2735 a = b a[ 1] = b
2736 a = b a[ 2] = b
2737 a = b a[ 3] = b
2738 a = b ==> insert-indices ==> a[ 4] = b
2739 a = b a[ 5] = b
2740 a = b a[ 6] = b
2741 a = b a[ 7] = b
2742 a = b a[ 8] = b"
2743
2744 (interactive "NMAX?")
2745 (save-excursion
2746 (let ((n 0))
2747 (while (< n MAX)
2748 (save-excursion
2749 (insert (format "[%3d]" n)))
2750 (next-line 1)
2751 (setq n (1+ n))))))
2752
2753
2754(defun verilog-generate-numbers (MAX)
2755 "Insert a set of generated numbers into a rectangle.
2756The upper left corner is defined by point. The numbers are padded to three
2757digits, starting with 000 and extending to (MAX - 1). If no prefix argument
2758is supplied, then the user is prompted for the MAX number. consider the
2759following code fragment:
2760
2761 buf buf buf buf000
2762 buf buf buf buf001
2763 buf buf buf buf002
2764 buf buf buf buf003
2765 buf buf ==> insert-indices ==> buf buf004
2766 buf buf buf buf005
2767 buf buf buf buf006
2768 buf buf buf buf007
2769 buf buf buf buf008"
2770
2771 (interactive "NMAX?")
2772 (save-excursion
2773 (let ((n 0))
2774 (while (< n MAX)
2775 (save-excursion
2776 (insert (format "%3.3d" n)))
2777 (next-line 1)
2778 (setq n (1+ n))))))
2779
2780(defun verilog-mark-defun ()
2781 "Mark the current verilog function (or procedure).
2782This puts the mark at the end, and point at the beginning."
2783 (interactive)
2784 (push-mark (point))
2785 (verilog-end-of-defun)
2786 (push-mark (point))
2787 (verilog-beg-of-defun)
2788 (zmacs-activate-region))
2789
2790(defun verilog-comment-region (start end)
2791 ; checkdoc-params: (start end)
2792 "Put the region into a Verilog comment.
2793The comments that are in this area are \"deformed\":
2794`*)' becomes `!(*' and `}' becomes `!{'.
2795These deformed comments are returned to normal if you use
2796\\[verilog-uncomment-region] to undo the commenting.
2797
2798The commented area starts with `verilog-exclude-str-start', and ends with
2799`verilog-exclude-str-end'. But if you change these variables,
2800\\[verilog-uncomment-region] won't recognize the comments."
2801 (interactive "r")
2802 (save-excursion
2803 ;; Insert start and endcomments
2804 (goto-char end)
2805 (if (and (save-excursion (skip-chars-forward " \t") (eolp))
2806 (not (save-excursion (skip-chars-backward " \t") (bolp))))
2807 (forward-line 1)
2808 (beginning-of-line))
2809 (insert verilog-exclude-str-end)
2810 (setq end (point))
2811 (newline)
2812 (goto-char start)
2813 (beginning-of-line)
2814 (insert verilog-exclude-str-start)
2815 (newline)
2816 ;; Replace end-comments within commented area
2817 (goto-char end)
2818 (save-excursion
2819 (while (re-search-backward "\\*/" start t)
2820 (replace-match "*-/" t t)))
2821 (save-excursion
2822 (let ((s+1 (1+ start)))
2823 (while (re-search-backward "/\\*" s+1 t)
2824 (replace-match "/-*" t t))))
2825 ))
2826
2827(defun verilog-uncomment-region ()
2828 "Uncomment a commented area; change deformed comments back to normal.
2829This command does nothing if the pointer is not in a commented
2830area. See also `verilog-comment-region'."
2831 (interactive)
2832 (save-excursion
2833 (let ((start (point))
2834 (end (point)))
2835 ;; Find the boundaries of the comment
2836 (save-excursion
2837 (setq start (progn (search-backward verilog-exclude-str-start nil t)
2838 (point)))
2839 (setq end (progn (search-forward verilog-exclude-str-end nil t)
2840 (point))))
2841 ;; Check if we're really inside a comment
2842 (if (or (equal start (point)) (<= end (point)))
2843 (message "Not standing within commented area.")
2844 (progn
2845 ;; Remove endcomment
2846 (goto-char end)
2847 (beginning-of-line)
2848 (let ((pos (point)))
2849 (end-of-line)
2850 (delete-region pos (1+ (point))))
2851 ;; Change comments back to normal
2852 (save-excursion
2853 (while (re-search-backward "\\*-/" start t)
2854 (replace-match "*/" t t)))
2855 (save-excursion
2856 (while (re-search-backward "/-\\*" start t)
2857 (replace-match "/*" t t)))
2858 ;; Remove start comment
2859 (goto-char start)
2860 (beginning-of-line)
2861 (let ((pos (point)))
2862 (end-of-line)
2863 (delete-region pos (1+ (point)))))))))
2864
2865(defun verilog-beg-of-defun ()
2866 "Move backward to the beginning of the current function or procedure."
2867 (interactive)
2868 (verilog-re-search-backward verilog-defun-re nil 'move))
2869
2870(defun verilog-end-of-defun ()
2871 "Move forward to the end of the current function or procedure."
2872 (interactive)
2873 (verilog-re-search-forward verilog-end-defun-re nil 'move))
2874
2875(defun verilog-get-beg-of-defun (&optional warn)
2876 (save-excursion
2877 (cond ((verilog-re-search-forward-quick verilog-defun-re nil t)
2878 (point))
2879 (t
2880 (error "%s: Can't find module beginning" (verilog-point-text))
2881 (point-max)))))
2882(defun verilog-get-end-of-defun (&optional warn)
2883 (save-excursion
2884 (cond ((verilog-re-search-forward-quick verilog-end-defun-re nil t)
2885 (point))
2886 (t
2887 (error "%s: Can't find endmodule" (verilog-point-text))
2888 (point-max)))))
2889
2890(defun verilog-label-be (&optional arg)
2891 "Label matching begin ... end, fork ... join and case ... endcase statements.
2892With ARG, first kill any existing labels."
2893 (interactive)
2894 (let ((cnt 0)
2895 (oldpos (point))
2896 (b (progn
2897 (verilog-beg-of-defun)
2898 (point-marker)))
2899 (e (progn
2900 (verilog-end-of-defun)
2901 (point-marker)))
2902 )
2903 (goto-char (marker-position b))
2904 (if (> (- e b) 200)
2905 (message "Relabeling module..."))
2906 (while (and
2907 (> (marker-position e) (point))
2908 (verilog-re-search-forward
2909 (concat
2910 "\\<end\\(\\(function\\)\\|\\(task\\)\\|\\(module\\)\\|\\(primitive\\)\\|\\(interface\\)\\|\\(package\\)\\|\\(case\\)\\)?\\>"
2911 "\\|\\(`endif\\)\\|\\(`else\\)")
2912 nil 'move))
2913 (goto-char (match-beginning 0))
2914 (let ((indent-str (verilog-indent-line)))
2915 (verilog-set-auto-endcomments indent-str 't)
2916 (end-of-line)
2917 (delete-horizontal-space)
2918 )
2919 (setq cnt (1+ cnt))
2920 (if (= 9 (% cnt 10))
2921 (message "%d..." cnt))
2922 )
2923 (goto-char oldpos)
2924 (if (or
2925 (> (- e b) 200)
2926 (> cnt 20))
2927 (message "%d lines auto commented" cnt))
2928 ))
2929
2930(defun verilog-beg-of-statement ()
2931 "Move backward to beginning of statement."
2932 (interactive)
2933 ;; Move back token by token until we see the end
2934 ;; of some ealier line.
2935 (while
2936 ;; If the current point does not begin a new
2937 ;; statement, as in the character ahead of us is a ';', or SOF
2938 ;; or the string after us unambiguosly starts a statement,
2939 ;; or the token before us unambiguously ends a statement,
2940 ;; then move back a token and test again.
2941 (not (or
2942 (bolp)
2943 (= (preceding-char) ?\;)
2944 (not (or
2945 (looking-at "\\<")
2946 (forward-word -1)))
2947 (and
2948 (looking-at verilog-extended-complete-re)
2949 (not (save-excursion
2950 (verilog-backward-token)
2951 (looking-at verilog-extended-complete-re)))
2952 )
2953 (looking-at verilog-basic-complete-re)
2954 (save-excursion
2955 (verilog-backward-token)
2956 (or
2957 (looking-at verilog-end-block-re)
2958 (looking-at verilog-preprocessor-re)))
2959 ))
2960 (verilog-backward-syntactic-ws)
2961 (verilog-backward-token))
2962 ;; Now point is where the previous line ended.
2963 (verilog-forward-syntactic-ws))
2964
2965(defun verilog-beg-of-statement-1 ()
2966 "Move backward to beginning of statement."
2967 (interactive)
2968 (let ((pt (point)))
2969
2970 (while (and (not (looking-at verilog-complete-reg))
2971 (setq pt (point))
2972 (verilog-backward-token)
2973 (not (looking-at verilog-complete-reg))
2974 (verilog-backward-syntactic-ws)
2975 (setq pt (point))
2976 (not (bolp))
2977 (not (= (preceding-char) ?\;))))
2978 (goto-char pt)
2979 (verilog-forward-ws&directives)))
2980
2981(defun verilog-end-of-statement ()
2982 "Move forward to end of current statement."
2983 (interactive)
2984 (let ((nest 0) pos)
2985 (or (looking-at verilog-beg-block-re)
2986 ;; Skip to end of statement
2987 (setq pos (catch 'found
2988 (while t
2989 (forward-sexp 1)
2990 (verilog-skip-forward-comment-or-string)
2991 (cond ((looking-at "[ \t]*;")
2992 (skip-chars-forward "^;")
2993 (forward-char 1)
2994 (throw 'found (point)))
2995 ((save-excursion
2996 (forward-sexp -1)
2997 (looking-at verilog-beg-block-re))
2998 (goto-char (match-beginning 0))
2999 (throw 'found nil))
3000 ((looking-at "[ \t]*)")
3001 (throw 'found (point)))
3002 ((eobp)
3003 (throw 'found (point))))))))
3004 (if (not pos)
3005 ;; Skip a whole block
3006 (catch 'found
3007 (while t
3008 (verilog-re-search-forward verilog-end-statement-re nil 'move)
3009 (setq nest (if (match-end 1)
3010 (1+ nest)
3011 (1- nest)))
3012 (cond ((eobp)
3013 (throw 'found (point)))
3014 ((= 0 nest)
3015 (throw 'found (verilog-end-of-statement))))))
3016 pos)))
3017
3018(defun verilog-in-case-region-p ()
3019 "Return TRUE if in a case region;
3020more specifically, point @ in the line foo : @ begin"
3021 (interactive)
3022 (save-excursion
3023 (if (and
3024 (progn (verilog-forward-syntactic-ws)
3025 (looking-at "\\<begin\\>"))
3026 (progn (verilog-backward-syntactic-ws)
3027 (= (preceding-char) ?\:)))
3028 (catch 'found
3029 (let ((nest 1))
3030 (while t
3031 (verilog-re-search-backward
3032 (concat "\\(\\<module\\>\\)\\|\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|"
3033 "\\(\\<endcase\\>\\)\\>")
3034 nil 'move)
3035 (cond
3036 ((match-end 3)
3037 (setq nest (1+ nest)))
3038 ((match-end 2)
3039 (if (= nest 1)
3040 (throw 'found 1))
3041 (setq nest (1- nest)))
3042 (t
3043 (throw 'found (= nest 0)))
3044 ))))
3045 nil)))
3046(defun verilog-in-struct-region-p ()
3047 "Return TRUE if in a struct region;
3048more specifically, in a list after a struct|union keyword"
3049 (interactive)
3050 (save-excursion
3051 (let* ((state (parse-partial-sexp (point-min) (point)))
3052 (depth (nth 0 state)))
3053 (if depth
3054 (progn (backward-up-list depth)
3055 (verilog-beg-of-statement)
3056 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>")
3057 )
3058 )
3059 )
3060 )
3061 )
3062
3063(defun verilog-in-generate-region-p ()
3064 "Return TRUE if in a generate region;
3065more specifically, after a generate and before an endgenerate"
3066 (interactive)
3067 (let ((lim (save-excursion (verilog-beg-of-defun) (point)))
3068 (nest 1)
3069 )
3070 (save-excursion
3071 (while (and
3072 (/= nest 0)
3073 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move)
3074 (cond
3075 ((match-end 1) ; generate
3076 (setq nest (1- nest)))
3077 ((match-end 2) ; endgenerate
3078 (setq nest (1+ nest)))
3079 ))
3080 ))
3081 (= nest 0) )) ; return nest
3082
3083(defun verilog-in-fork-region-p ()
3084 "Return true if between a fork and join."
3085 (interactive)
3086 (let ((lim (save-excursion (verilog-beg-of-defun) (point)))
3087 (nest 1)
3088 )
3089 (save-excursion
3090 (while (and
3091 (/= nest 0)
3092 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move)
3093 (cond
3094 ((match-end 1) ; fork
3095 (setq nest (1- nest)))
3096 ((match-end 2) ; join
3097 (setq nest (1+ nest)))
3098 ))
3099 ))
3100 (= nest 0) )) ; return nest
3101
3102(defun verilog-backward-case-item (lim)
3103 "Skip backward to nearest enclosing case item.
3104Limit search to point LIM."
3105 (interactive)
3106 (let ((str 'nil)
3107 (lim1
3108 (progn
3109 (save-excursion
3110 (verilog-re-search-backward verilog-endcomment-reason-re
3111 lim 'move)
3112 (point)))))
3113 ;; Try to find the real :
3114 (if (save-excursion (search-backward ":" lim1 t))
3115 (let ((colon 0)
3116 b e )
3117 (while
3118 (and
3119 (< colon 1)
3120 (verilog-re-search-backward "\\(\\[\\)\\|\\(\\]\\)\\|\\(:\\)"
3121 lim1 'move))
3122 (cond
3123 ((match-end 1) ;; [
3124 (setq colon (1+ colon))
3125 (if (>= colon 0)
3126 (error "%s: unbalanced [" (verilog-point-text))))
3127 ((match-end 2) ;; ]
3128 (setq colon (1- colon)))
3129
3130 ((match-end 3) ;; :
3131 (setq colon (1+ colon)))
3132 ))
3133 ;; Skip back to beginning of case item
3134 (skip-chars-backward "\t ")
3135 (verilog-skip-backward-comment-or-string)
3136 (setq e (point))
3137 (setq b
3138 (progn
3139 (if
3140 (verilog-re-search-backward
3141 "\\<\\(case[zx]?\\)\\>\\|;\\|\\<end\\>" nil 'move)
3142 (progn
3143 (cond
3144 ((match-end 1)
3145 (goto-char (match-end 1))
3146 (verilog-forward-ws&directives)
3147 (if (looking-at "(")
3148 (progn
3149 (forward-sexp)
3150 (verilog-forward-ws&directives)))
3151 (point))
3152 (t
3153 (goto-char (match-end 0))
3154 (verilog-forward-ws&directives)
3155 (point))
3156 ))
3157 (error "Malformed case item")
3158 )))
3159 (setq str (buffer-substring b e))
3160 (if
3161 (setq e
3162 (string-match
3163 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str))
3164 (setq str (concat (substring str 0 e) "...")))
3165 str)
3166 'nil)))
3167
3168
3169;;
3170;; Other functions
3171;;
3172
3173(defun verilog-kill-existing-comment ()
3174 "Kill auto comment on this line."
3175 (save-excursion
3176 (let* (
3177 (e (progn
3178 (end-of-line)
3179 (point)))
3180 (b (progn
3181 (beginning-of-line)
3182 (search-forward "//" e t))))
3183 (if b
3184 (delete-region (- b 2) e)))))
3185
3186(defconst verilog-directive-nest-re
3187 (concat "\\(`else\\>\\)\\|"
3188 "\\(`endif\\>\\)\\|"
3189 "\\(`if\\>\\)\\|"
3190 "\\(`ifdef\\>\\)\\|"
3191 "\\(`ifndef\\>\\)"))
3192(defun verilog-set-auto-endcomments (indent-str kill-existing-comment)
3193 "Add ending comment with given INDENT-STR.
3194With KILL-EXISTING-COMMENT, remove what was there before.
3195Insert `// case: 7 ' or `// NAME ' on this line if appropriate.
3196Insert `// case expr ' if this line ends a case block.
3197Insert `// ifdef FOO ' if this line ends code conditional on FOO.
3198Insert `// NAME ' if this line ends a function, task, module, primitive or interface named NAME."
3199 (save-excursion
3200 (cond
3201 (; Comment close preprocessor directives
3202 (and
3203 (looking-at "\\(`endif\\)\\|\\(`else\\)")
3204 (or kill-existing-comment
3205 (not (save-excursion
3206 (end-of-line)
3207 (search-backward "//" (verilog-get-beg-of-line) t)))))
3208 (let ((nest 1) b e
3209 m
3210 (else (if (match-end 2) "!" " "))
3211 )
3212 (end-of-line)
3213 (if kill-existing-comment
3214 (verilog-kill-existing-comment))
3215 (delete-horizontal-space)
3216 (save-excursion
3217 (backward-sexp 1)
3218 (while (and (/= nest 0)
3219 (verilog-re-search-backward verilog-directive-nest-re nil 'move))
3220 (cond
3221 ((match-end 1) ; `else
3222 (if (= nest 1)
3223 (setq else "!")))
3224 ((match-end 2) ; `endif
3225 (setq nest (1+ nest)))
3226 ((match-end 3) ; `if
3227 (setq nest (1- nest)))
3228 ((match-end 4) ; `ifdef
3229 (setq nest (1- nest)))
3230 ((match-end 5) ; `ifndef
3231 (setq nest (1- nest)))
3232 ))
3233 (if (match-end 0)
3234 (setq
3235 m (buffer-substring
3236 (match-beginning 0)
3237 (match-end 0))
3238 b (progn
3239 (skip-chars-forward "^ \t")
3240 (verilog-forward-syntactic-ws)
3241 (point))
3242 e (progn
3243 (skip-chars-forward "a-zA-Z0-9_")
3244 (point)
3245 ))))
3246 (if b
3247 (if (> (count-lines (point) b) verilog-minimum-comment-distance)
3248 (insert (concat " // " else m " " (buffer-substring b e))))
3249 (progn
3250 (insert " // unmatched `else or `endif")
3251 (ding 't))
3252 )))
3253
3254 (; Comment close case/class/function/task/module and named block
3255 (and (looking-at "\\<end")
3256 (or kill-existing-comment
3257 (not (save-excursion
3258 (end-of-line)
3259 (search-backward "//" (verilog-get-beg-of-line) t)))))
3260 (let ((type (car indent-str)))
3261 (unless (eq type 'declaration)
3262 (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ;; ignore named ends
3263 (if (looking-at verilog-end-block-ordered-re)
3264 (cond
3265 (;- This is a case block; search back for the start of this case
3266 (match-end 1) ;; of verilog-end-block-ordered-re
3267
3268 (let ((err 't)
3269 (str "UNMATCHED!!"))
3270 (save-excursion
3271 (verilog-leap-to-head)
3272 (cond
3273 ((looking-at "\\<randcase\\>")
3274 (setq str "randcase")
3275 (setq err nil)
3276 )
3277 ((match-end 0)
3278 (goto-char (match-end 1))
3279 (if nil
3280 (let (s f)
3281 (setq s (match-beginning 1))
3282 (setq f (progn (end-of-line)
3283 (point)))
3284 (setq str (buffer-substring s f)))
3285 (setq err nil))
3286 (setq str (concat (buffer-substring (match-beginning 1) (match-end 1))
3287 " "
3288 (verilog-get-expr))))))
3289 (end-of-line)
3290 (if kill-existing-comment
3291 (verilog-kill-existing-comment))
3292 (delete-horizontal-space)
3293 (insert (concat " // " str ))
3294 (if err (ding 't))
3295 ))
3296
3297 (;- This is a begin..end block
3298 (match-end 2) ;; of verilog-end-block-ordered-re
3299 (let ((str " // UNMATCHED !!")
3300 (err 't)
3301 (here (point))
3302 there
3303 cntx
3304 )
3305 (save-excursion
3306 (verilog-leap-to-head)
3307 (setq there (point))
3308 (if (not (match-end 0))
3309 (progn
3310 (goto-char here)
3311 (end-of-line)
3312 (if kill-existing-comment
3313 (verilog-kill-existing-comment))
3314 (delete-horizontal-space)
3315 (insert str)
3316 (ding 't)
3317 )
3318 (let ((lim
3319 (save-excursion (verilog-beg-of-defun) (point)))
3320 (here (point))
3321 )
3322 (cond
3323 (;-- handle named block differently
3324 (looking-at verilog-named-block-re)
3325 (search-forward ":")
3326 (setq there (point))
3327 (setq str (verilog-get-expr))
3328 (setq err nil)
3329 (setq str (concat " // block: " str )))
3330
3331 ((verilog-in-case-region-p) ;-- handle case item differently
3332 (goto-char here)
3333 (setq str (verilog-backward-case-item lim))
3334 (setq there (point))
3335 (setq err nil)
3336 (setq str (concat " // case: " str )))
3337
3338 (;- try to find "reason" for this begin
3339 (cond
3340 (;
3341 (eq here (progn
3342 (verilog-backward-token)
3343 (verilog-beg-of-statement-1)
3344 (point)))
3345 (setq err nil)
3346 (setq str ""))
3347 ((looking-at verilog-endcomment-reason-re)
3348 (setq there (match-end 0))
3349 (setq cntx (concat
3350 (buffer-substring (match-beginning 0) (match-end 0)) " "))
3351 (cond
3352 (;- begin
3353 (match-end 2)
3354 (setq err nil)
3355 (save-excursion
3356 (if (and (verilog-continued-line)
3357 (looking-at "\\<repeat\\>\\|\\<wait\\>\\|\\<always\\>"))
3358 (progn
3359 (goto-char (match-end 0))
3360 (setq there (point))
3361 (setq str
3362 (concat " // "
3363 (buffer-substring (match-beginning 0) (match-end 0)) " "
3364 (verilog-get-expr))))
3365 (setq str ""))))
3366
3367 (;- else
3368 (match-end 4)
3369 (let ((nest 0)
3370 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")
3371 )
3372 (catch 'skip
3373 (while (verilog-re-search-backward reg nil 'move)
3374 (cond
3375 ((match-end 1) ; begin
3376 (setq nest (1- nest)))
3377 ((match-end 2) ; end
3378 (setq nest (1+ nest)))
3379 ((match-end 3)
3380 (if (= 0 nest)
3381 (progn
3382 (goto-char (match-end 0))
3383 (setq there (point))
3384 (setq err nil)
3385 (setq str (verilog-get-expr))
3386 (setq str (concat " // else: !if" str ))
3387 (throw 'skip 1))
3388 )))
3389 ))))
3390
3391 (;- end else
3392 (match-end 5)
3393 (goto-char there)
3394 (let ((nest 0)
3395 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")
3396 )
3397 (catch 'skip
3398 (while (verilog-re-search-backward reg nil 'move)
3399 (cond
3400 ((match-end 1) ; begin
3401 (setq nest (1- nest)))
3402 ((match-end 2) ; end
3403 (setq nest (1+ nest)))
3404 ((match-end 3)
3405 (if (= 0 nest)
3406 (progn
3407 (goto-char (match-end 0))
3408 (setq there (point))
3409 (setq err nil)
3410 (setq str (verilog-get-expr))
3411 (setq str (concat " // else: !if" str ))
3412 (throw 'skip 1))
3413 )))
3414 ))))
3415
3416 (;- task/function/initial et cetera
3417 t
3418 (match-end 0)
3419 (goto-char (match-end 0))
3420 (setq there (point))
3421 (setq err nil)
3422 (setq str (verilog-get-expr))
3423 (setq str (concat " // " cntx str )))
3424
3425 (;-- otherwise...
3426 (setq str " // auto-endcomment confused "))
3427 ))
3428
3429 ((and
3430 (verilog-in-case-region-p) ;-- handle case item differently
3431 (progn
3432 (setq there (point))
3433 (goto-char here)
3434 (setq str (verilog-backward-case-item lim))))
3435 (setq err nil)
3436 (setq str (concat " // case: " str )))
3437
3438 ((verilog-in-fork-region-p)
3439 (setq err nil)
3440 (setq str " // fork branch" ))
3441
3442 ((looking-at "\\<end\\>")
3443 ;; HERE
3444 (forward-word 1)
3445 (verilog-forward-syntactic-ws)
3446 (setq err nil)
3447 (setq str (verilog-get-expr))
3448 (setq str (concat " // " cntx str )))
3449
3450 ))))
3451 (goto-char here)
3452 (end-of-line)
3453 (if kill-existing-comment
3454 (verilog-kill-existing-comment))
3455 (delete-horizontal-space)
3456 (if (or err
3457 (> (count-lines here there) verilog-minimum-comment-distance))
3458 (insert str))
3459 (if err (ding 't))
3460 ))))
3461 (;- this is endclass, which can be nested
3462 (match-end 11) ;; of verilog-end-block-ordered-re
3463 ;;(goto-char there)
3464 (let ((nest 0)
3465 ( reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>")
3466 string
3467 )
3468 (save-excursion
3469 (catch 'skip
3470 (while (verilog-re-search-backward reg nil 'move)
3471 (cond
3472 ((match-end 3) ; endclass
3473 (ding 't)
3474 (setq string "unmatched endclass")
3475 (throw 'skip 1))
3476
3477 ((match-end 2) ; endclass
3478 (setq nest (1+ nest)))
3479
3480 ((match-end 1) ; class
3481 (setq nest (1- nest))
3482 (if (< nest 0)
3483 (progn
3484 (goto-char (match-end 0))
3485 (let (b e)
3486 (setq b (progn
3487 (skip-chars-forward "^ \t")
3488 (verilog-forward-ws&directives)
3489 (point))
3490 e (progn
3491 (skip-chars-forward "a-zA-Z0-9_")
3492 (point)))
3493 (setq string (buffer-substring b e)))
3494 (throw 'skip 1))))
3495 ))))
3496 (end-of-line)
3497 (insert (concat " // " string )))
3498 )
3499
3500 (;- this is end{function,generate,task,module,primitive,table,generate}
3501 ;- which can not be nested.
3502 t
3503 (let (string reg (width nil))
3504 (end-of-line)
3505 (if kill-existing-comment
3506 (save-match-data
3507 (verilog-kill-existing-comment)))
3508 (delete-horizontal-space)
3509 (backward-sexp)
3510 (cond
3511 ((match-end 5) ;; of verilog-end-block-ordered-re
3512 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)")
3513 (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?")
3514 )
3515 ((match-end 6) ;; of verilog-end-block-ordered-re
3516 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)"))
3517 ((match-end 7) ;; of verilog-end-block-ordered-re
3518 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>"))
3519 ((match-end 8) ;; of verilog-end-block-ordered-re
3520 (setq reg "\\(\\<primitive\\>\\)\\|\\(\\<\\(endprimitive\\|package\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
3521 ((match-end 9) ;; of verilog-end-block-ordered-re
3522 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<\\(endinterface\\|package\\|primitive\\|\\(macro\\)?module\\)\\>\\)"))
3523 ((match-end 10) ;; of verilog-end-block-ordered-re
3524 (setq reg "\\(\\<package\\>\\)\\|\\(\\<\\(endpackage\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
3525 ((match-end 11) ;; of verilog-end-block-ordered-re
3526 (setq reg "\\(\\<class\\>\\)\\|\\(\\<\\(endclass\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
3527 ((match-end 12) ;; of verilog-end-block-ordered-re
3528 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<\\(endcovergroup\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
3529 ((match-end 13) ;; of verilog-end-block-ordered-re
3530 (setq reg "\\(\\<program\\>\\)\\|\\(\\<\\(endprogram\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
3531 ((match-end 14) ;; of verilog-end-block-ordered-re
3532 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
3533 ((match-end 15) ;; of verilog-end-block-ordered-re
3534 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>"))
3535
3536 (t (error "Problem in verilog-set-auto-endcomments"))
3537 )
3538 (let (b e)
3539 (save-excursion
3540 (verilog-re-search-backward reg nil 'move)
3541 (cond
3542 ((match-end 1)
3543 (setq b (progn
3544 (skip-chars-forward "^ \t")
3545 (verilog-forward-ws&directives)
3546 (if (and width (looking-at width))
3547 (progn
3548 (goto-char (match-end 0))
3549 (verilog-forward-ws&directives)
3550 ))
3551 (point))
3552 e (progn
3553 (skip-chars-forward "a-zA-Z0-9_")
3554 (point)))
3555 (setq string (buffer-substring b e)))
3556 (t
3557 (ding 't)
3558 (setq string "unmatched end(function|task|module|primitive|interface|package|class|clocking)")))))
3559 (end-of-line)
3560 (insert (concat " // " string )))
3561 ))))))))))
3562
3563(defun verilog-get-expr()
3564 "Grab expression at point, e.g, case ( a | b & (c ^d))"
3565 (let* ((b (progn
3566 (verilog-forward-syntactic-ws)
3567 (skip-chars-forward " \t")
3568 (point)))
3569 (e (let ((par 1))
3570 (cond
3571 ((looking-at "@")
3572 (forward-char 1)
3573 (verilog-forward-syntactic-ws)
3574 (if (looking-at "(")
3575 (progn
3576 (forward-char 1)
3577 (while (and (/= par 0)
3578 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move))
3579 (cond
3580 ((match-end 1)
3581 (setq par (1+ par)))
3582 ((match-end 2)
3583 (setq par (1- par)))))))
3584 (point))
3585 ((looking-at "(")
3586 (forward-char 1)
3587 (while (and (/= par 0)
3588 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move))
3589 (cond
3590 ((match-end 1)
3591 (setq par (1+ par)))
3592 ((match-end 2)
3593 (setq par (1- par)))))
3594 (point))
3595 ((looking-at "\\[")
3596 (forward-char 1)
3597 (while (and (/= par 0)
3598 (verilog-re-search-forward "\\(\\[\\)\\|\\(\\]\\)" nil 'move))
3599 (cond
3600 ((match-end 1)
3601 (setq par (1+ par)))
3602 ((match-end 2)
3603 (setq par (1- par)))))
3604 (verilog-forward-syntactic-ws)
3605 (skip-chars-forward "^ \t\n\f")
3606 (point))
3607 ((looking-at "/[/\\*]")
3608 b)
3609 ('t
3610 (skip-chars-forward "^: \t\n\f")
3611 (point)
3612 ))))
3613 (str (buffer-substring b e)))
3614 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str))
3615 (setq str (concat (substring str 0 e) "...")))
3616 str))
3617
3618(defun verilog-expand-vector ()
3619 "Take a signal vector on the current line and expand it to multiple lines.
3620Useful for creating tri's and other expanded fields."
3621 (interactive)
3622 (verilog-expand-vector-internal "[" "]"))
3623
3624(defun verilog-expand-vector-internal (bra ket)
3625 "Given BRA, the start brace and KET, the end brace, expand one line into many lines."
3626 (save-excursion
3627 (forward-line 0)
3628 (let ((signal-string (buffer-substring (point)
3629 (progn
3630 (end-of-line) (point)))))
3631 (if (string-match (concat "\\(.*\\)"
3632 (regexp-quote bra)
3633 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)"
3634 (regexp-quote ket)
3635 "\\(.*\\)$") signal-string)
3636 (let* ((sig-head (match-string 1 signal-string))
3637 (vec-start (string-to-int (match-string 2 signal-string)))
3638 (vec-end (if (= (match-beginning 3) (match-end 3))
3639 vec-start
3640 (string-to-int (substring signal-string (1+ (match-beginning 3)) (match-end 3)))))
3641 (vec-range (if (= (match-beginning 4) (match-end 4))
3642 1
3643 (string-to-int (substring signal-string (+ 2 (match-beginning 4)) (match-end 4)))))
3644 (sig-tail (match-string 5 signal-string))
3645 vec)
3646 ;; Decode vectors
3647 (setq vec nil)
3648 (if (< vec-range 0)
3649 (let ((tmp vec-start))
3650 (setq vec-start vec-end
3651 vec-end tmp
3652 vec-range (- vec-range))))
3653 (if (< vec-end vec-start)
3654 (while (<= vec-end vec-start)
3655 (setq vec (append vec (list vec-start)))
3656 (setq vec-start (- vec-start vec-range)))
3657 (while (<= vec-start vec-end)
3658 (setq vec (append vec (list vec-start)))
3659 (setq vec-start (+ vec-start vec-range))))
3660 ;;
3661 ;; Delete current line
3662 (delete-region (point) (progn (forward-line 0) (point)))
3663 ;;
3664 ;; Expand vector
3665 (while vec
3666 (insert (concat sig-head bra (int-to-string (car vec)) ket sig-tail "\n"))
3667 (setq vec (cdr vec)))
3668 (delete-char -1)
3669 ;;
3670 )))))
3671
3672(defun verilog-strip-comments ()
3673 "Strip all comments from the verilog code."
3674 (interactive)
3675 (goto-char (point-min))
3676 (while (re-search-forward "//" nil t)
3677 (if (verilog-within-string)
3678 (re-search-forward "\"" nil t)
3679 (if (verilog-in-star-comment-p)
3680 (re-search-forward "\*/" nil t)
3681 (let ((bpt (- (point) 2)))
3682 (end-of-line)
3683 (delete-region bpt (point))))))
3684 ;;
3685 (goto-char (point-min))
3686 (while (re-search-forward "/\\*" nil t)
3687 (if (verilog-within-string)
3688 (re-search-forward "\"" nil t)
3689 (let ((bpt (- (point) 2)))
3690 (re-search-forward "\\*/")
3691 (delete-region bpt (point))))))
3692
3693(defun verilog-one-line ()
3694 "Convert structural verilog instances to occupy one line."
3695 (interactive)
3696 (goto-char (point-min))
3697 (while (re-search-forward "\\([^;]\\)[ \t]*\n[ \t]*" nil t)
3698 (replace-match "\\1 " nil nil)))
3699
3700(defun verilog-linter-name ()
3701 "Return name of linter, either surelint or verilint."
3702 (let ((compile-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil
3703 compile-command))
3704 (lint-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil
3705 verilog-linter)))
3706 (cond ((equal compile-word1 "surelint") `surelint)
3707 ((equal compile-word1 "verilint") `verilint)
3708 ((equal lint-word1 "surelint") `surelint)
3709 ((equal lint-word1 "verilint") `verilint)
3710 (t `surelint)))) ;; back compatibility
3711
3712(defun verilog-lint-off ()
3713 "Convert a Verilog linter warning line into a disable statement.
3714For example:
3715 pci_bfm_null.v, line 46: Unused input: pci_rst_
3716becomes a comment for the appropriate tool.
3717
3718The first word of the `compile-command' or `verilog-linter'
3719variables are used to determine which product is being used.
3720
3721See \\[verilog-surelint-off] and \\[verilog-verilint-off]."
3722 (interactive)
3723 (let ((linter (verilog-linter-name)))
3724 (cond ((equal linter `surelint)
3725 (verilog-surelint-off))
3726 ((equal linter `verilint)
3727 (verilog-verilint-off))
3728 (t (error "Linter name not set")))))
3729
3730(defun verilog-surelint-off ()
3731 "Convert a SureLint warning line into a disable statement.
3732Run from Verilog source window; assumes there is a *compile* buffer
3733with point set appropriately.
3734
3735For example:
3736 WARNING [STD-UDDONX]: xx.v, line 8: output out is never assigned.
3737becomes:
3738 // surefire lint_line_off UDDONX"
3739 (interactive)
3740 (save-excursion
3741 (switch-to-buffer compilation-last-buffer)
3742 (beginning-of-line)
3743 (when
3744 (looking-at "\\(INFO\\|WARNING\\|ERROR\\) \\[[^-]+-\\([^]]+\\)\\]: \\([^,]+\\), line \\([0-9]+\\): \\(.*\\)$")
3745 (let* ((code (match-string 2))
3746 (file (match-string 3))
3747 (line (match-string 4))
3748 (buffer (get-file-buffer file))
3749 dir filename)
3750 (unless buffer
3751 (progn
3752 (setq buffer
3753 (and (file-exists-p file)
3754 (find-file-noselect file)))
3755 (or buffer
3756 (let* ((pop-up-windows t))
3757 (let ((name (expand-file-name
3758 (read-file-name
3759 (format "Find this error in: (default %s) "
3760 file)
3761 dir file t))))
3762 (if (file-directory-p name)
3763 (setq name (expand-file-name filename name)))
3764 (setq buffer
3765 (and (file-exists-p name)
3766 (find-file-noselect name))))))))
3767 (switch-to-buffer buffer)
3768 (goto-line (string-to-number line))
3769 (end-of-line)
3770 (catch 'already
3771 (cond
3772 ((verilog-in-slash-comment-p)
3773 (re-search-backward "//")
3774 (cond
3775 ((looking-at "// surefire lint_off_line ")
3776 (goto-char (match-end 0))
3777 (let ((lim (save-excursion (end-of-line) (point))))
3778 (if (re-search-forward code lim 'move)
3779 (throw 'already t)
3780 (insert-string (concat " " code)))))
3781 (t
3782 )))
3783 ((verilog-in-star-comment-p)
3784 (re-search-backward "/\*")
3785 (insert-string (format " // surefire lint_off_line %6s" code ))
3786 )
3787 (t
3788 (insert-string (format " // surefire lint_off_line %6s" code ))
3789 )))))))
3790
3791(defun verilog-verilint-off ()
3792 "Convert a Verilint warning line into a disable statement.
3793
3794For example:
3795 (W240) pci_bfm_null.v, line 46: Unused input: pci_rst_
3796becomes:
3797 //Verilint 240 off // WARNING: Unused input"
3798 (interactive)
3799 (save-excursion
3800 (beginning-of-line)
3801 (when (looking-at "\\(.*\\)([WE]\\([0-9A-Z]+\\)).*,\\s +line\\s +[0-9]+:\\s +\\([^:\n]+\\):?.*$")
3802 (replace-match (format
3803 ;; %3s makes numbers 1-999 line up nicely
3804 "\\1//Verilint %3s off // WARNING: \\3"
3805 (match-string 2)))
3806 (beginning-of-line)
3807 (verilog-indent-line))))
3808
3809(defun verilog-auto-save-compile ()
3810 "Update automatics with \\[verilog-auto], save the buffer, and compile."
3811 (interactive)
3812 (verilog-auto) ; Always do it for safety
3813 (save-buffer)
3814 (compile compile-command))
3815
3816
3817
3818;;
3819;; Batch
3820;;
3821
3822(defmacro verilog-batch-error-wrapper (&rest body)
3823 "Execute BODY and add error prefix to any errors found.
3824This lets programs calling batch mode to easily extract error messages."
3825 `(condition-case err
3826 (progn ,@body)
3827 (error
3828 (error "%%Error: %s%s" (error-message-string err)
3829 (if (featurep 'xemacs) "\n" ""))))) ;; xemacs forgets to add a newline
3830
3831(defun verilog-batch-execute-func (funref)
3832 "Internal processing of a batch command, running FUNREF on all command arguments."
3833 (verilog-batch-error-wrapper
3834 ;; General globals needed
3835 (setq make-backup-files nil)
3836 (setq-default make-backup-files nil)
3837 (setq enable-local-variables t)
3838 (setq enable-local-eval t)
3839 ;; Make sure any sub-files we read get proper mode
3840 (setq default-major-mode `verilog-mode)
3841 ;; Ditto files already read in
3842 (mapcar '(lambda (buf)
3843 (when (buffer-file-name buf)
3844 (save-excursion
3845 (set-buffer buf)
3846 (verilog-mode))))
3847 (buffer-list))
3848 ;; Process the files
3849 (mapcar '(lambda (buf)
3850 (when (buffer-file-name buf)
3851 (save-excursion
3852 (if (not (file-exists-p (buffer-file-name buf)))
3853 (error (concat "File not found: " (buffer-file-name buf))))
3854 (message (concat "Processing " (buffer-file-name buf)))
3855 (set-buffer buf)
3856 (funcall funref)
3857 (save-buffer))))
3858 (buffer-list))))
3859
3860(defun verilog-batch-auto ()
3861 "For use with --batch, perform automatic expansions as a stand-alone tool.
3862This sets up the appropriate Verilog-Mode environment, updates automatics
3863with \\[verilog-auto] on all command-line files, and saves the buffers.
3864For proper results, multiple filenames need to be passed on the command
3865line in bottom-up order."
3866 (unless noninteractive
3867 (error "Use verilog-batch-auto only with --batch")) ;; Otherwise we'd mess up buffer modes
3868 (verilog-batch-execute-func `verilog-auto))
3869
3870(defun verilog-batch-delete-auto ()
3871 "For use with --batch, perform automatic deletion as a stand-alone tool.
3872This sets up the appropriate Verilog-Mode environment, deletes automatics
3873with \\[verilog-delete-auto] on all command-line files, and saves the buffers."
3874 (unless noninteractive
3875 (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes
3876 (verilog-batch-execute-func `verilog-delete-auto))
3877
3878(defun verilog-batch-inject-auto ()
3879 "For use with --batch, perform automatic injection as a stand-alone tool.
3880This sets up the appropriate Verilog-Mode environment, injects new automatics
3881with \\[verilog-inject-auto] on all command-line files, and saves the buffers.
3882For proper results, multiple filenames need to be passed on the command
3883line in bottom-up order."
3884 (unless noninteractive
3885 (error "Use verilog-batch-inject-auto only with --batch")) ;; Otherwise we'd mess up buffer modes
3886 (verilog-batch-execute-func `verilog-inject-auto))
3887
3888(defun verilog-batch-indent ()
3889 "For use with --batch, reindent an a entire file as a stand-alone tool.
3890This sets up the appropriate Verilog-Mode environment, calls
3891\\[verilog-indent-buffer] on all command-line files, and saves the buffers."
3892 (unless noninteractive
3893 (error "Use verilog-batch-indent only with --batch")) ;; Otherwise we'd mess up buffer modes
3894 (verilog-batch-execute-func `verilog-indent-buffer))
3895
3896
3897;;
3898;; Indentation
3899;;
3900(defconst verilog-indent-alist
3901 '((block . (+ ind verilog-indent-level))
3902 (case . (+ ind verilog-case-indent))
3903 (cparenexp . (+ ind verilog-indent-level))
3904 (cexp . (+ ind verilog-cexp-indent))
3905 (defun . verilog-indent-level-module)
3906 (declaration . verilog-indent-level-declaration)
3907 (directive . (verilog-calculate-indent-directive))
3908 (tf . verilog-indent-level)
3909 (behavioral . (+ verilog-indent-level-behavioral verilog-indent-level-module))
3910 (statement . ind)
3911 (cpp . 0)
3912 (comment . (verilog-comment-indent))
3913 (unknown . 3)
3914 (string . 0)))
3915
3916(defun verilog-continued-line-1 (lim)
3917 "Return true if this is a continued line.
3918Set point to where line starts. Limit search to point LIM."
3919 (let ((continued 't))
3920 (if (eq 0 (forward-line -1))
3921 (progn
3922 (end-of-line)
3923 (verilog-backward-ws&directives lim)
3924 (if (bobp)
3925 (setq continued nil)
3926 (setq continued (verilog-backward-token))))
3927 (setq continued nil))
3928 continued))
3929
3930(defun verilog-calculate-indent ()
3931 "Calculate the indent of the current Verilog line.
3932Examine previous lines. Once a line is found that is definitive as to the
3933type of the current line, return that lines' indent level and its
3934type. Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
3935 (save-excursion
3936 (let* ((starting_position (point))
3937 (par 0)
3938 (begin (looking-at "[ \t]*begin\\>"))
3939 (lim (save-excursion (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)" nil t)))
3940 (type (catch 'nesting
3941 ;; Keep working backwards until we can figure out
3942 ;; what type of statement this is.
3943 ;; Basically we need to figure out
3944 ;; 1) if this is a continuation of the previous line;
3945 ;; 2) are we in a block scope (begin..end)
3946
3947 ;; if we are in a comment, done.
3948 (if (verilog-in-star-comment-p)
3949 (throw 'nesting 'comment))
3950
3951 ;; if we have a directive, done.
3952 (if (save-excursion (beginning-of-line) (looking-at verilog-directive-re-1))
3953 (throw 'nesting 'directive))
3954
3955 ;; unless we are in the newfangled coverpoint or constraint blocks
3956 ;; if we are in a parenthesized list, and the user likes to indent these, return.
3957 (if (and
3958 verilog-indent-lists
3959 (not (verilog-in-coverage))
3960 (verilog-in-paren))
3961 (progn (setq par 1)
3962 (throw 'nesting 'block))
3963 )
3964
3965 ;; See if we are continuing a previous line
3966 (while t
3967 ;; trap out if we crawl off the top of the buffer
3968 (if (bobp) (throw 'nesting 'cpp))
3969
3970 (if (verilog-continued-line-1 lim)
3971 (let ((sp (point)))
3972 (if (and
3973 (not (looking-at verilog-complete-reg))
3974 (verilog-continued-line-1 lim))
3975 (progn (goto-char sp)
3976 (throw 'nesting 'cexp))
3977
3978 (goto-char sp))
3979
3980 (if (and begin
3981 (not verilog-indent-begin-after-if)
3982 (looking-at verilog-no-indent-begin-re))
3983 (progn
3984 (beginning-of-line)
3985 (skip-chars-forward " \t")
3986 (throw 'nesting 'statement))
3987 (progn
3988 (throw 'nesting 'cexp))))
3989 ;; not a continued line
3990 (goto-char starting_position))
3991
3992 (if (looking-at "\\<else\\>")
3993 ;; search back for governing if, striding across begin..end pairs
3994 ;; appropriately
3995 (let ((elsec 1))
3996 (while (verilog-re-search-backward verilog-ends-re nil 'move)
3997 (cond
3998 ((match-end 1) ; else, we're in deep
3999 (setq elsec (1+ elsec)))
4000 ((match-end 2) ; if
4001 (setq elsec (1- elsec))
4002 (if (= 0 elsec)
4003 (if verilog-align-ifelse
4004 (throw 'nesting 'statement)
4005 (progn ;; back up to first word on this line
4006 (beginning-of-line)
4007 (verilog-forward-syntactic-ws)
4008 (throw 'nesting 'statement)))))
4009 (t ; endblock
4010 ; try to leap back to matching outward block by striding across
4011 ; indent level changing tokens then immediately
4012 ; previous line governs indentation.
4013 (let (( reg) (nest 1))
4014;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup
4015 (cond
4016 ((match-end 3) ; end
4017 ;; Search back for matching begin
4018 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" ))
4019 ((match-end 4) ; endcase
4020 ;; Search back for matching case
4021 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ))
4022 ((match-end 5) ; endfunction
4023 ;; Search back for matching function
4024 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" ))
4025 ((match-end 6) ; endtask
4026 ;; Search back for matching task
4027 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" ))
4028 ((match-end 7) ; endspecify
4029 ;; Search back for matching specify
4030 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" ))
4031 ((match-end 8) ; endtable
4032 ;; Search back for matching table
4033 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" ))
4034 ((match-end 9) ; endgenerate
4035 ;; Search back for matching generate
4036 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" ))
4037 ((match-end 10) ; joins
4038 ;; Search back for matching fork
4039 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" ))
4040 ((match-end 11) ; class
4041 ;; Search back for matching class
4042 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
4043 ((match-end 12) ; covergroup
4044 ;; Search back for matching covergroup
4045 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))
4046 )
4047 (catch 'skip
4048 (while (verilog-re-search-backward reg nil 'move)
4049 (cond
4050 ((match-end 1) ; begin
4051 (setq nest (1- nest))
4052 (if (= 0 nest)
4053 (throw 'skip 1)))
4054 ((match-end 2) ; end
4055 (setq nest (1+ nest)))))
4056 )
4057 ))
4058 ))))
4059 (throw 'nesting (verilog-calc-1))
4060 )
4061 );; catch nesting
4062 );; type
4063 )
4064 ;; Return type of block and indent level.
4065 (if (not type)
4066 (setq type 'cpp))
4067 (if (> par 0) ; Unclosed Parenthesis
4068 (list 'cparenexp par)
4069 (cond
4070 ((eq type 'case)
4071 (list type (verilog-case-indent-level)))
4072 ((eq type 'statement)
4073 (list type (current-column)))
4074 ((eq type 'defun)
4075 (list type 0))
4076 (t
4077 (list type (verilog-current-indent-level)))))
4078 )))
4079(defun verilog-wai ()
4080 "Show matching nesting block for debugging."
4081 (interactive)
4082 (save-excursion
4083 (let ((nesting (verilog-calc-1)))
4084 (message "You are at nesting %s" nesting))))
4085
4086(defun verilog-calc-1 ()
4087 (catch 'nesting
4088 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move)
4089 (cond
4090 ((equal (char-after) ?\{)
4091 (if (verilog-at-constraint-p)
4092 (throw 'nesting 'block)
4093 ))
4094 ((equal (char-after) ?\})
4095
4096 (let ((there (verilog-at-close-constraint-p)))
4097 (if there (goto-char there))))
4098
4099 ((looking-at verilog-beg-block-re-ordered)
4100 (cond
4101 ((match-end 2) ; *sigh* could be "unique case" or "priority casex"
4102 (let ((here (point)))
4103 (verilog-beg-of-statement)
4104 (if (looking-at verilog-extended-case-re)
4105 (throw 'nesting 'case)
4106 (goto-char here)))
4107 (throw 'nesting 'case))
4108
4109 ;; need to consider typedef struct here...
4110 ((looking-at "\\<class\\|struct\\|function\\|task\\|property\\>")
4111 ; *sigh* These words have an optional prefix:
4112 ; extern {virtual|protected}? function a();
4113 ; assert property (p_1);
4114 ; typedef class foo;
4115 ; and we don't want to confuse this with
4116 ; function a();
4117 ; property
4118 ; ...
4119 ; endfunction
4120 (let ((here (point)))
4121 (save-excursion
4122 (verilog-beg-of-statement)
4123 (if (= (point) here)
4124 (throw 'nesting 'block))
4125 )))
4126 (t (throw 'nesting 'block))))
4127
4128 ((looking-at verilog-end-block-re)
4129 (verilog-leap-to-head)
4130 (if (verilog-in-case-region-p)
4131 (progn
4132 (verilog-leap-to-case-head)
4133 (if (looking-at verilog-case-re)
4134 (throw 'nesting 'case)))))
4135
4136 ((looking-at (if (verilog-in-generate-region-p)
4137 verilog-defun-level-not-generate-re
4138 verilog-defun-level-re))
4139 (throw 'nesting 'defun))
4140
4141 ((looking-at verilog-cpp-level-re)
4142 (throw 'nesting 'cpp))
4143
4144 ((bobp)
4145 (throw 'nesting 'cpp))
4146 ))
4147 (throw 'nesting 'cpp)
4148 )
4149 )
4150
4151(defun verilog-calculate-indent-directive ()
4152 "Return indentation level for directive.
4153For speed, the searcher looks at the last directive, not the indent
4154of the appropriate enclosing block."
4155 (let ((base -1) ;; Indent of the line that determines our indentation
4156 (ind 0) ;; Relative offset caused by other directives (like `endif on same line as `else)
4157 )
4158 ;; Start at current location, scan back for another directive
4159
4160 (save-excursion
4161 (beginning-of-line)
4162 (while (and (< base 0)
4163 (verilog-re-search-backward verilog-directive-re nil t))
4164 (cond ((save-excursion (skip-chars-backward " \t") (bolp))
4165 (setq base (current-indentation))
4166 ))
4167 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL
4168 (setq ind (- ind verilog-indent-level-directive)))
4169 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL
4170 (setq ind (+ ind verilog-indent-level-directive)))
4171 ((looking-at verilog-directive-begin)
4172 (setq ind (+ ind verilog-indent-level-directive)))))
4173 ;; Adjust indent to starting indent of critical line
4174 (setq ind (max 0 (+ ind base))))
4175
4176 (save-excursion
4177 (beginning-of-line)
4178 (skip-chars-forward " \t")
4179 (cond ((or (looking-at verilog-directive-middle)
4180 (looking-at verilog-directive-end))
4181 (setq ind (max 0 (- ind verilog-indent-level-directive))))))
4182 ind))
4183
4184(defun verilog-leap-to-case-head ()
4185 (let ((nest 1))
4186 (while (/= 0 nest)
4187 (verilog-re-search-backward "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" nil 'move)
4188 (cond
4189 ((match-end 1)
4190 (setq nest (1- nest)))
4191 ((match-end 2)
4192 (setq nest (1+ nest)))
4193 ((bobp)
4194 (ding 't)
4195 (setq nest 0))))))
4196
4197(defun verilog-leap-to-head ()
4198 "Move point to the head of this block; jump from end to matching begin,
4199from endcase to matching case, and so on."
4200 (let ((reg nil)
4201 snest
4202 (nest 1))
4203 (cond
4204 ((looking-at "\\<end\\>")
4205 ;; 1: Search back for matching begin
4206 (setq reg (concat "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|"
4207 "\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )))
4208 ((looking-at "\\<endcase\\>")
4209 ;; 2: Search back for matching case
4210 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" ))
4211 ((looking-at "\\<join\\(_any\\|_none\\)?\\>")
4212 ;; 3: Search back for matching fork
4213 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))
4214 ((looking-at "\\<endclass\\>")
4215 ;; 4: Search back for matching class
4216 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
4217 ((looking-at "\\<endtable\\>")
4218 ;; 5: Search back for matching table
4219 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" ))
4220 ((looking-at "\\<endspecify\\>")
4221 ;; 6: Search back for matching specify
4222 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" ))
4223 ((looking-at "\\<endfunction\\>")
4224 ;; 7: Search back for matching function
4225 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" ))
4226 ((looking-at "\\<endgenerate\\>")
4227 ;; 8: Search back for matching generate
4228 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" ))
4229 ((looking-at "\\<endtask\\>")
4230 ;; 9: Search back for matching task
4231 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" ))
4232 ((looking-at "\\<endgroup\\>")
4233 ;; 10: Search back for matching covergroup
4234 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))
4235 ((looking-at "\\<endproperty\\>")
4236 ;; 11: Search back for matching property
4237 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" ))
4238 ((looking-at "\\<endinterface\\>")
4239 ;; 12: Search back for matching interface
4240 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<endinterface\\>\\)" ))
4241 ((looking-at "\\<endsequence\\>")
4242 ;; 12: Search back for matching sequence
4243 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ))
4244 ((looking-at "\\<endclocking\\>")
4245 ;; 12: Search back for matching clocking
4246 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" ))
4247 )
4248 (if reg
4249 (catch 'skip
4250 (let (sreg)
4251 (while (verilog-re-search-backward reg nil 'move)
4252 (cond
4253 ((match-end 1) ; begin
4254 (setq nest (1- nest))
4255 (if (= 0 nest)
4256 ;; Now previous line describes syntax
4257 (throw 'skip 1))
4258 (if (and snest
4259 (= snest nest))
4260 (setq reg sreg)))
4261 ((match-end 2) ; end
4262 (setq nest (1+ nest)))
4263 ((match-end 3)
4264 ;; endcase, jump to case
4265 (setq snest nest)
4266 (setq nest (1+ nest))
4267 (setq sreg reg)
4268 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ))
4269 ((match-end 4)
4270 ;; join, jump to fork
4271 (setq snest nest)
4272 (setq nest (1+ nest))
4273 (setq sreg reg)
4274 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))
4275 )))))))
4276
4277(defun verilog-continued-line ()
4278 "Return true if this is a continued line.
4279Set point to where line starts"
4280 (let ((continued 't))
4281 (if (eq 0 (forward-line -1))
4282 (progn
4283 (end-of-line)
4284 (verilog-backward-ws&directives)
4285 (if (bobp)
4286 (setq continued nil)
4287 (while (and continued
4288 (save-excursion
4289 (skip-chars-backward " \t")
4290 (not (bolp))))
4291 (setq continued (verilog-backward-token))
4292 ) ;; while
4293 ))
4294 (setq continued nil))
4295 continued))
4296
4297(defun verilog-backward-token ()
4298 "Step backward token, returning true if we are now at an end of line token."
4299 (interactive)
4300 (verilog-backward-syntactic-ws)
4301 (cond
4302 ((bolp)
4303 nil)
4304 (;-- Anything ending in a ; is complete
4305 (= (preceding-char) ?\;)
4306 nil)
4307 (; If a "}" is prefixed by a ";", then this is a complete statement
4308 ; i.e.: constraint foo { a = b; }
4309 (= (preceding-char) ?\})
4310 (progn
4311 (backward-char)
4312 (verilog-at-close-constraint-p))
4313 )
4314 (;-- constraint foo { a = b }
4315 ; is a complete statement. *sigh*
4316 (= (preceding-char) ?\{)
4317 (progn
4318 (backward-char)
4319 (not (verilog-at-constraint-p)))
4320 )
4321 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete
4322 ; also could be simply '@(foo)'
4323 ; or foo u1 #(a=8)
4324 ; (b, ... which ISN'T complete
4325 ;;;; Do we need this???
4326 (= (preceding-char) ?\))
4327 (progn
4328 (backward-char)
4329 (backward-up-list 1)
4330 (verilog-backward-syntactic-ws)
4331 (let ((back (point)))
4332 (forward-word -1)
4333 (cond
4334 ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>")
4335 (not (looking-at "\\<randcase\\>\\|\\<case[xz]?\\>[^:]")))
4336 (t
4337 (goto-char back)
4338 (cond
4339 ((= (preceding-char) ?\@)
4340 (backward-char)
4341 (save-excursion
4342 (verilog-backward-token)
4343 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>"))))
4344 ((= (preceding-char) ?\#)
4345 (backward-char)
4346 )
4347 (t t))
4348 )))))
4349
4350 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete
4351 t
4352 (forward-word -1)
4353 (cond
4354 ((looking-at "\\<else\\>")
4355 t)
4356 ((looking-at verilog-indent-re)
4357 nil)
4358 (t
4359 (let
4360 ((back (point)))
4361 (verilog-backward-syntactic-ws)
4362 (cond
4363 ((= (preceding-char) ?\:)
4364 (backward-char)
4365 (verilog-backward-syntactic-ws)
4366 (backward-sexp)
4367 (if (looking-at verilog-nameable-item-re )
4368 nil
4369 t)
4370 )
4371 ((= (preceding-char) ?\#)
4372 (backward-char)
4373 t)
4374 ((= (preceding-char) ?\`)
4375 (backward-char)
4376 t)
4377
4378 (t
4379 (goto-char back)
4380 t)
4381 )))))))
4382
4383(defun verilog-backward-syntactic-ws (&optional bound)
4384 "Backward skip over syntactic whitespace for Emacs 19.
4385Optional BOUND limits search."
4386 (save-restriction
4387 (let* ((bound (or bound (point-min))) (here bound) )
4388 (if (< bound (point))
4389 (progn
4390 (narrow-to-region bound (point))
4391 (while (/= here (point))
4392 (setq here (point))
4393 (verilog-skip-backward-comments)
4394 )))
4395 ))
4396 t)
4397
4398(defun verilog-forward-syntactic-ws (&optional bound)
4399 "Forward skip over syntactic whitespace for Emacs 19.
4400Optional BOUND limits search."
4401 (save-restriction
4402 (let* ((bound (or bound (point-max)))
4403 (here bound)
4404 )
4405 (if (> bound (point))
4406 (progn
4407 (narrow-to-region (point) bound)
4408 (while (/= here (point))
4409 (setq here (point))
4410 (forward-comment (buffer-size))
4411 )))
4412 )))
4413
4414(defun verilog-backward-ws&directives (&optional bound)
4415 "Backward skip over syntactic whitespace and compiler directives for Emacs 19.
4416Optional BOUND limits search."
4417 (save-restriction
4418 (let* ((bound (or bound (point-min)))
4419 (here bound)
4420 (p nil) )
4421 (if (< bound (point))
4422 (progn
4423 (let ((state
4424 (save-excursion
4425 (parse-partial-sexp (point-min) (point)))))
4426 (cond
4427 ((nth 7 state) ;; in // comment
4428 (verilog-re-search-backward "//" nil 'move)
4429 (skip-chars-backward "/"))
4430 ((nth 4 state) ;; in /* */ comment
4431 (verilog-re-search-backward "/\*" nil 'move))))
4432 (narrow-to-region bound (point))
4433 (while (/= here (point))
4434 (setq here (point))
4435 (verilog-skip-backward-comments)
4436 (setq p
4437 (save-excursion
4438 (beginning-of-line)
4439 (cond
4440 ((verilog-within-translate-off)
4441 (verilog-back-to-start-translate-off (point-min)))
4442 ((looking-at verilog-directive-re-1)
4443 (point))
4444 (t
4445 nil))))
4446 (if p (goto-char p))
4447 )))
4448 )))
4449
4450(defun verilog-forward-ws&directives (&optional bound)
4451 "Forward skip over syntactic whitespace and compiler directives for Emacs 19.
4452Optional BOUND limits search."
4453 (save-restriction
4454 (let* ((bound (or bound (point-max)))
4455 (here bound)
4456 jump
4457 )
4458 (if (> bound (point))
4459 (progn
4460 (let ((state
4461 (save-excursion
4462 (parse-partial-sexp (point-min) (point)))))
4463 (cond
4464 ((nth 7 state) ;; in // comment
4465 (verilog-re-search-forward "//" nil 'move))
4466 ((nth 4 state) ;; in /* */ comment
4467 (verilog-re-search-forward "/\*" nil 'move))))
4468 (narrow-to-region (point) bound)
4469 (while (/= here (point))
4470 (setq here (point)
4471 jump nil)
4472 (forward-comment (buffer-size))
4473 (save-excursion
4474 (beginning-of-line)
4475 (if (looking-at verilog-directive-re-1)
4476 (setq jump t)))
4477 (if jump
4478 (beginning-of-line 2))
4479 )))
4480 )))
4481
4482(defun verilog-in-comment-p ()
4483 "Return true if in a star or // comment."
4484 (let ((state
4485 (save-excursion
4486 (parse-partial-sexp (point-min) (point)))))
4487 (or (nth 4 state) (nth 7 state))))
4488
4489(defun verilog-in-star-comment-p ()
4490 "Return true if in a star comment."
4491 (let ((state
4492 (save-excursion
4493 (parse-partial-sexp (point-min) (point)))))
4494 (and
4495 (nth 4 state) ; t if in a comment of style a // or b /**/
4496 (not
4497 (nth 7 state) ; t if in a comment of style b /**/
4498 ))))
4499
4500(defun verilog-in-slash-comment-p ()
4501 "Return true if in a slash comment."
4502 (let ((state
4503 (save-excursion
4504 (parse-partial-sexp (point-min) (point)))))
4505 (nth 7 state)))
4506
4507(defun verilog-in-comment-or-string-p ()
4508 "Return true if in a string or comment."
4509 (let ((state
4510 (save-excursion
4511 (parse-partial-sexp (point-min) (point)))))
4512 (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment)
4513
4514(defun verilog-in-escaped-name-p ()
4515 "Return true if in an escaped name."
4516 (save-excursion
4517 (backward-char)
4518 (skip-chars-backward "^ \t\n\f")
4519 (if (equal (char-after (point) ) ?\\ )
4520 t
4521 nil)))
4522
4523(defun verilog-in-paren ()
4524 "Return true if in a parenthetical expression."
4525 (let ((state
4526 (save-excursion
4527 (parse-partial-sexp (point-min) (point)))))
4528 (> (nth 0 state) 0 )))
4529
4530(defun verilog-in-coverage ()
4531 "Return true if in a constraint or coverpoint expression."
4532 (interactive)
4533 (save-excursion
4534 (if (verilog-in-paren)
4535 (progn
4536 (backward-up-list 1)
4537 (verilog-at-constraint-p)
4538 )
4539 nil)))
4540(defun verilog-at-close-constraint-p ()
4541 "If at the } that closes a constraint or covergroup, return true."
4542 (if (and
4543 (equal (char-after) ?\})
4544 (verilog-in-paren))
4545
4546 (save-excursion
4547 (verilog-backward-ws&directives)
4548 (if (equal (char-before) ?\;)
4549 (point)
4550 nil))))
4551
4552(defun verilog-at-constraint-p ()
4553 "If at the { of a constraint or coverpoint definition, return true, moving point to constraint."
4554 (if (save-excursion
4555 (and
4556 (equal (char-after) ?\{)
4557 (forward-list)
4558 (progn (backward-char 1)
4559 (verilog-backward-ws&directives)
4560 (equal (char-before) ?\;))
4561 ))
4562 ;; maybe
4563 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move)
4564 ;; not
4565 nil
4566 )
4567 )
4568
4569(defun verilog-parenthesis-depth ()
4570 "Return non zero if in parenthetical-expression."
4571 (save-excursion
4572 (nth 1 (parse-partial-sexp (point-min) (point)))))
4573
4574
4575(defun verilog-skip-forward-comment-or-string ()
4576 "Return true if in a string or comment."
4577 (let ((state
4578 (save-excursion
4579 (parse-partial-sexp (point-min) (point)))))
4580 (cond
4581 ((nth 3 state) ;Inside string
4582 (goto-char (nth 3 state))
4583 t)
4584 ((nth 7 state) ;Inside // comment
4585 (forward-line 1)
4586 t)
4587 ((nth 4 state) ;Inside any comment (hence /**/)
4588 (search-forward "*/"))
4589 (t
4590 nil))))
4591
4592(defun verilog-skip-backward-comment-or-string ()
4593 "Return true if in a string or comment."
4594 (let ((state
4595 (save-excursion
4596 (parse-partial-sexp (point-min) (point)))))
4597 (cond
4598 ((nth 3 state) ;Inside string
4599 (search-backward "\"")
4600 t)
4601 ((nth 7 state) ;Inside // comment
4602 (search-backward "//")
4603 (skip-chars-backward "/")
4604 t)
4605 ((nth 4 state) ;Inside /* */ comment
4606 (search-backward "/*")
4607 t)
4608 (t
4609 nil))))
4610
4611(defun verilog-skip-backward-comments ()
4612 "Return true if a comment was skipped."
4613 (let ((more t))
4614 (while more
4615 (setq more
4616 (let ((state
4617 (save-excursion
4618 (parse-partial-sexp (point-min) (point)))))
4619 (cond
4620 ((nth 7 state) ;Inside // comment
4621 (search-backward "//")
4622 (skip-chars-backward "/")
4623 (skip-chars-backward " \t\n\f")
4624 t)
4625 ((nth 4 state) ;Inside /* */ comment
4626 (search-backward "/*")
4627 (skip-chars-backward " \t\n\f")
4628 t)
4629 ((and (not (bobp))
4630 (= (char-before) ?\/)
4631 (= (char-before (1- (point))) ?\*)
4632 )
4633 (goto-char (- (point) 2))
4634 t)
4635 (t
4636 (skip-chars-backward " \t\n\f")
4637 nil)))))))
4638
4639(defun verilog-skip-forward-comment-p ()
4640 "If in comment, move to end and return true."
4641 (let (state)
4642 (progn
4643 (setq state
4644 (save-excursion
4645 (parse-partial-sexp (point-min) (point))))
4646 (cond
4647 ((nth 3 state)
4648 t)
4649 ((nth 7 state) ;Inside // comment
4650 (end-of-line)
4651 (forward-char 1)
4652 t)
4653 ((nth 4 state) ;Inside any comment
4654 t)
4655 (t
4656 nil)))))
4657
4658(defun verilog-indent-line-relative ()
4659 "Cheap version of indent line.
4660Only look at a few lines to determine indent level."
4661 (interactive)
4662 (let ((indent-str)
4663 (sp (point)))
4664 (if (looking-at "^[ \t]*$")
4665 (cond ;- A blank line; No need to be too smart.
4666 ((bobp)
4667 (setq indent-str (list 'cpp 0)))
4668 ((verilog-continued-line)
4669 (let ((sp1 (point)))
4670 (if (verilog-continued-line)
4671 (progn (goto-char sp)
4672 (setq indent-str (list 'statement (verilog-current-indent-level))))
4673 (goto-char sp1)
4674 (setq indent-str (list 'block (verilog-current-indent-level)))))
4675 (goto-char sp))
4676 ((goto-char sp)
4677 (setq indent-str (verilog-calculate-indent))))
4678 (progn (skip-chars-forward " \t")
4679 (setq indent-str (verilog-calculate-indent))))
4680 (verilog-do-indent indent-str)))
4681
4682(defun verilog-indent-line ()
4683 "Indent for special part of code."
4684 (verilog-do-indent (verilog-calculate-indent)))
4685
4686(defun verilog-do-indent (indent-str)
4687 (let ((type (car indent-str))
4688 (ind (car (cdr indent-str))))
4689 (cond
4690 (; handle continued exp
4691 (eq type 'cexp)
4692 (let ((here (point)))
4693 (verilog-backward-syntactic-ws)
4694 (cond
4695 ((or
4696 (= (preceding-char) ?\,)
4697 (= (preceding-char) ?\])
4698 (save-excursion
4699 (verilog-beg-of-statement-1)
4700 (looking-at verilog-declaration-re)))
4701 (let* ( fst
4702 (val
4703 (save-excursion
4704 (backward-char 1)
4705 (verilog-beg-of-statement-1)
4706 (setq fst (point))
4707 (if (looking-at verilog-declaration-re)
4708 (progn ;; we have multiple words
4709 (goto-char (match-end 0))
4710 (skip-chars-forward " \t")
4711 (cond
4712 ((and verilog-indent-declaration-macros
4713 (= (following-char) ?\`))
4714 (progn
4715 (forward-char 1)
4716 (forward-word 1)
4717 (skip-chars-forward " \t")))
4718 ((= (following-char) ?\[)
4719 (progn
4720 (forward-char 1)
4721 (backward-up-list -1)
4722 (skip-chars-forward " \t")))
4723 )
4724 (current-column))
4725 (progn
4726 (goto-char fst)
4727 (+ (current-column) verilog-cexp-indent))
4728 ))))
4729 (goto-char here)
4730 (indent-line-to val))
4731 )
4732 ((= (preceding-char) ?\) )
4733 (goto-char here)
4734 (let ((val (eval (cdr (assoc type verilog-indent-alist)))))
4735 (indent-line-to val)))
4736 (t
4737 (goto-char here)
4738 (let ((val))
4739 (verilog-beg-of-statement-1)
4740 (if (and (< (point) here)
4741 (verilog-re-search-forward "=[ \\t]*" here 'move))
4742 (setq val (current-column))
4743 (setq val (eval (cdr (assoc type verilog-indent-alist)))))
4744 (goto-char here)
4745 (indent-line-to val)))
4746 )))
4747
4748 (; handle inside parenthetical expressions
4749 (eq type 'cparenexp)
4750 (let ((val (save-excursion
4751 (backward-up-list 1)
4752 (forward-char 1)
4753 (skip-chars-forward " \t")
4754 (current-column))))
4755 (indent-line-to val)
4756 (if (and (not (verilog-in-struct-region-p))
4757 (looking-at verilog-declaration-re))
4758 (verilog-indent-declaration ind))
4759 ))
4760
4761 (;-- Handle the ends
4762 (or
4763 (looking-at verilog-end-block-re )
4764 (verilog-at-close-constraint-p))
4765 (let ((val (if (eq type 'statement)
4766 (- ind verilog-indent-level)
4767 ind)))
4768 (indent-line-to val)))
4769
4770 (;-- Case -- maybe line 'em up
4771 (and (eq type 'case) (not (looking-at "^[ \t]*$")))
4772 (progn
4773 (cond
4774 ((looking-at "\\<endcase\\>")
4775 (indent-line-to ind))
4776 (t
4777 (let ((val (eval (cdr (assoc type verilog-indent-alist)))))
4778 (indent-line-to val))))))
4779
4780 (;-- defun
4781 (and (eq type 'defun)
4782 (looking-at verilog-zero-indent-re))
4783 (indent-line-to 0))
4784
4785 (;-- declaration
4786 (and (or
4787 (eq type 'defun)
4788 (eq type 'block))
4789 (looking-at verilog-declaration-re))
4790 (verilog-indent-declaration ind))
4791
4792 (;-- Everything else
4793 t
4794 (let ((val (eval (cdr (assoc type verilog-indent-alist)))))
4795 (indent-line-to val)))
4796 )
4797 (if (looking-at "[ \t]+$")
4798 (skip-chars-forward " \t"))
4799 indent-str ; Return indent data
4800 ))
4801
4802(defun verilog-current-indent-level ()
4803 "Return the indent-level the current statement has."
4804 (save-excursion
4805 (let (par-pos)
4806 (beginning-of-line)
4807 (setq par-pos (verilog-parenthesis-depth))
4808 (while par-pos
4809 (goto-char par-pos)
4810 (beginning-of-line)
4811 (setq par-pos (verilog-parenthesis-depth)))
4812 (skip-chars-forward " \t")
4813 (current-column))))
4814
4815(defun verilog-case-indent-level ()
4816 "Return the indent-level the current statement has.
4817Do not count named blocks or case-statements."
4818 (save-excursion
4819 (skip-chars-forward " \t")
4820 (cond
4821 ((looking-at verilog-named-block-re)
4822 (current-column))
4823 ((and (not (looking-at verilog-case-re))
4824 (looking-at "^[^:;]+[ \t]*:"))
4825 (verilog-re-search-forward ":" nil t)
4826 (skip-chars-forward " \t")
4827 (current-column))
4828 (t
4829 (current-column)))))
4830
4831(defun verilog-indent-comment ()
4832 "Indent current line as comment."
4833 (let* ((stcol
4834 (cond
4835 ((verilog-in-star-comment-p)
4836 (save-excursion
4837 (re-search-backward "/\\*" nil t)
4838 (1+(current-column))))
4839 (comment-column
4840 comment-column )
4841 (t
4842 (save-excursion
4843 (re-search-backward "//" nil t)
4844 (current-column)))
4845 )))
4846 (indent-line-to stcol)
4847 stcol))
4848
4849(defun verilog-more-comment ()
4850 "Make more comment lines like the previous."
4851 (let* ((star 0)
4852 (stcol
4853 (cond
4854 ((verilog-in-star-comment-p)
4855 (save-excursion
4856 (setq star 1)
4857 (re-search-backward "/\\*" nil t)
4858 (1+(current-column))))
4859 (comment-column
4860 comment-column )
4861 (t
4862 (save-excursion
4863 (re-search-backward "//" nil t)
4864 (current-column)))
4865 )))
4866 (progn
4867 (indent-to stcol)
4868 (if (and star
4869 (save-excursion
4870 (forward-line -1)
4871 (skip-chars-forward " \t")
4872 (looking-at "\*")))
4873 (insert "* ")))))
4874
4875(defun verilog-comment-indent (&optional arg)
4876 "Return the column number the line should be indented to.
4877ARG is ignored, for `comment-indent-function' compatibility."
4878 (cond
4879 ((verilog-in-star-comment-p)
4880 (save-excursion
4881 (re-search-backward "/\\*" nil t)
4882 (1+(current-column))))
4883 ( comment-column
4884 comment-column )
4885 (t
4886 (save-excursion
4887 (re-search-backward "//" nil t)
4888 (current-column)))))
4889
4890;;
4891
4892(defun verilog-pretty-declarations ()
4893 "Line up declarations around point."
4894 (interactive)
4895 (save-excursion
4896 (if (progn
4897 (verilog-beg-of-statement-1)
4898 (looking-at verilog-declaration-re))
4899 (let* ((m1 (make-marker))
4900 (e) (r)
4901 (here (point))
4902 ;; Start of declaration range
4903 (start
4904 (progn
4905 (verilog-beg-of-statement-1)
4906 (while (looking-at verilog-declaration-re)
4907 (beginning-of-line)
4908 (setq e (point))
4909 (verilog-backward-syntactic-ws)
4910 (backward-char)
4911 (verilog-beg-of-statement-1)) ;Ack, need to grok `define
4912 e))
4913 ;; End of declaration range
4914 (end
4915 (progn
4916 (goto-char here)
4917 (verilog-end-of-statement)
4918 (setq e (point)) ;Might be on last line
4919 (verilog-forward-syntactic-ws)
4920 (while (looking-at verilog-declaration-re)
4921 (beginning-of-line)
4922 (verilog-end-of-statement)
4923 (setq e (point))
4924 (verilog-forward-syntactic-ws))
4925 e))
4926 (edpos (set-marker (make-marker) end))
4927 (ind)
4928 (base-ind
4929 (progn
4930 (goto-char start)
4931 (verilog-do-indent (verilog-calculate-indent))
4932 (verilog-forward-ws&directives)
4933 (current-column)))
4934 )
4935 (goto-char end)
4936 (goto-char start)
4937 (if (> (- end start) 100)
4938 (message "Lining up declarations..(please stand by)"))
4939 ;; Get the beginning of line indent first
4940 (while (progn (setq e (marker-position edpos))
4941 (< (point) e))
4942 (cond
4943 ( (save-excursion (skip-chars-backward " \t")
4944 (bolp))
4945 (verilog-forward-ws&directives)
4946 (indent-line-to base-ind)
4947 (verilog-forward-ws&directives)
4948 (verilog-re-search-forward "[ \t\n\f]" e 'move)
4949 )
4950 (t
4951 (just-one-space)
4952 (verilog-re-search-forward "[ \t\n\f]" e 'move)
4953 )
4954 )
4955 )
4956 ;;(forward-line))
4957 ;; Now find biggest prefix
4958 (setq ind (verilog-get-lineup-indent start edpos))
4959 ;; Now indent each line.
4960 (goto-char start)
4961 (while (progn (setq e (marker-position edpos))
4962 (setq r (- e (point)))
4963 (> r 0))
4964 (setq e (point))
4965 (message "%d" r)
4966 (cond
4967 ((or (and verilog-indent-declaration-macros
4968 (looking-at verilog-declaration-re-1-macro))
4969 (looking-at verilog-declaration-re-1-no-macro))
4970 (let ((p (match-end 0)))
4971 (set-marker m1 p)
4972 (if (verilog-re-search-forward "[[#`]" p 'move)
4973 (progn
4974 (forward-char -1)
4975 (just-one-space)
4976 (goto-char (marker-position m1))
4977 (just-one-space)
4978 (indent-to ind))
4979 (progn
4980 (just-one-space)
4981 (indent-to ind))
4982 )))
4983 ((verilog-continued-line-1 start)
4984 (goto-char e)
4985 (indent-line-to ind))
4986 (t ; Must be comment or white space
4987 (goto-char e)
4988 (verilog-forward-ws&directives)
4989 (forward-line -1))
4990 )
4991 (forward-line 1))
4992 (message "")))))
4993
4994(defun verilog-pretty-expr (&optional myre)
4995 "Line up expressions around point."
4996 (interactive "sRegular Expression: ((<|:)?=) ")
4997 (save-excursion
4998 (if (or (eq myre nil)
4999 (string-equal myre ""))
5000 (setq myre "\\(<\\|:\\)?="))
5001; (setq myre (concat "\\(^[^;" myre "]*\\)\\([" myre "]\\)"))
5002 (setq myre (concat "\\(^[^;#:?=]*\\)\\([" myre "]\\)"))
5003 (beginning-of-line)
5004 (if (and (not (looking-at (concat "^\\s-*" verilog-complete-reg)))
5005 (looking-at myre))
5006 (let* ((here (point))
5007 (e) (r)
5008 (start
5009 (progn
5010 (beginning-of-line)
5011 (setq e (point))
5012 (verilog-backward-syntactic-ws)
5013 (beginning-of-line)
5014 (while (and (not (looking-at (concat "^\\s-*" verilog-complete-reg)))
5015 (looking-at myre)
5016 (not (bobp))
5017 )
5018 (setq e (point))
5019 (verilog-backward-syntactic-ws)
5020 (beginning-of-line)
5021 ) ;Ack, need to grok `define
5022 e))
5023 (end
5024 (progn
5025 (goto-char here)
5026 (end-of-line)
5027 (setq e (point)) ;Might be on last line
5028 (verilog-forward-syntactic-ws)
5029 (beginning-of-line)
5030 (while (and (not(looking-at (concat "^\\s-*" verilog-complete-reg)))
5031 (looking-at myre))
5032 (end-of-line)
5033 (setq e (point))
5034 (verilog-forward-syntactic-ws)
5035 (beginning-of-line)
5036 )
5037 e))
5038 (edpos (set-marker (make-marker) end))
5039 (ind)
5040 )
5041 (goto-char start)
5042 (verilog-do-indent (verilog-calculate-indent))
5043 (if (> (- end start) 100)
5044 (message "Lining up expressions..(please stand by)"))
5045
5046 ;; Set indent to minimum throughout region
5047 (while (< (point) (marker-position edpos))
5048 (beginning-of-line)
5049 (verilog-just-one-space myre)
5050 (end-of-line)
5051 (verilog-forward-syntactic-ws)
5052 )
5053
5054 ;; Now find biggest prefix
5055 (setq ind (verilog-get-lineup-indent-2 myre start edpos))
5056
5057 ;; Now indent each line.
5058 (goto-char start)
5059 (while (progn (setq e (marker-position edpos))
5060 (setq r (- e (point)))
5061 (> r 0))
5062 (setq e (point))
5063 (message "%d" r)
5064 (cond
5065 ((looking-at myre)
5066 (goto-char (match-end 1))
5067 (if (eq (char-after) ?=)
5068 (indent-to (1+ ind)) ; line up the = of the <= with surrounding =
5069 (indent-to ind)
5070 )
5071 )
5072 ((verilog-continued-line-1 start)
5073 (goto-char e)
5074 (indent-line-to ind))
5075 (t ; Must be comment or white space
5076 (goto-char e)
5077 (verilog-forward-ws&directives)
5078 (forward-line -1))
5079 )
5080 (forward-line 1))
5081 (message "")
5082 ))))
5083
5084(defun verilog-just-one-space (myre)
5085 "Remove extra spaces around regular expression MYRE."
5086 (interactive)
5087 (if (and (not(looking-at verilog-complete-reg))
5088 (looking-at myre))
5089 (let ((p1 (match-end 1))
5090 (p2 (match-end 2)))
5091 (progn
5092 (goto-char p2)
5093 (if (looking-at "\\s-") (just-one-space) )
5094 (goto-char p1)
5095 (forward-char -1)
5096 (if (looking-at "\\s-") (just-one-space))
5097 )
5098 ))
5099 (message ""))
5100
5101(defun verilog-indent-declaration (baseind)
5102 "Indent current lines as declaration.
5103Line up the variable names based on previous declaration's indentation.
5104BASEIND is the base indent to offset everything."
5105 (interactive)
5106 (let ((pos (point-marker))
5107 (lim (save-excursion
5108 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move)
5109 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move)
5110 (point)))
5111 (ind)
5112 (val)
5113 (m1 (make-marker))
5114 )
5115 (setq val (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist)))))
5116 (indent-line-to val)
5117
5118 ;; Use previous declaration (in this module) as template.
5119 (if (or (memq 'all verilog-auto-lineup)
5120 (memq 'declaration verilog-auto-lineup))
5121 (if (verilog-re-search-backward
5122 (or (and verilog-indent-declaration-macros
5123 verilog-declaration-re-1-macro)
5124 verilog-declaration-re-1-no-macro) lim t)
5125 (progn
5126 (goto-char (match-end 0))
5127 (skip-chars-forward " \t")
5128 (setq ind (current-column))
5129 (goto-char pos)
5130 (setq val (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist)))))
5131 (indent-line-to val)
5132 (if (and verilog-indent-declaration-macros
5133 (looking-at verilog-declaration-re-2-macro))
5134 (let ((p (match-end 0)))
5135 (set-marker m1 p)
5136 (if (verilog-re-search-forward "[[#`]" p 'move)
5137 (progn
5138 (forward-char -1)
5139 (just-one-space)
5140 (goto-char (marker-position m1))
5141 (just-one-space)
5142 (indent-to ind)
5143 )
5144 (if (/= (current-column) ind)
5145 (progn
5146 (just-one-space)
5147 (indent-to ind))
5148 )))
5149 (if (looking-at verilog-declaration-re-2-no-macro)
5150 (let ((p (match-end 0)))
5151 (set-marker m1 p)
5152 (if (verilog-re-search-forward "[[`#]" p 'move)
5153 (progn
5154 (forward-char -1)
5155 (just-one-space)
5156 (goto-char (marker-position m1))
5157 (just-one-space)
5158 (indent-to ind))
5159 (if (/= (current-column) ind)
5160 (progn
5161 (just-one-space)
5162 (indent-to ind))
5163 )))
5164 )))
5165 )
5166 )
5167 (goto-char pos)
5168 )
5169 )
5170
5171(defun verilog-get-lineup-indent (b edpos)
5172 "Return the indent level that will line up several lines within the region.
5173Region is defined by B and EDPOS."
5174 (save-excursion
5175 (let ((ind 0) e)
5176 (goto-char b)
5177 ;; Get rightmost position
5178 (while (progn (setq e (marker-position edpos))
5179 (< (point) e))
5180 (if (verilog-re-search-forward
5181 (or (and verilog-indent-declaration-macros
5182 verilog-declaration-re-1-macro)
5183 verilog-declaration-re-1-no-macro) e 'move)
5184 (progn
5185 (goto-char (match-end 0))
5186 (verilog-backward-syntactic-ws)
5187 (if (> (current-column) ind)
5188 (setq ind (current-column)))
5189 (goto-char (match-end 0)))))
5190 (if (> ind 0)
5191 (1+ ind)
5192 ;; No lineup-string found
5193 (goto-char b)
5194 (end-of-line)
5195 (skip-chars-backward " \t")
5196 (1+ (current-column))))))
5197
5198(defun verilog-get-lineup-indent-2 (myre b edpos)
5199 "Return the indent level that will line up several lines within the region."
5200 (save-excursion
5201 (let ((ind 0) e)
5202 (goto-char b)
5203 ;; Get rightmost position
5204 (while (progn (setq e (marker-position edpos))
5205 (< (point) e))
5206 (if (verilog-re-search-forward myre e 'move)
5207 (progn
5208 (goto-char (match-end 0))
5209 (verilog-backward-syntactic-ws)
5210 (if (> (current-column) ind)
5211 (setq ind (current-column)))
5212 (goto-char (match-end 0)))))
5213 (if (> ind 0)
5214 (1+ ind)
5215 ;; No lineup-string found
5216 (goto-char b)
5217 (end-of-line)
5218 (skip-chars-backward " \t")
5219 (1+ (current-column))))))
5220
5221(defun verilog-comment-depth (type val)
5222 "A useful mode debugging aide. TYPE and VAL are comments for insertion."
5223 (save-excursion
5224 (let
5225 ((b (prog2
5226 (beginning-of-line)
5227 (point-marker)
5228 (end-of-line)))
5229 (e (point-marker)))
5230 (if (re-search-backward " /\\* \[#-\]# \[a-zA-Z\]+ \[0-9\]+ ## \\*/" b t)
5231 (progn
5232 (replace-match " /* -# ## */")
5233 (end-of-line))
5234 (progn
5235 (end-of-line)
5236 (insert " /* ## ## */"))))
5237 (backward-char 6)
5238 (insert
5239 (format "%s %d" type val))))
5240
5241;;
5242;;
5243;; Completion
5244;;
5245(defvar verilog-str nil)
5246(defvar verilog-all nil)
5247(defvar verilog-pred nil)
5248(defvar verilog-buffer-to-use nil)
5249(defvar verilog-flag nil)
5250(defvar verilog-toggle-completions nil
5251 "*True means \\<verilog-mode-map>\\[verilog-complete-word] should try all possible completions one by one.
5252Repeated use of \\[verilog-complete-word] will show you all of them.
5253Normally, when there is more than one possible completion,
5254it displays a list of all possible completions.")
5255
5256
5257(defvar verilog-type-keywords
5258 '(
5259 "and" "buf" "bufif0" "bufif1" "cmos" "defparam" "inout" "input"
5260 "integer" "localparam" "logic" "mailbox" "nand" "nmos" "nor" "not" "notif0"
5261 "notif1" "or" "output" "parameter" "pmos" "pull0" "pull1" "pullup"
5262 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" "rtranif0"
5263 "rtranif1" "semaphore" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1"
5264 "triand" "trior" "trireg" "wand" "wire" "wor" "xnor" "xor"
5265 )
5266 "*Keywords for types used when completing a word in a declaration or parmlist.
5267\(eg. integer, real, reg...)")
5268
5269(defvar verilog-cpp-keywords
5270 '("module" "macromodule" "primitive" "timescale" "define" "ifdef" "ifndef" "else"
5271 "endif")
5272 "*Keywords to complete when at first word of a line in declarative scope.
5273\(eg. initial, always, begin, assign.)
5274The procedures and variables defined within the Verilog program
5275will be completed runtime and should not be added to this list.")
5276
5277(defvar verilog-defun-keywords
5278 (append
5279 '(
5280 "always" "always_comb" "always_ff" "always_latch" "assign"
5281 "begin" "end" "generate" "endgenerate" "module" "endmodule"
5282 "specify" "endspecify" "function" "endfunction" "initial" "final"
5283 "task" "endtask" "primitive" "endprimitive"
5284 )
5285 verilog-type-keywords)
5286 "*Keywords to complete when at first word of a line in declarative scope.
5287\(eg. initial, always, begin, assign.)
5288The procedures and variables defined within the Verilog program
5289will be completed runtime and should not be added to this list.")
5290
5291(defvar verilog-block-keywords
5292 '(
5293 "begin" "break" "case" "continue" "else" "end" "endfunction"
5294 "endgenerate" "endinterface" "endpackage" "endspecify" "endtask"
5295 "for" "fork" "if" "join" "join_any" "join_none" "repeat" "return"
5296 "while")
5297 "*Keywords to complete when at first word of a line in behavioral scope.
5298\(eg. begin, if, then, else, for, fork.)
5299The procedures and variables defined within the Verilog program
5300will be completed runtime and should not be added to this list.")
5301
5302(defvar verilog-tf-keywords
5303 '("begin" "break" "fork" "join" "join_any" "join_none" "case" "end" "endtask" "endfunction" "if" "else" "for" "while" "repeat")
5304 "*Keywords to complete when at first word of a line in a task or function.
5305\(eg. begin, if, then, else, for, fork.)
5306The procedures and variables defined within the Verilog program
5307will be completed runtime and should not be added to this list.")
5308
5309(defvar verilog-case-keywords
5310 '("begin" "fork" "join" "join_any" "join_none" "case" "end" "endcase" "if" "else" "for" "repeat")
5311 "*Keywords to complete when at first word of a line in case scope.
5312\(eg. begin, if, then, else, for, fork.)
5313The procedures and variables defined within the Verilog program
5314will be completed runtime and should not be added to this list.")
5315
5316(defvar verilog-separator-keywords
5317 '("else" "then" "begin")
5318 "*Keywords to complete when NOT standing at the first word of a statement.
5319\(eg. else, then.)
5320Variables and function names defined within the
5321Verilog program are completed runtime and should not be added to this list.")
5322
5323(defun verilog-string-diff (str1 str2)
5324 "Return index of first letter where STR1 and STR2 differs."
5325 (catch 'done
5326 (let ((diff 0))
5327 (while t
5328 (if (or (> (1+ diff) (length str1))
5329 (> (1+ diff) (length str2)))
5330 (throw 'done diff))
5331 (or (equal (aref str1 diff) (aref str2 diff))
5332 (throw 'done diff))
5333 (setq diff (1+ diff))))))
5334
5335;; Calculate all possible completions for functions if argument is `function',
5336;; completions for procedures if argument is `procedure' or both functions and
5337;; procedures otherwise.
5338
5339(defun verilog-func-completion (type)
5340 "Build regular expression for module/task/function names.
5341TYPE is 'module, 'tf for task or function, or t if unknown."
5342 (if (string= verilog-str "")
5343 (setq verilog-str "[a-zA-Z_]"))
5344 (let ((verilog-str (concat (cond
5345 ((eq type 'module) "\\<\\(module\\)\\s +")
5346 ((eq type 'tf) "\\<\\(task\\|function\\)\\s +")
5347 (t "\\<\\(task\\|function\\|module\\)\\s +"))
5348 "\\<\\(" verilog-str "[a-zA-Z0-9_.]*\\)\\>"))
5349 match)
5350
5351 (if (not (looking-at verilog-defun-re))
5352 (verilog-re-search-backward verilog-defun-re nil t))
5353 (forward-char 1)
5354
5355 ;; Search through all reachable functions
5356 (goto-char (point-min))
5357 (while (verilog-re-search-forward verilog-str (point-max) t)
5358 (progn (setq match (buffer-substring (match-beginning 2)
5359 (match-end 2)))
5360 (if (or (null verilog-pred)
5361 (funcall verilog-pred match))
5362 (setq verilog-all (cons match verilog-all)))))
5363 (if (match-beginning 0)
5364 (goto-char (match-beginning 0)))))
5365
5366(defun verilog-get-completion-decl (end)
5367 "Macro for searching through current declaration (var, type or const)
5368for matches of `str' and adding the occurrence tp `all' through point END."
5369 (let ((re (or (and verilog-indent-declaration-macros
5370 verilog-declaration-re-2-macro)
5371 verilog-declaration-re-2-no-macro))
5372 decl-end match)
5373 ;; Traverse lines
5374 (while (and (< (point) end)
5375 (verilog-re-search-forward re end t))
5376 ;; Traverse current line
5377 (setq decl-end (save-excursion (verilog-declaration-end)))
5378 (while (and (verilog-re-search-forward verilog-symbol-re decl-end t)
5379 (not (match-end 1)))
5380 (setq match (buffer-substring (match-beginning 0) (match-end 0)))
5381 (if (string-match (concat "\\<" verilog-str) match)
5382 (if (or (null verilog-pred)
5383 (funcall verilog-pred match))
5384 (setq verilog-all (cons match verilog-all)))))
5385 (forward-line 1)
5386 )
5387 )
5388 verilog-all
5389 )
5390
5391(defun verilog-type-completion ()
5392 "Calculate all possible completions for types."
5393 (let ((start (point))
5394 goon)
5395 ;; Search for all reachable type declarations
5396 (while (or (verilog-beg-of-defun)
5397 (setq goon (not goon)))
5398 (save-excursion
5399 (if (and (< start (prog1 (save-excursion (verilog-end-of-defun)
5400 (point))
5401 (forward-char 1)))
5402 (verilog-re-search-forward
5403 "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>"
5404 start t)
5405 (not (match-end 1)))
5406 ;; Check current type declaration
5407 (verilog-get-completion-decl start))))))
5408
5409(defun verilog-var-completion ()
5410 "Calculate all possible completions for variables (or constants)."
5411 (let ((start (point)))
5412 ;; Search for all reachable var declarations
5413 (verilog-beg-of-defun)
5414 (save-excursion
5415 ;; Check var declarations
5416 (verilog-get-completion-decl start))))
5417
5418(defun verilog-keyword-completion (keyword-list)
5419 "Give list of all possible completions of keywords in KEYWORD-LIST."
5420 (mapcar '(lambda (s)
5421 (if (string-match (concat "\\<" verilog-str) s)
5422 (if (or (null verilog-pred)
5423 (funcall verilog-pred s))
5424 (setq verilog-all (cons s verilog-all)))))
5425 keyword-list))
5426
5427
5428(defun verilog-completion (verilog-str verilog-pred verilog-flag)
5429 "Function passed to `completing-read', `try-completion' or `all-completions'.
5430Called to get completion on VERILOG-STR. If VERILOG-PRED is non-nil, it
5431must be a function to be called for every match to check if this should
5432really be a match. If VERILOG-FLAG is t, the function returns a list of all
5433possible completions. If VERILOG-FLAG is nil it returns a string, the
5434longest possible completion, or t if STR is an exact match. If VERILOG-FLAG
5435is 'lambda, the function returns t if STR is an exact match, nil
5436otherwise."
5437 (save-excursion
5438 (let ((verilog-all nil))
5439 ;; Set buffer to use for searching labels. This should be set
5440 ;; within functions which use verilog-completions
5441 (set-buffer verilog-buffer-to-use)
5442
5443 ;; Determine what should be completed
5444 (let ((state (car (verilog-calculate-indent))))
5445 (cond ((eq state 'defun)
5446 (save-excursion (verilog-var-completion))
5447 (verilog-func-completion 'module)
5448 (verilog-keyword-completion verilog-defun-keywords))
5449
5450 ((eq state 'behavioral)
5451 (save-excursion (verilog-var-completion))
5452 (verilog-func-completion 'module)
5453 (verilog-keyword-completion verilog-defun-keywords))
5454
5455 ((eq state 'block)
5456 (save-excursion (verilog-var-completion))
5457 (verilog-func-completion 'tf)
5458 (verilog-keyword-completion verilog-block-keywords))
5459
5460 ((eq state 'case)
5461 (save-excursion (verilog-var-completion))
5462 (verilog-func-completion 'tf)
5463 (verilog-keyword-completion verilog-case-keywords))
5464
5465 ((eq state 'tf)
5466 (save-excursion (verilog-var-completion))
5467 (verilog-func-completion 'tf)
5468 (verilog-keyword-completion verilog-tf-keywords))
5469
5470 ((eq state 'cpp)
5471 (save-excursion (verilog-var-completion))
5472 (verilog-keyword-completion verilog-cpp-keywords))
5473
5474 ((eq state 'cparenexp)
5475 (save-excursion (verilog-var-completion)))
5476
5477 (t;--Anywhere else
5478 (save-excursion (verilog-var-completion))
5479 (verilog-func-completion 'both)
5480 (verilog-keyword-completion verilog-separator-keywords))))
5481
5482 ;; Now we have built a list of all matches. Give response to caller
5483 (verilog-completion-response))))
5484
5485(defun verilog-completion-response ()
5486 (cond ((or (equal verilog-flag 'lambda) (null verilog-flag))
5487 ;; This was not called by all-completions
5488 (if (null verilog-all)
5489 ;; Return nil if there was no matching label
5490 nil
5491 ;; Get longest string common in the labels
5492 (let* ((elm (cdr verilog-all))
5493 (match (car verilog-all))
5494 (min (length match))
5495 tmp)
5496 (if (string= match verilog-str)
5497 ;; Return t if first match was an exact match
5498 (setq match t)
5499 (while (not (null elm))
5500 ;; Find longest common string
5501 (if (< (setq tmp (verilog-string-diff match (car elm))) min)
5502 (progn
5503 (setq min tmp)
5504 (setq match (substring match 0 min))))
5505 ;; Terminate with match=t if this is an exact match
5506 (if (string= (car elm) verilog-str)
5507 (progn
5508 (setq match t)
5509 (setq elm nil))
5510 (setq elm (cdr elm)))))
5511 ;; If this is a test just for exact match, return nil ot t
5512 (if (and (equal verilog-flag 'lambda) (not (equal match 't)))
5513 nil
5514 match))))
5515 ;; If flag is t, this was called by all-completions. Return
5516 ;; list of all possible completions
5517 (verilog-flag
5518 verilog-all)))
5519
5520(defvar verilog-last-word-numb 0)
5521(defvar verilog-last-word-shown nil)
5522(defvar verilog-last-completions nil)
5523
5524(defun verilog-complete-word ()
5525 "Complete word at current point.
5526\(See also `verilog-toggle-completions', `verilog-type-keywords',
5527and `verilog-separator-keywords'.)"
5528 (interactive)
5529 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point)))
5530 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))
5531 (verilog-str (buffer-substring b e))
5532 ;; The following variable is used in verilog-completion
5533 (verilog-buffer-to-use (current-buffer))
5534 (allcomp (if (and verilog-toggle-completions
5535 (string= verilog-last-word-shown verilog-str))
5536 verilog-last-completions
5537 (all-completions verilog-str 'verilog-completion)))
5538 (match (if verilog-toggle-completions
5539 "" (try-completion
5540 verilog-str (mapcar '(lambda (elm)
5541 (cons elm 0)) allcomp)))))
5542 ;; Delete old string
5543 (delete-region b e)
5544
5545 ;; Toggle-completions inserts whole labels
5546 (if verilog-toggle-completions
5547 (progn
5548 ;; Update entry number in list
5549 (setq verilog-last-completions allcomp
5550 verilog-last-word-numb
5551 (if (>= verilog-last-word-numb (1- (length allcomp)))
5552 0
5553 (1+ verilog-last-word-numb)))
5554 (setq verilog-last-word-shown (elt allcomp verilog-last-word-numb))
5555 ;; Display next match or same string if no match was found
5556 (if (not (null allcomp))
5557 (insert "" verilog-last-word-shown)
5558 (insert "" verilog-str)
5559 (message "(No match)")))
5560 ;; The other form of completion does not necessarily do that.
5561
5562 ;; Insert match if found, or the original string if no match
5563 (if (or (null match) (equal match 't))
5564 (progn (insert "" verilog-str)
5565 (message "(No match)"))
5566 (insert "" match))
5567 ;; Give message about current status of completion
5568 (cond ((equal match 't)
5569 (if (not (null (cdr allcomp)))
5570 (message "(Complete but not unique)")
5571 (message "(Sole completion)")))
5572 ;; Display buffer if the current completion didn't help
5573 ;; on completing the label.
5574 ((and (not (null (cdr allcomp))) (= (length verilog-str)
5575 (length match)))
5576 (with-output-to-temp-buffer "*Completions*"
5577 (display-completion-list allcomp))
5578 ;; Wait for a key press. Then delete *Completion* window
5579 (momentary-string-display "" (point))
5580 (delete-window (get-buffer-window (get-buffer "*Completions*")))
5581 )))))
5582
5583(defun verilog-show-completions ()
5584 "Show all possible completions at current point."
5585 (interactive)
5586 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point)))
5587 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))
5588 (verilog-str (buffer-substring b e))
5589 ;; The following variable is used in verilog-completion
5590 (verilog-buffer-to-use (current-buffer))
5591 (allcomp (if (and verilog-toggle-completions
5592 (string= verilog-last-word-shown verilog-str))
5593 verilog-last-completions
5594 (all-completions verilog-str 'verilog-completion))))
5595 ;; Show possible completions in a temporary buffer.
5596 (with-output-to-temp-buffer "*Completions*"
5597 (display-completion-list allcomp))
5598 ;; Wait for a key press. Then delete *Completion* window
5599 (momentary-string-display "" (point))
5600 (delete-window (get-buffer-window (get-buffer "*Completions*")))))
5601
5602
5603(defun verilog-get-default-symbol ()
5604 "Return symbol around current point as a string."
5605 (save-excursion
5606 (buffer-substring (progn
5607 (skip-chars-backward " \t")
5608 (skip-chars-backward "a-zA-Z0-9_")
5609 (point))
5610 (progn
5611 (skip-chars-forward "a-zA-Z0-9_")
5612 (point)))))
5613
5614(defun verilog-build-defun-re (str &optional arg)
5615 "Return function/task/module starting with STR as regular expression.
5616With optional second ARG non-nil, STR is the complete name of the instruction."
5617 (if arg
5618 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "\\)\\>")
5619 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "[a-zA-Z0-9_]*\\)\\>")))
5620
5621(defun verilog-comp-defun (verilog-str verilog-pred verilog-flag)
5622 "Function passed to `completing-read', `try-completion' or `all-completions'.
5623Returns a completion on any function name based on VERILOG-STR prefix. If
5624VERILOG-PRED is non-nil, it must be a function to be called for every match
5625to check if this should really be a match. If VERILOG-FLAG is t, the
5626function returns a list of all possible completions. If it is nil it
5627returns a string, the longest possible completion, or t if VERILOG-STR is
5628an exact match. If VERILOG-FLAG is 'lambda, the function returns t if
5629VERILOG-STR is an exact match, nil otherwise."
5630 (save-excursion
5631 (let ((verilog-all nil)
5632 match)
5633
5634 ;; Set buffer to use for searching labels. This should be set
5635 ;; within functions which use verilog-completions
5636 (set-buffer verilog-buffer-to-use)
5637
5638 (let ((verilog-str verilog-str))
5639 ;; Build regular expression for functions
5640 (if (string= verilog-str "")
5641 (setq verilog-str (verilog-build-defun-re "[a-zA-Z_]"))
5642 (setq verilog-str (verilog-build-defun-re verilog-str)))
5643 (goto-char (point-min))
5644
5645 ;; Build a list of all possible completions
5646 (while (verilog-re-search-forward verilog-str nil t)
5647 (setq match (buffer-substring (match-beginning 2) (match-end 2)))
5648 (if (or (null verilog-pred)
5649 (funcall verilog-pred match))
5650 (setq verilog-all (cons match verilog-all)))))
5651
5652 ;; Now we have built a list of all matches. Give response to caller
5653 (verilog-completion-response))))
5654
5655(defun verilog-goto-defun ()
5656 "Move to specified Verilog module/task/function.
5657The default is a name found in the buffer around point.
5658If search fails, other files are checked based on
5659`verilog-library-flags'."
5660 (interactive)
5661 (let* ((default (verilog-get-default-symbol))
5662 ;; The following variable is used in verilog-comp-function
5663 (verilog-buffer-to-use (current-buffer))
5664 (label (if (not (string= default ""))
5665 ;; Do completion with default
5666 (completing-read (concat "Label: (default " default ") ")
5667 'verilog-comp-defun nil nil "")
5668 ;; There is no default value. Complete without it
5669 (completing-read "Label: "
5670 'verilog-comp-defun nil nil "")))
5671 pt)
5672 ;; If there was no response on prompt, use default value
5673 (if (string= label "")
5674 (setq label default))
5675 ;; Goto right place in buffer if label is not an empty string
5676 (or (string= label "")
5677 (progn
5678 (save-excursion
5679 (goto-char (point-min))
5680 (setq pt (re-search-forward (verilog-build-defun-re label t) nil t)))
5681 (when pt
5682 (goto-char pt)
5683 (beginning-of-line))
5684 pt)
5685 (verilog-goto-defun-file label)
5686 )))
5687
5688;; Eliminate compile warning
5689(eval-when-compile
5690 (if (not (boundp 'occur-pos-list))
5691 (defvar occur-pos-list nil "Backward compatibility occur positions.")))
5692
5693(defun verilog-showscopes ()
5694 "List all scopes in this module."
5695 (interactive)
5696 (let ((buffer (current-buffer))
5697 (linenum 1)
5698 (nlines 0)
5699 (first 1)
5700 (prevpos (point-min))
5701 (final-context-start (make-marker))
5702 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)")
5703 )
5704 (with-output-to-temp-buffer "*Occur*"
5705 (save-excursion
5706 (message (format "Searching for %s ..." regexp))
5707 ;; Find next match, but give up if prev match was at end of buffer.
5708 (while (and (not (= prevpos (point-max)))
5709 (verilog-re-search-forward regexp nil t))
5710 (goto-char (match-beginning 0))
5711 (beginning-of-line)
5712 (save-match-data
5713 (setq linenum (+ linenum (count-lines prevpos (point)))))
5714 (setq prevpos (point))
5715 (goto-char (match-end 0))
5716 (let* ((start (save-excursion
5717 (goto-char (match-beginning 0))
5718 (forward-line (if (< nlines 0) nlines (- nlines)))
5719 (point)))
5720 (end (save-excursion
5721 (goto-char (match-end 0))
5722 (if (> nlines 0)
5723 (forward-line (1+ nlines))
5724 (forward-line 1))
5725 (point)))
5726 (tag (format "%3d" linenum))
5727 (empty (make-string (length tag) ?\ ))
5728 tem)
5729 (save-excursion
5730 (setq tem (make-marker))
5731 (set-marker tem (point))
5732 (set-buffer standard-output)
5733 (setq occur-pos-list (cons tem occur-pos-list))
5734 (or first (zerop nlines)
5735 (insert "--------\n"))
5736 (setq first nil)
5737 (insert-buffer-substring buffer start end)
5738 (backward-char (- end start))
5739 (setq tem (if (< nlines 0) (- nlines) nlines))
5740 (while (> tem 0)
5741 (insert empty ?:)
5742 (forward-line 1)
5743 (setq tem (1- tem)))
5744 (let ((this-linenum linenum))
5745 (set-marker final-context-start
5746 (+ (point) (- (match-end 0) (match-beginning 0))))
5747 (while (< (point) final-context-start)
5748 (if (null tag)
5749 (setq tag (format "%3d" this-linenum)))
5750 (insert tag ?:)))))))
5751 (set-buffer-modified-p nil))))
5752
5753
5754;; Highlight helper functions
5755(defconst verilog-directive-regexp "\\(translate\\|coverage\\|lint\\)_")
5756(defun verilog-within-translate-off ()
5757 "Return point if within translate-off region, else nil."
5758 (and (save-excursion
5759 (re-search-backward
5760 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "\\(on\\|off\\)\\>")
5761 nil t))
5762 (equal "off" (match-string 2))
5763 (point)))
5764
5765(defun verilog-start-translate-off (limit)
5766 "Return point before translate-off directive if before LIMIT, else nil."
5767 (when (re-search-forward
5768 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>")
5769 limit t)
5770 (match-beginning 0)))
5771
5772(defun verilog-back-to-start-translate-off (limit)
5773 "Return point before translate-off directive if before LIMIT, else nil."
5774 (when (re-search-backward
5775 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>")
5776 limit t)
5777 (match-beginning 0)))
5778
5779(defun verilog-end-translate-off (limit)
5780 "Return point after translate-on directive if before LIMIT, else nil."
5781
5782 (re-search-forward (concat
5783 "//\\s-*.*\\s-*" verilog-directive-regexp "on\\>") limit t))
5784
5785(defun verilog-match-translate-off (limit)
5786 "Match a translate-off block, setting `match-data' and returning t, else nil.
5787Bound search by LIMIT."
5788 (when (< (point) limit)
5789 (let ((start (or (verilog-within-translate-off)
5790 (verilog-start-translate-off limit)))
5791 (case-fold-search t))
5792 (when start
5793 (let ((end (or (verilog-end-translate-off limit) limit)))
5794 (set-match-data (list start end))
5795 (goto-char end))))))
5796
5797(defun verilog-font-lock-match-item (limit)
5798 "Match, and move over, any declaration item after point.
5799Bound search by LIMIT. Adapted from
5800`font-lock-match-c-style-declaration-item-and-skip-to-next'."
5801 (condition-case nil
5802 (save-restriction
5803 (narrow-to-region (point-min) limit)
5804 ;; match item
5805 (when (looking-at "\\s-*\\([a-zA-Z]\\w*\\)")
5806 (save-match-data
5807 (goto-char (match-end 1))
5808 ;; move to next item
5809 (if (looking-at "\\(\\s-*,\\)")
5810 (goto-char (match-end 1))
5811 (end-of-line) t))))
5812 (error nil)))
5813
5814
5815;; Added by Subbu Meiyappan for Header
5816
5817(defun verilog-header ()
5818 "Insert a standard Verilog file header."
5819 (interactive)
5820 (let ((start (point)))
5821 (insert "\
5822//-----------------------------------------------------------------------------
5823// Title : <title>
5824// Project : <project>
5825//-----------------------------------------------------------------------------
5826// File : <filename>
5827// Author : <author>
5828// Created : <credate>
5829// Last modified : <moddate>
5830//-----------------------------------------------------------------------------
5831// Description :
5832// <description>
5833//-----------------------------------------------------------------------------
5834// Copyright (c) <copydate> by <company> This model is the confidential and
5835// proprietary property of <company> and the possession or use of this
5836// file requires a written license from <company>.
5837//------------------------------------------------------------------------------
5838// Modification history :
5839// <modhist>
5840//-----------------------------------------------------------------------------
5841
5842")
5843 (goto-char start)
5844 (search-forward "<filename>")
5845 (replace-match (buffer-name) t t)
5846 (search-forward "<author>") (replace-match "" t t)
5847 (insert (user-full-name))
5848 (insert " <" (user-login-name) "@" (system-name) ">")
5849 (search-forward "<credate>") (replace-match "" t t)
5850 (verilog-insert-date)
5851 (search-forward "<moddate>") (replace-match "" t t)
5852 (verilog-insert-date)
5853 (search-forward "<copydate>") (replace-match "" t t)
5854 (verilog-insert-year)
5855 (search-forward "<modhist>") (replace-match "" t t)
5856 (verilog-insert-date)
5857 (insert " : created")
5858 (goto-char start)
5859 (let (string)
5860 (setq string (read-string "title: "))
5861 (search-forward "<title>")
5862 (replace-match string t t)
5863 (setq string (read-string "project: " verilog-project))
5864 (make-variable-buffer-local 'verilog-project)
5865 (setq verilog-project string)
5866 (search-forward "<project>")
5867 (replace-match string t t)
5868 (setq string (read-string "Company: " verilog-company))
5869 (make-variable-buffer-local 'verilog-company)
5870 (setq verilog-company string)
5871 (search-forward "<company>")
5872 (replace-match string t t)
5873 (search-forward "<company>")
5874 (replace-match string t t)
5875 (search-forward "<company>")
5876 (replace-match string t t)
5877 (search-backward "<description>")
5878 (replace-match "" t t)
5879 )))
5880
5881;; verilog-header Uses the verilog-insert-date function
5882
5883(defun verilog-insert-date ()
5884 "Insert date from the system."
5885 (interactive)
5886 (let ((timpos))
5887 (setq timpos (point))
5888 (if verilog-date-scientific-format
5889 (shell-command "date \"+@%Y/%m/%d\"" t)
5890 (shell-command "date \"+@%d.%m.%Y\"" t))
5891 (search-forward "@")
5892 (delete-region timpos (point))
5893 (end-of-line))
5894 (delete-char 1))
5895
5896(defun verilog-insert-year ()
5897 "Insert year from the system."
5898 (interactive)
5899 (let ((timpos))
5900 (setq timpos (point))
5901 (shell-command "date \"+@%Y\"" t)
5902 (search-forward "@")
5903 (delete-region timpos (point))
5904 (end-of-line))
5905 (delete-char 1))
5906
5907
5908;;
5909;; Signal list parsing
5910;;
5911
5912;; Elements of a signal list
5913(defsubst verilog-sig-name (sig)
5914 (car sig))
5915(defsubst verilog-sig-bits (sig)
5916 (nth 1 sig))
5917(defsubst verilog-sig-comment (sig)
5918 (nth 2 sig))
5919(defsubst verilog-sig-memory (sig)
5920 (nth 3 sig))
5921(defsubst verilog-sig-enum (sig)
5922 (nth 4 sig))
5923(defsubst verilog-sig-signed (sig)
5924 (nth 5 sig))
5925(defsubst verilog-sig-type (sig)
5926 (nth 6 sig))
5927(defsubst verilog-sig-multidim (sig)
5928 (nth 7 sig))
5929(defsubst verilog-sig-multidim-string (sig)
5930 (if (verilog-sig-multidim sig)
5931 (let ((str "") (args (verilog-sig-multidim sig)))
5932 (while args
5933 (setq str (concat str (car args)))
5934 (setq args (cdr args)))
5935 str)))
5936(defsubst verilog-sig-width (sig)
5937 (verilog-make-width-expression (verilog-sig-bits sig)))
5938
5939(defsubst verilog-alw-get-inputs (sigs)
5940 (nth 2 sigs))
5941(defsubst verilog-alw-get-outputs (sigs)
5942 (nth 0 sigs))
5943(defsubst verilog-alw-get-uses-delayed (sigs)
5944 (nth 3 sigs))
5945
5946(defun verilog-signals-not-in (in-list not-list)
5947 "Return list of signals in IN-LIST that aren't also in NOT-LIST,
5948and also remove any duplicates in IN-LIST.
5949Signals must be in standard (base vector) form."
5950 (let (out-list)
5951 (while in-list
5952 (if (not (or (assoc (car (car in-list)) not-list)
5953 (assoc (car (car in-list)) out-list)))
5954 (setq out-list (cons (car in-list) out-list)))
5955 (setq in-list (cdr in-list)))
5956 (nreverse out-list)))
5957;;(verilog-signals-not-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" "")))
5958
5959(defun verilog-signals-in (in-list other-list)
5960 "Return list of signals in IN-LIST that are also in OTHER-LIST.
5961Signals must be in standard (base vector) form."
5962 (let (out-list)
5963 (while in-list
5964 (if (assoc (car (car in-list)) other-list)
5965 (setq out-list (cons (car in-list) out-list)))
5966 (setq in-list (cdr in-list)))
5967 (nreverse out-list)))
5968;;(verilog-signals-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" "")))
5969
5970(defun verilog-signals-memory (in-list)
5971 "Return list of signals in IN-LIST that are memoried (multidimensional)."
5972 (let (out-list)
5973 (while in-list
5974 (if (nth 3 (car in-list))
5975 (setq out-list (cons (car in-list) out-list)))
5976 (setq in-list (cdr in-list)))
5977 out-list))
5978;;(verilog-signals-memory '(("A" nil nil "[3:0]")) '(("B" nil nil nil)))
5979
5980(defun verilog-signals-sort-compare (a b)
5981 "Compare signal A and B for sorting."
5982 (string< (car a) (car b)))
5983
5984(defun verilog-signals-not-params (in-list)
5985 "Return list of signals in IN-LIST that aren't parameters or numeric constants."
5986 (let (out-list)
5987 (while in-list
5988 (unless (boundp (intern (concat "vh-" (car (car in-list)))))
5989 (setq out-list (cons (car in-list) out-list)))
5990 (setq in-list (cdr in-list)))
5991 (nreverse out-list)))
5992
5993(defun verilog-signals-combine-bus (in-list)
5994 "Return a list of signals in IN-LIST, with busses combined.
5995Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]."
5996 (let (combo buswarn
5997 out-list
5998 sig highbit lowbit ; Temp information about current signal
5999 sv-name sv-highbit sv-lowbit ; Details about signal we are forming
6000 sv-comment sv-memory sv-enum sv-signed sv-type sv-multidim sv-busstring
6001 bus)
6002 ;; Shove signals so duplicated signals will be adjacent
6003 (setq in-list (sort in-list `verilog-signals-sort-compare))
6004 (while in-list
6005 (setq sig (car in-list))
6006 ;; No current signal; form from existing details
6007 (unless sv-name
6008 (setq sv-name (verilog-sig-name sig)
6009 sv-highbit nil
6010 sv-busstring nil
6011 sv-comment (verilog-sig-comment sig)
6012 sv-memory (verilog-sig-memory sig)
6013 sv-enum (verilog-sig-enum sig)
6014 sv-signed (verilog-sig-signed sig)
6015 sv-type (verilog-sig-type sig)
6016 sv-multidim (verilog-sig-multidim sig)
6017 combo ""
6018 buswarn ""
6019 ))
6020 ;; Extract bus details
6021 (setq bus (verilog-sig-bits sig))
6022 (cond ((and bus
6023 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus)
6024 (setq highbit (string-to-int (match-string 1 bus))
6025 lowbit (string-to-int (match-string 2 bus))))
6026 (and (string-match "\\[\\([0-9]+\\)\\]" bus)
6027 (setq highbit (string-to-int (match-string 1 bus))
6028 lowbit highbit))))
6029 ;; Combine bits in bus
6030 (if sv-highbit
6031 (setq sv-highbit (max highbit sv-highbit)
6032 sv-lowbit (min lowbit sv-lowbit))
6033 (setq sv-highbit highbit
6034 sv-lowbit lowbit)))
6035 (bus
6036 ;; String, probably something like `preproc:0
6037 (setq sv-busstring bus)))
6038 ;; Peek ahead to next signal
6039 (setq in-list (cdr in-list))
6040 (setq sig (car in-list))
6041 (cond ((and sig (equal sv-name (verilog-sig-name sig)))
6042 ;; Combine with this signal
6043 (when (and sv-busstring (not (equal sv-busstring (verilog-sig-bits sig))))
6044 (when nil ;; Debugging
6045 (message (concat "Warning, can't merge into single bus "
6046 sv-name bus
6047 ", the AUTOs may be wrong")))
6048 (setq buswarn ", Couldn't Merge"))
6049 (if (verilog-sig-comment sig) (setq combo ", ..."))
6050 (setq sv-memory (or sv-memory (verilog-sig-memory sig))
6051 sv-enum (or sv-enum (verilog-sig-enum sig))
6052 sv-signed (or sv-signed (verilog-sig-signed sig))
6053 sv-type (or sv-type (verilog-sig-type sig))
6054 sv-multidim (or sv-multidim (verilog-sig-multidim sig))))
6055 ;; Doesn't match next signal, add to queue, zero in prep for next
6056 ;; Note sig may also be nil for the last signal in the list
6057 (t
6058 (setq out-list
6059 (cons (list sv-name
6060 (or sv-busstring
6061 (if sv-highbit
6062 (concat "[" (int-to-string sv-highbit) ":" (int-to-string sv-lowbit) "]")))
6063 (concat sv-comment combo buswarn)
6064 sv-memory sv-enum sv-signed sv-type sv-multidim)
6065 out-list)
6066 sv-name nil)))
6067 )
6068 ;;
6069 out-list))
6070
6071(defun verilog-sig-tieoff (sig &optional no-width)
6072 "Return tieoff expression for given SIGNAL, with appropriate width.
6073Ignore width if optional NO-WIDTH is set."
6074 (let* ((width (if no-width nil (verilog-sig-width sig))))
6075 (concat
6076 (if (and verilog-active-low-regexp
6077 (string-match verilog-active-low-regexp (verilog-sig-name sig)))
6078 "~" "")
6079 (cond ((not width)
6080 "0")
6081 ((string-match "^[0-9]+$" width)
6082 (concat width (if (verilog-sig-signed sig) "'sh0" "'h0")))
6083 (t
6084 (concat "{" width "{1'b0}}"))))))
6085
6086;;
6087;; Port/Wire/Etc Reading
6088;;
6089
6090(defun verilog-read-inst-backward-name ()
6091 "Internal. Move point back to beginning of inst-name."
6092 (verilog-backward-open-paren)
6093 (let (done)
6094 (while (not done)
6095 (verilog-re-search-backward-quick "\\()\\|\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil) ; ] isn't word boundary
6096 (cond ((looking-at ")")
6097 (verilog-backward-open-paren))
6098 (t (setq done t)))))
6099 (while (looking-at "\\]")
6100 (verilog-backward-open-bracket)
6101 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil))
6102 (skip-chars-backward "a-zA-Z0-9`_$"))
6103
6104(defun verilog-read-inst-module ()
6105 "Return module_name when point is inside instantiation."
6106 (save-excursion
6107 (verilog-read-inst-backward-name)
6108 ;; Skip over instantiation name
6109 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil) ; ) isn't word boundary
6110 ;; Check for parameterized instantiations
6111 (when (looking-at ")")
6112 (verilog-backward-open-paren)
6113 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil))
6114 (skip-chars-backward "a-zA-Z0-9'_$")
6115 (looking-at "[a-zA-Z0-9`_\$]+")
6116 ;; Important: don't use match string, this must work with emacs 19 font-lock on
6117 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
6118
6119(defun verilog-read-inst-name ()
6120 "Return instance_name when point is inside instantiation."
6121 (save-excursion
6122 (verilog-read-inst-backward-name)
6123 (looking-at "[a-zA-Z0-9`_\$]+")
6124 ;; Important: don't use match string, this must work with emacs 19 font-lock on
6125 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
6126
6127(defun verilog-read-module-name ()
6128 "Return module name when after its ( or ;."
6129 (save-excursion
6130 (re-search-backward "[(;]")
6131 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)
6132 (skip-chars-backward "a-zA-Z0-9`_$")
6133 (looking-at "[a-zA-Z0-9`_\$]+")
6134 ;; Important: don't use match string, this must work with emacs 19 font-lock on
6135 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
6136
6137(defun verilog-read-auto-params (num-param &optional max-param)
6138 "Return parameter list inside auto.
6139Optional NUM-PARAM and MAX-PARAM check for a specific number of parameters."
6140 (let ((olist))
6141 (save-excursion
6142 ;; /*AUTOPUNT("parameter", "parameter")*/
6143 (search-backward "(")
6144 (while (looking-at "(?\\s *\"\\([^\"]*\\)\"\\s *,?")
6145 (setq olist (cons (match-string 1) olist))
6146 (goto-char (match-end 0))))
6147 (or (eq nil num-param)
6148 (<= num-param (length olist))
6149 (error "%s: Expected %d parameters" (verilog-point-text) num-param))
6150 (if (eq max-param nil) (setq max-param num-param))
6151 (or (eq nil max-param)
6152 (>= max-param (length olist))
6153 (error "%s: Expected <= %d parameters" (verilog-point-text) max-param))
6154 (nreverse olist)))
6155
6156(defun verilog-read-decls ()
6157 "Compute signal declaration information for the current module at point.
6158Return a array of [outputs inouts inputs wire reg assign const]."
6159 (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max)))
6160 (functask 0) (paren 0) (sig-paren 0)
6161 sigs-in sigs-out sigs-inout sigs-wire sigs-reg sigs-assign sigs-const sigs-gparam
6162 vec expect-signal keywd newsig rvalue enum io signed typedefed multidim)
6163 (save-excursion
6164 (verilog-beg-of-defun)
6165 (setq sigs-const (verilog-read-auto-constants (point) end-mod-point))
6166 (while (< (point) end-mod-point)
6167 ;;(if dbg (setq dbg (cons (format "Pt %s Vec %s Kwd'%s'\n" (point) vec keywd) dbg)))
6168 (cond
6169 ((looking-at "//")
6170 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
6171 (setq enum (match-string 1)))
6172 (search-forward "\n"))
6173 ((looking-at "/\\*")
6174 (forward-char 2)
6175 (if (looking-at "[^*]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
6176 (setq enum (match-string 1)))
6177 (or (search-forward "*/")
6178 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
6179 ((looking-at "(\\*")
6180 (forward-char 2)
6181 (or (looking-at "\\s-*)") ; It's a "always @ (*)"
6182 (search-forward "*)")
6183 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
6184 ((eq ?\" (following-char))
6185 (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first
6186 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point))))
6187 ((eq ?\; (following-char))
6188 (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil)
6189 (forward-char 1))
6190 ((eq ?= (following-char))
6191 (setq rvalue t newsig nil)
6192 (forward-char 1))
6193 ((and (or rvalue sig-paren)
6194 (cond ((and (eq ?, (following-char))
6195 (eq paren sig-paren))
6196 (setq rvalue nil)
6197 (forward-char 1)
6198 t)
6199 ;; ,'s can occur inside {} & funcs
6200 ((looking-at "[{(]")
6201 (setq paren (1+ paren))
6202 (forward-char 1)
6203 t)
6204 ((looking-at "[})]")
6205 (setq paren (1- paren))
6206 (forward-char 1)
6207 (when (< paren sig-paren)
6208 (setq expect-signal nil)) ; ) that ends variables inside v2k arg list
6209 t)
6210 )))
6211 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)")
6212 (goto-char (match-end 0))
6213 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3)
6214 (setcar (cdr (cdr (cdr newsig))) (match-string 1)))
6215 (vec ;; Multidimensional
6216 (setq multidim (cons vec multidim))
6217 (setq vec (verilog-string-replace-matches
6218 "\\s-+" "" nil nil (match-string 1))))
6219 (t ;; Bit width
6220 (setq vec (verilog-string-replace-matches
6221 "\\s-+" "" nil nil (match-string 1))))))
6222 ;; Normal or escaped identifier -- note we remember the \ if escaped
6223 ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)")
6224 (goto-char (match-end 0))
6225 (setq keywd (match-string 1))
6226 (when (string-match "^\\\\" keywd)
6227 (setq keywd (concat keywd " "))) ;; Escaped ID needs space at end
6228 (cond ((equal keywd "input")
6229 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren
6230 expect-signal 'sigs-in io t))
6231 ((equal keywd "output")
6232 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren
6233 expect-signal 'sigs-out io t))
6234 ((equal keywd "inout")
6235 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren
6236 expect-signal 'sigs-inout io t))
6237 ((or (equal keywd "wire")
6238 (equal keywd "tri")
6239 (equal keywd "tri0")
6240 (equal keywd "tri1"))
6241 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
6242 expect-signal 'sigs-wire)))
6243 ((or (equal keywd "reg")
6244 (equal keywd "trireg"))
6245 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
6246 expect-signal 'sigs-reg)))
6247 ((equal keywd "assign")
6248 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
6249 expect-signal 'sigs-assign))
6250 ((or (equal keywd "supply0")
6251 (equal keywd "supply1")
6252 (equal keywd "supply")
6253 (equal keywd "localparam"))
6254 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
6255 expect-signal 'sigs-const)))
6256 ((or (equal keywd "parameter"))
6257 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
6258 expect-signal 'sigs-gparam)))
6259 ((equal keywd "signed")
6260 (setq signed "signed"))
6261 ((or (equal keywd "function")
6262 (equal keywd "task"))
6263 (setq functask (1+ functask)))
6264 ((or (equal keywd "endfunction")
6265 (equal keywd "endtask"))
6266 (setq functask (1- functask)))
6267 ((or (equal keywd "`ifdef")
6268 (equal keywd "`ifndef"))
6269 (setq rvalue t))
6270 ((verilog-typedef-name-p keywd)
6271 (setq typedefed keywd))
6272 ((and expect-signal
6273 (eq functask 0)
6274 (not rvalue)
6275 (eq paren sig-paren)
6276 (not (member keywd verilog-keywords)))
6277 ;; Add new signal to expect-signal's variable
6278 (setq newsig (list keywd vec nil nil enum signed typedefed multidim))
6279 (set expect-signal (cons newsig
6280 (symbol-value expect-signal))))))
6281 (t
6282 (forward-char 1)))
6283 (skip-syntax-forward " "))
6284 ;; Return arguments
6285 (vector (nreverse sigs-out)
6286 (nreverse sigs-inout)
6287 (nreverse sigs-in)
6288 (nreverse sigs-wire)
6289 (nreverse sigs-reg)
6290 (nreverse sigs-assign)
6291 (nreverse sigs-const)
6292 (nreverse sigs-gparam)
6293 ))))
6294
6295(defvar sigs-in nil) ; Prevent compile warning
6296(defvar sigs-inout nil) ; Prevent compile warning
6297(defvar sigs-out nil) ; Prevent compile warning
6298
6299(defun verilog-read-sub-decls-sig (submodi comment port sig vec multidim)
6300 "For verilog-read-sub-decls-line, add a signal."
6301 (let (portdata)
6302 (when sig
6303 (setq port (verilog-symbol-detick-denumber port))
6304 (setq sig (verilog-symbol-detick-denumber sig))
6305 (if sig (setq sig (verilog-string-replace-matches "^[---+~!|&]+" "" nil nil sig)))
6306 (if vec (setq vec (verilog-symbol-detick-denumber vec)))
6307 (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim)))
6308 (unless (or (not sig)
6309 (equal sig "")) ;; Ignore .foo(1'b1) assignments
6310 (cond ((setq portdata (assoc port (verilog-modi-get-inouts submodi)))
6311 (setq sigs-inout (cons (list sig vec (concat "To/From " comment) nil nil
6312 (verilog-sig-signed portdata)
6313 (verilog-sig-type portdata)
6314 multidim)
6315 sigs-inout)))
6316 ((setq portdata (assoc port (verilog-modi-get-outputs submodi)))
6317 (setq sigs-out (cons (list sig vec (concat "From " comment) nil nil
6318 (verilog-sig-signed portdata)
6319 (verilog-sig-type portdata)
6320 multidim)
6321 sigs-out)))
6322 ((setq portdata (assoc port (verilog-modi-get-inputs submodi)))
6323 (setq sigs-in (cons (list sig vec (concat "To " comment) nil nil
6324 (verilog-sig-signed portdata)
6325 (verilog-sig-type portdata)
6326 multidim)
6327 sigs-in)))
6328 ;; (t -- warning pin isn't defined.) ; Leave for lint tool
6329 )))))
6330
6331(defun verilog-read-sub-decls-line (submodi comment)
6332 "For read-sub-decls, read lines of port defs until none match anymore.
6333Return the list of signals found, using submodi to look up each port."
6334 (let (done port sig vec multidim)
6335 (save-excursion
6336 (forward-line 1)
6337 (while (not done)
6338 ;; Get port name
6339 (cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*")
6340 (setq port (match-string 1))
6341 (goto-char (match-end 0)))
6342 ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*")
6343 (setq port (concat (match-string 1) " ")) ;; escaped id's need trailing space
6344 (goto-char (match-end 0)))
6345 ((looking-at "\\s-*\\.[^(]*(")
6346 (setq port nil) ;; skip this line
6347 (goto-char (match-end 0)))
6348 (t
6349 (setq port nil done t))) ;; Unknown, ignore rest of line
6350 ;; Get signal name
6351 (when port
6352 (setq multidim nil)
6353 (cond ((looking-at "\\(\\\\[^ \t\n\f]*\\)\\s-*)")
6354 (setq sig (concat (match-string 1) " ") ;; escaped id's need trailing space
6355 vec nil))
6356 ; We intentionally ignore (non-escaped) signals with .s in them
6357 ; this prevents AUTOWIRE etc from noticing hierarchical sigs.
6358 ((looking-at "\\([^[({).]*\\)\\s-*)")
6359 (setq sig (verilog-string-remove-spaces (match-string 1))
6360 vec nil))
6361 ((looking-at "\\([^[({).]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)")
6362 (setq sig (verilog-string-remove-spaces (match-string 1))
6363 vec (match-string 2)))
6364 ((looking-at "\\([^[({).]*\\)\\s-*/\\*\\(\\[[^*]+\\]\\)\\*/\\s-*)")
6365 (setq sig (verilog-string-remove-spaces (match-string 1))
6366 vec nil)
6367 (let ((parse (match-string 2)))
6368 (while (string-match "^\\(\\[[^]]+\\]\\)\\(.*\\)$" parse)
6369 (when vec (setq multidim (cons vec multidim)))
6370 (setq vec (match-string 1 parse))
6371 (setq parse (match-string 2 parse)))))
6372 ((looking-at "{\\(.*\\)}.*\\s-*)")
6373 (let ((mlst (split-string (match-string 1) ","))
6374 mstr)
6375 (while (setq mstr (pop mlst))
6376 ;;(unless noninteractive (message "sig: %s " mstr))
6377 (cond
6378 ((string-match "\\(['`a-zA-Z0-9_$]+\\)\\s-*$" mstr)
6379 (setq sig (verilog-string-remove-spaces (match-string 1 mstr))
6380 vec nil)
6381 ;;(unless noninteractive (message "concat sig1: %s %s" mstr (match-string 1 mstr)))
6382 )
6383 ((string-match "\\([^[({).]+\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*" mstr)
6384 (setq sig (verilog-string-remove-spaces (match-string 1 mstr))
6385 vec (match-string 2 mstr))
6386 ;;(unless noninteractive (message "concat sig2: '%s' '%s' '%s'" mstr (match-string 1 mstr) (match-string 2 mstr)))
6387 )
6388 (t
6389 (setq sig nil)))
6390 ;; Process signals
6391 (verilog-read-sub-decls-sig submodi comment port sig vec multidim))))
6392 (t
6393 (setq sig nil)))
6394 ;; Process signals
6395 (verilog-read-sub-decls-sig submodi comment port sig vec multidim))
6396 ;;
6397 (forward-line 1)))))
6398
6399(defun verilog-read-sub-decls ()
6400 "Internally parse signals going to modules under this module.
6401Return a array of [ outputs inouts inputs ] signals for modules that are
6402instantiated in this module. For example if declare A A (.B(SIG)) and SIG
6403is a output, then SIG will be included in the list.
6404
6405This only works on instantiations created with /*AUTOINST*/ converted by
6406\\[verilog-auto-inst]. Otherwise, it would have to read in the whole
6407component library to determine connectivity of the design.
6408
6409One work around for this problem is to manually create // Inputs and //
6410Outputs comments above subcell signals, for example:
6411
6412 module1 instance1x (
6413 // Outputs
6414 .out (out),
6415 // Inputs
6416 .in (in));"
6417 (save-excursion
6418 (let ((end-mod-point (verilog-get-end-of-defun t))
6419 st-point end-inst-point
6420 ;; below 3 modified by verilog-read-sub-decls-line
6421 sigs-out sigs-inout sigs-in)
6422 (verilog-beg-of-defun)
6423 (while (re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t)
6424 (save-excursion
6425 (goto-char (match-beginning 0))
6426 (unless (verilog-inside-comment-p)
6427 ;; Attempt to snarf a comment
6428 (let* ((submod (verilog-read-inst-module))
6429 (inst (verilog-read-inst-name))
6430 (comment (concat inst " of " submod ".v")) submodi)
6431 (when (setq submodi (verilog-modi-lookup submod t))
6432 ;; This could have used a list created by verilog-auto-inst
6433 ;; However I want it to be runnable even on user's manually added signals
6434 (verilog-backward-open-paren)
6435 (setq end-inst-point (save-excursion (forward-sexp 1) (point))
6436 st-point (point))
6437 (while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t)
6438 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-out
6439 (goto-char st-point)
6440 (while (re-search-forward "\\s *// Inouts" end-inst-point t)
6441 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-inout
6442 (goto-char st-point)
6443 (while (re-search-forward "\\s *// Inputs" end-inst-point t)
6444 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-in
6445 )))))
6446 ;; Combine duplicate bits
6447 ;;(setq rr (vector sigs-out sigs-inout sigs-in))
6448 (vector (verilog-signals-combine-bus (nreverse sigs-out))
6449 (verilog-signals-combine-bus (nreverse sigs-inout))
6450 (verilog-signals-combine-bus (nreverse sigs-in))))))
6451
6452(defun verilog-read-inst-pins ()
6453 "Return a array of [ pins ] for the current instantiation at point.
6454For example if declare A A (.B(SIG)) then B will be included in the list."
6455 (save-excursion
6456 (let ((end-mod-point (point)) ;; presume at /*AUTOINST*/ point
6457 pins pin)
6458 (verilog-backward-open-paren)
6459 (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t)
6460 (setq pin (match-string 1))
6461 (unless (verilog-inside-comment-p)
6462 (setq pins (cons (list pin) pins))
6463 (when (looking-at "(")
6464 (forward-sexp 1))))
6465 (vector pins))))
6466
6467(defun verilog-read-arg-pins ()
6468 "Return a array of [ pins ] for the current argument declaration at point."
6469 (save-excursion
6470 (let ((end-mod-point (point)) ;; presume at /*AUTOARG*/ point
6471 pins pin)
6472 (verilog-backward-open-paren)
6473 (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t)
6474 (setq pin (match-string 1))
6475 (unless (verilog-inside-comment-p)
6476 (setq pins (cons (list pin) pins))))
6477 (vector pins))))
6478
6479(defun verilog-read-auto-constants (beg end-mod-point)
6480 "Return a list of AUTO_CONSTANTs used in the region from BEG to END-MOD-POINT."
6481 ;; Insert new
6482 (save-excursion
6483 (let (sig-list tpl-end-pt)
6484 (goto-char beg)
6485 (while (re-search-forward "\\<AUTO_CONSTANT" end-mod-point t)
6486 (if (not (looking-at "\\s *("))
6487 (error "%s: Missing () after AUTO_CONSTANT" (verilog-point-text)))
6488 (search-forward "(" end-mod-point)
6489 (setq tpl-end-pt (save-excursion
6490 (backward-char 1)
6491 (forward-sexp 1) ;; Moves to paren that closes argdecl's
6492 (backward-char 1)
6493 (point)))
6494 (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t)
6495 (setq sig-list (cons (list (match-string 1) nil nil) sig-list))))
6496 sig-list)))
6497
6498(defun verilog-read-auto-lisp (start end)
6499 "Look for and evaluate a AUTO_LISP between START and END."
6500 (save-excursion
6501 (goto-char start)
6502 (while (re-search-forward "\\<AUTO_LISP(" end t)
6503 (backward-char)
6504 (let* ((beg-pt (prog1 (point)
6505 (forward-sexp 1))) ;; Closing paren
6506 (end-pt (point)))
6507 (eval-region beg-pt end-pt nil)))))
6508
6509(eval-when-compile
6510 ;; These are passed in a let, not global
6511 (if (not (boundp 'sigs-in))
6512 (defvar sigs-in nil) (defvar sigs-out nil)
6513 (defvar got-sig nil) (defvar got-rvalue nil) (defvar uses-delayed nil)))
6514
6515(defun verilog-read-always-signals-recurse
6516 (exit-keywd rvalue ignore-next)
6517 "Recursive routine for parentheses/bracket matching.
6518EXIT-KEYWD is expression to stop at, nil if top level.
6519RVALUE is true if at right hand side of equal.
6520IGNORE-NEXT is true to ignore next token, fake from inside case statement."
6521 (let* ((semi-rvalue (equal "endcase" exit-keywd)) ;; true if after a ; we are looking for rvalue
6522 keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-rvalue end-else-check)
6523 ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue ignore-next))))
6524 (while (not (or (eobp) gotend))
6525 (cond
6526 ((looking-at "//")
6527 (search-forward "\n"))
6528 ((looking-at "/\\*")
6529 (or (search-forward "*/")
6530 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
6531 ((looking-at "(\\*")
6532 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)"
6533 (search-forward "*)")
6534 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
6535 (t (setq keywd (buffer-substring-no-properties
6536 (point)
6537 (save-excursion (when (eq 0 (skip-chars-forward "a-zA-Z0-9$_.%`"))
6538 (forward-char 1))
6539 (point)))
6540 sig-last-tolk sig-tolk
6541 sig-tolk nil)
6542 ;;(if dbg (setq dbg (concat dbg (format "\tPt=%S %S\trv=%S in=%S ee=%S\n" (point) keywd rvalue ignore-next end-else-check))))
6543 (cond
6544 ((equal keywd "\"")
6545 (or (re-search-forward "[^\\]\"" nil t)
6546 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point))))
6547 ;; else at top level loop, keep parsing
6548 ((and end-else-check (equal keywd "else"))
6549 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else %s\n" keywd))))
6550 ;; no forward movement, want to see else in lower loop
6551 (setq end-else-check nil))
6552 ;; End at top level loop
6553 ((and end-else-check (looking-at "[^ \t\n\f]"))
6554 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else-other %s\n" keywd))))
6555 (setq gotend t))
6556 ;; Final statement?
6557 ((and exit-keywd (equal keywd exit-keywd))
6558 (setq gotend t)
6559 (forward-char (length keywd)))
6560 ;; Standard tokens...
6561 ((equal keywd ";")
6562 (setq ignore-next nil rvalue semi-rvalue)
6563 ;; Final statement at top level loop?
6564 (when (not exit-keywd)
6565 ;;(if dbg (setq dbg (concat dbg (format "\ttop-end-check %s\n" keywd))))
6566 (setq end-else-check t))
6567 (forward-char 1))
6568 ((equal keywd "'")
6569 (if (looking-at "'s?[hdxbo][0-9a-fA-F_xz? \t]*")
6570 (goto-char (match-end 0))
6571 (forward-char 1)))
6572 ((equal keywd ":") ;; Case statement, begin/end label, x?y:z
6573 (cond ((equal "endcase" exit-keywd) ;; case x: y=z; statement next
6574 (setq ignore-next nil rvalue nil))
6575 ((equal "?" exit-keywd) ;; x?y:z rvalue
6576 ) ;; NOP
6577 (got-sig ;; label: statement
6578 (setq ignore-next nil rvalue semi-rvalue got-sig nil))
6579 ((not rvalue) ;; begin label
6580 (setq ignore-next t rvalue nil)))
6581 (forward-char 1))
6582 ((equal keywd "=")
6583 (if (eq (char-before) ?< )
6584 (setq uses-delayed 1))
6585 (setq ignore-next nil rvalue t)
6586 (forward-char 1))
6587 ((equal keywd "?")
6588 (forward-char 1)
6589 (verilog-read-always-signals-recurse ":" rvalue nil))
6590 ((equal keywd "[")
6591 (forward-char 1)
6592 (verilog-read-always-signals-recurse "]" t nil))
6593 ((equal keywd "(")
6594 (forward-char 1)
6595 (cond (sig-last-tolk ;; Function call; zap last signal
6596 (setq got-sig nil)))
6597 (cond ((equal last-keywd "for")
6598 (verilog-read-always-signals-recurse ";" nil nil)
6599 (verilog-read-always-signals-recurse ";" t nil)
6600 (verilog-read-always-signals-recurse ")" nil nil))
6601 (t (verilog-read-always-signals-recurse ")" t nil))))
6602 ((equal keywd "begin")
6603 (skip-syntax-forward "w_")
6604 (verilog-read-always-signals-recurse "end" nil nil)
6605 ;;(if dbg (setq dbg (concat dbg (format "\tgot-end %s\n" exit-keywd))))
6606 (setq ignore-next nil rvalue semi-rvalue)
6607 (if (not exit-keywd) (setq end-else-check t)))
6608 ((or (equal keywd "case")
6609 (equal keywd "casex")
6610 (equal keywd "casez"))
6611 (skip-syntax-forward "w_")
6612 (verilog-read-always-signals-recurse "endcase" t nil)
6613 (setq ignore-next nil rvalue semi-rvalue)
6614 (if (not exit-keywd) (setq gotend t))) ;; top level begin/end
6615 ((string-match "^[$`a-zA-Z_]" keywd) ;; not exactly word constituent
6616 (cond ((or (equal keywd "`ifdef")
6617 (equal keywd "`ifndef"))
6618 (setq ignore-next t))
6619 ((or ignore-next
6620 (member keywd verilog-keywords)
6621 (string-match "^\\$" keywd)) ;; PLI task
6622 (setq ignore-next nil))
6623 (t
6624 (setq keywd (verilog-symbol-detick-denumber keywd))
6625 (when got-sig
6626 (if got-rvalue (setq sigs-in (cons got-sig sigs-in))
6627 (setq sigs-out (cons got-sig sigs-out)))
6628 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue))))
6629 )
6630 (setq got-rvalue rvalue
6631 got-sig (if (or (not keywd)
6632 (assoc keywd (if got-rvalue sigs-in sigs-out)))
6633 nil (list keywd nil nil))
6634 sig-tolk t)))
6635 (skip-chars-forward "a-zA-Z0-9$_.%`"))
6636 (t
6637 (forward-char 1)))
6638 ;; End of non-comment token
6639 (setq last-keywd keywd)
6640 ))
6641 (skip-syntax-forward " "))
6642 ;; Append the final pending signal
6643 (when got-sig
6644 (if got-rvalue (setq sigs-in (cons got-sig sigs-in))
6645 (setq sigs-out (cons got-sig sigs-out)))
6646 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue))))
6647 (setq got-sig nil))
6648 ;;(if dbg (setq dbg (concat dbg (format "ENDRecursion %s\n" exit-keywd))))
6649 ))
6650
6651(defun verilog-read-always-signals ()
6652 "Parse always block at point and return list of (outputs inout inputs)."
6653 ;; Insert new
6654 (save-excursion
6655 (let* (;;(dbg "")
6656 sigs-in sigs-out
6657 uses-delayed) ;; Found signal/rvalue; push if not function
6658 (search-forward ")")
6659 (verilog-read-always-signals-recurse nil nil nil)
6660 ;;(if dbg (save-excursion (set-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg "")))
6661 ;; Return what was found
6662 (list sigs-out nil sigs-in uses-delayed))))
6663
6664(defun verilog-read-instants ()
6665 "Parse module at point and return list of ( ( file instance ) ... )."
6666 (verilog-beg-of-defun)
6667 (let* ((end-mod-point (verilog-get-end-of-defun t))
6668 (state nil)
6669 (instants-list nil))
6670 (save-excursion
6671 (while (< (point) end-mod-point)
6672 ;; Stay at level 0, no comments
6673 (while (progn
6674 (setq state (parse-partial-sexp (point) end-mod-point 0 t nil))
6675 (or (> (car state) 0) ; in parens
6676 (nth 5 state) ; comment
6677 ))
6678 (forward-line 1))
6679 (beginning-of-line)
6680 (if (looking-at "^\\s-*\\([a-zA-Z0-9`_$]+\\)\\s-+\\([a-zA-Z0-9`_$]+\\)\\s-*(")
6681 ;;(if (looking-at "^\\(.+\\)$")
6682 (let ((module (match-string 1))
6683 (instant (match-string 2)))
6684 (if (not (member module verilog-keywords))
6685 (setq instants-list (cons (list module instant) instants-list)))))
6686 (forward-line 1)
6687 ))
6688 instants-list))
6689
6690
6691(defun verilog-read-auto-template (module)
6692 "Look for a auto_template for the instantiation of the given MODULE.
6693If found returns the signal name connections. Return REGEXP and
6694list of ( (signal_name connection_name)... )"
6695 (save-excursion
6696 ;; Find beginning
6697 (let ((tpl-regexp "\\([0-9]+\\)")
6698 (lineno 0)
6699 (templateno 0)
6700 tpl-sig-list tpl-wild-list tpl-end-pt rep)
6701 (cond ((or
6702 (re-search-backward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t)
6703 (progn
6704 (goto-char (point-min))
6705 (re-search-forward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t)))
6706 (goto-char (match-end 0))
6707 ;; Parse "REGEXP"
6708 ;; We reserve @"..." for future lisp expressions that evaluate once-per-AUTOINST
6709 (when (looking-at "\\s-*\"\\([^\"]*)\\)\"")
6710 (setq tpl-regexp (match-string 1))
6711 (goto-char (match-end 0)))
6712 (search-forward "(")
6713 ;; Parse lines in the template
6714 (when verilog-auto-inst-template-numbers
6715 (save-excursion
6716 (goto-char (point-min))
6717 (while (search-forward "AUTO_TEMPLATE" nil t)
6718 (setq templateno (1+ templateno)))))
6719 (setq tpl-end-pt (save-excursion
6720 (backward-char 1)
6721 (forward-sexp 1) ;; Moves to paren that closes argdecl's
6722 (backward-char 1)
6723 (point)))
6724 ;;
6725 (while (< (point) tpl-end-pt)
6726 (cond ((looking-at "\\s-*\\.\\([a-zA-Z0-9`_$]+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
6727 (setq tpl-sig-list (cons (list
6728 (match-string-no-properties 1)
6729 (match-string-no-properties 2)
6730 templateno lineno)
6731 tpl-sig-list))
6732 (goto-char (match-end 0)))
6733 ;; Regexp form??
6734 ((looking-at
6735 ;; Regexp bug in xemacs disallows ][ inside [], and wants + last
6736 "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
6737 (setq rep (match-string-no-properties 3))
6738 (goto-char (match-end 0))
6739 (setq tpl-wild-list
6740 (cons (list
6741 (concat "^"
6742 (verilog-string-replace-matches "@" "\\\\([0-9]+\\\\)" nil nil
6743 (match-string 1))
6744 "$")
6745 rep
6746 templateno lineno)
6747 tpl-wild-list)))
6748 ((looking-at "[ \t\f]+")
6749 (goto-char (match-end 0)))
6750 ((looking-at "\n")
6751 (setq lineno (1+ lineno))
6752 (goto-char (match-end 0)))
6753 ((looking-at "//")
6754 (search-forward "\n"))
6755 ((looking-at "/\\*")
6756 (forward-char 2)
6757 (or (search-forward "*/")
6758 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
6759 (t
6760 (error "%s: AUTO_TEMPLATE parsing error: %s"
6761 (verilog-point-text)
6762 (progn (looking-at ".*$") (match-string 0))))
6763 ))
6764 ;; Return
6765 (vector tpl-regexp
6766 (list tpl-sig-list tpl-wild-list)))
6767 ;; If no template found
6768 (t (vector tpl-regexp nil))))))
6769;;(progn (find-file "auto-template.v") (verilog-read-auto-template "ptl_entry"))
6770
6771(defun verilog-set-define (defname defvalue &optional buffer enumname)
6772 "Set the definition DEFNAME to the DEFVALUE in the given BUFFER.
6773Optionally associate it with the specified enumeration ENUMNAME."
6774 (save-excursion
6775 (set-buffer (or buffer (current-buffer)))
6776 (let ((mac (intern (concat "vh-" defname))))
6777 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1)
6778 ;; Need to define to a constant if no value given
6779 (set (make-variable-buffer-local mac)
6780 (if (equal defvalue "") "1" defvalue)))
6781 (if enumname
6782 (let ((enumvar (intern (concat "venum-" enumname))))
6783 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1)
6784 (make-variable-buffer-local enumvar)
6785 (add-to-list enumvar defname)))
6786 ))
6787
6788(defun verilog-read-defines (&optional filename recurse subcall)
6789 "Read `defines and parameters for the current file, or optional FILENAME.
6790If the filename is provided, `verilog-library-flags' will be used to
6791resolve it. If optional RECURSE is non-nil, recurse through `includes.
6792
6793Parameters must be simple assignments to constants, or have their own
6794\"parameter\" label rather than a list of parameters. Thus:
6795
6796 parameter X = 5, Y = 10; // Ok
6797 parameter X = {1'b1, 2'h2}; // Ok
6798 parameter X = {1'b1, 2'h2}, Y = 10; // Bad, make into 2 parameter lines
6799
6800Defines must be simple text substitutions, one on a line, starting
6801at the beginning of the line. Any ifdefs or multiline comments around the
6802define are ignored.
6803
6804Defines are stored inside Emacs variables using the name vh-{definename}.
6805
6806This function is useful for setting vh-* variables. The file variables
6807feature can be used to set defines that `verilog-mode' can see; put at the
6808*END* of your file something like:
6809
6810 // Local Variables:
6811 // vh-macro:\"macro_definition\"
6812 // End:
6813
6814If macros are defined earlier in the same file and you want their values,
6815you can read them automatically (provided `enable-local-eval' is on):
6816
6817 // Local Variables:
6818 // eval:(verilog-read-defines)
6819 // eval:(verilog-read-defines \"group_standard_includes.v\")
6820 // End:
6821
6822Note these are only read when the file is first visited, you must use
6823\\[find-alternate-file] RET to have these take effect after editing them!
6824
6825If you want to disable the \"Process `eval' or hook local variables\"
6826warning message, you need to add to your .emacs file:
6827
6828 (setq enable-local-eval t)"
6829 (let ((origbuf (current-buffer)))
6830 (save-excursion
6831 (unless subcall (verilog-getopt-flags))
6832 (when filename
6833 (let ((fns (verilog-library-filenames filename (buffer-file-name))))
6834 (if fns
6835 (set-buffer (find-file-noselect (car fns)))
6836 (error (concat (verilog-point-text)
6837 ": Can't find verilog-read-defines file: " filename)))))
6838 (when recurse
6839 (goto-char (point-min))
6840 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t)
6841 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string-no-properties 1))))
6842 (unless (verilog-inside-comment-p)
6843 (verilog-read-defines inc recurse t)))))
6844 ;; Read `defines
6845 ;; note we don't use verilog-re... it's faster this way, and that
6846 ;; function has problems when comments are at the end of the define
6847 (goto-char (point-min))
6848 (while (re-search-forward "^\\s-*`define\\s-+\\([a-zA-Z0-9_$]+\\)\\s-+\\(.*\\)$" nil t)
6849 (let ((defname (match-string-no-properties 1))
6850 (defvalue (match-string-no-properties 2)))
6851 (setq defvalue (verilog-string-replace-matches "\\s-*/[/*].*$" "" nil nil defvalue))
6852 (verilog-set-define defname defvalue origbuf)))
6853 ;; Hack: Read parameters
6854 (goto-char (point-min))
6855 (while (re-search-forward
6856 "^\\s-*\\(parameter\\|localparam\\)\\(\\(\\s-*\\[[^]]*\\]\\|\\)\\s-+\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\|\\)\\s-*" nil t)
6857 (let ((var (match-string-no-properties 4))
6858 (val (match-string-no-properties 5))
6859 enumname)
6860 ;; The primary way of getting defines is verilog-read-decls
6861 ;; However, that isn't called yet for included files, so we'll add another scheme
6862 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
6863 (setq enumname (match-string-no-properties 1)))
6864 (if var
6865 (verilog-set-define var val origbuf enumname))
6866 (forward-comment 999)
6867 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*")
6868 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname)
6869 (goto-char (match-end 0))
6870 (forward-comment 999))))
6871 )))
6872
6873(defun verilog-read-includes ()
6874 "Read `includes for the current file.
6875This will find all of the `includes which are at the beginning of lines,
6876ignoring any ifdefs or multiline comments around them.
6877`verilog-read-defines' is then performed on the current and each included
6878file.
6879
6880It is often useful put at the *END* of your file something like:
6881
6882 // Local Variables:
6883 // eval:(verilog-read-defines)
6884 // eval:(verilog-read-includes)
6885 // End:
6886
6887Note includes are only read when the file is first visited, you must use
6888\\[find-alternate-file] RET to have these take effect after editing them!
6889
6890It is good to get in the habit of including all needed files in each .v
6891file that needs it, rather than waiting for compile time. This will aid
6892this process, Verilint, and readability. To prevent defining the same
6893variable over and over when many modules are compiled together, put a test
6894around the inside each include file:
6895
6896foo.v (a include):
6897 `ifdef _FOO_V // include if not already included
6898 `else
6899 `define _FOO_V
6900 ... contents of file
6901 `endif // _FOO_V"
6902;;slow: (verilog-read-defines nil t))
6903 (save-excursion
6904 (verilog-getopt-flags)
6905 (goto-char (point-min))
6906 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t)
6907 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string 1))))
6908 (verilog-read-defines inc nil t)))))
6909
6910(defun verilog-read-signals (&optional start end)
6911 "Return a simple list of all possible signals in the file.
6912Bounded by optional region from START to END. Overly aggressive but fast.
6913Some macros and such are also found and included. For dinotrace.el"
6914 (let (sigs-all keywd)
6915 (progn;save-excursion
6916 (goto-char (or start (point-min)))
6917 (setq end (or end (point-max)))
6918 (while (re-search-forward "[\"/a-zA-Z_.%`]" end t)
6919 (forward-char -1)
6920 (cond
6921 ((looking-at "//")
6922 (search-forward "\n"))
6923 ((looking-at "/\\*")
6924 (search-forward "*/"))
6925 ((looking-at "(\\*")
6926 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)"
6927 (search-forward "*)")))
6928 ((eq ?\" (following-char))
6929 (re-search-forward "[^\\]\"")) ;; don't forward-char first, since we look for a non backslash first
6930 ((looking-at "\\s-*\\([a-zA-Z0-9$_.%`]+\\)")
6931 (goto-char (match-end 0))
6932 (setq keywd (match-string-no-properties 1))
6933 (or (member keywd verilog-keywords)
6934 (member keywd sigs-all)
6935 (setq sigs-all (cons keywd sigs-all))))
6936 (t (forward-char 1)))
6937 )
6938 ;; Return list
6939 sigs-all)))
6940
6941;;
6942;; Argument file parsing
6943;;
6944
6945(defun verilog-getopt (arglist)
6946 "Parse -f, -v etc arguments in ARGLIST list or string."
6947 (unless (listp arglist) (setq arglist (list arglist)))
6948 (let ((space-args '())
6949 arg next-param)
6950 ;; Split on spaces, so users can pass whole command lines
6951 (while arglist
6952 (setq arg (car arglist)
6953 arglist (cdr arglist))
6954 (while (string-match "^\\([^ \t\n\f]+\\)[ \t\n\f]*\\(.*$\\)" arg)
6955 (setq space-args (append space-args
6956 (list (match-string-no-properties 1 arg))))
6957 (setq arg (match-string 2 arg))))
6958 ;; Parse arguments
6959 (while space-args
6960 (setq arg (car space-args)
6961 space-args (cdr space-args))
6962 (cond
6963 ;; Need another arg
6964 ((equal arg "-f")
6965 (setq next-param arg))
6966 ((equal arg "-v")
6967 (setq next-param arg))
6968 ((equal arg "-y")
6969 (setq next-param arg))
6970 ;; +libext+(ext1)+(ext2)...
6971 ((string-match "^\\+libext\\+\\(.*\\)" arg)
6972 (setq arg (match-string 1 arg))
6973 (while (string-match "\\([^+]+\\)\\+?\\(.*\\)" arg)
6974 (verilog-add-list-unique `verilog-library-extensions
6975 (match-string 1 arg))
6976 (setq arg (match-string 2 arg))))
6977 ;;
6978 ((or (string-match "^-D\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; -Ddefine=val
6979 (string-match "^-D\\([^+=]*\\)\\(\\)" arg) ;; -Ddefine
6980 (string-match "^\\+define\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; +define+val
6981 (string-match "^\\+define\\([^+=]*\\)\\(\\)" arg)) ;; +define+define
6982 (verilog-set-define (match-string 1 arg) (match-string 2 arg)))
6983 ;;
6984 ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ;; +incdir+dir
6985 (string-match "^-I\\(.*\\)" arg)) ;; -Idir
6986 (verilog-add-list-unique `verilog-library-directories
6987 (match-string 1 arg)))
6988 ;; Ignore
6989 ((equal "+librescan" arg))
6990 ((string-match "^-U\\(.*\\)" arg)) ;; -Udefine
6991 ;; Second parameters
6992 ((equal next-param "-f")
6993 (setq next-param nil)
6994 (verilog-getopt-file arg))
6995 ((equal next-param "-v")
6996 (setq next-param nil)
6997 (verilog-add-list-unique `verilog-library-files arg))
6998 ((equal next-param "-y")
6999 (setq next-param nil)
7000 (verilog-add-list-unique `verilog-library-directories arg))
7001 ;; Filename
7002 ((string-match "^[^-+]" arg)
7003 (verilog-add-list-unique `verilog-library-files arg))
7004 ;; Default - ignore; no warning
7005 )
7006 )
7007 )
7008 )
7009;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir"))
7010
7011(defun verilog-getopt-file (filename)
7012 "Read verilog options from the specified FILENAME."
7013 (save-excursion
7014 (let ((fns (verilog-library-filenames filename (buffer-file-name)))
7015 (orig-buffer (current-buffer))
7016 line)
7017 (if fns
7018 (set-buffer (find-file-noselect (car fns)))
7019 (error (concat (verilog-point-text)
7020 "Can't find verilog-getopt-file -f file: " filename)))
7021 (goto-char (point-min))
7022 (while (not (eobp))
7023 (setq line (buffer-substring (point)
7024 (save-excursion (end-of-line) (point))))
7025 (forward-line 1)
7026 (when (string-match "//" line)
7027 (setq line (substring line 0 (match-beginning 0))))
7028 (save-excursion
7029 (set-buffer orig-buffer) ; Variables are buffer-local, so need right context.
7030 (verilog-getopt line))))))
7031
7032(defun verilog-getopt-flags ()
7033 "Convert `verilog-library-flags' into standard library variables."
7034 ;; If the flags are local, then all the outputs should be local also
7035 (when (local-variable-p `verilog-library-flags (current-buffer))
7036 (make-variable-buffer-local 'verilog-library-extensions)
7037 (make-variable-buffer-local 'verilog-library-directories)
7038 (make-variable-buffer-local 'verilog-library-files)
7039 (make-variable-buffer-local 'verilog-library-flags))
7040 ;; Allow user to customize
7041 (run-hooks 'verilog-before-getopt-flags-hook)
7042 ;; Process arguments
7043 (verilog-getopt verilog-library-flags)
7044 ;; Allow user to customize
7045 (run-hooks 'verilog-getopt-flags-hook))
7046
7047(defun verilog-add-list-unique (varref object)
7048 "Append to VARREF list the given OBJECT,
7049unless it is already a member of the variable's list"
7050 (unless (member object (symbol-value varref))
7051 (set varref (append (symbol-value varref) (list object))))
7052 varref)
7053;;(progn (setq l '()) (verilog-add-list-unique `l "a") (verilog-add-list-unique `l "a") l)
7054
7055
7056;;
7057;; Module name lookup
7058;;
7059
7060(defun verilog-module-inside-filename-p (module filename)
7061 "Return point if MODULE is specified inside FILENAME, else nil.
7062Allows version control to check out the file if need be."
7063 (and (or (file-exists-p filename)
7064 (and
7065 (condition-case nil
7066 (fboundp 'vc-backend)
7067 (error nil))
7068 (vc-backend filename)))
7069 (let (pt)
7070 (save-excursion
7071 (set-buffer (find-file-noselect filename))
7072 (goto-char (point-min))
7073 (while (and
7074 ;; It may be tempting to look for verilog-defun-re, don't, it slows things down a lot!
7075 (verilog-re-search-forward-quick "\\<module\\>" nil t)
7076 (verilog-re-search-forward-quick "[(;]" nil t))
7077 (if (equal module (verilog-read-module-name))
7078 (setq pt (point))))
7079 pt))))
7080
7081(defun verilog-is-number (symbol)
7082 "Return true if SYMBOL is number-like."
7083 (or (string-match "^[0-9 \t:]+$" symbol)
7084 (string-match "^[---]*[0-9]+$" symbol)
7085 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol)
7086 ))
7087
7088(defun verilog-symbol-detick (symbol wing-it)
7089 "Return a expanded SYMBOL name without any defines.
7090If the variable vh-{symbol} is defined, return that value.
7091If undefined, and WING-IT, return just SYMBOL without the tick, else nil."
7092 (while (and symbol (string-match "^`" symbol))
7093 (setq symbol (substring symbol 1))
7094 (setq symbol
7095 (if (boundp (intern (concat "vh-" symbol)))
7096 ;; Emacs has a bug where boundp on a buffer-local
7097 ;; variable in only one buffer returns t in another.
7098 ;; This can confuse, so check for nil.
7099 (let ((val (eval (intern (concat "vh-" symbol)))))
7100 (if (eq val nil)
7101 (if wing-it symbol nil)
7102 val))
7103 (if wing-it symbol nil))))
7104 symbol)
7105;;(verilog-symbol-detick "`mod" nil)
7106
7107(defun verilog-symbol-detick-denumber (symbol)
7108 "Return SYMBOL with defines converted and any numbers dropped to nil."
7109 (when (string-match "^`" symbol)
7110 ;; This only will work if the define is a simple signal, not
7111 ;; something like a[b]. Sorry, it should be substituted into the parser
7112 (setq symbol
7113 (verilog-string-replace-matches
7114 "\[[^0-9: \t]+\]" "" nil nil
7115 (or (verilog-symbol-detick symbol nil)
7116 (if verilog-auto-sense-defines-constant
7117 "0"
7118 symbol)))))
7119 (if (verilog-is-number symbol)
7120 nil
7121 symbol))
7122
7123(defun verilog-symbol-detick-text (text)
7124 "Return TEXT with any without any known defines.
7125If the variable vh-{symbol} is defined, substitute that value."
7126 (let ((ok t) symbol val)
7127 (while (and ok (string-match "`\\([a-zA-Z0-9_]+\\)" text))
7128 (setq symbol (match-string 1 text))
7129 (message symbol)
7130 (cond ((and
7131 (boundp (intern (concat "vh-" symbol)))
7132 ;; Emacs has a bug where boundp on a buffer-local
7133 ;; variable in only one buffer returns t in another.
7134 ;; This can confuse, so check for nil.
7135 (setq val (eval (intern (concat "vh-" symbol)))))
7136 (setq text (replace-match val nil nil text)))
7137 (t (setq ok nil)))))
7138 text)
7139;;(progn (setq vh-mod "`foo" vh-foo "bar") (verilog-symbol-detick-text "bar `mod `undefed"))
7140
7141(defun verilog-expand-dirnames (&optional dirnames)
7142 "Return a list of existing directories given a list of wildcarded DIRNAMES.
7143Or, just the existing dirnames themselves if there are no wildcards."
7144 (interactive)
7145 (unless dirnames (error "`verilog-library-directories' should include at least '.'"))
7146 (setq dirnames (reverse dirnames)) ; not nreverse
7147 (let ((dirlist nil)
7148 pattern dirfile dirfiles dirname root filename rest)
7149 (while dirnames
7150 (setq dirname (substitute-in-file-name (car dirnames))
7151 dirnames (cdr dirnames))
7152 (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ;; root
7153 "\\([^/\\]*[*?][^/\\]*\\)" ;; filename with *?
7154 "\\(.*\\)") ;; rest
7155 dirname)
7156 (setq root (match-string 1 dirname)
7157 filename (match-string 2 dirname)
7158 rest (match-string 3 dirname)
7159 pattern filename)
7160 ;; now replace those * and ? with .+ and .
7161 ;; use ^ and /> to get only whole file names
7162 ;;verilog-string-replace-matches
7163 (setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern)
7164 pattern (verilog-string-replace-matches "[?]" "." nil nil pattern)
7165
7166 ;; Unfortunately allows abc/*/rtl to match abc/rtl
7167 ;; because abc/.. shows up in dirfiles. Solutions welcome.
7168 dirfiles (if (file-directory-p root) ; Ignore version control external
7169 (directory-files root t pattern nil)))
7170 (while dirfiles
7171 (setq dirfile (expand-file-name (concat (car dirfiles) rest))
7172 dirfiles (cdr dirfiles))
7173 (if (file-directory-p dirfile)
7174 (setq dirlist (cons dirfile dirlist))))
7175 )
7176 ;; Defaults
7177 (t
7178 (if (file-directory-p dirname)
7179 (setq dirlist (cons dirname dirlist))))
7180 ))
7181 dirlist))
7182;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v"))
7183
7184(defun verilog-library-filenames (filename current &optional check-ext)
7185 "Return a search path to find the given FILENAME name.
7186Uses the CURRENT filename, `verilog-library-directories' and
7187`verilog-library-extensions' variables to build the path.
7188With optional CHECK-EXT also check `verilog-library-extensions'."
7189 (let ((ckdir (verilog-expand-dirnames verilog-library-directories))
7190 fn outlist)
7191 (while ckdir
7192 (let ((ckext (if check-ext verilog-library-extensions `(""))))
7193 (while ckext
7194 (setq fn (expand-file-name
7195 (concat filename (car ckext))
7196 (expand-file-name (car ckdir) (file-name-directory current))))
7197 (if (file-exists-p fn)
7198 (setq outlist (cons fn outlist)))
7199 (setq ckext (cdr ckext))))
7200 (setq ckdir (cdr ckdir)))
7201 (nreverse outlist)))
7202
7203(defun verilog-module-filenames (module current)
7204 "Return a search path to find the given MODULE name.
7205Uses the CURRENT filename, `verilog-library-extensions',
7206`verilog-library-directories' and `verilog-library-files'
7207variables to build the path."
7208 ;; Return search locations for it
7209 (append (list current) ; first, current buffer
7210 (verilog-library-filenames module current t)
7211 verilog-library-files)) ; finally, any libraries
7212
7213;;
7214;; Module Information
7215;;
7216;; Many of these functions work on "modi" a module information structure
7217;; A modi is: [module-name-string file-name begin-point]
7218
7219(defvar verilog-cache-enabled t
7220 "If true, enable caching of signals, etc. Set to nil for debugging to make things SLOW!")
7221
7222(defvar verilog-modi-cache-list nil
7223 "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)...
7224For speeding up verilog-modi-get-* commands.
7225Buffer-local.")
7226
7227(defvar verilog-modi-cache-preserve-tick nil
7228 "Modification tick after which the cache is still considered valid.
7229Use verilog-preserve-cache's to set")
7230(defvar verilog-modi-cache-preserve-buffer nil
7231 "Modification tick after which the cache is still considered valid.
7232Use verilog-preserve-cache's to set")
7233
7234(defun verilog-modi-current ()
7235 "Return the modi structure for the module currently at point."
7236 (let* (name pt)
7237 ;; read current module's name
7238 (save-excursion
7239 (verilog-re-search-backward-quick verilog-defun-re nil nil)
7240 (verilog-re-search-forward-quick "(" nil nil)
7241 (setq name (verilog-read-module-name))
7242 (setq pt (point)))
7243 ;; return
7244 (vector name (or (buffer-file-name) (current-buffer)) pt)))
7245
7246(defvar verilog-modi-lookup-last-mod nil "Cache of last module looked up.")
7247(defvar verilog-modi-lookup-last-modi nil "Cache of last modi returned.")
7248(defvar verilog-modi-lookup-last-current nil "Cache of last `current-buffer' looked up.")
7249(defvar verilog-modi-lookup-last-tick nil "Cache of last `buffer-modified-tick' looked up.")
7250
7251(defun verilog-modi-lookup (module allow-cache &optional ignore-error)
7252 "Find the file and point at which MODULE is defined.
7253If ALLOW-CACHE is set, check and remember cache of previous lookups.
7254Return modi if successful, else print message unless IGNORE-ERROR is true."
7255 (let* ((current (or (buffer-file-name) (current-buffer))))
7256 (cond ((and verilog-modi-lookup-last-modi
7257 verilog-cache-enabled
7258 allow-cache
7259 (equal verilog-modi-lookup-last-mod module)
7260 (equal verilog-modi-lookup-last-current current)
7261 (equal verilog-modi-lookup-last-tick (buffer-modified-tick)))
7262 ;; ok as is
7263 )
7264 (t (let* ((realmod (verilog-symbol-detick module t))
7265 (orig-filenames (verilog-module-filenames realmod current))
7266 (filenames orig-filenames)
7267 pt)
7268 (while (and filenames (not pt))
7269 (if (not (setq pt (verilog-module-inside-filename-p realmod (car filenames))))
7270 (setq filenames (cdr filenames))))
7271 (cond (pt (setq verilog-modi-lookup-last-modi
7272 (vector realmod (car filenames) pt)))
7273 (t (setq verilog-modi-lookup-last-modi nil)
7274 (or ignore-error
7275 (error (concat (verilog-point-text)
7276 ": Can't locate " module " module definition"
7277 (if (not (equal module realmod))
7278 (concat " (Expanded macro to " realmod ")")
7279 "")
7280 "\n Check the verilog-library-directories variable."
7281 "\n I looked in (if not listed, doesn't exist):\n\t"
7282 (mapconcat 'concat orig-filenames "\n\t")))))
7283 )
7284 (setq verilog-modi-lookup-last-mod module
7285 verilog-modi-lookup-last-current current
7286 verilog-modi-lookup-last-tick (buffer-modified-tick)))))
7287 verilog-modi-lookup-last-modi
7288 ))
7289
7290(defsubst verilog-modi-name (modi)
7291 (aref modi 0))
7292(defsubst verilog-modi-file-or-buffer (modi)
7293 (aref modi 1))
7294(defsubst verilog-modi-point (modi)
7295 (aref modi 2))
7296
7297(defun verilog-modi-filename (modi)
7298 "Filename of MODI, or name of buffer if its never been saved."
7299 (if (bufferp (verilog-modi-file-or-buffer modi))
7300 (or (buffer-file-name (verilog-modi-file-or-buffer modi))
7301 (buffer-name (verilog-modi-file-or-buffer modi)))
7302 (verilog-modi-file-or-buffer modi)))
7303
7304(defun verilog-modi-goto (modi)
7305 "Move point/buffer to specified MODI."
7306 (or modi (error "Passed unfound modi to goto, check earlier"))
7307 (set-buffer (if (bufferp (verilog-modi-file-or-buffer modi))
7308 (verilog-modi-file-or-buffer modi)
7309 (find-file-noselect (verilog-modi-file-or-buffer modi))))
7310 (or (equal major-mode `verilog-mode) ;; Put into verilog mode to get syntax
7311 (verilog-mode))
7312 (goto-char (verilog-modi-point modi)))
7313
7314(defun verilog-goto-defun-file (module)
7315 "Move point to the file at which a given MODULE is defined."
7316 (interactive "sGoto File for Module: ")
7317 (let* ((modi (verilog-modi-lookup module nil)))
7318 (when modi
7319 (verilog-modi-goto modi)
7320 (switch-to-buffer (current-buffer)))))
7321
7322(defun verilog-modi-cache-results (modi function)
7323 "Run on MODI the given FUNCTION. Locate the module in a file.
7324Cache the output of function so next call may have faster access."
7325 (let (func-returns fass)
7326 (save-excursion
7327 (verilog-modi-goto modi)
7328 (if (and (setq fass (assoc (list (verilog-modi-name modi) function)
7329 verilog-modi-cache-list))
7330 ;; Destroy caching when incorrect; Modified or file changed
7331 (not (and verilog-cache-enabled
7332 (or (equal (buffer-modified-tick) (nth 1 fass))
7333 (and verilog-modi-cache-preserve-tick
7334 (<= verilog-modi-cache-preserve-tick (nth 1 fass))
7335 (equal verilog-modi-cache-preserve-buffer (current-buffer))))
7336 (equal (visited-file-modtime) (nth 2 fass)))))
7337 (setq verilog-modi-cache-list nil
7338 fass nil))
7339 (cond (fass
7340 ;; Found
7341 (setq func-returns (nth 3 fass)))
7342 (t
7343 ;; Read from file
7344 ;; Clear then restore any hilighting to make emacs19 happy
7345 (let ((fontlocked (when (and (boundp 'font-lock-mode)
7346 font-lock-mode)
7347 (font-lock-mode nil)
7348 t)))
7349 (setq func-returns (funcall function))
7350 (when fontlocked (font-lock-mode t)))
7351 ;; Cache for next time
7352 (make-variable-buffer-local 'verilog-modi-cache-list)
7353 (setq verilog-modi-cache-list
7354 (cons (list (list (verilog-modi-name modi) function)
7355 (buffer-modified-tick)
7356 (visited-file-modtime)
7357 func-returns)
7358 verilog-modi-cache-list)))
7359 ))
7360 ;;
7361 func-returns))
7362
7363(defun verilog-modi-cache-add (modi function element sig-list)
7364 "Add function return results to the module cache.
7365Update MODI's cache for given FUNCTION so that the return ELEMENT of that
7366function now contains the additional SIG-LIST parameters."
7367 (let (fass)
7368 (save-excursion
7369 (verilog-modi-goto modi)
7370 (if (setq fass (assoc (list (verilog-modi-name modi) function)
7371 verilog-modi-cache-list))
7372 (let ((func-returns (nth 3 fass)))
7373 (aset func-returns element
7374 (append sig-list (aref func-returns element))))))))
7375
7376(defmacro verilog-preserve-cache (&rest body)
7377 "Execute the BODY forms, allowing cache preservation within BODY.
7378This means that changes to the buffer will not result in the cache being
7379flushed. If the changes affect the modsig state, they must call the
7380modsig-cache-add-* function, else the results of later calls may be
7381incorrect. Without this, changes are assumed to be adding/removing signals
7382and invalidating the cache."
7383 `(let ((verilog-modi-cache-preserve-tick (buffer-modified-tick))
7384 (verilog-modi-cache-preserve-buffer (current-buffer)))
7385 (progn ,@body)))
7386
7387(defsubst verilog-modi-get-decls (modi)
7388 (verilog-modi-cache-results modi 'verilog-read-decls))
7389
7390(defsubst verilog-modi-get-sub-decls (modi)
7391 (verilog-modi-cache-results modi 'verilog-read-sub-decls))
7392
7393;; Signal reading for given module
7394;; Note these all take modi's - as returned from the verilog-modi-current function
7395(defsubst verilog-modi-get-outputs (modi)
7396 (aref (verilog-modi-get-decls modi) 0))
7397(defsubst verilog-modi-get-inouts (modi)
7398 (aref (verilog-modi-get-decls modi) 1))
7399(defsubst verilog-modi-get-inputs (modi)
7400 (aref (verilog-modi-get-decls modi) 2))
7401(defsubst verilog-modi-get-wires (modi)
7402 (aref (verilog-modi-get-decls modi) 3))
7403(defsubst verilog-modi-get-regs (modi)
7404 (aref (verilog-modi-get-decls modi) 4))
7405(defsubst verilog-modi-get-assigns (modi)
7406 (aref (verilog-modi-get-decls modi) 5))
7407(defsubst verilog-modi-get-consts (modi)
7408 (aref (verilog-modi-get-decls modi) 6))
7409(defsubst verilog-modi-get-gparams (modi)
7410 (aref (verilog-modi-get-decls modi) 7))
7411(defsubst verilog-modi-get-sub-outputs (modi)
7412 (aref (verilog-modi-get-sub-decls modi) 0))
7413(defsubst verilog-modi-get-sub-inouts (modi)
7414 (aref (verilog-modi-get-sub-decls modi) 1))
7415(defsubst verilog-modi-get-sub-inputs (modi)
7416 (aref (verilog-modi-get-sub-decls modi) 2))
7417
7418
7419(defun verilog-signals-matching-enum (in-list enum)
7420 "Return all signals in IN-LIST matching the given ENUM."
7421 (let (out-list)
7422 (while in-list
7423 (if (equal (verilog-sig-enum (car in-list)) enum)
7424 (setq out-list (cons (car in-list) out-list)))
7425 (setq in-list (cdr in-list)))
7426 ;; New scheme
7427 (let* ((enumvar (intern (concat "venum-" enum)))
7428 (enumlist (and (boundp enumvar) (eval enumvar))))
7429 (while enumlist
7430 (add-to-list 'out-list (list (car enumlist)))
7431 (setq enumlist (cdr enumlist))))
7432 (nreverse out-list)))
7433
7434(defun verilog-signals-not-matching-regexp (in-list regexp)
7435 "Return all signals in IN-LIST not matching the given REGEXP, if non-nil."
7436 (if (not regexp)
7437 in-list
7438 (let (out-list)
7439 (while in-list
7440 (if (not (string-match regexp (verilog-sig-name (car in-list))))
7441 (setq out-list (cons (car in-list) out-list)))
7442 (setq in-list (cdr in-list)))
7443 (nreverse out-list))))
7444
7445;; Combined
7446(defun verilog-modi-get-signals (modi)
7447 (append
7448 (verilog-modi-get-outputs modi)
7449 (verilog-modi-get-inouts modi)
7450 (verilog-modi-get-inputs modi)
7451 (verilog-modi-get-wires modi)
7452 (verilog-modi-get-regs modi)
7453 (verilog-modi-get-assigns modi)
7454 (verilog-modi-get-consts modi)
7455 (verilog-modi-get-gparams modi)))
7456
7457(defun verilog-modi-get-ports (modi)
7458 (append
7459 (verilog-modi-get-outputs modi)
7460 (verilog-modi-get-inouts modi)
7461 (verilog-modi-get-inputs modi)))
7462
7463(defsubst verilog-modi-cache-add-outputs (modi sig-list)
7464 (verilog-modi-cache-add modi 'verilog-read-decls 0 sig-list))
7465(defsubst verilog-modi-cache-add-inouts (modi sig-list)
7466 (verilog-modi-cache-add modi 'verilog-read-decls 1 sig-list))
7467(defsubst verilog-modi-cache-add-inputs (modi sig-list)
7468 (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list))
7469(defsubst verilog-modi-cache-add-wires (modi sig-list)
7470 (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list))
7471(defsubst verilog-modi-cache-add-regs (modi sig-list)
7472 (verilog-modi-cache-add modi 'verilog-read-decls 4 sig-list))
7473
7474(defun verilog-signals-from-signame (signame-list)
7475 "Return signals in standard form from SIGNAME-LIST, a simple list of signal names."
7476 (mapcar (function (lambda (name) (list name nil nil)))
7477 signame-list))
7478
7479;;
7480;; Auto creation utilities
7481;;
7482
7483(defun verilog-auto-search-do (search-for func)
7484 "Search for the given auto text SEARCH-FOR, and perform FUNC where it occurs."
7485 (goto-char (point-min))
7486 (while (search-forward search-for nil t)
7487 (if (not (save-excursion
7488 (goto-char (match-beginning 0))
7489 (verilog-inside-comment-p)))
7490 (funcall func))))
7491
7492(defun verilog-auto-re-search-do (search-for func)
7493 "Search for the given auto text SEARCH-FOR, and perform FUNC where it occurs."
7494 (goto-char (point-min))
7495 (while (re-search-forward search-for nil t)
7496 (if (not (save-excursion
7497 (goto-char (match-beginning 0))
7498 (verilog-inside-comment-p)))
7499 (funcall func))))
7500
7501(defun verilog-insert-one-definition (sig type indent-pt)
7502 "Print out a definition for SIGNAL of the given TYPE,
7503with appropriate INDENT-PT indentation."
7504 (indent-to indent-pt)
7505 (insert type)
7506 (when (verilog-sig-signed sig)
7507 (insert " " (verilog-sig-signed sig)))
7508 (when (verilog-sig-multidim sig)
7509 (insert " " (verilog-sig-multidim-string sig)))
7510 (when (verilog-sig-bits sig)
7511 (insert " " (verilog-sig-bits sig)))
7512 (indent-to (max 24 (+ indent-pt 16)))
7513 (unless (= (char-syntax (preceding-char)) ?\ )
7514 (insert " ")) ; Need space between "]name" if indent-to did nothing
7515 (insert (verilog-sig-name sig)))
7516
7517(defun verilog-insert-definition (sigs direction indent-pt v2k &optional dont-sort)
7518 "Print out a definition for a list of SIGS of the given DIRECTION,
7519with appropriate INDENT-PT indentation. If V2K, use Verilog 2001 I/O
7520format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output."
7521 (or dont-sort
7522 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare)))
7523 (while sigs
7524 (let ((sig (car sigs)))
7525 (verilog-insert-one-definition
7526 sig
7527 ;; Want "type x" or "output type x", not "wire type x"
7528 (cond ((verilog-sig-type sig)
7529 (concat
7530 (if (not (equal direction "wire"))
7531 (concat direction " "))
7532 (verilog-sig-type sig)))
7533 (t direction))
7534 indent-pt)
7535 (insert (if v2k "," ";"))
7536 (if (or (not (verilog-sig-comment sig))
7537 (equal "" (verilog-sig-comment sig)))
7538 (insert "\n")
7539 (indent-to (max 48 (+ indent-pt 40)))
7540 (insert (concat "// " (verilog-sig-comment sig) "\n")))
7541 (setq sigs (cdr sigs)))))
7542
7543(eval-when-compile
7544 (if (not (boundp 'indent-pt))
7545 (defvar indent-pt nil "Local used by insert-indent")))
7546
7547(defun verilog-insert-indent (&rest stuff)
7548 "Indent to position stored in local `indent-pt' variable, then insert STUFF.
7549Presumes that any newlines end a list element."
7550 (let ((need-indent t))
7551 (while stuff
7552 (if need-indent (indent-to indent-pt))
7553 (setq need-indent nil)
7554 (insert (car stuff))
7555 (setq need-indent (string-match "\n$" (car stuff))
7556 stuff (cdr stuff)))))
7557;;(let ((indent-pt 10)) (verilog-insert-indent "hello\n" "addon" "there\n"))
7558
7559(defun verilog-repair-open-comma ()
7560 "If backwards-from-point is other than a open parenthesis insert comma."
7561 (save-excursion
7562 (verilog-backward-syntactic-ws)
7563 (when (save-excursion
7564 (backward-char 1)
7565 (and (not (looking-at "[(,]"))
7566 (progn
7567 (verilog-re-search-backward "[(`]" nil t)
7568 (looking-at "("))))
7569 (insert ","))))
7570
7571(defun verilog-repair-close-comma ()
7572 "If point is at a comma followed by a close parenthesis, fix it.
7573This repairs those mis-inserted by a AUTOARG."
7574 ;; It would be much nicer if Verilog allowed extra commas like Perl does!
7575 (save-excursion
7576 (verilog-forward-close-paren)
7577 (backward-char 1)
7578 (verilog-backward-syntactic-ws)
7579 (backward-char 1)
7580 (when (looking-at ",")
7581 (delete-char 1))))
7582
7583(defun verilog-get-list (start end)
7584 "Return the elements of a comma separated list between START and END."
7585 (interactive)
7586 (let ((my-list (list))
7587 my-string)
7588 (save-excursion
7589 (while (< (point) end)
7590 (when (re-search-forward "\\([^,{]+\\)" end t)
7591 (setq my-string (verilog-string-remove-spaces (match-string 1)))
7592 (setq my-list (nconc my-list (list my-string) ))
7593 (goto-char (match-end 0))))
7594 my-list)))
7595
7596(defun verilog-make-width-expression (range-exp)
7597 "Return an expression calculating the length of a range [x:y] in RANGE-EXP."
7598 ;; strip off the []
7599 (cond ((not range-exp)
7600 "1")
7601 (t
7602 (if (string-match "^\\[\\(.*\\)\\]$" range-exp)
7603 (setq range-exp (match-string 1 range-exp)))
7604 (cond ((not range-exp)
7605 "1")
7606 ((string-match "^\\s *\\([0-9]+\\)\\s *:\\s *\\([0-9]+\\)\\s *$" range-exp)
7607 (int-to-string (1+ (abs (- (string-to-int (match-string 1 range-exp))
7608 (string-to-int (match-string 2 range-exp)))))))
7609 ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp)
7610 (concat "(1+(" (match-string 1 range-exp)
7611 ")"
7612 (if (equal "0" (match-string 2 range-exp)) ;; Don't bother with -(0)
7613 ""
7614 (concat "-(" (match-string 2 range-exp) ")"))
7615 ")"))
7616 (t nil)))))
7617;;(verilog-make-width-expression "`A:`B")
7618
7619(defun verilog-typedef-name-p (variable-name)
7620 "Return true if the VARIABLE-NAME is a type definition."
7621 (when verilog-typedef-regexp
7622 (string-match verilog-typedef-regexp variable-name)))
7623
7624;;
7625;; Auto deletion
7626;;
7627
7628(defun verilog-delete-autos-lined ()
7629 "Delete autos that occupy multiple lines, between begin and end comments."
7630 (let ((pt (point)))
7631 (forward-line 1)
7632 (when (and
7633 (looking-at "\\s-*// Beginning")
7634 (search-forward "// End of automatic" nil t))
7635 ;; End exists
7636 (end-of-line)
7637 (delete-region pt (point))
7638 (forward-line 1))
7639 ))
7640
7641(defun verilog-forward-close-paren ()
7642 "Find the close parenthesis that match the current point,
7643ignore other close parenthesis with matching open parens"
7644 (let ((parens 1))
7645 (while (> parens 0)
7646 (unless (verilog-re-search-forward-quick "[()]" nil t)
7647 (error "%s: Mismatching ()" (verilog-point-text)))
7648 (cond ((= (preceding-char) ?\( )
7649 (setq parens (1+ parens)))
7650 ((= (preceding-char) ?\) )
7651 (setq parens (1- parens)))))))
7652
7653(defun verilog-backward-open-paren ()
7654 "Find the open parenthesis that match the current point,
7655ignore other open parenthesis with matching close parens"
7656 (let ((parens 1))
7657 (while (> parens 0)
7658 (unless (verilog-re-search-backward-quick "[()]" nil t)
7659 (error "%s: Mismatching ()" (verilog-point-text)))
7660 (cond ((= (following-char) ?\) )
7661 (setq parens (1+ parens)))
7662 ((= (following-char) ?\( )
7663 (setq parens (1- parens)))))))
7664
7665(defun verilog-backward-open-bracket ()
7666 "Find the open bracket that match the current point,
7667ignore other open bracket with matching close bracket"
7668 (let ((parens 1))
7669 (while (> parens 0)
7670 (unless (verilog-re-search-backward-quick "[][]" nil t)
7671 (error "%s: Mismatching []" (verilog-point-text)))
7672 (cond ((= (following-char) ?\] )
7673 (setq parens (1+ parens)))
7674 ((= (following-char) ?\[ )
7675 (setq parens (1- parens)))))))
7676
7677(defun verilog-delete-to-paren ()
7678 "Delete the automatic inst/sense/arg created by autos.
7679Deletion stops at the matching end parenthesis."
7680 (delete-region (point)
7681 (save-excursion
7682 (verilog-backward-open-paren)
7683 (forward-sexp 1) ;; Moves to paren that closes argdecl's
7684 (backward-char 1)
7685 (point))))
7686
7687(defun verilog-auto-star-safe ()
7688 "Return if a .* AUTOINST is safe to delete or expand.
7689It was created by the AUTOS themselves, or by the user."
7690 (and verilog-auto-star-expand
7691 (looking-at "[ \t\n\f,]*\\([)]\\|// \\(Outputs\\|Inouts\\|Inputs\\)\\)")))
7692
7693(defun verilog-delete-auto-star-all ()
7694 "Delete a .* AUTOINST, if it is safe."
7695 (when (verilog-auto-star-safe)
7696 (verilog-delete-to-paren)))
7697
7698(defun verilog-delete-auto-star-implicit ()
7699 "Delete all .* implicit connections created by `verilog-auto-star'.
7700This function will be called automatically at save unless
7701`verilog-auto-star-save' is set, any non-templated expanded pins will be
7702removed."
7703 (interactive)
7704 (let (paren-pt indent have-close-paren)
7705 (save-excursion
7706 (goto-char (point-min))
7707 ;; We need to match these even outside of comments.
7708 ;; For reasonable performance, we don't check if inside comments, sorry.
7709 (while (re-search-forward "// Implicit \\.\\*" nil t)
7710 (setq paren-pt (point))
7711 (beginning-of-line)
7712 (setq have-close-paren
7713 (save-excursion
7714 (when (search-forward ");" paren-pt t)
7715 (setq indent (current-indentation))
7716 t)))
7717 (delete-region (point) (+ 1 paren-pt)) ; Nuke line incl CR
7718 (when have-close-paren
7719 ;; Delete extra commentary
7720 (save-excursion
7721 (while (progn
7722 (forward-line -1)
7723 (looking-at "\\s *//\\s *\\(Outputs\\|Inouts\\|Inputs\\)\n"))
7724 (delete-region (match-beginning 0) (match-end 0))))
7725 ;; If it is simple, we can put the ); on the same line as the last text
7726 (let ((rtn-pt (point)))
7727 (save-excursion
7728 (while (progn (backward-char 1)
7729 (looking-at "[ \t\n\f]")))
7730 (when (looking-at ",")
7731 (delete-region (+ 1 (point)) rtn-pt))))
7732 (when (bolp)
7733 (indent-to indent))
7734 (insert ");\n")
7735 ;; Still need to kill final comma - always is one as we put one after the .*
7736 (re-search-backward ",")
7737 (delete-char 1))))))
7738
7739(defun verilog-delete-auto ()
7740 "Delete the automatic outputs, regs, and wires created by \\[verilog-auto].
7741Use \\[verilog-auto] to re-insert the updated AUTOs.
7742
7743The hooks `verilog-before-delete-auto-hook' and `verilog-delete-auto-hook' are
7744called before and after this function, respectively."
7745 (interactive)
7746 (save-excursion
7747 (if (buffer-file-name)
7748 (find-file-noselect (buffer-file-name))) ;; To check we have latest version
7749 ;; Allow user to customize
7750 (run-hooks 'verilog-before-delete-auto-hook)
7751
7752 ;; Remove those that have multi-line insertions
7753 (verilog-auto-re-search-do "/\\*AUTO\\(OUTPUTEVERY\\|CONCATCOMMENT\\|WIRE\\|REG\\|DEFINEVALUE\\|REGINPUT\\|INPUT\\|OUTPUT\\|INOUT\\|RESET\\|TIEOFF\\|UNUSED\\)\\*/"
7754 'verilog-delete-autos-lined)
7755 ;; Remove those that have multi-line insertions with parameters
7756 (verilog-auto-re-search-do "/\\*AUTO\\(INOUTMODULE\\|ASCIIENUM\\)([^)]*)\\*/"
7757 'verilog-delete-autos-lined)
7758 ;; Remove those that are in parenthesis
7759 (verilog-auto-re-search-do "/\\*\\(AS\\|AUTO\\(ARG\\|CONCATWIDTH\\|INST\\|INSTPARAM\\|SENSE\\)\\)\\*/"
7760 'verilog-delete-to-paren)
7761 ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments
7762 (verilog-auto-re-search-do "\\.\\*"
7763 'verilog-delete-auto-star-all)
7764 ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed
7765 (goto-char (point-min))
7766 (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t)
7767 (replace-match ""))
7768
7769 ;; Final customize
7770 (run-hooks 'verilog-delete-auto-hook)))
7771
7772;;
7773;; Auto inject
7774;;
7775
7776(defun verilog-inject-auto ()
7777 "Examine legacy non-AUTO code and insert AUTOs in appropriate places.
7778
7779Any always @ blocks with sensitivity lists that match computed lists will
7780be replaced with /*AS*/ comments.
7781
7782Any cells will get /*AUTOINST*/ added to the end of the pin list. Pins with
7783have identical names will be deleted.
7784
7785Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to
7786support adding new ports. You may wish to delete older ports yourself.
7787
7788For example:
7789
7790 module ex_inject (i, o);
7791 input i;
7792 input j;
7793 output o;
7794 always @ (i or j)
7795 o = i | j;
7796 cell cell (.foobar(baz),
7797 .j(j));
7798 endmodule
7799
7800Typing \\[verilog-inject-auto] will make this into:
7801
7802 module ex_inject (i, o/*AUTOARG*/
7803 // Inputs
7804 j);
7805 input i;
7806 output o;
7807 always @ (/*AS*/i or j)
7808 o = i | j;
7809 cell cell (.foobar(baz),
7810 /*AUTOINST*/
7811 // Outputs
7812 .j(j));
7813 endmodule"
7814 (interactive)
7815 (verilog-auto t))
7816
7817(defun verilog-inject-arg ()
7818 "Inject AUTOARG into new code. See `verilog-inject-auto'."
7819 ;; Presume one module per file.
7820 (save-excursion
7821 (goto-char (point-min))
7822 (while (verilog-re-search-forward-quick "\\<module\\>" nil t)
7823 (let ((endmodp (save-excursion
7824 (verilog-re-search-forward-quick "\\<endmodule\\>" nil t)
7825 (point))))
7826 ;; See if there's already a comment .. inside a comment so not verilog-re-search
7827 (when (not (re-search-forward "/\\*AUTOARG\\*/" endmodp t))
7828 (verilog-re-search-forward-quick ";" nil t)
7829 (backward-char 1)
7830 (verilog-backward-syntactic-ws)
7831 (backward-char 1) ; Moves to paren that closes argdecl's
7832 (when (looking-at ")")
7833 (insert "/*AUTOARG*/")))))))
7834
7835(defun verilog-inject-sense ()
7836 "Inject AUTOSENSE into new code. See `verilog-inject-auto'."
7837 (save-excursion
7838 (goto-char (point-min))
7839 (while (verilog-re-search-forward-quick "\\<always\\s *@\\s *(" nil t)
7840 (let ((start-pt (point))
7841 (modi (verilog-modi-current))
7842 pre-sigs
7843 got-sigs)
7844 (backward-char 1)
7845 (forward-sexp 1)
7846 (backward-char 1) ;; End )
7847 (when (not (verilog-re-search-backward "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t))
7848 (setq pre-sigs (verilog-signals-from-signame
7849 (verilog-read-signals start-pt (point)))
7850 got-sigs (verilog-auto-sense-sigs modi nil))
7851 (when (not (or (verilog-signals-not-in pre-sigs got-sigs) ; Both are equal?
7852 (verilog-signals-not-in got-sigs pre-sigs)))
7853 (delete-region start-pt (point))
7854 (insert "/*AS*/")))))))
7855
7856(defun verilog-inject-inst ()
7857 "Inject AUTOINST into new code. See `verilog-inject-auto'."
7858 (save-excursion
7859 (goto-char (point-min))
7860 ;; It's hard to distinguish modules; we'll instead search for pins.
7861 (while (verilog-re-search-forward-quick "\\.\\s *[a-zA-Z0-9`_\$]+\\s *(\\s *[a-zA-Z0-9`_\$]+\\s *)" nil t)
7862 (verilog-backward-open-paren) ;; Inst start
7863 (cond
7864 ((= (preceding-char) ?\#) ;; #(...) parameter section, not pin. Skip.
7865 (forward-char 1)
7866 (verilog-forward-close-paren)) ;; Parameters done
7867 (t
7868 (forward-char 1)
7869 (let ((indent-pt (+ (current-column)))
7870 (end-pt (save-excursion (verilog-forward-close-paren) (point))))
7871 (cond ((verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t)
7872 (goto-char end-pt)) ;; Already there, continue search with next instance
7873 (t
7874 ;; Delete identical interconnect
7875 (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc
7876 (while (verilog-re-search-forward "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t)
7877 (delete-region (match-beginning 0) (match-end 0))
7878 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct
7879 (while (or (looking-at "[ \t\n\f,]+")
7880 (looking-at "//[^\n]*"))
7881 (delete-region (match-beginning 0) (match-end 0))
7882 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))))))
7883 (verilog-forward-close-paren)
7884 (backward-char 1)
7885 ;; Not verilog-re-search, as we don't want to strip comments
7886 (while (re-search-backward "[ \t\n\f]+" (- (point) 1) t)
7887 (delete-region (match-beginning 0) (match-end 0)))
7888 (insert "\n")
7889 (indent-to indent-pt)
7890 (insert "/*AUTOINST*/")))))))))
7891
7892;;
7893;; Auto save
7894;;
7895
7896(defun verilog-auto-save-check ()
7897 "On saving see if we need auto update."
7898 (cond ((not verilog-auto-save-policy)) ; disabled
7899 ((not (save-excursion
7900 (save-match-data
7901 (let ((case-fold-search nil))
7902 (goto-char (point-min))
7903 (re-search-forward "AUTO" nil t))))))
7904 ((eq verilog-auto-save-policy 'force)
7905 (verilog-auto))
7906 ((not (buffer-modified-p)))
7907 ((eq verilog-auto-update-tick (buffer-modified-tick))) ; up-to-date
7908 ((eq verilog-auto-save-policy 'detect)
7909 (verilog-auto))
7910 (t
7911 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ")
7912 (verilog-auto))
7913 ;; Don't ask again if didn't update
7914 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick))
7915 ))
7916 (when (not verilog-auto-star-save)
7917 (verilog-delete-auto-star-implicit))
7918 nil) ;; Always return nil -- we don't write the file ourselves
7919
7920(defun verilog-auto-read-locals ()
7921 "Return file local variable segment at bottom of file."
7922 (save-excursion
7923 (goto-char (point-max))
7924 (if (re-search-backward "Local Variables:" nil t)
7925 (buffer-substring-no-properties (point) (point-max))
7926 "")))
7927
7928(defun verilog-auto-reeval-locals (&optional force)
7929 "Read file local variable segment at bottom of file if it has changed.
7930If FORCE, always reread it."
7931 (make-variable-buffer-local 'verilog-auto-last-file-locals)
7932 (let ((curlocal (verilog-auto-read-locals)))
7933 (when (or force (not (equal verilog-auto-last-file-locals curlocal)))
7934 (setq verilog-auto-last-file-locals curlocal)
7935 ;; Note this may cause this function to be recursively invoked.
7936 ;; The above when statement will prevent it from recursing forever.
7937 (hack-local-variables)
7938 t)))
7939
7940;;
7941;; Auto creation
7942;;
7943
7944(defun verilog-auto-arg-ports (sigs message indent-pt)
7945 "Print a list of ports for a AUTOINST.
7946Takes SIGS list, adds MESSAGE to front and inserts each at INDENT-PT."
7947 (when sigs
7948 (insert "\n")
7949 (indent-to indent-pt)
7950 (insert message)
7951 (insert "\n")
7952 (let ((space ""))
7953 (indent-to indent-pt)
7954 (while sigs
7955 (cond ((> (+ 2 (current-column) (length (verilog-sig-name (car sigs)))) fill-column)
7956 (insert "\n")
7957 (indent-to indent-pt))
7958 (t (insert space)))
7959 (insert (verilog-sig-name (car sigs)) ",")
7960 (setq sigs (cdr sigs)
7961 space " ")))))
7962
7963(defun verilog-auto-arg ()
7964 "Expand AUTOARG statements.
7965Replace the argument declarations at the beginning of the
7966module with ones automatically derived from input and output
7967statements. This can be dangerous if the module is instantiated
7968using position-based connections, so use only name-based when
7969instantiating the resulting module. Long lines are split based
7970on the `fill-column', see \\[set-fill-column].
7971
7972Limitations:
7973 Concatenation and outputting partial busses is not supported.
7974
7975 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
7976
7977For example:
7978
7979 module ex_arg (/*AUTOARG*/);
7980 input i;
7981 output o;
7982 endmodule
7983
7984Typing \\[verilog-auto] will make this into:
7985
7986 module ex_arg (/*AUTOARG*/
7987 // Outputs
7988 o,
7989 // Inputs
7990 i
7991 );
7992 input i;
7993 output o;
7994 endmodule
7995
7996Any ports declared between the ( and /*AUTOARG*/ are presumed to be
7997predeclared and are not redeclared by AUTOARG. AUTOARG will make a
7998conservative guess on adding a comma for the first signal, if you have any
7999ifdefs or complicated expressions before the AUTOARG you will need to
8000choose the comma yourself.
8001
8002Avoid declaring ports manually, as it makes code harder to maintain."
8003 (save-excursion
8004 (let ((modi (verilog-modi-current))
8005 (skip-pins (aref (verilog-read-arg-pins) 0)))
8006 (verilog-repair-open-comma)
8007 (verilog-auto-arg-ports (verilog-signals-not-in
8008 (verilog-modi-get-outputs modi)
8009 skip-pins)
8010 "// Outputs"
8011 verilog-indent-level-declaration)
8012 (verilog-auto-arg-ports (verilog-signals-not-in
8013 (verilog-modi-get-inouts modi)
8014 skip-pins)
8015 "// Inouts"
8016 verilog-indent-level-declaration)
8017 (verilog-auto-arg-ports (verilog-signals-not-in
8018 (verilog-modi-get-inputs modi)
8019 skip-pins)
8020 "// Inputs"
8021 verilog-indent-level-declaration)
8022 (verilog-repair-close-comma)
8023 (unless (eq (char-before) ?/ )
8024 (insert "\n"))
8025 (indent-to verilog-indent-level-declaration)
8026 )))
8027
8028(defun verilog-auto-inst-port-map (port-st)
8029 nil)
8030
8031(defvar vector-skip-list nil) ; Prevent compile warning
8032(defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning
8033(defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning
8034(defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning
8035(defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning
8036(defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning
8037
8038(defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star)
8039 "Print out a instantiation connection for this PORT-ST.
8040Insert to INDENT-PT, use template TPL-LIST.
8041@ are instantiation numbers, replaced with TPL-NUM.
8042@\"(expression @)\" are evaluated, with @ as a variable."
8043 (let* ((port (verilog-sig-name port-st))
8044 (tpl-ass (or (assoc port (car tpl-list))
8045 (verilog-auto-inst-port-map port-st)))
8046 ;; vl-* are documented for user use
8047 (vl-name (verilog-sig-name port-st))
8048 (vl-width (verilog-sig-width port-st))
8049 (vl-bits (if (or verilog-auto-inst-vector
8050 (not (assoc port vector-skip-list))
8051 (not (equal (verilog-sig-bits port-st)
8052 (verilog-sig-bits (assoc port vector-skip-list)))))
8053 (or (verilog-sig-bits port-st) "")
8054 ""))
8055 ;; Default if not found
8056 (tpl-net (if (verilog-sig-multidim port-st)
8057 (concat port "/*" (verilog-sig-multidim-string port-st)
8058 vl-bits "*/")
8059 (concat port vl-bits)))
8060 (case-fold-search nil))
8061 ;; Find template
8062 (cond (tpl-ass ; Template of exact port name
8063 (setq tpl-net (nth 1 tpl-ass)))
8064 ((nth 1 tpl-list) ; Wildcards in template, search them
8065 (let ((wildcards (nth 1 tpl-list)))
8066 (while wildcards
8067 (when (string-match (nth 0 (car wildcards)) port)
8068 (setq tpl-ass (car wildcards) ; so allow @ parsing
8069 tpl-net (replace-match (nth 1 (car wildcards))
8070 t nil port)))
8071 (setq wildcards (cdr wildcards))))))
8072 ;; Parse Templated variable
8073 (when tpl-ass
8074 ;; Evaluate @"(lispcode)"
8075 (when (string-match "@\".*[^\\]\"" tpl-net)
8076 (while (string-match "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\"" tpl-net)
8077 (setq tpl-net
8078 (concat
8079 (substring tpl-net 0 (match-beginning 0))
8080 (save-match-data
8081 (let* ((expr (match-string 1 tpl-net))
8082 (value
8083 (progn
8084 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr))
8085 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr))
8086 (prin1 (eval (car (read-from-string expr)))
8087 (lambda (ch) ())))))
8088 (if (numberp value) (setq value (number-to-string value)))
8089 value
8090 ))
8091 (substring tpl-net (match-end 0))))))
8092 ;; Replace @ and [] magic variables in final output
8093 (setq tpl-net (verilog-string-replace-matches "@" tpl-num nil nil tpl-net))
8094 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net))
8095 )
8096 (indent-to indent-pt)
8097 (insert "." port)
8098 (indent-to verilog-auto-inst-column)
8099 (insert "(" tpl-net "),")
8100 (cond (tpl-ass
8101 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
8102 verilog-auto-inst-column))
8103 (insert " // Templated")
8104 (when verilog-auto-inst-template-numbers
8105 (insert " T" (int-to-string (nth 2 tpl-ass))
8106 " L" (int-to-string (nth 3 tpl-ass)))))
8107 (for-star
8108 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
8109 verilog-auto-inst-column))
8110 (insert " // Implicit .\*"))) ;For some reason the . or * must be escaped...
8111 (insert "\n")))
8112;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3")
8113;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]")
8114;;(x ".out (outgo[@\"(concat (+ (* 8 @) 7) \\\":\\\" ( * 8 @))\"]));")
8115
8116(defun verilog-auto-inst-first ()
8117 "Insert , etc before first ever port in this instant, as part of \\[verilog-auto-inst]."
8118 ;; Do we need a trailing comma?
8119 ;; There maybe a ifdef or something similar before us. What a mess. Thus
8120 ;; to avoid trouble we only insert on preceeding ) or *.
8121 ;; Insert first port on new line
8122 (insert "\n") ;; Must insert before search, so point will move forward if insert comma
8123 (save-excursion
8124 (verilog-re-search-backward "[^ \t\n\f]" nil nil)
8125 (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure
8126 (forward-char 1)
8127 (insert ","))))
8128
8129(defun verilog-auto-star ()
8130 "Expand SystemVerilog .* pins, as part of \\[verilog-auto].
8131
8132If `verilog-auto-star-expand' is set, .* pins are treated if they were
8133AUTOINST statements, otherwise they are ignored. For safety, Verilog-Mode
8134will also ignore any .* that are not last in your pin list (this prevents
8135it from deleting pins following the .* when it expands the AUTOINST.)
8136
8137On writing your file, unless `verilog-auto-star-save' is set, any
8138non-templated expanded pins will be removed. You may do this at any time
8139with \\[verilog-delete-auto-star-implicit].
8140
8141If you are converting a module to use .* for the first time, you may wish
8142to use \\[verilog-inject-auto] and then replace the created AUTOINST with .*.
8143
8144See `verilog-auto-inst' for examples, templates, and more information."
8145 (when (verilog-auto-star-safe)
8146 (verilog-auto-inst)))
8147
8148(defun verilog-auto-inst ()
8149 "Expand AUTOINST statements, as part of \\[verilog-auto].
8150Replace the pin connections to an instantiation with ones
8151automatically derived from the module header of the instantiated netlist.
8152
8153If `verilog-auto-star-expand' is set, also expand SystemVerilog .* ports,
8154and delete them before saving unless `verilog-auto-star-save' is set.
8155See `verilog-auto-star' for more information.
8156
8157Limitations:
8158 Module names must be resolvable to filenames by adding a
8159 `verilog-library-extensions', and being found in the same directory, or
8160 by changing the variable `verilog-library-flags' or
8161 `verilog-library-directories'. Macros `modname are translated through the
8162 vh-{name} Emacs variable, if that is not found, it just ignores the `.
8163
8164 In templates you must have one signal per line, ending in a ), or ));,
8165 and have proper () nesting, including a final ); to end the template.
8166
8167 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
8168
8169 SystemVerilog multidimmensional input/output has only experimental support.
8170
8171For example, first take the submodule inst.v:
8172
8173 module inst (o,i)
8174 output [31:0] o;
8175 input i;
8176 wire [31:0] o = {32{i}};
8177 endmodule
8178
8179This is then used in a upper level module:
8180
8181 module ex_inst (o,i)
8182 output o;
8183 input i;
8184 inst inst (/*AUTOINST*/);
8185 endmodule
8186
8187Typing \\[verilog-auto] will make this into:
8188
8189 module ex_inst (o,i)
8190 output o;
8191 input i;
8192 inst inst (/*AUTOINST*/
8193 // Outputs
8194 .ov (ov[31:0]),
8195 // Inputs
8196 .i (i));
8197 endmodule
8198
8199Where the list of inputs and outputs came from the inst module.
8200
8201Exceptions:
8202
8203 Unless you are instantiating a module multiple times, or the module is
8204 something trivial like a adder, DO NOT CHANGE SIGNAL NAMES ACROSS HIERARCHY.
8205 It just makes for unmaintainable code. To sanitize signal names, try
8206 vrename from http://www.veripool.com
8207
8208 When you need to violate this suggestion there are two ways to list
8209 exceptions, placing them before the AUTOINST, or using templates.
8210
8211 Any ports defined before the /*AUTOINST*/ are not included in the list of
8212 automatics. This is similar to making a template as described below, but
8213 is restricted to simple connections just like you normally make. Also note
8214 that any signals before the AUTOINST will only be picked up by AUTOWIRE if
8215 you have the appropriate // Input or // Output comment, and exactly the
8216 same line formatting as AUTOINST itself uses.
8217
8218 inst inst (// Inputs
8219 .i (my_i_dont_mess_with_it),
8220 /*AUTOINST*/
8221 // Outputs
8222 .ov (ov[31:0]));
8223
8224
8225Templates:
8226
8227 For multiple instantiations based upon a single template, create a
8228 commented out template:
8229
8230 /* instantiating_module_name AUTO_TEMPLATE (
8231 .sig3 (sigz[]),
8232 );
8233 */
8234
8235 Templates go ABOVE the instantiation(s). When a instantiation is
8236 expanded `verilog-mode' simply searches up for the closest template.
8237 Thus you can have multiple templates for the same module, just alternate
8238 between the template for a instantiation and the instantiation itself.
8239
8240 The module name must be the same as the name of the module in the
8241 instantiation name, and the code \"AUTO_TEMPLATE\" must be in these exact
8242 words and capitalized. Only signals that must be different for each
8243 instantiation need to be listed.
8244
8245 Inside a template, a [] in a connection name (with nothing else inside
8246 the brackets) will be replaced by the same bus subscript as it is being
8247 connected to, or the [] will be removed if it is a single bit signal.
8248 Generally it is a good idea to do this for all connections in a template,
8249 as then they will work for any width signal, and with AUTOWIRE. See
8250 PTL_BUS becoming PTL_BUSNEW below.
8251
8252 If you have a complicated template, set `verilog-auto-inst-template-numbers'
8253 to see which regexps are matching. Don't leave that mode set after
8254 debugging is completed though, it will result in lots of extra differences
8255 and merge conflicts.
8256
8257 For example:
8258
8259 /* psm_mas AUTO_TEMPLATE (
8260 .ptl_bus (ptl_busnew[]),
8261 );
8262 */
8263 psm_mas ms2m (/*AUTOINST*/);
8264
8265 Typing \\[verilog-auto] will make this into:
8266
8267 psm_mas ms2m (/*AUTOINST*/
8268 // Outputs
8269 .NotInTemplate (NotInTemplate),
8270 .ptl_bus (ptl_busnew[3:0]), // Templated
8271 ....
8272
8273@ Templates:
8274
8275 It is common to instantiate a cell multiple times, so templates make it
8276 trivial to substitute part of the cell name into the connection name.
8277
8278 /* cell_type AUTO_TEMPLATE <optional \"REGEXP\"> (
8279 .sig1 (sigx[@]),
8280 .sig2 (sigy[@\"(% (+ 1 @) 4)\"]),
8281 );
8282 */
8283
8284 If no regular expression is provided immediately after the AUTO_TEMPLATE
8285 keyword, then the @ character in any connection names will be replaced
8286 with the instantiation number; the first digits found in the cell's
8287 instantiation name.
8288
8289 If a regular expression is provided, the @ character will be replaced
8290 with the first \(\) grouping that matches against the cell name. Using a
8291 regexp of \"\\([0-9]+\\)\" provides identical values for @ as when no
8292 regexp is provided. If you use multiple layers of parenthesis,
8293 \"test\\([^0-9]+\\)_\\([0-9]+\\)\" would replace @ with non-number
8294 characters after test and before _, whereas
8295 \"\\(test\\([a-z]+\\)_\\([0-9]+\\)\\)\" would replace @ with the entire
8296 match.
8297
8298 For example:
8299
8300 /* psm_mas AUTO_TEMPLATE (
8301 .ptl_mapvalidx (ptl_mapvalid[@]),
8302 .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]),
8303 );
8304 */
8305 psm_mas ms2m (/*AUTOINST*/);
8306
8307 Typing \\[verilog-auto] will make this into:
8308
8309 psm_mas ms2m (/*AUTOINST*/
8310 // Outputs
8311 .ptl_mapvalidx (ptl_mapvalid[2]),
8312 .ptl_mapvalidp1x (ptl_mapvalid[3]));
8313
8314 Note the @ character was replaced with the 2 from \"ms2m\".
8315
8316 Alternatively, using a regular expression for @:
8317
8318 /* psm_mas AUTO_TEMPLATE \"_\\([a-z]+\\)\" (
8319 .ptl_mapvalidx (@_ptl_mapvalid),
8320 .ptl_mapvalidp1x (ptl_mapvalid_@),
8321 );
8322 */
8323 psm_mas ms2_FOO (/*AUTOINST*/);
8324 psm_mas ms2_BAR (/*AUTOINST*/);
8325
8326 Typing \\[verilog-auto] will make this into:
8327
8328 psm_mas ms2_FOO (/*AUTOINST*/
8329 // Outputs
8330 .ptl_mapvalidx (FOO_ptl_mapvalid),
8331 .ptl_mapvalidp1x (ptl_mapvalid_FOO));
8332 psm_mas ms2_BAR (/*AUTOINST*/
8333 // Outputs
8334 .ptl_mapvalidx (BAR_ptl_mapvalid),
8335 .ptl_mapvalidp1x (ptl_mapvalid_BAR));
8336
8337
8338Regexp Templates:
8339
8340 A template entry of the form
8341
8342 .pci_req\\([0-9]+\\)_l (pci_req_jtag_[\\1]),
8343
8344 will apply a Emacs style regular expression search for any port beginning
8345 in pci_req followed by numbers and ending in _l and connecting that to
8346 the pci_req_jtag_[] net, with the bus subscript coming from what matches
8347 inside the first set of \\( \\). Thus pci_req2_l becomes pci_req_jtag_[2].
8348
8349 Since \\([0-9]+\\) is so common and ugly to read, a @ in the port name
8350 does the same thing. (Note a @ in the connection/replacement text is
8351 completely different -- still use \\1 there!) Thus this is the same as
8352 the above template:
8353
8354 .pci_req@_l (pci_req_jtag_[\\1]),
8355
8356 Here's another example to remove the _l, useful when naming conventions
8357 specify _ alone to mean active low. Note the use of [] to keep the bus
8358 subscript:
8359
8360 .\\(.*\\)_l (\\1_[]),
8361
8362Lisp Templates:
8363
8364 First any regular expression template is expanded.
8365
8366 If the syntax @\"( ... )\" is found in a connection, the expression in
8367 quotes will be evaluated as a Lisp expression, with @ replaced by the
8368 instantiation number. The MAPVALIDP1X example above would put @+1 modulo
8369 4 into the brackets. Quote all double-quotes inside the expression with
8370 a leading backslash (\\\"). There are special variables defined that are
8371 useful in these Lisp functions:
8372
8373 vl-name Name portion of the input/output port
8374 vl-bits Bus bits portion of the input/output port ('[2:0]')
8375 vl-width Width of the input/output port ('3' for [2:0])
8376 May be a (...) expression if bits isn't a constant.
8377 vl-dir Direction of the pin input/output/inout.
8378 vl-cell-type Module name/type of the cell ('psm_mas')
8379 vl-cell-name Instance name of the cell ('ms2m')
8380
8381 Normal Lisp variables may be used in expressions. See
8382 `verilog-read-defines' which can set vh-{definename} variables for use
8383 here. Also, any comments of the form:
8384
8385 /*AUTO_LISP(setq foo 1)*/
8386
8387 will evaluate any Lisp expression inside the parenthesis between the
8388 beginning of the buffer and the point of the AUTOINST. This allows
8389 functions to be defined or variables to be changed between instantiations.
8390
8391 Note that when using lisp expressions errors may occur when @ is not a
8392 number, you may need to use the standard Emacs Lisp functions
8393 `number-to-string' and `string-to-number'.
8394
8395 After the evaluation is completed, @ substitution and [] substitution
8396 occur."
8397 (save-excursion
8398 ;; Find beginning
8399 (let* ((pt (point))
8400 (for-star (save-excursion (backward-char 2) (looking-at "\\.\\*")))
8401 (indent-pt (save-excursion (verilog-backward-open-paren)
8402 (1+ (current-column))))
8403 (verilog-auto-inst-column (max verilog-auto-inst-column
8404 (+ 16 (* 8 (/ (+ indent-pt 7) 8)))))
8405 (modi (verilog-modi-current))
8406 (vector-skip-list (unless verilog-auto-inst-vector
8407 (verilog-modi-get-signals modi)))
8408 submod submodi inst skip-pins tpl-list tpl-num did-first)
8409 ;; Find module name that is instantiated
8410 (setq submod (verilog-read-inst-module)
8411 inst (verilog-read-inst-name)
8412 vl-cell-type submod
8413 vl-cell-name inst
8414 skip-pins (aref (verilog-read-inst-pins) 0))
8415
8416 ;; Parse any AUTO_LISP() before here
8417 (verilog-read-auto-lisp (point-min) pt)
8418
8419 ;; Lookup position, etc of submodule
8420 ;; Note this may raise an error
8421 (when (setq submodi (verilog-modi-lookup submod t))
8422 ;; If there's a number in the instantiation, it may be a argument to the
8423 ;; automatic variable instantiation program.
8424 (let* ((tpl-info (verilog-read-auto-template submod))
8425 (tpl-regexp (aref tpl-info 0)))
8426 (setq tpl-num (if (string-match tpl-regexp inst)
8427 (match-string 1 inst)
8428 "")
8429 tpl-list (aref tpl-info 1)))
8430 ;; Find submodule's signals and dump
8431 (let ((sig-list (verilog-signals-not-in
8432 (verilog-modi-get-outputs submodi)
8433 skip-pins))
8434 (vl-dir "output"))
8435 (when sig-list
8436 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
8437 (indent-to indent-pt)
8438 (insert "// Outputs\n") ;; Note these are searched for in verilog-read-sub-decls
8439 (mapcar (function (lambda (port)
8440 (verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star)))
8441 sig-list)))
8442 (let ((sig-list (verilog-signals-not-in
8443 (verilog-modi-get-inouts submodi)
8444 skip-pins))
8445 (vl-dir "inout"))
8446 (when sig-list
8447 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
8448 (indent-to indent-pt)
8449 (insert "// Inouts\n")
8450 (mapcar (function (lambda (port)
8451 (verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star)))
8452 sig-list)))
8453 (let ((sig-list (verilog-signals-not-in
8454 (verilog-modi-get-inputs submodi)
8455 skip-pins))
8456 (vl-dir "input"))
8457 (when sig-list
8458 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
8459 (indent-to indent-pt)
8460 (insert "// Inputs\n")
8461 (mapcar (function (lambda (port)
8462 (verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star)))
8463 sig-list)))
8464 ;; Kill extra semi
8465 (save-excursion
8466 (cond (did-first
8467 (re-search-backward "," pt t)
8468 (delete-char 1)
8469 (insert ");")
8470 (search-forward "\n") ;; Added by inst-port
8471 (delete-backward-char 1)
8472 (if (search-forward ")" nil t) ;; From user, moved up a line
8473 (delete-backward-char 1))
8474 (if (search-forward ";" nil t) ;; Don't error if user had syntax error and forgot it
8475 (delete-backward-char 1))
8476 )))
8477 ))))
8478
8479(defun verilog-auto-inst-param ()
8480 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto].
8481Replace the parameter connections to an instantiation with ones
8482automatically derived from the module header of the instantiated netlist.
8483
8484See \\[verilog-auto-inst] for limitations, and templates to customize the
8485output.
8486
8487For example, first take the submodule inst.v:
8488
8489 module inst (o,i)
8490 parameter PAR;
8491 endmodule
8492
8493This is then used in a upper level module:
8494
8495 module ex_inst (o,i)
8496 parameter PAR;
8497 inst #(/*AUTOINSTPARAM*/)
8498 inst (/*AUTOINST*/);
8499 endmodule
8500
8501Typing \\[verilog-auto] will make this into:
8502
8503 module ex_inst (o,i)
8504 output o;
8505 input i;
8506 inst (/*AUTOINSTPARAM*/
8507 // Parameters
8508 .PAR (PAR));
8509 inst (/*AUTOINST*/);
8510 endmodule
8511
8512Where the list of parameter connections come from the inst module.
8513
8514Templates:
8515
8516 You can customize the parameter connections using AUTO_TEMPLATEs,
8517 just as you would with \\[verilog-auto-inst]."
8518 (save-excursion
8519 ;; Find beginning
8520 (let* ((pt (point))
8521 (indent-pt (save-excursion (verilog-backward-open-paren)
8522 (1+ (current-column))))
8523 (verilog-auto-inst-column (max verilog-auto-inst-column
8524 (+ 16 (* 8 (/ (+ indent-pt 7) 8)))))
8525 (modi (verilog-modi-current))
8526 (vector-skip-list (unless verilog-auto-inst-vector
8527 (verilog-modi-get-signals modi)))
8528 submod submodi inst skip-pins tpl-list tpl-num did-first)
8529 ;; Find module name that is instantiated
8530 (setq submod (save-excursion
8531 ;; Get to the point where AUTOINST normally is to read the module
8532 (verilog-re-search-forward-quick "[(;]" nil nil)
8533 (verilog-read-inst-module))
8534 inst (save-excursion
8535 ;; Get to the point where AUTOINST normally is to read the module
8536 (verilog-re-search-forward-quick "[(;]" nil nil)
8537 (verilog-read-inst-name))
8538 vl-cell-type submod
8539 vl-cell-name inst
8540 skip-pins (aref (verilog-read-inst-pins) 0))
8541
8542 ;; Parse any AUTO_LISP() before here
8543 (verilog-read-auto-lisp (point-min) pt)
8544
8545 ;; Lookup position, etc of submodule
8546 ;; Note this may raise an error
8547 (when (setq submodi (verilog-modi-lookup submod t))
8548 ;; If there's a number in the instantiation, it may be a argument to the
8549 ;; automatic variable instantiation program.
8550 (let* ((tpl-info (verilog-read-auto-template submod))
8551 (tpl-regexp (aref tpl-info 0)))
8552 (setq tpl-num (if (string-match tpl-regexp inst)
8553 (match-string 1 inst)
8554 "")
8555 tpl-list (aref tpl-info 1)))
8556 ;; Find submodule's signals and dump
8557 (let ((sig-list (verilog-signals-not-in
8558 (verilog-modi-get-gparams submodi)
8559 skip-pins))
8560 (vl-dir "parameter"))
8561 (when sig-list
8562 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
8563 (indent-to indent-pt)
8564 (insert "// Parameters\n") ;; Note these are searched for in verilog-read-sub-decls
8565 (mapcar (function (lambda (port)
8566 (verilog-auto-inst-port port indent-pt tpl-list tpl-num nil)))
8567 sig-list)))
8568 ;; Kill extra semi
8569 (save-excursion
8570 (cond (did-first
8571 (re-search-backward "," pt t)
8572 (delete-char 1)
8573 (insert ")")
8574 (search-forward "\n") ;; Added by inst-port
8575 (delete-backward-char 1)
8576 (if (search-forward ")" nil t) ;; From user, moved up a line
8577 (delete-backward-char 1))
8578 )))
8579 ))))
8580
8581(defun verilog-auto-reg ()
8582 "Expand AUTOREG statements, as part of \\[verilog-auto].
8583Make reg statements for any output that isn't already declared,
8584and isn't a wire output from a block.
8585
8586Limitations:
8587 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
8588
8589 This does NOT work on memories, declare those yourself.
8590
8591An example:
8592
8593 module ex_reg (o,i)
8594 output o;
8595 input i;
8596 /*AUTOREG*/
8597 always o = i;
8598 endmodule
8599
8600Typing \\[verilog-auto] will make this into:
8601
8602 module ex_reg (o,i)
8603 output o;
8604 input i;
8605 /*AUTOREG*/
8606 // Beginning of automatic regs (for this module's undeclared outputs)
8607 reg o;
8608 // End of automatics
8609 always o = i;
8610 endmodule"
8611 (save-excursion
8612 ;; Point must be at insertion point.
8613 (let* ((indent-pt (current-indentation))
8614 (modi (verilog-modi-current))
8615 (sig-list (verilog-signals-not-in
8616 (verilog-modi-get-outputs modi)
8617 (append (verilog-modi-get-wires modi)
8618 (verilog-modi-get-regs modi)
8619 (verilog-modi-get-assigns modi)
8620 (verilog-modi-get-consts modi)
8621 (verilog-modi-get-gparams modi)
8622 (verilog-modi-get-sub-outputs modi)
8623 (verilog-modi-get-sub-inouts modi)
8624 ))))
8625 (forward-line 1)
8626 (when sig-list
8627 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n")
8628 (verilog-insert-definition sig-list "reg" indent-pt nil)
8629 (verilog-modi-cache-add-regs modi sig-list)
8630 (verilog-insert-indent "// End of automatics\n"))
8631 )))
8632
8633(defun verilog-auto-reg-input ()
8634 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto].
8635Make reg statements instantiation inputs that aren't already declared.
8636This is useful for making a top level shell for testing the module that is
8637to be instantiated.
8638
8639Limitations:
8640 This ONLY detects inputs of AUTOINSTants (see `verilog-read-sub-decls').
8641
8642 This does NOT work on memories, declare those yourself.
8643
8644An example (see `verilog-auto-inst' for what else is going on here):
8645
8646 module ex_reg_input (o,i)
8647 output o;
8648 input i;
8649 /*AUTOREGINPUT*/
8650 inst inst (/*AUTOINST*/);
8651 endmodule
8652
8653Typing \\[verilog-auto] will make this into:
8654
8655 module ex_reg_input (o,i)
8656 output o;
8657 input i;
8658 /*AUTOREGINPUT*/
8659 // Beginning of automatic reg inputs (for undeclared ...
8660 reg [31:0] iv; // From inst of inst.v
8661 // End of automatics
8662 inst inst (/*AUTOINST*/
8663 // Outputs
8664 .o (o[31:0]),
8665 // Inputs
8666 .iv (iv));
8667 endmodule"
8668 (save-excursion
8669 ;; Point must be at insertion point.
8670 (let* ((indent-pt (current-indentation))
8671 (modi (verilog-modi-current))
8672 (sig-list (verilog-signals-combine-bus
8673 (verilog-signals-not-in
8674 (append (verilog-modi-get-sub-inputs modi)
8675 (verilog-modi-get-sub-inouts modi))
8676 (verilog-modi-get-signals modi)
8677 ))))
8678 (forward-line 1)
8679 (when sig-list
8680 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n")
8681 (verilog-insert-definition sig-list "reg" indent-pt nil)
8682 (verilog-modi-cache-add-regs modi sig-list)
8683 (verilog-insert-indent "// End of automatics\n"))
8684 )))
8685
8686(defun verilog-auto-wire ()
8687 "Expand AUTOWIRE statements, as part of \\[verilog-auto].
8688Make wire statements for instantiations outputs that aren't
8689already declared.
8690
8691Limitations:
8692 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'),
8693 and all busses must have widths, such as those from AUTOINST, or using []
8694 in AUTO_TEMPLATEs.
8695
8696 This does NOT work on memories or SystemVerilog .name connections,
8697 declare those yourself.
8698
8699 Verilog-mode will add \"Couldn't Merge\" comments to signals it cannot
8700 determine how to bus together. This occurs when you have ports with
8701 non-numeric or non-sequential bus subscripts. If Verilog-Mode
8702 mis-guessed, you'll have to declare them yourself.
8703
8704An example (see `verilog-auto-inst' for what else is going on here):
8705
8706 module ex_wire (o,i)
8707 output o;
8708 input i;
8709 /*AUTOWIRE*/
8710 inst inst (/*AUTOINST*/);
8711 endmodule
8712
8713Typing \\[verilog-auto] will make this into:
8714
8715 module ex_wire (o,i)
8716 output o;
8717 input i;
8718 /*AUTOWIRE*/
8719 // Beginning of automatic wires
8720 wire [31:0] ov; // From inst of inst.v
8721 // End of automatics
8722 inst inst (/*AUTOINST*/
8723 // Outputs
8724 .ov (ov[31:0]),
8725 // Inputs
8726 .i (i));
8727 wire o = | ov;
8728 endmodule"
8729 (save-excursion
8730 ;; Point must be at insertion point.
8731 (let* ((indent-pt (current-indentation))
8732 (modi (verilog-modi-current))
8733 (sig-list (verilog-signals-combine-bus
8734 (verilog-signals-not-in
8735 (append (verilog-modi-get-sub-outputs modi)
8736 (verilog-modi-get-sub-inouts modi))
8737 (verilog-modi-get-signals modi)
8738 ))))
8739 (forward-line 1)
8740 (when sig-list
8741 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n")
8742 (verilog-insert-definition sig-list "wire" indent-pt nil)
8743 (verilog-modi-cache-add-wires modi sig-list)
8744 (verilog-insert-indent "// End of automatics\n")
8745 (when nil ;; Too slow on huge modules, plus makes everyone's module change
8746 (beginning-of-line)
8747 (setq pnt (point))
8748 (verilog-pretty-declarations)
8749 (goto-char pnt)
8750 (verilog-pretty-expr "//")))
8751 )))
8752
8753(defun verilog-auto-output ()
8754 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto].
8755Make output statements for any output signal from an /*AUTOINST*/ that
8756isn't a input to another AUTOINST. This is useful for modules which
8757only instantiate other modules.
8758
8759Limitations:
8760 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
8761
8762 If placed inside the parenthesis of a module declaration, it creates
8763 Verilog 2001 style, else uses Verilog 1995 style.
8764
8765 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's
8766 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
8767
8768 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
8769
8770 Signals matching `verilog-auto-output-ignore-regexp' are not included.
8771
8772An example (see `verilog-auto-inst' for what else is going on here):
8773
8774 module ex_output (ov,i)
8775 input i;
8776 /*AUTOOUTPUT*/
8777 inst inst (/*AUTOINST*/);
8778 endmodule
8779
8780Typing \\[verilog-auto] will make this into:
8781
8782 module ex_output (ov,i)
8783 input i;
8784 /*AUTOOUTPUT*/
8785 // Beginning of automatic outputs (from unused autoinst outputs)
8786 output [31:0] ov; // From inst of inst.v
8787 // End of automatics
8788 inst inst (/*AUTOINST*/
8789 // Outputs
8790 .ov (ov[31:0]),
8791 // Inputs
8792 .i (i));
8793 endmodule"
8794 (save-excursion
8795 ;; Point must be at insertion point.
8796 (let* ((indent-pt (current-indentation))
8797 (v2k (verilog-in-paren))
8798 (modi (verilog-modi-current))
8799 (sig-list (verilog-signals-not-in
8800 (verilog-modi-get-sub-outputs modi)
8801 (append (verilog-modi-get-outputs modi)
8802 (verilog-modi-get-inouts modi)
8803 (verilog-modi-get-sub-inputs modi)
8804 (verilog-modi-get-sub-inouts modi)
8805 ))))
8806 (setq sig-list (verilog-signals-not-matching-regexp
8807 sig-list verilog-auto-output-ignore-regexp))
8808 (forward-line 1)
8809 (when v2k (verilog-repair-open-comma))
8810 (when sig-list
8811 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n")
8812 (verilog-insert-definition sig-list "output" indent-pt v2k)
8813 (verilog-modi-cache-add-outputs modi sig-list)
8814 (verilog-insert-indent "// End of automatics\n"))
8815 (when v2k (verilog-repair-close-comma))
8816 )))
8817
8818(defun verilog-auto-output-every ()
8819 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto].
8820Make output statements for any signals that aren't primary inputs or
8821outputs already. This makes every signal in the design a output. This is
8822useful to get Synopsys to preserve every signal in the design, since it
8823won't optimize away the outputs.
8824
8825An example:
8826
8827 module ex_output_every (o,i,tempa,tempb)
8828 output o;
8829 input i;
8830 /*AUTOOUTPUTEVERY*/
8831 wire tempa = i;
8832 wire tempb = tempa;
8833 wire o = tempb;
8834 endmodule
8835
8836Typing \\[verilog-auto] will make this into:
8837
8838 module ex_output_every (o,i,tempa,tempb)
8839 output o;
8840 input i;
8841 /*AUTOOUTPUTEVERY*/
8842 // Beginning of automatic outputs (every signal)
8843 output tempb;
8844 output tempa;
8845 // End of automatics
8846 wire tempa = i;
8847 wire tempb = tempa;
8848 wire o = tempb;
8849 endmodule"
8850 (save-excursion
8851 ;;Point must be at insertion point
8852 (let* ((indent-pt (current-indentation))
8853 (v2k (verilog-in-paren))
8854 (modi (verilog-modi-current))
8855 (sig-list (verilog-signals-combine-bus
8856 (verilog-signals-not-in
8857 (verilog-modi-get-signals modi)
8858 (verilog-modi-get-ports modi)
8859 ))))
8860 (forward-line 1)
8861 (when v2k (verilog-repair-open-comma))
8862 (when sig-list
8863 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n")
8864 (verilog-insert-definition sig-list "output" indent-pt v2k)
8865 (verilog-modi-cache-add-outputs modi sig-list)
8866 (verilog-insert-indent "// End of automatics\n"))
8867 (when v2k (verilog-repair-close-comma))
8868 )))
8869
8870(defun verilog-auto-input ()
8871 "Expand AUTOINPUT statements, as part of \\[verilog-auto].
8872Make input statements for any input signal into an /*AUTOINST*/ that
8873isn't declared elsewhere inside the module. This is useful for modules which
8874only instantiate other modules.
8875
8876Limitations:
8877 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
8878
8879 If placed inside the parenthesis of a module declaration, it creates
8880 Verilog 2001 style, else uses Verilog 1995 style.
8881
8882 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's
8883 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
8884
8885 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
8886
8887 Signals matching `verilog-auto-input-ignore-regexp' are not included.
8888
8889An example (see `verilog-auto-inst' for what else is going on here):
8890
8891 module ex_input (ov,i)
8892 output [31:0] ov;
8893 /*AUTOINPUT*/
8894 inst inst (/*AUTOINST*/);
8895 endmodule
8896
8897Typing \\[verilog-auto] will make this into:
8898
8899 module ex_input (ov,i)
8900 output [31:0] ov;
8901 /*AUTOINPUT*/
8902 // Beginning of automatic inputs (from unused autoinst inputs)
8903 input i; // From inst of inst.v
8904 // End of automatics
8905 inst inst (/*AUTOINST*/
8906 // Outputs
8907 .ov (ov[31:0]),
8908 // Inputs
8909 .i (i));
8910 endmodule"
8911 (save-excursion
8912 (let* ((indent-pt (current-indentation))
8913 (v2k (verilog-in-paren))
8914 (modi (verilog-modi-current))
8915 (sig-list (verilog-signals-not-in
8916 (verilog-modi-get-sub-inputs modi)
8917 (append (verilog-modi-get-inputs modi)
8918 (verilog-modi-get-inouts modi)
8919 (verilog-modi-get-wires modi)
8920 (verilog-modi-get-regs modi)
8921 (verilog-modi-get-consts modi)
8922 (verilog-modi-get-gparams modi)
8923 (verilog-modi-get-sub-outputs modi)
8924 (verilog-modi-get-sub-inouts modi)
8925 ))))
8926 (setq sig-list (verilog-signals-not-matching-regexp
8927 sig-list verilog-auto-input-ignore-regexp))
8928 (forward-line 1)
8929 (when v2k (verilog-repair-open-comma))
8930 (when sig-list
8931 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n")
8932 (verilog-insert-definition sig-list "input" indent-pt v2k)
8933 (verilog-modi-cache-add-inputs modi sig-list)
8934 (verilog-insert-indent "// End of automatics\n"))
8935 (when v2k (verilog-repair-close-comma))
8936 )))
8937
8938(defun verilog-auto-inout ()
8939 "Expand AUTOINOUT statements, as part of \\[verilog-auto].
8940Make inout statements for any inout signal in an /*AUTOINST*/ that
8941isn't declared elsewhere inside the module.
8942
8943Limitations:
8944 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
8945
8946 If placed inside the parenthesis of a module declaration, it creates
8947 Verilog 2001 style, else uses Verilog 1995 style.
8948
8949 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's
8950 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
8951
8952 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
8953
8954 Signals matching `verilog-auto-inout-ignore-regexp' are not included.
8955
8956An example (see `verilog-auto-inst' for what else is going on here):
8957
8958 module ex_inout (ov,i)
8959 input i;
8960 /*AUTOINOUT*/
8961 inst inst (/*AUTOINST*/);
8962 endmodule
8963
8964Typing \\[verilog-auto] will make this into:
8965
8966 module ex_inout (ov,i)
8967 input i;
8968 /*AUTOINOUT*/
8969 // Beginning of automatic inouts (from unused autoinst inouts)
8970 inout [31:0] ov; // From inst of inst.v
8971 // End of automatics
8972 inst inst (/*AUTOINST*/
8973 // Inouts
8974 .ov (ov[31:0]),
8975 // Inputs
8976 .i (i));
8977 endmodule"
8978 (save-excursion
8979 ;; Point must be at insertion point.
8980 (let* ((indent-pt (current-indentation))
8981 (v2k (verilog-in-paren))
8982 (modi (verilog-modi-current))
8983 (sig-list (verilog-signals-not-in
8984 (verilog-modi-get-sub-inouts modi)
8985 (append (verilog-modi-get-outputs modi)
8986 (verilog-modi-get-inouts modi)
8987 (verilog-modi-get-inputs modi)
8988 (verilog-modi-get-sub-inputs modi)
8989 (verilog-modi-get-sub-outputs modi)
8990 ))))
8991 (setq sig-list (verilog-signals-not-matching-regexp
8992 sig-list verilog-auto-inout-ignore-regexp))
8993 (forward-line 1)
8994 (when v2k (verilog-repair-open-comma))
8995 (when sig-list
8996 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n")
8997 (verilog-insert-definition sig-list "inout" indent-pt v2k)
8998 (verilog-modi-cache-add-inouts modi sig-list)
8999 (verilog-insert-indent "// End of automatics\n"))
9000 (when v2k (verilog-repair-close-comma))
9001 )))
9002
9003(defun verilog-auto-inout-module ()
9004 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto].
9005Take input/output/inout statements from the specified module and insert
9006into the current module. This is useful for making null templates and
9007shell modules which need to have identical I/O with another module. Any
9008I/O which are already defined in this module will not be redefined.
9009
9010Limitations:
9011 If placed inside the parenthesis of a module declaration, it creates
9012 Verilog 2001 style, else uses Verilog 1995 style.
9013
9014 Concatenation and outputting partial busses is not supported.
9015
9016 Module names must be resolvable to filenames. See `verilog-auto-inst'.
9017
9018 Signals are not inserted in the same order as in the original module,
9019 though they will appear to be in the same order to a AUTOINST
9020 instantiating either module.
9021
9022An example:
9023
9024 module ex_shell (/*AUTOARG*/)
9025 /*AUTOINOUTMODULE(\"ex_main\")*/
9026 endmodule
9027
9028 module ex_main (i,o,io)
9029 input i;
9030 output o;
9031 inout io;
9032 endmodule
9033
9034Typing \\[verilog-auto] will make this into:
9035
9036 module ex_shell (/*AUTOARG*/i,o,io)
9037 /*AUTOINOUTMODULE(\"ex_main\")*/
9038 // Beginning of automatic in/out/inouts (from specific module)
9039 input i;
9040 output o;
9041 inout io;
9042 // End of automatics
9043 endmodule"
9044 (save-excursion
9045 (let* ((submod (car (verilog-read-auto-params 1))) submodi)
9046 ;; Lookup position, etc of co-module
9047 ;; Note this may raise an error
9048 (when (setq submodi (verilog-modi-lookup submod t))
9049 (let* ((indent-pt (current-indentation))
9050 (v2k (verilog-in-paren))
9051 (modi (verilog-modi-current))
9052 (sig-list-i (verilog-signals-not-in
9053 (verilog-modi-get-inputs submodi)
9054 (append (verilog-modi-get-inputs modi))))
9055 (sig-list-o (verilog-signals-not-in
9056 (verilog-modi-get-outputs submodi)
9057 (append (verilog-modi-get-outputs modi))))
9058 (sig-list-io (verilog-signals-not-in
9059 (verilog-modi-get-inouts submodi)
9060 (append (verilog-modi-get-inouts modi)))))
9061 (forward-line 1)
9062 (when v2k (verilog-repair-open-comma))
9063 (when (or sig-list-i sig-list-o sig-list-io)
9064 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n")
9065 ;; Don't sort them so a upper AUTOINST will match the main module
9066 (verilog-insert-definition sig-list-o "output" indent-pt v2k t)
9067 (verilog-insert-definition sig-list-io "inout" indent-pt v2k t)
9068 (verilog-insert-definition sig-list-i "input" indent-pt v2k t)
9069 (verilog-modi-cache-add-inputs modi sig-list-i)
9070 (verilog-modi-cache-add-outputs modi sig-list-o)
9071 (verilog-modi-cache-add-inouts modi sig-list-io)
9072 (verilog-insert-indent "// End of automatics\n"))
9073 (when v2k (verilog-repair-close-comma))
9074 )))))
9075
9076(defun verilog-auto-sense-sigs (modi presense-sigs)
9077 "Return list of signals for current AUTOSENSE block."
9078 (let* ((sigss (verilog-read-always-signals))
9079 (sig-list (verilog-signals-not-params
9080 (verilog-signals-not-in (verilog-alw-get-inputs sigss)
9081 (append (and (not verilog-auto-sense-include-inputs)
9082 (verilog-alw-get-outputs sigss))
9083 (verilog-modi-get-consts modi)
9084 (verilog-modi-get-gparams modi)
9085 presense-sigs)))))
9086 sig-list))
9087
9088(defun verilog-auto-sense ()
9089 "Expand AUTOSENSE statements, as part of \\[verilog-auto].
9090Replace the always (/*AUTOSENSE*/) sensitivity list (/*AS*/ for short)
9091with one automatically derived from all inputs declared in the always
9092statement. Signals that are generated within the same always block are NOT
9093placed into the sensitivity list (see `verilog-auto-sense-include-inputs').
9094Long lines are split based on the `fill-column', see \\[set-fill-column].
9095
9096Limitations:
9097 Verilog does not allow memories (multidimensional arrays) in sensitivity
9098 lists. AUTOSENSE will thus exclude them, and add a /*memory or*/ comment.
9099
9100Constant signals:
9101 AUTOSENSE cannot always determine if a `define is a constant or a signal
9102 (it could be in a include file for example). If a `define or other signal
9103 is put into the AUTOSENSE list and is not desired, use the AUTO_CONSTANT
9104 declaration anywhere in the module (parenthesis are required):
9105
9106 /* AUTO_CONSTANT ( `this_is_really_constant_dont_autosense_it ) */
9107
9108 Better yet, use a parameter, which will be understood to be constant
9109 automatically.
9110
9111OOps!
9112 If AUTOSENSE makes a mistake, please report it. (First try putting
9113 a begin/end after your always!) As a workaround, if a signal that
9114 shouldn't be in the sensitivity list was, use the AUTO_CONSTANT above.
9115 If a signal should be in the sensitivity list wasn't, placing it before
9116 the /*AUTOSENSE*/ comment will prevent it from being deleted when the
9117 autos are updated (or added if it occurs there already).
9118
9119An example:
9120
9121 always @ (/*AUTOSENSE*/) begin
9122 /* AUTO_CONSTANT (`constant) */
9123 outin = ina | inb | `constant;
9124 out = outin;
9125 end
9126
9127Typing \\[verilog-auto] will make this into:
9128
9129 always @ (/*AUTOSENSE*/ina or inb) begin
9130 /* AUTO_CONSTANT (`constant) */
9131 outin = ina | inb | `constant;
9132 out = outin;
9133 end"
9134 (save-excursion
9135 ;; Find beginning
9136 (let* ((start-pt (save-excursion
9137 (verilog-re-search-backward "(" nil t)
9138 (point)))
9139 (indent-pt (save-excursion
9140 (or (and (goto-char start-pt) (1+ (current-column)))
9141 (current-indentation))))
9142 (modi (verilog-modi-current))
9143 (sig-memories (verilog-signals-memory
9144 (append
9145 (verilog-modi-get-regs modi)
9146 (verilog-modi-get-wires modi))))
9147 sig-list not-first presense-sigs)
9148 ;; Read signals in always, eliminate outputs from sense list
9149 (setq presense-sigs (verilog-signals-from-signame
9150 (save-excursion
9151 (verilog-read-signals start-pt (point)))))
9152 (setq sig-list (verilog-auto-sense-sigs modi presense-sigs))
9153 (when sig-memories
9154 (let ((tlen (length sig-list)))
9155 (setq sig-list (verilog-signals-not-in sig-list sig-memories))
9156 (if (not (eq tlen (length sig-list))) (insert " /*memory or*/ "))))
9157 (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/"
9158 (save-excursion (goto-char (point))
9159 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t)
9160 (verilog-re-search-backward "\\s-" start-pt t)
9161 (while (looking-at "\\s-`endif")
9162 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t)
9163 (verilog-re-search-backward "\\s-" start-pt t))
9164 (not (looking-at "\\s-or\\b"))))
9165 (setq not-first t))
9166 (setq sig-list (sort sig-list `verilog-signals-sort-compare))
9167 (while sig-list
9168 (cond ((> (+ 4 (current-column) (length (verilog-sig-name (car sig-list)))) fill-column) ;+4 for width of or
9169 (insert "\n")
9170 (indent-to indent-pt)
9171 (if not-first (insert "or ")))
9172 (not-first (insert " or ")))
9173 (insert (verilog-sig-name (car sig-list)))
9174 (setq sig-list (cdr sig-list)
9175 not-first t))
9176 )))
9177
9178(defun verilog-auto-reset ()
9179 "Expand AUTORESET statements, as part of \\[verilog-auto].
9180Replace the /*AUTORESET*/ comment with code to initialize all
9181registers set elsewhere in the always block.
9182
9183Limitations:
9184 AUTORESET will not clear memories.
9185
9186 AUTORESET uses <= if there are any <= in the block, else it uses =.
9187
9188/*AUTORESET*/ presumes that any signals mentioned between the previous
9189begin/case/if statement and the AUTORESET comment are being reset manually
9190and should not be automatically reset. This includes omitting any signals
9191used on the right hand side of assignments.
9192
9193By default, AUTORESET will include the width of the signal in the autos,
9194this is a recent change. To control this behavior, see
9195`verilog-auto-reset-widths'.
9196
9197AUTORESET ties signals to deasserted, which is presumed to be zero.
9198Signals that match `verilog-active-low-regexp' will be deasserted by tieing
9199them to a one.
9200
9201An example:
9202
9203 always @(posedge clk or negedge reset_l) begin
9204 if (!reset_l) begin
9205 c <= 1;
9206 /*AUTORESET*/
9207 end
9208 else begin
9209 a <= in_a;
9210 b <= in_b;
9211 c <= in_c;
9212 end
9213 end
9214
9215Typing \\[verilog-auto] will make this into:
9216
9217 always @(posedge core_clk or negedge reset_l) begin
9218 if (!reset_l) begin
9219 c <= 1;
9220 /*AUTORESET*/
9221 // Beginning of autoreset for uninitialized flops
9222 a <= 0;
9223 b <= 0;
9224 // End of automatics
9225 end
9226 else begin
9227 a <= in_a;
9228 b <= in_b;
9229 c <= in_c;
9230 end
9231 end"
9232
9233 (interactive)
9234 (save-excursion
9235 ;; Find beginning
9236 (let* ((indent-pt (current-indentation))
9237 (modi (verilog-modi-current))
9238 (all-list (verilog-modi-get-signals modi))
9239 sigss sig-list prereset-sigs assignment-str)
9240 ;; Read signals in always, eliminate outputs from reset list
9241 (setq prereset-sigs (verilog-signals-from-signame
9242 (save-excursion
9243 (verilog-read-signals
9244 (save-excursion
9245 (verilog-re-search-backward "\\(@\\|\\<begin\\>\\|\\<if\\>\\|\\<case\\>\\)" nil t)
9246 (point))
9247 (point)))))
9248 (save-excursion
9249 (verilog-re-search-backward "@" nil t)
9250 (setq sigss (verilog-read-always-signals)))
9251 (setq assignment-str (if (verilog-alw-get-uses-delayed sigss)
9252 (concat " <= " verilog-assignment-delay)
9253 " = "))
9254 (setq sig-list (verilog-signals-not-in (verilog-alw-get-outputs sigss)
9255 prereset-sigs))
9256 (setq sig-list (sort sig-list `verilog-signals-sort-compare))
9257 (when sig-list
9258 (insert "\n");
9259 (indent-to indent-pt)
9260 (insert "// Beginning of autoreset for uninitialized flops\n");
9261 (indent-to indent-pt)
9262 (while sig-list
9263 (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths
9264 (car sig-list))))
9265 (insert (verilog-sig-name sig)
9266 assignment-str
9267 (verilog-sig-tieoff sig (not verilog-auto-reset-widths))
9268 ";\n")
9269 (indent-to indent-pt)
9270 (setq sig-list (cdr sig-list))))
9271 (insert "// End of automatics"))
9272 )))
9273
9274(defun verilog-auto-tieoff ()
9275 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto].
9276Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output
9277signals to deasserted.
9278
9279/*AUTOTIEOFF*/ is used to make stub modules; modules that have the same
9280input/output list as another module, but no internals. Specifically, it
9281finds all outputs in the module, and if that input is not otherwise declared
9282as a register or wire, creates a tieoff.
9283
9284AUTORESET ties signals to deasserted, which is presumed to be zero.
9285Signals that match `verilog-active-low-regexp' will be deasserted by tieing
9286them to a one.
9287
9288An example of making a stub for another module:
9289
9290 module FooStub (/*AUTOINST*/);
9291 /*AUTOINOUTMODULE(\"Foo\")*/
9292 /*AUTOTIEOFF*/
9293 // verilator lint_off UNUSED
9294 wire _unused_ok = &{1'b0,
9295 /*AUTOUNUSED*/
9296 1'b0};
9297 // verilator lint_on UNUSED
9298 endmodule
9299
9300Typing \\[verilog-auto] will make this into:
9301
9302 module FooStub (/*AUTOINST*/...);
9303 /*AUTOINOUTMODULE(\"Foo\")*/
9304 // Beginning of autotieoff
9305 output [2:0] foo;
9306 // End of automatics
9307
9308 /*AUTOTIEOFF*/
9309 // Beginning of autotieoff
9310 wire [2:0] foo = 3'b0;
9311 // End of automatics
9312 ...
9313 endmodule"
9314 (interactive)
9315 (save-excursion
9316 ;; Find beginning
9317 (let* ((indent-pt (current-indentation))
9318 (modi (verilog-modi-current))
9319 (sig-list (verilog-signals-not-in
9320 (verilog-modi-get-outputs modi)
9321 (append (verilog-modi-get-wires modi)
9322 (verilog-modi-get-regs modi)
9323 (verilog-modi-get-assigns modi)
9324 (verilog-modi-get-consts modi)
9325 (verilog-modi-get-gparams modi)
9326 (verilog-modi-get-sub-outputs modi)
9327 (verilog-modi-get-sub-inouts modi)
9328 ))))
9329 (when sig-list
9330 (forward-line 1)
9331 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n")
9332 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare))
9333 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list
9334 (while sig-list
9335 (let ((sig (car sig-list)))
9336 (verilog-insert-one-definition sig "wire" indent-pt)
9337 (indent-to (max 48 (+ indent-pt 40)))
9338 (insert "= " (verilog-sig-tieoff sig)
9339 ";\n")
9340 (setq sig-list (cdr sig-list))))
9341 (verilog-insert-indent "// End of automatics\n")
9342 ))))
9343
9344(defun verilog-auto-unused ()
9345 "Expand AUTOUNUSED statements, as part of \\[verilog-auto].
9346Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused
9347input and inout signals.
9348
9349/*AUTOUNUSED*/ is used to make stub modules; modules that have the same
9350input/output list as another module, but no internals. Specifically, it
9351finds all inputs and inouts in the module, and if that input is not otherwise
9352used, adds it to a comma separated list.
9353
9354The comma separated list is intended to be used to create a _unused_ok
9355signal. Using the exact name \"_unused_ok\" for name of the temporary
9356signal is recommended as it will insure maximum forward compatibility, it
9357also makes lint warnings easy to understand; ignore any unused warnings
9358with \"unused\" in the signal name.
9359
9360To reduce simulation time, the _unused_ok signal should be forced to a
9361constant to prevent wiggling. The easiest thing to do is use a
9362reduction-and with 1'b0 as shown.
9363
9364This way all unused signals are in one place, making it convenient to add
9365your tool's specific pragmas around the assignment to disable any unused
9366warnings.
9367
9368You can add signals you do not want included in AUTOUNUSED with
9369`verilog-auto-unused-ignore-regexp'.
9370
9371An example of making a stub for another module:
9372
9373 module FooStub (/*AUTOINST*/);
9374 /*AUTOINOUTMODULE(\"Foo\")*/
9375 /*AUTOTIEOFF*/
9376 // verilator lint_off UNUSED
9377 wire _unused_ok = &{1'b0,
9378 /*AUTOUNUSED*/
9379 1'b0};
9380 // verilator lint_on UNUSED
9381 endmodule
9382
9383Typing \\[verilog-auto] will make this into:
9384
9385 ...
9386 // verilator lint_off UNUSED
9387 wire _unused_ok = &{1'b0,
9388 /*AUTOUNUSED*/
9389 // Beginning of automatics
9390 unused_input_a,
9391 unused_input_b,
9392 unused_input_c,
9393 // End of automatics
9394 1'b0};
9395 // verilator lint_on UNUSED
9396 endmodule"
9397 (interactive)
9398 (save-excursion
9399 ;; Find beginning
9400 (let* ((indent-pt (progn (search-backward "/*") (current-column)))
9401 (modi (verilog-modi-current))
9402 (sig-list (verilog-signals-not-in
9403 (append (verilog-modi-get-inputs modi)
9404 (verilog-modi-get-inouts modi))
9405 (append (verilog-modi-get-sub-inputs modi)
9406 (verilog-modi-get-sub-inouts modi)
9407 ))))
9408 (setq sig-list (verilog-signals-not-matching-regexp
9409 sig-list verilog-auto-unused-ignore-regexp))
9410 (when sig-list
9411 (forward-line 1)
9412 (verilog-insert-indent "// Beginning of automatic unused inputs\n")
9413 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare))
9414 (while sig-list
9415 (let ((sig (car sig-list)))
9416 (indent-to indent-pt)
9417 (insert (verilog-sig-name sig) ",\n")
9418 (setq sig-list (cdr sig-list))))
9419 (verilog-insert-indent "// End of automatics\n")
9420 ))))
9421
9422(defun verilog-enum-ascii (signm elim-regexp)
9423 "Convert a enum name SIGNM to a ascii string for insertion.
9424Remove user provided prefix ELIM-REGEXP."
9425 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_"))
9426 (let ((case-fold-search t))
9427 ;; All upper becomes all lower for readability
9428 (downcase (verilog-string-replace-matches elim-regexp "" nil nil signm))))
9429
9430(defun verilog-auto-ascii-enum ()
9431 "Expand AUTOASCIIENUM statements, as part of \\[verilog-auto].
9432Create a register to contain the ASCII decode of a enumerated signal type.
9433This will allow trace viewers to show the ASCII name of states.
9434
9435First, parameters are built into a enumeration using the synopsys enum
9436comment. The comment must be between the keyword and the symbol.
9437\(Annoying, but that's what Synopsys's dc_shell FSM reader requires.)
9438
9439Next, registers which that enum applies to are also tagged with the same
9440enum. Synopsys also suggests labeling state vectors, but `verilog-mode'
9441doesn't care.
9442
9443Finally, a AUTOASCIIENUM command is used.
9444
9445 The first parameter is the name of the signal to be decoded.
9446
9447 The second parameter is the name to store the ASCII code into. For the
9448 signal foo, I suggest the name _foo__ascii, where the leading _ indicates
9449 a signal that is just for simulation, and the magic characters _ascii
9450 tell viewers like Dinotrace to display in ASCII format.
9451
9452 The final optional parameter is a string which will be removed from the
9453 state names.
9454
9455An example:
9456
9457 //== State enumeration
9458 parameter [2:0] // synopsys enum state_info
9459 SM_IDLE = 3'b000,
9460 SM_SEND = 3'b001,
9461 SM_WAIT1 = 3'b010;
9462 //== State variables
9463 reg [2:0] /* synopsys enum state_info */
9464 state_r; /* synopsys state_vector state_r */
9465 reg [2:0] /* synopsys enum state_info */
9466 state_e1;
9467
9468 //== ASCII state decoding
9469
9470 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/
9471
9472Typing \\[verilog-auto] will make this into:
9473
9474 ... same front matter ...
9475
9476 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/
9477 // Beginning of automatic ASCII enum decoding
9478 reg [39:0] state_ascii_r; // Decode of state_r
9479 always @(state_r) begin
9480 case ({state_r})
9481 SM_IDLE: state_ascii_r = \"idle \";
9482 SM_SEND: state_ascii_r = \"send \";
9483 SM_WAIT1: state_ascii_r = \"wait1\";
9484 default: state_ascii_r = \"%Erro\";
9485 endcase
9486 end
9487 // End of automatics"
9488 (save-excursion
9489 (let* ((params (verilog-read-auto-params 2 3))
9490 (undecode-name (nth 0 params))
9491 (ascii-name (nth 1 params))
9492 (elim-regexp (nth 2 params))
9493 ;;
9494 (indent-pt (current-indentation))
9495 (modi (verilog-modi-current))
9496 ;;
9497 (sig-list-consts (append (verilog-modi-get-consts modi)
9498 (verilog-modi-get-gparams modi)))
9499 (sig-list-all (append (verilog-modi-get-regs modi)
9500 (verilog-modi-get-outputs modi)
9501 (verilog-modi-get-inouts modi)
9502 (verilog-modi-get-inputs modi)
9503 (verilog-modi-get-wires modi)))
9504 ;;
9505 (undecode-sig (or (assoc undecode-name sig-list-all)
9506 (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name)))
9507 (undecode-enum (or (verilog-sig-enum undecode-sig)
9508 (error "%s: Signal %s does not have a enum tag" (verilog-point-text) undecode-name)))
9509 ;;
9510 (enum-sigs (or (verilog-signals-matching-enum sig-list-consts undecode-enum)
9511 (error "%s: No state definitions for %s" (verilog-point-text) undecode-enum)))
9512 ;;
9513 (enum-chars 0)
9514 (ascii-chars 0))
9515 ;;
9516 ;; Find number of ascii chars needed
9517 (let ((tmp-sigs enum-sigs))
9518 (while tmp-sigs
9519 (setq enum-chars (max enum-chars (length (verilog-sig-name (car tmp-sigs))))
9520 ascii-chars (max ascii-chars (length (verilog-enum-ascii
9521 (verilog-sig-name (car tmp-sigs))
9522 elim-regexp)))
9523 tmp-sigs (cdr tmp-sigs))))
9524 ;;
9525 (forward-line 1)
9526 (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n")
9527 (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1))
9528 (concat "Decode of " undecode-name) nil nil))))
9529 (verilog-insert-definition decode-sig-list "reg" indent-pt nil)
9530 (verilog-modi-cache-add-regs modi decode-sig-list))
9531 ;;
9532 (verilog-insert-indent "always @(" undecode-name ") begin\n")
9533 (setq indent-pt (+ indent-pt verilog-indent-level))
9534 (indent-to indent-pt)
9535 (insert "case ({" undecode-name "})\n")
9536 (setq indent-pt (+ indent-pt verilog-case-indent))
9537 ;;
9538 (let ((tmp-sigs enum-sigs)
9539 (chrfmt (format "%%-%ds %s = \"%%-%ds\";\n" (1+ (max 8 enum-chars))
9540 ascii-name ascii-chars))
9541 (errname (substring "%Error" 0 (min 6 ascii-chars))))
9542 (while tmp-sigs
9543 (verilog-insert-indent
9544 (format chrfmt (concat (verilog-sig-name (car tmp-sigs)) ":")
9545 (verilog-enum-ascii (verilog-sig-name (car tmp-sigs))
9546 elim-regexp)))
9547 (setq tmp-sigs (cdr tmp-sigs)))
9548 (verilog-insert-indent (format chrfmt "default:" errname)))
9549 ;;
9550 (setq indent-pt (- indent-pt verilog-case-indent))
9551 (verilog-insert-indent "endcase\n")
9552 (setq indent-pt (- indent-pt verilog-indent-level))
9553 (verilog-insert-indent "end\n"
9554 "// End of automatics\n")
9555 )))
9556
9557(defun verilog-auto-templated-rel ()
9558 "Replace Templated relative line numbers with absolute line numbers.
9559Internal use only. This hacks around the line numbers in AUTOINST Templates
9560being different from the final output's line numbering."
9561 (let ((templateno 0) (template-line (list 0)))
9562 ;; Find line number each template is on
9563 (goto-char (point-min))
9564 (while (search-forward "AUTO_TEMPLATE" nil t)
9565 (setq templateno (1+ templateno))
9566 (setq template-line (cons (count-lines (point-min) (point)) template-line)))
9567 (setq template-line (nreverse template-line))
9568 ;; Replace T# L# with absolute line number
9569 (goto-char (point-min))
9570 (while (re-search-forward " Templated T\\([0-9]+\\) L\\([0-9]+\\)" nil t)
9571 (replace-match (concat " Templated "
9572 (int-to-string (+ (nth (string-to-int (match-string 1))
9573 template-line)
9574 (string-to-int (match-string 2)))))
9575 t t))))
9576
9577
9578;;
9579;; Auto top level
9580;;
9581
9582(defun verilog-auto (&optional inject) ; Use verilog-inject-auto instead of passing a arg
9583 "Expand AUTO statements.
9584Look for any /*AUTO...*/ commands in the code, as used in
9585instantiations or argument headers. Update the list of signals
9586following the /*AUTO...*/ command.
9587
9588Use \\[verilog-delete-auto] to remove the AUTOs.
9589
9590Use \\[verilog-inject-auto] to insert AUTOs for the first time.
9591
9592Use \\[verilog-faq] for a pointer to frequently asked questions.
9593
9594The hooks `verilog-before-auto-hook' and `verilog-auto-hook' are
9595called before and after this function, respectively.
9596
9597For example:
9598 module (/*AUTOARG*/)
9599 /*AUTOINPUT*/
9600 /*AUTOOUTPUT*/
9601 /*AUTOWIRE*/
9602 /*AUTOREG*/
9603 somesub sub #(/*AUTOINSTPARAM*/) (/*AUTOINST*/);
9604
9605You can also update the AUTOs from the shell using:
9606 emacs --batch <filenames.v> -f verilog-batch-auto
9607Or fix indentation with:
9608 emacs --batch <filenames.v> -f verilog-batch-indent
9609Likewise, you can delete or inject AUTOs with:
9610 emacs --batch <filenames.v> -f verilog-batch-delete-auto
9611 emacs --batch <filenames.v> -f verilog-batch-inject-auto
9612
9613Using \\[describe-function], see also:
9614 `verilog-auto-arg' for AUTOARG module instantiations
9615 `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding
9616 `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere
9617 `verilog-auto-inout' for AUTOINOUT making hierarchy inouts
9618 `verilog-auto-input' for AUTOINPUT making hierarchy inputs
9619 `verilog-auto-inst' for AUTOINST instantiation pins
9620 `verilog-auto-star' for AUTOINST .* SystemVerilog pins
9621 `verilog-auto-inst-param' for AUTOINSTPARAM instantiation params
9622 `verilog-auto-output' for AUTOOUTPUT making hierarchy outputs
9623 `verilog-auto-output-every' for AUTOOUTPUTEVERY making all outputs
9624 `verilog-auto-reg' for AUTOREG registers
9625 `verilog-auto-reg-input' for AUTOREGINPUT instantiation registers
9626 `verilog-auto-reset' for AUTORESET flop resets
9627 `verilog-auto-sense' for AUTOSENSE always sensitivity lists
9628 `verilog-auto-tieoff' for AUTOTIEOFF output tieoffs
9629 `verilog-auto-unused' for AUTOUNUSED unused inputs/inouts
9630 `verilog-auto-wire' for AUTOWIRE instantiation wires
9631
9632 `verilog-read-defines' for reading `define values
9633 `verilog-read-includes' for reading `includes
9634
9635If you have bugs with these autos, try contacting the AUTOAUTHOR
9636Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com."
9637 (interactive)
9638 (unless noninteractive (message "Updating AUTOs..."))
9639 (if (featurep 'dinotrace)
9640 (dinotrace-unannotate-all))
9641 (let ((oldbuf (if (not (buffer-modified-p))
9642 (buffer-string)))
9643 ;; Before version 20, match-string with font-lock returns a
9644 ;; vector that is not equal to the string. IE if on "input"
9645 ;; nil==(equal "input" (progn (looking-at "input") (match-string 0)))
9646 (fontlocked (when (and (boundp 'font-lock-mode)
9647 font-lock-mode)
9648 (font-lock-mode nil)
9649 t)))
9650 (unwind-protect
9651 (save-excursion
9652 ;; If we're not in verilog-mode, change syntax table so parsing works right
9653 (unless (eq major-mode `verilog-mode) (verilog-mode))
9654 ;; Allow user to customize
9655 (run-hooks 'verilog-before-auto-hook)
9656 ;; Try to save the user from needing to revert-file to reread file local-variables
9657 (verilog-auto-reeval-locals)
9658 (verilog-read-auto-lisp (point-min) (point-max))
9659 (verilog-getopt-flags)
9660 ;; These two may seem obvious to do always, but on large includes it can be way too slow
9661 (when verilog-auto-read-includes
9662 (verilog-read-includes)
9663 (verilog-read-defines nil nil t))
9664 ;; This particular ordering is important
9665 ;; INST: Lower modules correct, no internal dependencies, FIRST
9666 (verilog-preserve-cache
9667 ;; Clear existing autos else we'll be screwed by existing ones
9668 (verilog-delete-auto)
9669 ;; Injection if appropriate
9670 (when inject
9671 (verilog-inject-inst)
9672 (verilog-inject-sense)
9673 (verilog-inject-arg))
9674 ;;
9675 (verilog-auto-search-do "/*AUTOINSTPARAM*/" 'verilog-auto-inst-param)
9676 (verilog-auto-search-do "/*AUTOINST*/" 'verilog-auto-inst)
9677 (verilog-auto-search-do ".*" 'verilog-auto-star)
9678 ;; Doesn't matter when done, but combine it with a common changer
9679 (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense)
9680 (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset)
9681 ;; Must be done before autoin/out as creates a reg
9682 (verilog-auto-re-search-do "/\\*AUTOASCIIENUM([^)]*)\\*/" 'verilog-auto-ascii-enum)
9683 ;;
9684 ;; first in/outs from other files
9685 (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module)
9686 ;; next in/outs which need previous sucked inputs first
9687 (verilog-auto-search-do "/*AUTOOUTPUT*/" 'verilog-auto-output)
9688 (verilog-auto-search-do "/*AUTOINPUT*/" 'verilog-auto-input)
9689 (verilog-auto-search-do "/*AUTOINOUT*/" 'verilog-auto-inout)
9690 ;; Then tie off those in/outs
9691 (verilog-auto-search-do "/*AUTOTIEOFF*/" 'verilog-auto-tieoff)
9692 ;; Wires/regs must be after inputs/outputs
9693 (verilog-auto-search-do "/*AUTOWIRE*/" 'verilog-auto-wire)
9694 (verilog-auto-search-do "/*AUTOREG*/" 'verilog-auto-reg)
9695 (verilog-auto-search-do "/*AUTOREGINPUT*/" 'verilog-auto-reg-input)
9696 ;; outputevery needs AUTOOUTPUTs done first
9697 (verilog-auto-search-do "/*AUTOOUTPUTEVERY*/" 'verilog-auto-output-every)
9698 ;; After we've created all new variables
9699 (verilog-auto-search-do "/*AUTOUNUSED*/" 'verilog-auto-unused)
9700 ;; Must be after all inputs outputs are generated
9701 (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg)
9702 ;; Fix line numbers (comments only)
9703 (verilog-auto-templated-rel)
9704 )
9705 ;;
9706 (run-hooks 'verilog-auto-hook)
9707 ;;
9708 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick))
9709 ;;
9710 ;; If end result is same as when started, clear modified flag
9711 (cond ((and oldbuf (equal oldbuf (buffer-string)))
9712 (set-buffer-modified-p nil)
9713 (unless noninteractive (message "Updating AUTOs...done (no changes)")))
9714 (t (unless noninteractive (message "Updating AUTOs...done")))))
9715 ;; Unwind forms
9716 (progn
9717 ;; Restore font-lock
9718 (when fontlocked (font-lock-mode t)))
9719 )))
9720
9721
9722;;
9723;; Skeleton based code insertion
9724;;
9725(defvar verilog-template-map
9726 (let ((map (make-sparse-keymap)))
9727 (define-key map "a" 'verilog-sk-always)
9728 (define-key map "b" 'verilog-sk-begin)
9729 (define-key map "c" 'verilog-sk-case)
9730 (define-key map "f" 'verilog-sk-for)
9731 (define-key map "g" 'verilog-sk-generate)
9732 (define-key map "h" 'verilog-sk-header)
9733 (define-key map "i" 'verilog-sk-initial)
9734 (define-key map "j" 'verilog-sk-fork)
9735 (define-key map "m" 'verilog-sk-module)
9736 (define-key map "p" 'verilog-sk-primitive)
9737 (define-key map "r" 'verilog-sk-repeat)
9738 (define-key map "s" 'verilog-sk-specify)
9739 (define-key map "t" 'verilog-sk-task)
9740 (define-key map "w" 'verilog-sk-while)
9741 (define-key map "x" 'verilog-sk-casex)
9742 (define-key map "z" 'verilog-sk-casez)
9743 (define-key map "?" 'verilog-sk-if)
9744 (define-key map ":" 'verilog-sk-else-if)
9745 (define-key map "/" 'verilog-sk-comment)
9746 (define-key map "A" 'verilog-sk-assign)
9747 (define-key map "F" 'verilog-sk-function)
9748 (define-key map "I" 'verilog-sk-input)
9749 (define-key map "O" 'verilog-sk-output)
9750 (define-key map "S" 'verilog-sk-state-machine)
9751 (define-key map "=" 'verilog-sk-inout)
9752 (define-key map "W" 'verilog-sk-wire)
9753 (define-key map "R" 'verilog-sk-reg)
9754 (define-key map "D" 'verilog-sk-define-signal)
9755 map)
9756 "Keymap used in Verilog mode for smart template operations.")
9757
9758
9759;;
9760;; Place the templates into Verilog Mode. They may be inserted under any key.
9761;; C-c C-t will be the default. If you use templates a lot, you
9762;; may want to consider moving the binding to another key in your .emacs
9763;; file.
9764;;
9765;(define-key verilog-mode-map "\C-ct" verilog-template-map)
9766(define-key verilog-mode-map "\C-c\C-t" verilog-template-map)
9767
9768;;; ---- statement skeletons ------------------------------------------
9769
9770(define-skeleton verilog-sk-prompt-condition
9771 "Prompt for the loop condition."
9772 "[condition]: " str )
9773
9774(define-skeleton verilog-sk-prompt-init
9775 "Prompt for the loop init statement."
9776 "[initial statement]: " str )
9777
9778(define-skeleton verilog-sk-prompt-inc
9779 "Prompt for the loop increment statement."
9780 "[increment statement]: " str )
9781
9782(define-skeleton verilog-sk-prompt-name
9783 "Prompt for the name of something."
9784 "[name]: " str)
9785
9786(define-skeleton verilog-sk-prompt-clock
9787 "Prompt for the name of something."
9788 "name and edge of clock(s): " str)
9789
9790(defvar verilog-sk-reset nil)
9791(defun verilog-sk-prompt-reset ()
9792 "Prompt for the name of a state machine reset."
9793 (setq verilog-sk-reset (read-input "name of reset: " "rst")))
9794
9795
9796(define-skeleton verilog-sk-prompt-state-selector
9797 "Prompt for the name of a state machine selector."
9798 "name of selector (eg {a,b,c,d}): " str )
9799
9800(define-skeleton verilog-sk-prompt-output
9801 "Prompt for the name of something."
9802 "output: " str)
9803
9804(define-skeleton verilog-sk-prompt-msb
9805 "Prompt for least significant bit specification."
9806 "msb:" str & ?: & (verilog-sk-prompt-lsb) | -1 )
9807
9808(define-skeleton verilog-sk-prompt-lsb
9809 "Prompt for least significant bit specification."
9810 "lsb:" str )
9811
9812(defvar verilog-sk-p nil)
9813(define-skeleton verilog-sk-prompt-width
9814 "Prompt for a width specification."
9815 ()
9816 (progn
9817 (setq verilog-sk-p (point))
9818 (verilog-sk-prompt-msb)
9819 (if (> (point) verilog-sk-p) "] " " ")))
9820
9821(defun verilog-sk-header ()
9822 "Insert a descriptive header at the top of the file."
9823 (interactive "*")
9824 (save-excursion
9825 (goto-char (point-min))
9826 (verilog-sk-header-tmpl)))
9827
9828(define-skeleton verilog-sk-header-tmpl
9829 "Insert a comment block containing the module title, author, etc."
9830 "[Description]: "
9831 "// -*- Mode: Verilog -*-"
9832 "\n// Filename : " (buffer-name)
9833 "\n// Description : " str
9834 "\n// Author : " (user-full-name)
9835 "\n// Created On : " (current-time-string)
9836 "\n// Last Modified By: ."
9837 "\n// Last Modified On: ."
9838 "\n// Update Count : 0"
9839 "\n// Status : Unknown, Use with caution!"
9840 "\n")
9841
9842(define-skeleton verilog-sk-module
9843 "Insert a module definition."
9844 ()
9845 > "module " (verilog-sk-prompt-name) " (/*AUTOARG*/ ) ;" \n
9846 > _ \n
9847 > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil))
9848
9849(define-skeleton verilog-sk-primitive
9850 "Insert a task definition."
9851 ()
9852 > "primitive " (verilog-sk-prompt-name) " ( " (verilog-sk-prompt-output) ("input:" ", " str ) " );"\n
9853 > _ \n
9854 > (- verilog-indent-level-behavioral) "endprimitive" (progn (electric-verilog-terminate-line) nil))
9855
9856(define-skeleton verilog-sk-task
9857 "Insert a task definition."
9858 ()
9859 > "task " (verilog-sk-prompt-name) & ?; \n
9860 > _ \n
9861 > "begin" \n
9862 > \n
9863 > (- verilog-indent-level-behavioral) "end" \n
9864 > (- verilog-indent-level-behavioral) "endtask" (progn (electric-verilog-terminate-line) nil))
9865
9866(define-skeleton verilog-sk-function
9867 "Insert a function definition."
9868 ()
9869 > "function [" (verilog-sk-prompt-width) | -1 (verilog-sk-prompt-name) ?; \n
9870 > _ \n
9871 > "begin" \n
9872 > \n
9873 > (- verilog-indent-level-behavioral) "end" \n
9874 > (- verilog-indent-level-behavioral) "endfunction" (progn (electric-verilog-terminate-line) nil))
9875
9876(define-skeleton verilog-sk-always
9877 "Insert always block. Uses the minibuffer to prompt
9878for sensitivity list."
9879 ()
9880 > "always @ ( /*AUTOSENSE*/ ) begin\n"
9881 > _ \n
9882 > (- verilog-indent-level-behavioral) "end" \n >
9883 )
9884
9885(define-skeleton verilog-sk-initial
9886 "Insert an initial block."
9887 ()
9888 > "initial begin\n"
9889 > _ \n
9890 > (- verilog-indent-level-behavioral) "end" \n > )
9891
9892(define-skeleton verilog-sk-specify
9893 "Insert specify block. "
9894 ()
9895 > "specify\n"
9896 > _ \n
9897 > (- verilog-indent-level-behavioral) "endspecify" \n > )
9898
9899(define-skeleton verilog-sk-generate
9900 "Insert generate block. "
9901 ()
9902 > "generate\n"
9903 > _ \n
9904 > (- verilog-indent-level-behavioral) "endgenerate" \n > )
9905
9906(define-skeleton verilog-sk-begin
9907 "Insert begin end block. Uses the minibuffer to prompt for name"
9908 ()
9909 > "begin" (verilog-sk-prompt-name) \n
9910 > _ \n
9911 > (- verilog-indent-level-behavioral) "end"
9912)
9913
9914(define-skeleton verilog-sk-fork
9915 "Insert an fork join block."
9916 ()
9917 > "fork\n"
9918 > "begin" \n
9919 > _ \n
9920 > (- verilog-indent-level-behavioral) "end" \n
9921 > "begin" \n
9922 > \n
9923 > (- verilog-indent-level-behavioral) "end" \n
9924 > (- verilog-indent-level-behavioral) "join" \n
9925 > )
9926
9927
9928(define-skeleton verilog-sk-case
9929 "Build skeleton case statement, prompting for the selector expression,
9930and the case items."
9931 "[selector expression]: "
9932 > "case (" str ") " \n
9933 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n )
9934 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil))
9935
9936(define-skeleton verilog-sk-casex
9937 "Build skeleton casex statement, prompting for the selector expression,
9938and the case items."
9939 "[selector expression]: "
9940 > "casex (" str ") " \n
9941 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n )
9942 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil))
9943
9944(define-skeleton verilog-sk-casez
9945 "Build skeleton casez statement, prompting for the selector expression,
9946and the case items."
9947 "[selector expression]: "
9948 > "casez (" str ") " \n
9949 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n )
9950 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil))
9951
9952(define-skeleton verilog-sk-if
9953 "Insert a skeleton if statement."
9954 > "if (" (verilog-sk-prompt-condition) & ")" " begin" \n
9955 > _ \n
9956 > (- verilog-indent-level-behavioral) "end " \n )
9957
9958(define-skeleton verilog-sk-else-if
9959 "Insert a skeleton else if statement."
9960 > (verilog-indent-line) "else if ("
9961 (progn (setq verilog-sk-p (point)) nil) (verilog-sk-prompt-condition) (if (> (point) verilog-sk-p) ") " -1 ) & " begin" \n
9962 > _ \n
9963 > "end" (progn (electric-verilog-terminate-line) nil))
9964
9965(define-skeleton verilog-sk-datadef
9966 "Common routine to get data definition"
9967 ()
9968 (verilog-sk-prompt-width) | -1 ("name (RET to end):" str ", ") -2 ";" \n)
9969
9970(define-skeleton verilog-sk-input
9971 "Insert an input definition."
9972 ()
9973 > "input [" (verilog-sk-datadef))
9974
9975(define-skeleton verilog-sk-output
9976 "Insert an output definition."
9977 ()
9978 > "output [" (verilog-sk-datadef))
9979
9980(define-skeleton verilog-sk-inout
9981 "Insert an inout definition."
9982 ()
9983 > "inout [" (verilog-sk-datadef))
9984
9985(defvar verilog-sk-signal nil)
9986(define-skeleton verilog-sk-def-reg
9987 "Insert a reg definition."
9988 ()
9989 > "reg [" (verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) )
9990
9991(defun verilog-sk-define-signal ()
9992 "Insert a definition of signal under point at top of module."
9993 (interactive "*")
9994 (let* (
9995 (sig-re "[a-zA-Z0-9_]*")
9996 (v1 (buffer-substring
9997 (save-excursion
9998 (skip-chars-backward sig-re)
9999 (point))
10000 (save-excursion
10001 (skip-chars-forward sig-re)
10002 (point))))
10003 )
10004 (if (not (member v1 verilog-keywords))
10005 (save-excursion
10006 (setq verilog-sk-signal v1)
10007 (verilog-beg-of-defun)
10008 (verilog-end-of-statement)
10009 (verilog-forward-syntactic-ws)
10010 (verilog-sk-def-reg)
10011 (message "signal at point is %s" v1))
10012 (message "object at point (%s) is a keyword" v1))
10013 )
10014 )
10015
10016
10017(define-skeleton verilog-sk-wire
10018 "Insert a wire definition."
10019 ()
10020 > "wire [" (verilog-sk-datadef))
10021
10022(define-skeleton verilog-sk-reg
10023 "Insert a reg definition."
10024 ()
10025 > "reg [" (verilog-sk-datadef))
10026
10027(define-skeleton verilog-sk-assign
10028 "Insert a skeleton assign statement."
10029 ()
10030 > "assign " (verilog-sk-prompt-name) " = " _ ";" \n)
10031
10032(define-skeleton verilog-sk-while
10033 "Insert a skeleton while loop statement."
10034 ()
10035 > "while (" (verilog-sk-prompt-condition) ") begin" \n
10036 > _ \n
10037 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil))
10038
10039(define-skeleton verilog-sk-repeat
10040 "Insert a skeleton repeat loop statement."
10041 ()
10042 > "repeat (" (verilog-sk-prompt-condition) ") begin" \n
10043 > _ \n
10044 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil))
10045
10046(define-skeleton verilog-sk-for
10047 "Insert a skeleton while loop statement."
10048 ()
10049 > "for ("
10050 (verilog-sk-prompt-init) "; "
10051 (verilog-sk-prompt-condition) "; "
10052 (verilog-sk-prompt-inc)
10053 ") begin" \n
10054 > _ \n
10055 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil))
10056
10057(define-skeleton verilog-sk-comment
10058 "Inserts three comment lines, making a display comment."
10059 ()
10060 > "/*\n"
10061 > "* " _ \n
10062 > "*/")
10063
10064(define-skeleton verilog-sk-state-machine
10065 "Insert a state machine definition."
10066 "Name of state variable: "
10067 '(setq input "state")
10068 > "// State registers for " str | -23 \n
10069 '(setq verilog-sk-state str)
10070 > "reg [" (verilog-sk-prompt-width) | -1 verilog-sk-state ", next_" verilog-sk-state ?; \n
10071 '(setq input nil)
10072 > \n
10073 > "// State FF for " verilog-sk-state \n
10074 > "always @ ( " (read-string "clock:" "posedge clk") " or " (verilog-sk-prompt-reset) " ) begin" \n
10075 > "if ( " verilog-sk-reset " ) " verilog-sk-state " = 0; else" \n
10076 > verilog-sk-state " = next_" verilog-sk-state ?; \n
10077 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil)
10078 > \n
10079 > "// Next State Logic for " verilog-sk-state \n
10080 > "always @ ( /*AUTOSENSE*/ ) begin\n"
10081 > "case (" (verilog-sk-prompt-state-selector) ") " \n
10082 > ("case selector: " str ": begin" \n > "next_" verilog-sk-state " = " _ ";" \n > (- verilog-indent-level-behavioral) "end" \n )
10083 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)
10084 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil))
10085
10086;; Eliminate compile warning
10087(eval-when-compile
10088 (if (not (boundp 'mode-popup-menu))
10089 (defvar mode-popup-menu nil "Compatibility with XEmacs.")))
10090
10091;; ---- add menu 'Statements' in Verilog mode (MH)
10092(defun verilog-add-statement-menu ()
10093 "Add the menu 'Statements' to the menu bar in Verilog mode."
10094 (if (featurep 'xemacs)
10095 (progn
10096 (easy-menu-add verilog-stmt-menu)
10097 (easy-menu-add verilog-menu)
10098 (setq mode-popup-menu (cons "Verilog Mode" verilog-stmt-menu)))))
10099
10100(add-hook 'verilog-mode-hook 'verilog-add-statement-menu)
10101
10102
10103
10104;;
10105;; Include file loading with mouse/return event
10106;;
10107;; idea & first impl.: M. Rouat (eldo-mode.el)
10108;; second (emacs/xemacs) impl.: G. Van der Plas (spice-mode.el)
10109
10110(if (featurep 'xemacs)
10111 (require 'overlay)
10112 (require 'lucid)) ;; what else can we do ??
10113
10114(defconst verilog-include-file-regexp
10115 "^`include\\s-+\"\\([^\n\"]*\\)\""
10116 "Regexp that matches the include file.")
10117
10118(defvar verilog-mode-mouse-map
10119 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map
10120 (set-keymap-parent map verilog-mode-map)
10121 ;; mouse button bindings
10122 (define-key map "\r" 'verilog-load-file-at-point)
10123 (if (featurep 'xemacs)
10124 (define-key map 'button2 'verilog-load-file-at-mouse);ffap-at-mouse ?
10125 (define-key map [mouse-2] 'verilog-load-file-at-mouse))
10126 (if (featurep 'xemacs)
10127 (define-key map 'Sh-button2 'mouse-yank) ; you wanna paste don't you ?
10128 (define-key map [S-mouse-2] 'mouse-yank-at-click))
10129 map)
10130 "Map containing mouse bindings for `verilog-mode'.")
10131
10132
10133(defun verilog-colorize-include-files (beg end old-len)
10134 "This function colorizes included files when the mouse passes over them.
10135Clicking on the middle-mouse button loads them in a buffer (as in dired)."
10136 (save-excursion
10137 (save-match-data
10138 (let (end-point)
10139 (goto-char end)
10140 (setq end-point (verilog-get-end-of-line))
10141 (goto-char beg)
10142 (beginning-of-line) ; scan entire line !
10143 ;; delete overlays existing on this line
10144 (let ((overlays (overlays-in (point) end-point)))
10145 (while overlays
10146 (if (and
10147 (overlay-get (car overlays) 'detachable)
10148 (overlay-get (car overlays) 'verilog-include-file))
10149 (delete-overlay (car overlays)))
10150 (setq overlays (cdr overlays)))) ; let
10151 ;; make new ones, could reuse deleted one ?
10152 (while (search-forward-regexp verilog-include-file-regexp end-point t)
10153 (let (ov)
10154 (goto-char (match-beginning 1))
10155 (setq ov (make-overlay (match-beginning 1) (match-end 1)))
10156 (overlay-put ov 'start-closed 't)
10157 (overlay-put ov 'end-closed 't)
10158 (overlay-put ov 'evaporate 't)
10159 (overlay-put ov 'verilog-include-file 't)
10160 (overlay-put ov 'mouse-face 'highlight)
10161 (overlay-put ov 'local-map verilog-mode-mouse-map)))))))
10162
10163
10164(defun verilog-colorize-include-files-buffer ()
10165 "Colorize a include file."
10166 (interactive)
10167 ;; delete overlays
10168 (let ((overlays (overlays-in (point-min) (point-max))))
10169 (while overlays
10170 (if (and
10171 (overlay-get (car overlays) 'detachable)
10172 (overlay-get (car overlays) 'verilog-include-file))
10173 (delete-overlay (car overlays)))
10174 (setq overlays (cdr overlays)))) ; let
10175 ;; remake overlays
10176 (verilog-colorize-include-files (point-min) (point-max) nil))
10177
10178;; ffap-at-mouse isn't useful for verilog mode. It uses library paths.
10179;; so define this function to do more or less the same as ffap-at-mouse
10180;; but first resolve filename...
10181(defun verilog-load-file-at-mouse (event)
10182 "Load file under button 2 click's EVENT.
10183Files are checked based on `verilog-library-directories'."
10184 (interactive "@e")
10185 (save-excursion ;; implement a verilog specific ffap-at-mouse
10186 (mouse-set-point event)
10187 (beginning-of-line)
10188 (if (looking-at verilog-include-file-regexp)
10189 (if (and (car (verilog-library-filenames
10190 (match-string 1) (buffer-file-name)))
10191 (file-readable-p (car (verilog-library-filenames
10192 (match-string 1) (buffer-file-name)))))
10193 (find-file (car (verilog-library-filenames
10194 (match-string 1) (buffer-file-name))))
10195 (progn
10196 (message
10197 "File '%s' isn't readable, use shift-mouse2 to paste in this field"
10198 (match-string 1))))
10199 )))
10200
10201;; ffap isn't useable for verilog mode. It uses library paths.
10202;; so define this function to do more or less the same as ffap
10203;; but first resolve filename...
10204(defun verilog-load-file-at-point ()
10205 "Load file under point.
10206Files are checked based on `verilog-library-directories'."
10207 (interactive)
10208 (save-excursion ;; implement a verilog specific ffap
10209 (beginning-of-line)
10210 (if (looking-at verilog-include-file-regexp)
10211 (if (and
10212 (car (verilog-library-filenames
10213 (match-string 1) (buffer-file-name)))
10214 (file-readable-p (car (verilog-library-filenames
10215 (match-string 1) (buffer-file-name)))))
10216 (find-file (car (verilog-library-filenames
10217 (match-string 1) (buffer-file-name))))))
10218 ))
10219
10220
10221;;
10222;; Bug reporting
10223;;
10224
10225(defun verilog-faq ()
10226 "Tell the user their current version, and where to get the FAQ etc."
10227 (interactive)
10228 (with-output-to-temp-buffer "*verilog-mode help*"
10229 (princ (format "You are using verilog-mode %s\n" verilog-mode-version))
10230 (princ "\n")
10231 (princ "For new releases, see http://www.verilog.com\n")
10232 (princ "\n")
10233 (princ "For frequently asked questions, see http://www.veripool.com/verilog-mode-faq.html\n")
10234 (princ "\n")
10235 (princ "To submit a bug, use M-x verilog-submit-bug-report\n")
10236 (princ "\n")))
10237
10238(defun verilog-submit-bug-report ()
10239 "Submit via mail a bug report on verilog-mode.el."
10240 (interactive)
10241 (let ((reporter-prompt-for-summary-p t))
10242 (reporter-submit-bug-report
10243 "mac@verilog.com"
10244 (concat "verilog-mode v" verilog-mode-version)
10245 '(
10246 verilog-align-ifelse
10247 verilog-auto-endcomments
10248 verilog-auto-hook
10249 verilog-auto-indent-on-newline
10250 verilog-auto-inst-vector
10251 verilog-auto-inst-template-numbers
10252 verilog-auto-lineup
10253 verilog-auto-newline
10254 verilog-auto-save-policy
10255 verilog-auto-sense-defines-constant
10256 verilog-auto-sense-include-inputs
10257 verilog-before-auto-hook
10258 verilog-case-indent
10259 verilog-cexp-indent
10260 verilog-compiler
10261 verilog-coverage
10262 verilog-highlight-translate-off
10263 verilog-indent-begin-after-if
10264 verilog-indent-declaration-macros
10265 verilog-indent-level
10266 verilog-indent-level-behavioral
10267 verilog-indent-level-declaration
10268 verilog-indent-level-directive
10269 verilog-indent-level-module
10270 verilog-indent-lists
10271 verilog-library-flags
10272 verilog-library-directories
10273 verilog-library-extensions
10274 verilog-library-files
10275 verilog-linter
10276 verilog-minimum-comment-distance
10277 verilog-mode-hook
10278 verilog-simulator
10279 verilog-tab-always-indent
10280 verilog-tab-to-comment
10281 )
10282 nil nil
10283 (concat "Hi Mac,
10284
10285I want to report a bug. I've read the `Bugs' section of `Info' on
10286Emacs, so I know how to make a clear and unambiguous report. To get
10287to that Info section, I typed
10288
10289M-x info RET m " invocation-name " RET m bugs RET
10290
10291Before I go further, I want to say that Verilog mode has changed my life.
10292I save so much time, my files are colored nicely, my co workers respect
10293my coding ability... until now. I'd really appreciate anything you
10294could do to help me out with this minor deficiency in the product.
10295
10296If you have bugs with the AUTO functions, please CC the AUTOAUTHOR Wilson
10297Snyder (wsnyder@wsnyder.org) and/or see http://www.veripool.com.
10298You may also want to look at the Verilog-Mode FAQ, see
10299http://www.veripool.com/verilog-mode-faq.html.
10300
10301To reproduce the bug, start a fresh Emacs via " invocation-name "
10302-no-init-file -no-site-file'. In a new buffer, in verilog mode, type
10303the code included below.
10304
10305Given those lines, I expected [[Fill in here]] to happen;
10306but instead, [[Fill in here]] happens!.
10307
10308== The code: =="))))
10309
10310(provide 'verilog-mode)
10311
10312;; Local Variables:
10313;; checkdoc-permit-comma-termination-flag:t
10314;; checkdoc-force-docstrings-flag:nil
10315;; End:
10316
10317;; arch-tag: 87923725-57b3-41b5-9494-be21118c6a6f
10318;;; verilog-mode.el ends here
diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el
index df315e4f46e..171bb286652 100644
--- a/lisp/progmodes/vhdl-mode.el
+++ b/lisp/progmodes/vhdl-mode.el
@@ -9095,8 +9095,9 @@ otherwise."
9095 (progn (delete-region (point) (progn (end-of-line) (point))) 9095 (progn (delete-region (point) (progn (end-of-line) (point)))
9096 (vhdl-template-insert-date)) 9096 (vhdl-template-insert-date))
9097 (unless noerror 9097 (unless noerror
9098 (error (concat "ERROR: Modification date prefix string \"" 9098 (error "ERROR: Modification date prefix string \"%s\" not found"
9099 vhdl-modify-date-prefix-string "\" not found"))))))) 9099 vhdl-modify-date-prefix-string))))))
9100
9100 9101
9101(defun vhdl-template-modify-noerror () 9102(defun vhdl-template-modify-noerror ()
9102 "Call `vhdl-template-modify' with NOERROR non-nil." 9103 "Call `vhdl-template-modify' with NOERROR non-nil."
@@ -10432,7 +10433,7 @@ with double-quotes is to be inserted. DEFAULT specifies a default string."
10432 "Query a decision from the user." 10433 "Query a decision from the user."
10433 (let ((start (point))) 10434 (let ((start (point)))
10434 (when string (vhdl-insert-keyword (concat string " "))) 10435 (when string (vhdl-insert-keyword (concat string " ")))
10435 (message prompt) 10436 (message "%s" (or prompt ""))
10436 (let ((char (read-char))) 10437 (let ((char (read-char)))
10437 (delete-region start (point)) 10438 (delete-region start (point))
10438 (if (and optional (eq char ?\r)) 10439 (if (and optional (eq char ?\r))
diff --git a/lisp/replace.el b/lisp/replace.el
index 34fdd5fe3df..8bd3bec20a0 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -552,8 +552,8 @@ A match split across lines preserves all the lines it lies in.
552When called from Lisp (and usually interactively as well, see below) 552When called from Lisp (and usually interactively as well, see below)
553applies to all lines starting after point. 553applies to all lines starting after point.
554 554
555If REGEXP contains upper case characters (excluding those preceded by `\\'), 555If REGEXP contains upper case characters (excluding those preceded by `\\')
556the matching is case-sensitive. 556and `search-upper-case' is non-nil, the matching is case-sensitive.
557 557
558Second and third arg RSTART and REND specify the region to operate on. 558Second and third arg RSTART and REND specify the region to operate on.
559This command operates on (the accessible part of) all lines whose 559This command operates on (the accessible part of) all lines whose
@@ -597,8 +597,10 @@ a previously found match."
597 (save-excursion 597 (save-excursion
598 (or (bolp) (forward-line 1)) 598 (or (bolp) (forward-line 1))
599 (let ((start (point)) 599 (let ((start (point))
600 (case-fold-search (and case-fold-search 600 (case-fold-search
601 (isearch-no-upper-case-p regexp t)))) 601 (if (and case-fold-search search-upper-case)
602 (isearch-no-upper-case-p regexp t)
603 case-fold-search)))
602 (while (< (point) rend) 604 (while (< (point) rend)
603 ;; Start is first char not preserved by previous match. 605 ;; Start is first char not preserved by previous match.
604 (if (not (re-search-forward regexp rend 'move)) 606 (if (not (re-search-forward regexp rend 'move))
@@ -626,8 +628,8 @@ well, see below), applies to the part of the buffer after point.
626The line point is in is deleted if and only if it contains a 628The line point is in is deleted if and only if it contains a
627match for regexp starting after point. 629match for regexp starting after point.
628 630
629If REGEXP contains upper case characters (excluding those preceded by `\\'), 631If REGEXP contains upper case characters (excluding those preceded by `\\')
630the matching is case-sensitive. 632and `search-upper-case' is non-nil, the matching is case-sensitive.
631 633
632Second and third arg RSTART and REND specify the region to operate on. 634Second and third arg RSTART and REND specify the region to operate on.
633Lines partially contained in this region are deleted if and only if 635Lines partially contained in this region are deleted if and only if
@@ -657,8 +659,10 @@ starting on the same line at which another match ended is ignored."
657 (setq rstart (point) 659 (setq rstart (point)
658 rend (point-max-marker))) 660 rend (point-max-marker)))
659 (goto-char rstart)) 661 (goto-char rstart))
660 (let ((case-fold-search (and case-fold-search 662 (let ((case-fold-search
661 (isearch-no-upper-case-p regexp t)))) 663 (if (and case-fold-search search-upper-case)
664 (isearch-no-upper-case-p regexp t)
665 case-fold-search)))
662 (save-excursion 666 (save-excursion
663 (while (and (< (point) rend) 667 (while (and (< (point) rend)
664 (re-search-forward regexp rend t)) 668 (re-search-forward regexp rend t))
@@ -676,8 +680,8 @@ When called from Lisp and INTERACTIVE is omitted or nil, just return
676the number, do not print it; if INTERACTIVE is t, the function behaves 680the number, do not print it; if INTERACTIVE is t, the function behaves
677in all respects has if it had been called interactively. 681in all respects has if it had been called interactively.
678 682
679If REGEXP contains upper case characters (excluding those preceded by `\\'), 683If REGEXP contains upper case characters (excluding those preceded by `\\')
680the matching is case-sensitive. 684and `search-upper-case' is non-nil, the matching is case-sensitive.
681 685
682Second and third arg RSTART and REND specify the region to operate on. 686Second and third arg RSTART and REND specify the region to operate on.
683 687
@@ -704,8 +708,10 @@ a previously found match."
704 (goto-char rstart)) 708 (goto-char rstart))
705 (let ((count 0) 709 (let ((count 0)
706 opoint 710 opoint
707 (case-fold-search (and case-fold-search 711 (case-fold-search
708 (isearch-no-upper-case-p regexp t)))) 712 (if (and case-fold-search search-upper-case)
713 (isearch-no-upper-case-p regexp t)
714 case-fold-search)))
709 (while (and (< (point) rend) 715 (while (and (< (point) rend)
710 (progn (setq opoint (point)) 716 (progn (setq opoint (point))
711 (re-search-forward regexp rend t))) 717 (re-search-forward regexp rend t)))
@@ -1030,8 +1036,8 @@ The lines are shown in a buffer named `*Occur*'.
1030It serves as a menu to find any of the occurrences in this buffer. 1036It serves as a menu to find any of the occurrences in this buffer.
1031\\<occur-mode-map>\\[describe-mode] in that buffer will explain how. 1037\\<occur-mode-map>\\[describe-mode] in that buffer will explain how.
1032 1038
1033If REGEXP contains upper case characters (excluding those preceded by `\\'), 1039If REGEXP contains upper case characters (excluding those preceded by `\\')
1034the matching is case-sensitive." 1040and `search-upper-case' is non-nil, the matching is case-sensitive."
1035 (interactive (occur-read-primary-args)) 1041 (interactive (occur-read-primary-args))
1036 (occur-1 regexp nlines (list (current-buffer)))) 1042 (occur-1 regexp nlines (list (current-buffer))))
1037 1043
@@ -1119,8 +1125,9 @@ See also `multi-occur'."
1119 (let ((count (occur-engine 1125 (let ((count (occur-engine
1120 regexp active-bufs occur-buf 1126 regexp active-bufs occur-buf
1121 (or nlines list-matching-lines-default-context-lines) 1127 (or nlines list-matching-lines-default-context-lines)
1122 (and case-fold-search 1128 (if (and case-fold-search search-upper-case)
1123 (isearch-no-upper-case-p regexp t)) 1129 (isearch-no-upper-case-p regexp t)
1130 case-fold-search)
1124 list-matching-lines-buffer-name-face 1131 list-matching-lines-buffer-name-face
1125 nil list-matching-lines-face 1132 nil list-matching-lines-face
1126 (not (eq occur-excluded-properties t))))) 1133 (not (eq occur-excluded-properties t)))))
@@ -1459,8 +1466,9 @@ make, or the user didn't cancel the call."
1459 (and query-flag minibuffer-auto-raise 1466 (and query-flag minibuffer-auto-raise
1460 (raise-frame (window-frame (minibuffer-window)))) 1467 (raise-frame (window-frame (minibuffer-window))))
1461 (let* ((case-fold-search 1468 (let* ((case-fold-search
1462 (and case-fold-search 1469 (if (and case-fold-search search-upper-case)
1463 (isearch-no-upper-case-p from-string regexp-flag))) 1470 (isearch-no-upper-case-p from-string regexp-flag)
1471 case-fold-search))
1464 (nocasify (not (and case-replace case-fold-search))) 1472 (nocasify (not (and case-replace case-fold-search)))
1465 (literal (or (not regexp-flag) (eq regexp-flag 'literal))) 1473 (literal (or (not regexp-flag) (eq regexp-flag 'literal)))
1466 (search-function (if regexp-flag 're-search-forward 'search-forward)) 1474 (search-function (if regexp-flag 're-search-forward 'search-forward))
diff --git a/lisp/server.el b/lisp/server.el
index e6477b92d6f..4d21959774a 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -242,8 +242,7 @@ ENV should be in the same format as `process-environment'."
242 "Delete PROC, including its buffers, terminals and frames. 242 "Delete PROC, including its buffers, terminals and frames.
243If NOFRAME is non-nil, let the frames live. (To be used from 243If NOFRAME is non-nil, let the frames live. (To be used from
244`delete-frame-functions'.)" 244`delete-frame-functions'.)"
245 (server-log (concat "server-delete-client" (if noframe " noframe")) 245 (server-log (concat "server-delete-client" (if noframe " noframe")) proc)
246 proc)
247 ;; Force a new lookup of client (prevents infinite recursion). 246 ;; Force a new lookup of client (prevents infinite recursion).
248 (when (memq proc server-clients) 247 (when (memq proc server-clients)
249 (let ((buffers (process-get proc 'buffers))) 248 (let ((buffers (process-get proc 'buffers)))
@@ -339,7 +338,7 @@ If CLIENT is non-nil, add a description of it to the logged message."
339 display 338 display
340 ;; Make it display (and remember) some dummy buffer, so 339 ;; Make it display (and remember) some dummy buffer, so
341 ;; we can detect later if the frame is in use or not. 340 ;; we can detect later if the frame is in use or not.
342 `((server-dummmy-buffer . ,buffer) 341 `((server-dummy-buffer . ,buffer)
343 ;; This frame may be deleted later (see 342 ;; This frame may be deleted later (see
344 ;; server-unselect-display) so we want it to be as 343 ;; server-unselect-display) so we want it to be as
345 ;; unobtrusive as possible. 344 ;; unobtrusive as possible.
@@ -833,7 +832,8 @@ The following commands are accepted by the client:
833 ;; -display DISPLAY: 832 ;; -display DISPLAY:
834 ;; Open X frames on the given display instead of the default. 833 ;; Open X frames on the given display instead of the default.
835 ((and (equal "-display" arg) command-line-args-left) 834 ((and (equal "-display" arg) command-line-args-left)
836 (setq display (pop command-line-args-left))) 835 (setq display (pop command-line-args-left))
836 (if (zerop (length display)) (setq display nil)))
837 837
838 ;; -window-system: Open a new X frame. 838 ;; -window-system: Open a new X frame.
839 ((equal "-window-system" arg) 839 ((equal "-window-system" arg)
diff --git a/lisp/startup.el b/lisp/startup.el
index b20df2e9cd5..bec2438fa03 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1538,7 +1538,7 @@ splash screen in another window."
1538 (apply #'fancy-splash-insert text) 1538 (apply #'fancy-splash-insert text)
1539 (insert "\n")) 1539 (insert "\n"))
1540 (unless (current-message) 1540 (unless (current-message)
1541 (message fancy-splash-help-echo)) 1541 (message "%s" (or fancy-splash-help-echo "")))
1542 (set-buffer-modified-p nil) 1542 (set-buffer-modified-p nil)
1543 (goto-char (point-min)) 1543 (goto-char (point-min))
1544 (force-mode-line-update)) 1544 (force-mode-line-update))
diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el
index 3c648b9e6b3..641af430024 100644
--- a/lisp/term/mac-win.el
+++ b/lisp/term/mac-win.el
@@ -2228,7 +2228,7 @@ either in the current buffer or in the echo area."
2228 (if (not buffer-read-only) 2228 (if (not buffer-read-only)
2229 (insert text) 2229 (insert text)
2230 (kill-new text) 2230 (kill-new text)
2231 (message 2231 (message "%s"
2232 (substitute-command-keys 2232 (substitute-command-keys
2233 "The text from the Services menu can be accessed with \\[yank]"))))) 2233 "The text from the Services menu can be accessed with \\[yank]")))))
2234 2234
diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el
index f0442904185..63a9e8f615a 100644
--- a/lisp/textmodes/artist.el
+++ b/lisp/textmodes/artist.el
@@ -1151,14 +1151,14 @@ PREV-OP-ARG are used when invoked recursively during the build-up."
1151 (interactive) 1151 (interactive)
1152 (let ((next-op (cdr (cdr (assoc artist-curr-go artist-prev-next-op-alist))))) 1152 (let ((next-op (cdr (cdr (assoc artist-curr-go artist-prev-next-op-alist)))))
1153 (artist-select-operation next-op) 1153 (artist-select-operation next-op)
1154 (message next-op))) 1154 (message "%s" next-op)))
1155 1155
1156(defun artist-select-prev-op-in-list () 1156(defun artist-select-prev-op-in-list ()
1157 "Cyclically select previous drawing mode operation." 1157 "Cyclically select previous drawing mode operation."
1158 (interactive) 1158 (interactive)
1159 (let ((prev-op (car (cdr (assoc artist-curr-go artist-prev-next-op-alist))))) 1159 (let ((prev-op (car (cdr (assoc artist-curr-go artist-prev-next-op-alist)))))
1160 (artist-select-operation prev-op) 1160 (artist-select-operation prev-op)
1161 (message prev-op))) 1161 (message "%s" prev-op)))
1162 1162
1163;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1163;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1164 1164
diff --git a/lisp/textmodes/org-publish.el b/lisp/textmodes/org-publish.el
index e98afaf4a6b..807a844c425 100644
--- a/lisp/textmodes/org-publish.el
+++ b/lisp/textmodes/org-publish.el
@@ -481,7 +481,7 @@ FILENAME is the filename of the file to be published."
481 (plist (org-publish-get-plist-from-filename filename)) 481 (plist (org-publish-get-plist-from-filename filename))
482 (publishing-function (or (plist-get plist :publishing-function) 'org-publish-org-to-html))) 482 (publishing-function (or (plist-get plist :publishing-function) 'org-publish-org-to-html)))
483 (if (not project-name) 483 (if (not project-name)
484 (error (format "File %s is not part of any known project." filename))) 484 (error "File %s is not part of any known project." filename))
485 (when (org-publish-needed-p filename) 485 (when (org-publish-needed-p filename)
486 (if (listp publishing-function) 486 (if (listp publishing-function)
487 ;; allow chain of publishing functions 487 ;; allow chain of publishing functions
@@ -575,7 +575,7 @@ With prefix argument, force publishing all files in project."
575 (let* ((project-name (org-publish-get-project-from-filename (buffer-file-name))) 575 (let* ((project-name (org-publish-get-project-from-filename (buffer-file-name)))
576 (org-publish-use-timestamps-flag (if force nil t))) 576 (org-publish-use-timestamps-flag (if force nil t)))
577 (if (not project-name) 577 (if (not project-name)
578 (error (format "File %s is not part of any known project." (buffer-file-name)))) 578 (error "File %s is not part of any known project." (buffer-file-name)))
579 (org-publish project-name)))) 579 (org-publish project-name))))
580 580
581 581
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index 0535f679c40..ebcf060be65 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -6076,7 +6076,7 @@ If you want to insert the tree as is, just use \\[yank].
6076If optional TREE is given, use this text instead of the kill ring." 6076If optional TREE is given, use this text instead of the kill ring."
6077 (interactive "P") 6077 (interactive "P")
6078 (unless (org-kill-is-subtree-p tree) 6078 (unless (org-kill-is-subtree-p tree)
6079 (error 6079 (error "%s"
6080 (substitute-command-keys 6080 (substitute-command-keys
6081 "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway"))) 6081 "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway")))
6082 (let* ((txt (or tree (and kill-ring (current-kill 0)))) 6082 (let* ((txt (or tree (and kill-ring (current-kill 0))))
@@ -7487,7 +7487,7 @@ When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag."
7487 (org-hide-archived-subtrees beg end) 7487 (org-hide-archived-subtrees beg end)
7488 (goto-char beg) 7488 (goto-char beg)
7489 (if (looking-at (concat ".*:" org-archive-tag ":")) 7489 (if (looking-at (concat ".*:" org-archive-tag ":"))
7490 (message (substitute-command-keys 7490 (message "%s" (substitute-command-keys
7491 "Subtree is archived and stays closed. Use \\[org-force-cycle-archived] to cycle it anyway."))))))) 7491 "Subtree is archived and stays closed. Use \\[org-force-cycle-archived] to cycle it anyway.")))))))
7492 7492
7493(defun org-force-cycle-archived () 7493(defun org-force-cycle-archived ()
@@ -9366,7 +9366,8 @@ of the new mark."
9366 (goto-line l1))) 9366 (goto-line l1)))
9367 (if (not (= epos (point-at-eol))) (org-table-align)) 9367 (if (not (= epos (point-at-eol))) (org-table-align))
9368 (goto-line l) 9368 (goto-line l)
9369 (and (interactive-p) (message (cdr (assoc new org-recalc-marks)))))) 9369 (and (interactive-p)
9370 (message "%s" (or (cdr (assoc new org-recalc-marks)) "")))))
9370 9371
9371(defun org-table-maybe-recalculate-line () 9372(defun org-table-maybe-recalculate-line ()
9372 "Recompute the current line if marked for it, and if we haven't just done it." 9373 "Recompute the current line if marked for it, and if we haven't just done it."
@@ -12347,7 +12348,7 @@ to read."
12347 (move-marker (car org-mark-ring) 12348 (move-marker (car org-mark-ring)
12348 (or pos (point)) 12349 (or pos (point))
12349 (or buffer (current-buffer))) 12350 (or buffer (current-buffer)))
12350 (message 12351 (message "%s"
12351 (substitute-command-keys 12352 (substitute-command-keys
12352 "Position saved to mark ring, go back with \\[org-mark-ring-goto]."))) 12353 "Position saved to mark ring, go back with \\[org-mark-ring-goto].")))
12353 12354
@@ -12429,7 +12430,7 @@ onto the ring."
12429 (if (match-string 2 name) ; If there isn't a node, choose "Top" 12430 (if (match-string 2 name) ; If there isn't a node, choose "Top"
12430 (Info-find-node (match-string 1 name) (match-string 2 name)) 12431 (Info-find-node (match-string 1 name) (match-string 2 name))
12431 (Info-find-node (match-string 1 name) "Top"))) 12432 (Info-find-node (match-string 1 name) "Top")))
12432 (message (concat "Could not open: " name)))) 12433 (message "Could not open: %s" name)))
12433 12434
12434(defun org-follow-gnus-link (&optional group article) 12435(defun org-follow-gnus-link (&optional group article)
12435 "Follow a Gnus link to GROUP and ARTICLE." 12436 "Follow a Gnus link to GROUP and ARTICLE."
@@ -12553,7 +12554,7 @@ sequences, it will now work."
12553 (save-excursion 12554 (save-excursion
12554 (mh-index-previous-folder) 12555 (mh-index-previous-folder)
12555 (re-search-forward "^\\(+.*\\)$" nil t) 12556 (re-search-forward "^\\(+.*\\)$" nil t)
12556 (message (match-string 1)))) 12557 (message "%s" (match-string 1))))
12557 12558
12558(defun org-mhe-get-message-folder () 12559(defun org-mhe-get-message-folder ()
12559 "Return the name of the current message folder. Be careful if you 12560 "Return the name of the current message folder. Be careful if you
@@ -13759,7 +13760,7 @@ This function should be run in the `org-after-todo-state-change-hook'."
13759 (org-timestamp-change n (cdr (assoc what whata)))) 13760 (org-timestamp-change n (cdr (assoc what whata))))
13760 (setq msg (concat msg type org-last-changed-timestamp " "))) 13761 (setq msg (concat msg type org-last-changed-timestamp " ")))
13761 (setq org-log-post-message msg) 13762 (setq org-log-post-message msg)
13762 (message msg)))) 13763 (message "%s" msg))))
13763 13764
13764(defun org-show-todo-tree (arg) 13765(defun org-show-todo-tree (arg)
13765 "Make a compact tree which shows all headlines marked with TODO. 13766 "Make a compact tree which shows all headlines marked with TODO.
@@ -13978,7 +13979,7 @@ The auto-repeater uses this.")
13978 (with-current-buffer (marker-buffer org-log-note-return-to) 13979 (with-current-buffer (marker-buffer org-log-note-return-to)
13979 (goto-char org-log-note-return-to)) 13980 (goto-char org-log-note-return-to))
13980 (move-marker org-log-note-return-to nil) 13981 (move-marker org-log-note-return-to nil)
13981 (and org-log-post-message (message org-log-post-message))) 13982 (and org-log-post-message (message "%s" org-log-post-message)))
13982 13983
13983;; FIXME: what else would be useful? 13984;; FIXME: what else would be useful?
13984;; - priority 13985;; - priority
@@ -15216,10 +15217,10 @@ in the current file."
15216 (let* ((prop (completing-read 15217 (let* ((prop (completing-read
15217 "Property: " (org-entry-properties nil 'standard)))) 15218 "Property: " (org-entry-properties nil 'standard))))
15218 (list prop))) 15219 (list prop)))
15219 (message (concat "Property " property 15220 (message "Property %s %s" property
15220 (if (org-entry-delete nil property) 15221 (if (org-entry-delete nil property)
15221 " deleted" 15222 "deleted"
15222 " was not present in the entry")))) 15223 "was not present in the entry")))
15223 15224
15224(defun org-delete-property-globally (property) 15225(defun org-delete-property-globally (property)
15225 "Remove PROPERTY globally, from all entries." 15226 "Remove PROPERTY globally, from all entries."
@@ -16863,7 +16864,7 @@ days in order to avoid rounding problems."
16863 d (floor (+ (/ diff ds) 0.5)) 16864 d (floor (+ (/ diff ds) 0.5))
16864 h 0 m 0)) 16865 h 0 m 0))
16865 (if (not to-buffer) 16866 (if (not to-buffer)
16866 (message (org-make-tdiff-string y d h m)) 16867 (message "%s" (org-make-tdiff-string y d h m))
16867 (when (org-at-table-p) 16868 (when (org-at-table-p)
16868 (goto-char match-end) 16869 (goto-char match-end)
16869 (setq align t) 16870 (setq align t)
@@ -18806,7 +18807,7 @@ the buffer and restores the previous window configuration."
18806 (org-install-agenda-files-menu) 18807 (org-install-agenda-files-menu)
18807 (message "New agenda file list installed")) 18808 (message "New agenda file list installed"))
18808 nil 'local) 18809 nil 'local)
18809 (message (substitute-command-keys 18810 (message "%s" (substitute-command-keys
18810 "Edit list and finish with \\[save-buffer]"))) 18811 "Edit list and finish with \\[save-buffer]")))
18811 (customize-variable 'org-agenda-files))) 18812 (customize-variable 'org-agenda-files)))
18812 18813
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index 73bcf6d6a74..5b2d62c56f6 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -367,7 +367,7 @@ _ ^ Add/Remove parent key (to make this item a subitem).
367 (goto-char (or pos (point-min))) 367 (goto-char (or pos (point-min)))
368 (or (looking-at re) 368 (or (looking-at re)
369 (reftex-nearest-match re (length literal)))) 369 (reftex-nearest-match re (length literal))))
370 (t (message reftex-no-follow-message) nil)))) 370 (t (message "%s" reftex-no-follow-message) nil))))
371 (when match 371 (when match
372 (goto-char (match-beginning 0)) 372 (goto-char (match-beginning 0))
373 (recenter '(4)) 373 (recenter '(4))
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index d1d979b3fc0..e3d8b3e4793 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -626,7 +626,7 @@ point."
626 (message "%d section%s %smoted" 626 (message "%d section%s %smoted"
627 nsec (if (= 1 nsec) "" "s") pro-or-de) 627 nsec (if (= 1 nsec) "" "s") pro-or-de)
628 nil)) 628 nil))
629 (if msg (progn (ding) (message msg))))) 629 (if msg (progn (ding) (message "%s" msg)))))
630 630
631 631
632(defun reftex-toc-restore-region (point-line &optional mark-line) 632(defun reftex-toc-restore-region (point-line &optional mark-line)
@@ -833,7 +833,7 @@ label prefix determines the wording of a reference."
833 (switch-to-buffer-other-window 833 (switch-to-buffer-other-window
834 (reftex-get-file-buffer-force file nil)) 834 (reftex-get-file-buffer-force file nil))
835 (goto-char (if (eq where 'bof) (point-min) (point-max)))) 835 (goto-char (if (eq where 'bof) (point-min) (point-max))))
836 (message reftex-no-follow-message) nil)))) 836 (message "%s" reftex-no-follow-message) nil))))
837 837
838 ((stringp (car toc)) 838 ((stringp (car toc))
839 ;; a label 839 ;; a label
@@ -900,7 +900,7 @@ label prefix determines the wording of a reference."
900 (reftex-make-regexp-allow-for-ctrl-m literal) len) 900 (reftex-make-regexp-allow-for-ctrl-m literal) len)
901 (reftex-nearest-match 901 (reftex-nearest-match
902 (reftex-make-desperate-section-regexp literal) len))))) 902 (reftex-make-desperate-section-regexp literal) len)))))
903 (t (message reftex-no-follow-message) nil)))) 903 (t (message "%s" reftex-no-follow-message) nil))))
904 (when match 904 (when match
905 (goto-char (match-beginning 0)) 905 (goto-char (match-beginning 0))
906 (if (not (= (point) (point-max))) (recenter 1)) 906 (if (not (= (point) (point-max))) (recenter 1))
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 5383d88c386..d6ec29434d1 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -1978,7 +1978,7 @@ Works on both Emacs and XEmacs."
1978 (let ((char ?\?)) 1978 (let ((char ?\?))
1979 (save-window-excursion 1979 (save-window-excursion
1980 (catch 'exit 1980 (catch 'exit
1981 (message (concat prompt " (?=Help)")) 1981 (message "%s (?=Help)" prompt)
1982 (when (or (sit-for (or delay-time 0)) 1982 (when (or (sit-for (or delay-time 0))
1983 (= ?\? (setq char (read-char-exclusive)))) 1983 (= ?\? (setq char (read-char-exclusive))))
1984 (reftex-kill-buffer "*RefTeX Select*") 1984 (reftex-kill-buffer "*RefTeX Select*")
@@ -1994,17 +1994,17 @@ Works on both Emacs and XEmacs."
1994 (pos-visible-in-window-p (point-max))) 1994 (pos-visible-in-window-p (point-max)))
1995 nil 1995 nil
1996 (setq prompt (concat prompt (if scroll " (SPC/DEL=Scroll)" "")))) 1996 (setq prompt (concat prompt (if scroll " (SPC/DEL=Scroll)" ""))))
1997 (message prompt) 1997 (message "%s" prompt)
1998 (and (equal char ?\?) (setq char (read-char-exclusive))) 1998 (and (equal char ?\?) (setq char (read-char-exclusive)))
1999 (while t 1999 (while t
2000 (cond ((equal char ?\C-g) (keyboard-quit)) 2000 (cond ((equal char ?\C-g) (keyboard-quit))
2001 ((equal char ?\?)) 2001 ((equal char ?\?))
2002 ((and scroll (equal char ?\ )) 2002 ((and scroll (equal char ?\ ))
2003 (condition-case nil (scroll-up) (error nil)) 2003 (condition-case nil (scroll-up) (error nil))
2004 (message prompt)) 2004 (message "%s" prompt))
2005 ((and scroll (equal char ?\C-? )) 2005 ((and scroll (equal char ?\C-? ))
2006 (condition-case nil (scroll-down) (error nil)) 2006 (condition-case nil (scroll-down) (error nil))
2007 (message prompt)) 2007 (message "%s" prompt))
2008 (t (message "") 2008 (t (message "")
2009 (throw 'exit char))) 2009 (throw 'exit char)))
2010 (setq char (read-char-exclusive))))))) 2010 (setq char (read-char-exclusive)))))))
diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el
index 55e7134f87e..812fcca06d6 100644
--- a/lisp/textmodes/texinfmt.el
+++ b/lisp/textmodes/texinfmt.el
@@ -2061,9 +2061,8 @@ commands that are defined in texinfo.tex for printed output.
2061 (apply '+ texinfo-multitable-width-list)))) 2061 (apply '+ texinfo-multitable-width-list))))
2062 (if (> desired-columns fill-column) 2062 (if (> desired-columns fill-column)
2063 (error 2063 (error
2064 (format 2064 "Multi-column table width, %d chars, is greater than page width, %d chars."
2065 "Multi-column table width, %d chars, is greater than page width, %d chars." 2065 desired-columns fill-column)))
2066 desired-columns fill-column))))
2067 texinfo-multitable-width-list)) 2066 texinfo-multitable-width-list))
2068 2067
2069;; @item A1 @tab A2 @tab A3 2068;; @item A1 @tab A2 @tab A3
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 9d86733ab98..a1b86af13ae 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,12 @@
12007-12-11 Glenn Morris <rgm@gnu.org>
2
3 * url.el (url-configuration-directory): Make it a defcustom.
4
5 * url-util.el (url-make-private-file): New function.
6 * url-cookie.el (url-cookie-write-file):
7 * url-history.el (url-history-save-history):
8 Use url-make-private-file and with-temp-buffer.
9
12007-12-06 Glenn Morris <rgm@gnu.org> 102007-12-06 Glenn Morris <rgm@gnu.org>
2 11
3 * url-file.el, url-mailto.el: Remove directory part from filenames 12 * url-file.el, url-mailto.el: Remove directory part from filenames
diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el
index bc0fea4de44..40791d29fb6 100644
--- a/lisp/url/url-cookie.el
+++ b/lisp/url/url-cookie.el
@@ -119,19 +119,17 @@ telling Microsoft that."
119 (set var new))) 119 (set var new)))
120 120
121(defun url-cookie-write-file (&optional fname) 121(defun url-cookie-write-file (&optional fname)
122 (setq fname (or fname url-cookie-file)) 122 (when url-cookies-changed-since-last-save
123 (unless (file-directory-p (file-name-directory fname)) 123 (or fname (setq fname (expand-file-name url-cookie-file)))
124 (ignore-errors (make-directory (file-name-directory fname)))) 124 (if (condition-case nil
125 (cond 125 (progn
126 ((not url-cookies-changed-since-last-save) nil) 126 (url-make-private-file fname)
127 ((not (file-writable-p fname)) 127 nil)
128 (message "Cookies file %s (see variable `url-cookie-file') is unwritable." fname)) 128 (error t))
129 (t 129 (message "Error accessing cookie file `%s'" fname)
130 (url-cookie-clean-up) 130 (url-cookie-clean-up)
131 (url-cookie-clean-up t) 131 (url-cookie-clean-up t)
132 (with-current-buffer (get-buffer-create " *cookies*") 132 (with-temp-buffer
133 (erase-buffer)
134 (fundamental-mode)
135 (insert ";; Emacs-W3 HTTP cookies file\n" 133 (insert ";; Emacs-W3 HTTP cookies file\n"
136 ";; Automatically generated file!!! DO NOT EDIT!!!\n\n" 134 ";; Automatically generated file!!! DO NOT EDIT!!!\n\n"
137 "(setq url-cookie-storage\n '") 135 "(setq url-cookie-storage\n '")
@@ -144,9 +142,8 @@ telling Microsoft that."
144 ";; no-byte-compile: t\n" 142 ";; no-byte-compile: t\n"
145 ";; End:\n") 143 ";; End:\n")
146 (set (make-local-variable 'version-control) 'never) 144 (set (make-local-variable 'version-control) 'never)
147 (write-file fname) 145 (write-file fname))
148 (setq url-cookies-changed-since-last-save nil) 146 (setq url-cookies-changed-since-last-save nil))))
149 (kill-buffer (current-buffer))))))
150 147
151(defun url-cookie-store (name value &optional expires domain localpart secure) 148(defun url-cookie-store (name value &optional expires domain localpart secure)
152 "Store a netscape-style cookie." 149 "Store a netscape-style cookie."
diff --git a/lisp/url/url-history.el b/lisp/url/url-history.el
index 605ffa0145f..bf4acf5d046 100644
--- a/lisp/url/url-history.el
+++ b/lisp/url/url-history.el
@@ -112,29 +112,28 @@ to run the `url-history-setup-save-timer' function manually."
112 (puthash (if (vectorp url) (url-recreate-url url) url) time 112 (puthash (if (vectorp url) (url-recreate-url url) url) time
113 url-history-hash-table)) 113 url-history-hash-table))
114 114
115(autoload 'url-make-private-file "url-util")
116
115(defun url-history-save-history (&optional fname) 117(defun url-history-save-history (&optional fname)
116 "Write the global history file into `url-history-file'. 118 "Write the global history file into `url-history-file'.
117The type of data written is determined by what is in the file to begin 119The type of data written is determined by what is in the file to begin
118with. If the type of storage cannot be determined, then prompt the 120with. If the type of storage cannot be determined, then prompt the
119user for what type to save as." 121user for what type to save as."
120 (interactive) 122 (interactive)
121 (or fname (setq fname (expand-file-name url-history-file))) 123 (when url-history-changed-since-last-save
122 (unless (file-directory-p (file-name-directory fname)) 124 (or fname (setq fname (expand-file-name url-history-file)))
123 (condition-case nil 125 (if (condition-case nil
124 (make-directory (file-name-directory fname)) 126 (progn
125 (error nil))) 127 (url-make-private-file fname)
126 (cond 128 nil)
127 ((not url-history-changed-since-last-save) nil) 129 (error t))
128 ((not (file-writable-p fname)) 130 (message "Error accessing history file `%s'" fname)
129 (message "%s is unwritable." fname)) 131 (let ((make-backup-files nil)
130 (t 132 (version-control nil)
131 (let ((make-backup-files nil) 133 (require-final-newline t)
132 (version-control nil) 134 (count 0))
133 (require-final-newline t)) 135 (with-temp-buffer
134 (with-current-buffer (get-buffer-create " *url-tmp*") 136 (maphash (lambda (key value)
135 (erase-buffer)
136 (let ((count 0))
137 (maphash (lambda (key value)
138 (while (string-match "[\r\n]+" key) 137 (while (string-match "[\r\n]+" key)
139 (setq key (concat (substring key 0 (match-beginning 0)) 138 (setq key (concat (substring key 0 (match-beginning 0))
140 (substring key (match-end 0) nil)))) 139 (substring key (match-end 0) nil))))
@@ -153,9 +152,8 @@ user for what type to save as."
153 ;; (/ count 4))) 152 ;; (/ count 4)))
154 ;; (goto-char (point-max)) 153 ;; (goto-char (point-max))
155 (insert "\n") 154 (insert "\n")
156 (write-file fname)) 155 (write-file fname)))
157 (kill-buffer (current-buffer)))))) 156 (setq url-history-changed-since-last-save nil))))
158 (setq url-history-changed-since-last-save nil))
159 157
160(defun url-have-visited-url (url) 158(defun url-have-visited-url (url)
161 (url-do-setup) 159 (url-do-setup)
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el
index 119f40b4da4..865c3981ec1 100644
--- a/lisp/url/url-util.el
+++ b/lisp/url/url-util.el
@@ -523,6 +523,28 @@ Has a preference for looking backward when not directly on a symbol."
523 (set (make-local-variable 'url-current-mime-headers) 523 (set (make-local-variable 'url-current-mime-headers)
524 (mail-header-extract))))) 524 (mail-header-extract)))))
525 525
526(defun url-make-private-file (file)
527 "Make FILE only readable and writable by the current user.
528Creates FILE and its parent directories if they do not exist."
529 (let ((dir (file-name-directory file)))
530 (when dir
531 ;; For historical reasons.
532 (make-directory dir t)))
533 ;; Based on doc-view-make-safe-dir.
534 (condition-case nil
535 (let ((umask (default-file-modes)))
536 (unwind-protect
537 (progn
538 (set-default-file-modes #o0600)
539 (with-temp-buffer
540 (write-region (point-min) (point-max)
541 file nil 'silent nil 'excl)))
542 (set-default-file-modes umask)))
543 (file-already-exists
544 (if (file-symlink-p file)
545 (error "Danger: `%s' is a symbolic link" file))
546 (set-file-modes file #o0600))))
547
526(provide 'url-util) 548(provide 'url-util)
527 549
528;; arch-tag: 24352abc-5a5a-412e-90cd-313b26bed5c9 550;; arch-tag: 24352abc-5a5a-412e-90cd-313b26bed5c9
diff --git a/lisp/url/url.el b/lisp/url/url.el
index c375a75e06f..448b31f4b68 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -46,13 +46,16 @@
46(require 'url-parse) 46(require 'url-parse)
47(require 'url-util) 47(require 'url-util)
48 48
49;; Fixme: customize? convert-standard-filename? 49
50(defvar url-configuration-directory 50;; FIXME convert-standard-filename?
51 (cond 51(defcustom url-configuration-directory
52 ((file-directory-p "~/.url") "~/.url") 52 (if (and (file-directory-p user-emacs-directory)
53 ((file-directory-p user-emacs-directory) 53 (not (file-directory-p "~/.url")))
54 (concat user-emacs-directory "url")) 54 (expand-file-name "url" user-emacs-directory)
55 (t "~/.url"))) 55 "~/.url")
56 "Directory used by the URL package for cookies, history, etc."
57 :type 'directory
58 :group 'url)
56 59
57(defun url-do-setup () 60(defun url-do-setup ()
58 "Setup the url package. 61 "Setup the url package.
diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el
index c9c50fceba2..6d57a329b0c 100644
--- a/lisp/vc-cvs.el
+++ b/lisp/vc-cvs.el
@@ -351,7 +351,7 @@ its parents."
351 ((re-search-forward "Up-to-date check failed" nil t) 351 ((re-search-forward "Up-to-date check failed" nil t)
352 (mapc (lambda (file) (vc-file-setprop file 'vc-state 'needs-merge)) 352 (mapc (lambda (file) (vc-file-setprop file 'vc-state 'needs-merge))
353 files) 353 files)
354 (error (substitute-command-keys 354 (error "%s" (substitute-command-keys
355 (concat "Up-to-date check failed: " 355 (concat "Up-to-date check failed: "
356 "type \\[vc-next-action] to merge in changes")))) 356 "type \\[vc-next-action] to merge in changes"))))
357 (t 357 (t
diff --git a/lisp/vc-mcvs.el b/lisp/vc-mcvs.el
index b5a81866eca..c3b68f8aeaf 100644
--- a/lisp/vc-mcvs.el
+++ b/lisp/vc-mcvs.el
@@ -294,7 +294,7 @@ This is only possible if Meta-CVS is responsible for FILE's directory.")
294 ((re-search-forward "Up-to-date check failed" nil t) 294 ((re-search-forward "Up-to-date check failed" nil t)
295 (mapc (lambda (file) (vc-file-setprop file 'vc-state 'needs-merge)) 295 (mapc (lambda (file) (vc-file-setprop file 'vc-state 'needs-merge))
296 files) 296 files)
297 (error (substitute-command-keys 297 (error "%s" (substitute-command-keys
298 (concat "Up-to-date check failed: " 298 (concat "Up-to-date check failed: "
299 "type \\[vc-next-action] to merge in changes")))) 299 "type \\[vc-next-action] to merge in changes"))))
300 (t 300 (t
diff --git a/lisp/vc.el b/lisp/vc.el
index 622c9682fbc..995bcc25692 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -2619,13 +2619,13 @@ changes from the current branch are merged into the working file."
2619 (vc-checkout file nil "") 2619 (vc-checkout file nil "")
2620 (if (eq (vc-checkout-model file) 'locking) 2620 (if (eq (vc-checkout-model file) 'locking)
2621 (if (eq (vc-state file) 'edited) 2621 (if (eq (vc-state file) 'edited)
2622 (error 2622 (error "%s"
2623 (substitute-command-keys 2623 (substitute-command-keys
2624 "File is locked--type \\[vc-revert] to discard changes")) 2624 "File is locked--type \\[vc-revert] to discard changes"))
2625 (error 2625 (error "Unexpected file state (%s) -- type %s"
2626 (substitute-command-keys 2626 (vc-state file)
2627 "Unexpected file state (%s)--type \\[vc-next-action] to correct") 2627 (substitute-command-keys
2628 (vc-state file))) 2628 "\\[vc-next-action] to correct")))
2629 (if (not (vc-find-backend-function (vc-backend file) 'merge-news)) 2629 (if (not (vc-find-backend-function (vc-backend file) 'merge-news))
2630 (error "Sorry, merging news is not implemented for %s" 2630 (error "Sorry, merging news is not implemented for %s"
2631 (vc-backend file)) 2631 (vc-backend file))
diff --git a/lisp/wdired.el b/lisp/wdired.el
index 39d27d57848..2ab9306da43 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -492,7 +492,7 @@ Optional arguments are ignored."
492 (if (and 492 (if (and
493 (buffer-modified-p) 493 (buffer-modified-p)
494 (not (y-or-n-p "Buffer changed. Discard changes and kill buffer? "))) 494 (not (y-or-n-p "Buffer changed. Discard changes and kill buffer? ")))
495 (error nil))) 495 (error "Error.")))
496 496
497(defun wdired-next-line (arg) 497(defun wdired-next-line (arg)
498 "Move down lines then position at filename or the current column. 498 "Move down lines then position at filename or the current column.
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index f6c94534a00..896668fd569 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -789,8 +789,8 @@ This is meant to be added buffer-locally to `write-file-functions'."
789 (whitespace-cleanup-internal) 789 (whitespace-cleanup-internal)
790 (setq werr (whitespace-buffer))) 790 (setq werr (whitespace-buffer)))
791 (if (and whitespace-abort-on-error werr) 791 (if (and whitespace-abort-on-error werr)
792 (error (concat "Abort write due to whitespaces in " 792 (error "Abort write due to whitespaces in %s"
793 buffer-file-name)))) 793 buffer-file-name)))
794 nil) 794 nil)
795 795
796(defun whitespace-unload-function () 796(defun whitespace-unload-function ()
diff --git a/src/ChangeLog b/src/ChangeLog
index f55e4ac786c..d5edca82fe9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,72 @@
12007-12-14 Jason Rumney <jasonr@gnu.org>
2
3 * w32term.c (w32_read_socket): Use MULTIBYTE_CHAR_KEYSTROKE_EVENT
4 for characters above 127.
5
62007-12-13 Jason Rumney <jasonr@gnu.org>
7
8 * w32fns.c (w32_wnd_proc, Fw32_reconstruct_hot_key): Range check
9 before dereferencing array.
10 (lookup_vk_code): Remove zero comparison.
11
122007-12-14 Michael Albinus <michael.albinus@gmx.de>
13
14 * dbusbind.c (xd_retrieve_value, xd_retrieve_arg)
15 (Fdbus_call_method, Fdbus_send_signal, xd_read_message): Use
16 `unsigned int' instead of `uint'.
17 (xd_read_message, Fdbus_register_signal): Split expressions into
18 multiple lines before operators "&&" and "||", according to the
19 GNU Coding Standards.
20
212007-12-14 Eli Zaretskii <eliz@gnu.org>
22
23 * dispextern.h (WINDOWS_NT): Fix incorrect spelling of WINDOWSNT.
24
252007-12-12 Juri Linkov <juri@jurta.org>
26
27 * buffer.c (Frename_buffer): In interactive spec replace
28 `read-buffer' with `read-string' that uses `buffer-name-history'
29 as history, and the current buffer's name as default.
30
312007-12-10 Stefan Monnier <monnier@iro.umontreal.ca>
32
33 * keyboard.c (Fcommand_execute): Call Qcall_interactively instead of
34 manipulating the backtrace manually.
35 (make_lispy_event): Merge the ASCII and MULTIBYTE cases.
36 (struct backtrace, backtrace_list): Remove.
37 (command_loop_1): Remove dead var `no_direct'.
38
39 * buffer.c (reset_buffer_local_variables): If permanent_too is 0, also
40 preserve non-built-in buffer-local variables.
41 (Fkill_all_local_variables): Don't re-create&re-set permanent
42 buffer-local variables.
43
442007-12-09 Juri Linkov <juri@jurta.org>
45
46 * buffer.c (Frename_buffer): Change interactive spec from "s" to
47 Lisp code that uses `read-buffer' with current buffer as default.
48
492007-12-08 Michael Albinus <michael.albinus@gmx.de>
50
51 * dbusbind.c (xd_read_message): Generate an event for every
52 registered handler. There might be several handlers registered
53 for the same signal.
54 (Fdbus_register_signal): Don't overwrite a registration for the
55 same signal. Add a new registration if handlers are different.
56 (Vdbus_registered_functions_table): Rework doc string.
57
582007-12-07 Michael Albinus <michael.albinus@gmx.de>
59
60 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
61 (Fdbus_register_signal): Use DBUS_MAXIMUM_NAME_LENGTH and
62 DBUS_MAXIMUM_MATCH_RULE_LENGTH for string lengths.
63 (Fdbus_call_method, Fdbus_send_signal, Fdbus_register_signal):
64 Unify argument lists.
65 (xd_read_message, Fdbus_register_signal) Reorder and extend event
66 arguments and hash table keys. Use unique name for service.
67 (Fdbus_unregister_signal): Remove checks.
68 (Vdbus_registered_functions_table): Fix doc string.
69
12007-12-05 Magnus Henoch <mange@freemail.hu> 702007-12-05 Magnus Henoch <mange@freemail.hu>
2 71
3 * process.c (make_process): Initialize pty_flag to 0. 72 * process.c (make_process): Initialize pty_flag to 0.
diff --git a/src/buffer.c b/src/buffer.c
index 77af23ace39..009d7de86fc 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -107,12 +107,14 @@ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
107 107
108int last_per_buffer_idx; 108int last_per_buffer_idx;
109 109
110Lisp_Object Fset_buffer (); 110EXFUN (Fset_buffer, 1);
111void set_buffer_internal (); 111void set_buffer_internal P_ ((struct buffer *b));
112void set_buffer_internal_1 (); 112void set_buffer_internal_1 P_ ((struct buffer *b));
113static void call_overlay_mod_hooks (); 113static void call_overlay_mod_hooks P_ ((Lisp_Object list, Lisp_Object overlay,
114static void swap_out_buffer_local_variables (); 114 int after, Lisp_Object arg1,
115static void reset_buffer_local_variables (); 115 Lisp_Object arg2, Lisp_Object arg3));
116static void swap_out_buffer_local_variables P_ ((struct buffer *b));
117static void reset_buffer_local_variables P_ ((struct buffer *b, int permanent_too));
116 118
117/* Alist of all buffer names vs the buffers. */ 119/* Alist of all buffer names vs the buffers. */
118/* This used to be a variable, but is no longer, 120/* This used to be a variable, but is no longer,
@@ -717,7 +719,7 @@ reset_buffer (b)
717 it does not treat permanent locals consistently. 719 it does not treat permanent locals consistently.
718 Instead, use Fkill_all_local_variables. 720 Instead, use Fkill_all_local_variables.
719 721
720 If PERMANENT_TOO is 1, then we reset permanent built-in 722 If PERMANENT_TOO is 1, then we reset permanent
721 buffer-local variables. If PERMANENT_TOO is 0, 723 buffer-local variables. If PERMANENT_TOO is 0,
722 we preserve those. */ 724 we preserve those. */
723 725
@@ -755,7 +757,23 @@ reset_buffer_local_variables (b, permanent_too)
755#endif 757#endif
756 758
757 /* Reset all (or most) per-buffer variables to their defaults. */ 759 /* Reset all (or most) per-buffer variables to their defaults. */
758 b->local_var_alist = Qnil; 760 if (permanent_too)
761 b->local_var_alist = Qnil;
762 else
763 {
764 Lisp_Object tmp, last = Qnil;
765 for (tmp = b->local_var_alist; CONSP (tmp); tmp = XCDR (tmp))
766 if (CONSP (XCAR (tmp))
767 && SYMBOLP (XCAR (XCAR (tmp)))
768 && !NILP (Fget (XCAR (XCAR (tmp)), Qpermanent_local)))
769 /* If permanent-local, keep it. */
770 last = tmp;
771 else if (NILP (last))
772 b->local_var_alist = XCDR (tmp);
773 else
774 XSETCDR (last, XCDR (tmp));
775 }
776
759 for (i = 0; i < last_per_buffer_idx; ++i) 777 for (i = 0; i < last_per_buffer_idx; ++i)
760 if (permanent_too || buffer_permanent_local_flags[i] == 0) 778 if (permanent_too || buffer_permanent_local_flags[i] == 0)
761 SET_PER_BUFFER_VALUE_P (b, i, 0); 779 SET_PER_BUFFER_VALUE_P (b, i, 0);
@@ -1170,7 +1188,9 @@ buffer as BUFFER. */)
1170} 1188}
1171 1189
1172DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2, 1190DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2,
1173 "sRename buffer (to new name): \nP", 1191 "(list (read-string \"Rename buffer (to new name): \" \
1192 nil 'buffer-name-history (buffer-name (current-buffer))) \
1193 current-prefix-arg)",
1174 doc: /* Change current buffer's name to NEWNAME (a string). 1194 doc: /* Change current buffer's name to NEWNAME (a string).
1175If second arg UNIQUE is nil or omitted, it is an error if a 1195If second arg UNIQUE is nil or omitted, it is an error if a
1176buffer named NEWNAME already exists. 1196buffer named NEWNAME already exists.
@@ -2467,14 +2487,10 @@ The first thing this function does is run
2467the normal hook `change-major-mode-hook'. */) 2487the normal hook `change-major-mode-hook'. */)
2468 () 2488 ()
2469{ 2489{
2470 register Lisp_Object alist, sym, tem;
2471 Lisp_Object oalist;
2472
2473 if (!NILP (Vrun_hooks)) 2490 if (!NILP (Vrun_hooks))
2474 call1 (Vrun_hooks, Qchange_major_mode_hook); 2491 call1 (Vrun_hooks, Qchange_major_mode_hook);
2475 oalist = current_buffer->local_var_alist;
2476 2492
2477 /* Make sure none of the bindings in oalist 2493 /* Make sure none of the bindings in local_var_alist
2478 remain swapped in, in their symbols. */ 2494 remain swapped in, in their symbols. */
2479 2495
2480 swap_out_buffer_local_variables (current_buffer); 2496 swap_out_buffer_local_variables (current_buffer);
@@ -2483,20 +2499,6 @@ the normal hook `change-major-mode-hook'. */)
2483 2499
2484 reset_buffer_local_variables (current_buffer, 0); 2500 reset_buffer_local_variables (current_buffer, 0);
2485 2501
2486 /* Any which are supposed to be permanent,
2487 make local again, with the same values they had. */
2488
2489 for (alist = oalist; CONSP (alist); alist = XCDR (alist))
2490 {
2491 sym = XCAR (XCAR (alist));
2492 tem = Fget (sym, Qpermanent_local);
2493 if (! NILP (tem))
2494 {
2495 Fmake_local_variable (sym);
2496 Fset (sym, XCDR (XCAR (alist)));
2497 }
2498 }
2499
2500 /* Force mode-line redisplay. Useful here because all major mode 2502 /* Force mode-line redisplay. Useful here because all major mode
2501 commands call this function. */ 2503 commands call this function. */
2502 update_mode_lines++; 2504 update_mode_lines++;
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 07fc24243d7..0ccccc8b22d 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -112,7 +112,7 @@ Lisp_Object Vdbus_debug;
112 message. */ 112 message. */
113char * 113char *
114xd_retrieve_value (dtype, object) 114xd_retrieve_value (dtype, object)
115 uint dtype; 115 unsigned int dtype;
116 Lisp_Object object; 116 Lisp_Object object;
117{ 117{
118 118
@@ -146,7 +146,7 @@ xd_retrieve_value (dtype, object)
146 partly supported; they result always in a Lisp list. */ 146 partly supported; they result always in a Lisp list. */
147Lisp_Object 147Lisp_Object
148xd_retrieve_arg (dtype, iter) 148xd_retrieve_arg (dtype, iter)
149 uint dtype; 149 unsigned int dtype;
150 DBusMessageIter *iter; 150 DBusMessageIter *iter;
151{ 151{
152 152
@@ -241,7 +241,7 @@ DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name,
241 Lisp_Object bus; 241 Lisp_Object bus;
242{ 242{
243 DBusConnection *connection; 243 DBusConnection *connection;
244 char name[1024]; 244 char name[DBUS_MAXIMUM_NAME_LENGTH];
245 245
246 /* Check parameters. */ 246 /* Check parameters. */
247 CHECK_SYMBOL (bus); 247 CHECK_SYMBOL (bus);
@@ -287,8 +287,8 @@ are converted into a list of Lisp objects which correspond to the
287elements of the D-Bus container. Example: 287elements of the D-Bus container. Example:
288 288
289\(dbus-call-method 289\(dbus-call-method
290 :session "GetKeyField" "org.gnome.seahorse" 290 :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp"
291 "/org/gnome/seahorse/keys/openpgp" "org.gnome.seahorse.Keys" 291 "org.gnome.seahorse.Keys" "GetKeyField"
292 "openpgp:657984B8C7A966DD" "simple-name") 292 "openpgp:657984B8C7A966DD" "simple-name")
293 293
294 => (t ("Philip R. Zimmermann")) 294 => (t ("Philip R. Zimmermann"))
@@ -297,18 +297,18 @@ If the result of the METHOD call is just one value, the converted Lisp
297object is returned instead of a list containing this single Lisp object. 297object is returned instead of a list containing this single Lisp object.
298 298
299\(dbus-call-method 299\(dbus-call-method
300 :system "GetPropertyString" "org.freedesktop.Hal" 300 :system "org.freedesktop.Hal" "/org/freedesktop/Hal/devices/computer"
301 "/org/freedesktop/Hal/devices/computer" "org.freedesktop.Hal.Device" 301 "org.freedesktop.Hal.Device" "GetPropertyString"
302 "system.kernel.machine") 302 "system.kernel.machine")
303 303
304 => "i686" 304 => "i686"
305 305
306usage: (dbus-call-method BUS METHOD SERVICE PATH INTERFACE &rest ARGS) */) 306usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
307 (nargs, args) 307 (nargs, args)
308 int nargs; 308 int nargs;
309 register Lisp_Object *args; 309 register Lisp_Object *args;
310{ 310{
311 Lisp_Object bus, method, service, path, interface; 311 Lisp_Object bus, service, path, interface, method;
312 Lisp_Object result; 312 Lisp_Object result;
313 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 313 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
314 DBusConnection *connection; 314 DBusConnection *connection;
@@ -316,29 +316,29 @@ usage: (dbus-call-method BUS METHOD SERVICE PATH INTERFACE &rest ARGS) */)
316 DBusMessage *reply; 316 DBusMessage *reply;
317 DBusMessageIter iter; 317 DBusMessageIter iter;
318 DBusError derror; 318 DBusError derror;
319 uint dtype; 319 unsigned int dtype;
320 int i; 320 int i;
321 char *value; 321 char *value;
322 322
323 /* Check parameters. */ 323 /* Check parameters. */
324 bus = args[0]; 324 bus = args[0];
325 method = args[1]; 325 service = args[1];
326 service = args[2]; 326 path = args[2];
327 path = args[3]; 327 interface = args[3];
328 interface = args[4]; 328 method = args[4];
329 329
330 CHECK_SYMBOL (bus); 330 CHECK_SYMBOL (bus);
331 CHECK_STRING (method);
332 CHECK_STRING (service); 331 CHECK_STRING (service);
333 CHECK_STRING (path); 332 CHECK_STRING (path);
334 CHECK_STRING (interface); 333 CHECK_STRING (interface);
335 GCPRO5 (bus, method, service, path, interface); 334 CHECK_STRING (method);
335 GCPRO5 (bus, service, path, interface, method);
336 336
337 XD_DEBUG_MESSAGE ("%s %s %s %s", 337 XD_DEBUG_MESSAGE ("%s %s %s %s",
338 SDATA (method),
339 SDATA (service), 338 SDATA (service),
340 SDATA (path), 339 SDATA (path),
341 SDATA (interface)); 340 SDATA (interface),
341 SDATA (method));
342 342
343 /* Open a connection to the bus. */ 343 /* Open a connection to the bus. */
344 connection = xd_initialize (bus); 344 connection = xd_initialize (bus);
@@ -447,40 +447,41 @@ Other Lisp objects are not supported as arguments of SIGNAL.
447Example: 447Example:
448 448
449\(dbus-send-signal 449\(dbus-send-signal
450 :session "Started" "org.gnu.emacs" "/org/gnu/emacs" "org.gnu.emacs"))) 450 :session "org.gnu.Emacs" "/org/gnu/Emacs"
451 "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs")
451 452
452usage: (dbus-send-signal BUS SIGNAL SERVICE PATH INTERFACE &rest ARGS) */) 453usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
453 (nargs, args) 454 (nargs, args)
454 int nargs; 455 int nargs;
455 register Lisp_Object *args; 456 register Lisp_Object *args;
456{ 457{
457 Lisp_Object bus, signal, service, path, interface; 458 Lisp_Object bus, service, path, interface, signal;
458 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 459 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
459 DBusConnection *connection; 460 DBusConnection *connection;
460 DBusMessage *dmessage; 461 DBusMessage *dmessage;
461 uint dtype; 462 unsigned int dtype;
462 int i; 463 int i;
463 char *value; 464 char *value;
464 465
465 /* Check parameters. */ 466 /* Check parameters. */
466 bus = args[0]; 467 bus = args[0];
467 signal = args[1]; 468 service = args[1];
468 service = args[2]; 469 path = args[2];
469 path = args[3]; 470 interface = args[3];
470 interface = args[4]; 471 signal = args[4];
471 472
472 CHECK_SYMBOL (bus); 473 CHECK_SYMBOL (bus);
473 CHECK_STRING (signal);
474 CHECK_STRING (service); 474 CHECK_STRING (service);
475 CHECK_STRING (path); 475 CHECK_STRING (path);
476 CHECK_STRING (interface); 476 CHECK_STRING (interface);
477 GCPRO5 (bus, signal, service, path, interface); 477 CHECK_STRING (signal);
478 GCPRO5 (bus, service, path, interface, signal);
478 479
479 XD_DEBUG_MESSAGE ("%s %s %s %s", 480 XD_DEBUG_MESSAGE ("%s %s %s %s",
480 SDATA (signal),
481 SDATA (service), 481 SDATA (service),
482 SDATA (path), 482 SDATA (path),
483 SDATA (interface)); 483 SDATA (interface),
484 SDATA (signal));
484 485
485 /* Open a connection to the bus. */ 486 /* Open a connection to the bus. */
486 connection = xd_initialize (bus); 487 connection = xd_initialize (bus);
@@ -542,14 +543,17 @@ Lisp_Object
542xd_read_message (bus) 543xd_read_message (bus)
543 Lisp_Object bus; 544 Lisp_Object bus;
544{ 545{
545 Lisp_Object key; 546 Lisp_Object args, key, value;
546 struct gcpro gcpro1; 547 struct gcpro gcpro1;
547 static struct input_event event; 548 static struct input_event event;
548 DBusConnection *connection; 549 DBusConnection *connection;
549 DBusMessage *dmessage; 550 DBusMessage *dmessage;
550 DBusMessageIter iter; 551 DBusMessageIter iter;
551 uint dtype; 552 unsigned int dtype;
552 char service[1024], path[1024], interface[1024], member[1024]; 553 char uname[DBUS_MAXIMUM_NAME_LENGTH];
554 char path[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; /* Unlimited in D-Bus spec. */
555 char interface[DBUS_MAXIMUM_NAME_LENGTH];
556 char member[DBUS_MAXIMUM_NAME_LENGTH];
553 557
554 /* Open a connection to the bus. */ 558 /* Open a connection to the bus. */
555 connection = xd_initialize (bus); 559 connection = xd_initialize (bus);
@@ -562,16 +566,11 @@ xd_read_message (bus)
562 if (dmessage == NULL) 566 if (dmessage == NULL)
563 return; 567 return;
564 568
565 /* There is a message in the queue. Construct the D-Bus event. */
566 XD_DEBUG_MESSAGE ("Event received"); 569 XD_DEBUG_MESSAGE ("Event received");
567 EVENT_INIT (event);
568
569 event.kind = DBUS_EVENT;
570 event.frame_or_window = Qnil;
571 570
572 /* Collect the parameters. */ 571 /* Collect the parameters. */
573 event.arg = Qnil; 572 args = Qnil;
574 GCPRO1 (event.arg); 573 GCPRO1 (args);
575 574
576 if (!dbus_message_iter_init (dmessage, &iter)) 575 if (!dbus_message_iter_init (dmessage, &iter))
577 { 576 {
@@ -583,42 +582,61 @@ xd_read_message (bus)
583 /* Loop over the resulting parameters. Construct a list. */ 582 /* Loop over the resulting parameters. Construct a list. */
584 while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) 583 while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID)
585 { 584 {
586 event.arg = Fcons (xd_retrieve_arg (dtype, &iter), event.arg); 585 args = Fcons (xd_retrieve_arg (dtype, &iter), args);
587 dbus_message_iter_next (&iter); 586 dbus_message_iter_next (&iter);
588 } 587 }
589 588
590 /* The arguments are stored in reverse order. Reorder them. */ 589 /* The arguments are stored in reverse order. Reorder them. */
591 event.arg = Fnreverse (event.arg); 590 args = Fnreverse (args);
592 591
593 /* Read service, object path interface and member from the 592 /* Read unique name, object path, interface and member from the
594 message. */ 593 message. */
595 strcpy (service, dbus_message_get_sender (dmessage)); 594 strcpy (uname, dbus_message_get_sender (dmessage));
596 strcpy (path, dbus_message_get_path (dmessage)); 595 strcpy (path, dbus_message_get_path (dmessage));
597 strcpy (interface, dbus_message_get_interface (dmessage)); 596 strcpy (interface, dbus_message_get_interface (dmessage));
598 strcpy (member, dbus_message_get_member (dmessage)); 597 strcpy (member, dbus_message_get_member (dmessage));
599 598
600 /* Add them to the event. */ 599 /* Search for a registered function of the message. */
601 event.arg = Fcons ((member == NULL ? Qnil : build_string (member)), 600 key = list3 (bus, build_string (interface), build_string (member));
602 event.arg); 601 value = Fgethash (key, Vdbus_registered_functions_table, Qnil);
603 event.arg = Fcons ((interface == NULL ? Qnil : build_string (interface)), 602
604 event.arg); 603 /* Loop over the registered functions. Construct an event. */
605 event.arg = Fcons ((path == NULL ? Qnil : build_string (path)), 604 while (!NILP (value))
606 event.arg); 605 {
607 event.arg = Fcons ((service == NULL ? Qnil : build_string (service)), 606 key = XCAR (value);
608 event.arg); 607 /* key has the structure (SERVICE UNAME PATH HANDLER). */
609 608 if (((uname == NULL)
610 /* Add the bus symbol to the event. */ 609 || (NILP (XCAR (XCDR (key))))
611 event.arg = Fcons (bus, event.arg); 610 || (strcmp (uname, SDATA (XCAR (XCDR (key)))) == 0))
612 611 && ((path == NULL)
613 /* Add the registered function of the message. */ 612 || (NILP (XCAR (XCDR (XCDR (key)))))
614 key = list3 (bus, 613 || (strcmp (path, SDATA (XCAR (XCDR (XCDR (key))))) == 0))
615 (interface == NULL ? Qnil : build_string (interface)), 614 && (!NILP (XCAR (XCDR (XCDR (XCDR (key)))))))
616 (member == NULL ? Qnil : build_string (member))); 615 {
617 event.arg = Fcons (Fgethash (key, Vdbus_registered_functions_table, Qnil), 616 EVENT_INIT (event);
618 event.arg); 617 event.kind = DBUS_EVENT;
619 618 event.frame_or_window = Qnil;
620 /* Store it into the input event queue. */ 619 event.arg = Fcons (XCAR (XCDR (XCDR (XCDR (key)))), args);
621 kbd_buffer_store_event (&event); 620
621 /* Add uname, path, interface and member to the event. */
622 event.arg = Fcons ((member == NULL ? Qnil : build_string (member)),
623 event.arg);
624 event.arg = Fcons ((interface == NULL
625 ? Qnil : build_string (interface)),
626 event.arg);
627 event.arg = Fcons ((path == NULL ? Qnil : build_string (path)),
628 event.arg);
629 event.arg = Fcons ((uname == NULL ? Qnil : build_string (uname)),
630 event.arg);
631
632 /* Add the bus symbol to the event. */
633 event.arg = Fcons (bus, event.arg);
634
635 /* Store it into the input event queue. */
636 kbd_buffer_store_event (&event);
637 }
638 value = XCDR (value);
639 }
622 640
623 /* Cleanup. */ 641 /* Cleanup. */
624 dbus_message_unref (dmessage); 642 dbus_message_unref (dmessage);
@@ -666,31 +684,42 @@ SIGNAL and HANDLER must not be nil. Example:
666 (message "Device %s added" device)) 684 (message "Device %s added" device))
667 685
668\(dbus-register-signal 686\(dbus-register-signal
669 :system "DeviceAdded" 687 :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager"
670 (dbus-get-name-owner :system "org.freedesktop.Hal") 688 "org.freedesktop.Hal.Manager" "DeviceAdded" 'my-signal-handler)
671 "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager"
672 'my-signal-handler)
673 689
674 => (:system "org.freedesktop.Hal.Manager" "DeviceAdded") 690 => (:system ":1.3" "/org/freedesktop/Hal/Manager"
691 "org.freedesktop.Hal.Manager" "DeviceAdded")
675 692
676`dbus-register-signal' returns an object, which can be used in 693`dbus-register-signal' returns an object, which can be used in
677`dbus-unregister-signal' for removing the registration. */) 694`dbus-unregister-signal' for removing the registration. */)
678 (bus, signal, service, path, interface, handler) 695 (bus, service, path, interface, signal, handler)
679 Lisp_Object bus, signal, service, path, interface, handler; 696 Lisp_Object bus, service, path, interface, signal, handler;
680{ 697{
681 Lisp_Object key; 698 Lisp_Object unique_name, key, value;
682 DBusConnection *connection; 699 DBusConnection *connection;
683 char rule[1024]; 700 char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
684 DBusError derror; 701 DBusError derror;
685 702
686 /* Check parameters. */ 703 /* Check parameters. */
687 CHECK_SYMBOL (bus); 704 CHECK_SYMBOL (bus);
688 CHECK_STRING (signal);
689 if (!NILP (service)) CHECK_STRING (service); 705 if (!NILP (service)) CHECK_STRING (service);
690 if (!NILP (path)) CHECK_STRING (path); 706 if (!NILP (path)) CHECK_STRING (path);
691 CHECK_STRING (interface); 707 CHECK_STRING (interface);
708 CHECK_STRING (signal);
692 CHECK_SYMBOL (handler); 709 CHECK_SYMBOL (handler);
693 710
711 /* Retrieve unique name of service. If service is a known name, we
712 will register for the corresponding unique name, if any. Signals
713 are sent always with the unique name as sender. Note: the unique
714 name of "org.freedesktop.DBus" is that string itself. */
715 if ((!NILP (service))
716 && (strlen (SDATA (service)) > 0)
717 && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0)
718 && (strncmp (SDATA (service), ":", 1) != 0))
719 unique_name = call2 (intern ("dbus-get-name-owner"), bus, service);
720 else
721 unique_name = service;
722
694 /* Open a connection to the bus. */ 723 /* Open a connection to the bus. */
695 connection = xd_initialize (bus); 724 connection = xd_initialize (bus);
696 725
@@ -700,9 +729,9 @@ SIGNAL and HANDLER must not be nil. Example:
700 SDATA (interface), 729 SDATA (interface),
701 SDATA (signal)); 730 SDATA (signal));
702 731
703 /* Add service and path to the rule if they are non-nil. */ 732 /* Add unique name and path to the rule if they are non-nil. */
704 if (!NILP (service)) 733 if (!NILP (unique_name))
705 sprintf (rule, "%s,sender='%s'%", rule, SDATA (service)); 734 sprintf (rule, "%s,sender='%s'%", rule, SDATA (unique_name));
706 735
707 if (!NILP (path)) 736 if (!NILP (path))
708 sprintf (rule, "%s,path='%s'", rule, SDATA (path)); 737 sprintf (rule, "%s,path='%s'", rule, SDATA (path));
@@ -717,15 +746,21 @@ SIGNAL and HANDLER must not be nil. Example:
717 746
718 /* Create a hash table entry. */ 747 /* Create a hash table entry. */
719 key = list3 (bus, interface, signal); 748 key = list3 (bus, interface, signal);
720 Fputhash (key, handler, Vdbus_registered_functions_table); 749 value = Fgethash (key, Vdbus_registered_functions_table, Qnil);
721 XD_DEBUG_MESSAGE ("\"%s\" registered with handler \"%s\"", 750
722 SDATA (format2 ("%s", key, Qnil)), 751 if (NILP (Fmember (list4 (service, unique_name, path, handler), value)))
723 SDATA (format2 ("%s", handler, Qnil))); 752 Fputhash (key,
753 Fcons (list4 (service, unique_name, path, handler), value),
754 Vdbus_registered_functions_table);
724 755
725 /* Return key. */ 756 /* Return key. */
726 return key; 757 return key;
727} 758}
728 759
760/* The current implementation removes ALL registered functions for a
761 given signal. Shouldn't be a problem in general, but there might
762 be cases it is not desired. Maybe we can refine the
763 implementation. */
729DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal, 764DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal,
730 1, 1, 0, 765 1, 1, 0,
731 doc: /* Unregister OBJECT from the D-Bus. 766 doc: /* Unregister OBJECT from the D-Bus.
@@ -734,13 +769,6 @@ OBJECT must be the result of a preceding `dbus-register-signal' call. */)
734 Lisp_Object object; 769 Lisp_Object object;
735{ 770{
736 771
737 /* Check parameters. */
738 CHECK_SYMBOL (object);
739
740 XD_DEBUG_MESSAGE ("\"%s\" unregistered with handler \"%s\"",
741 SDATA (format2 ("%s", object, Qnil)),
742 SDATA (format2 ("%s", Fsymbol_function (object), Qnil)));
743
744 /* Unintern the signal symbol. */ 772 /* Unintern the signal symbol. */
745 Fremhash (object, Vdbus_registered_functions_table); 773 Fremhash (object, Vdbus_registered_functions_table);
746 774
@@ -788,13 +816,19 @@ syms_of_dbusbind ()
788 816
789 DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table, 817 DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table,
790 doc: /* Hash table of registered functions for D-Bus. 818 doc: /* Hash table of registered functions for D-Bus.
791The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is 819The key in the hash table is the list (BUS MEMBER INTERFACE). BUS is
792either the symbol `:system' or the symbol `:session'. INTERFACE is a 820either the symbol `:system' or the symbol `:session'. INTERFACE is a
793string which denotes a D-Bus interface, and MEMBER, also a string, is 821string which denotes a D-Bus interface, and MEMBER, also a string, is
794either a method or a signal INTERFACE is offering. 822either a method or a signal INTERFACE is offering. All arguments but
795 823BUS must not be nil.
796The value in the hash table a the function to be called when a D-Bus 824
797message, which matches the key criteria, arrives. */); 825The value in the hash table is a list of triple lists
826\((SERVICE UNAME PATH HANDLER) (SERVICE UNAME PATH HANDLER) ...).
827SERVICE is the service name as registered, UNAME is the corresponding
828unique name. PATH is the object path of the sending object. All of
829them be nil, which means a wildcard then. HANDLER is the function to
830be called when a D-Bus message, which matches the key criteria,
831arrives. */);
798 /* We initialize Vdbus_registered_functions_table in dbus.el, 832 /* We initialize Vdbus_registered_functions_table in dbus.el,
799 because we need to define a hash table function first. */ 833 because we need to define a hash table function first. */
800 Vdbus_registered_functions_table = Qnil; 834 Vdbus_registered_functions_table = Qnil;
diff --git a/src/dispextern.h b/src/dispextern.h
index a4021622ba1..b8027593721 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2785,7 +2785,7 @@ int draw_window_fringes P_ ((struct window *, int));
2785int update_window_fringes P_ ((struct window *, int)); 2785int update_window_fringes P_ ((struct window *, int));
2786void compute_fringe_widths P_ ((struct frame *, int)); 2786void compute_fringe_widths P_ ((struct frame *, int));
2787 2787
2788#ifdef WINDOWS_NT 2788#ifdef WINDOWSNT
2789void w32_init_fringe P_ ((struct redisplay_interface *)); 2789void w32_init_fringe P_ ((struct redisplay_interface *));
2790void w32_reset_fringes P_ ((void)); 2790void w32_reset_fringes P_ ((void));
2791#endif 2791#endif
diff --git a/src/keyboard.c b/src/keyboard.c
index 6595b7f800d..2230b339f5e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -108,21 +108,6 @@ int interrupt_input_pending;
108#define KBD_BUFFER_SIZE 4096 108#define KBD_BUFFER_SIZE 4096
109#endif /* No X-windows */ 109#endif /* No X-windows */
110 110
111/* Following definition copied from eval.c */
112
113struct backtrace
114 {
115 struct backtrace *next;
116 Lisp_Object *function;
117 Lisp_Object *args; /* Points to vector of args. */
118 int nargs; /* length of vector. If nargs is UNEVALLED,
119 args points to slot holding list of
120 unevalled args */
121 char evalargs;
122 /* Nonzero means call value of debugger when done with this operation. */
123 char debug_on_exit;
124 };
125
126#ifdef MULTI_KBOARD 111#ifdef MULTI_KBOARD
127KBOARD *initial_kboard; 112KBOARD *initial_kboard;
128KBOARD *current_kboard; 113KBOARD *current_kboard;
@@ -175,8 +160,6 @@ extern int minbuf_level;
175 160
176extern int message_enable_multibyte; 161extern int message_enable_multibyte;
177 162
178extern struct backtrace *backtrace_list;
179
180/* If non-nil, the function that implements the display of help. 163/* If non-nil, the function that implements the display of help.
181 It's called with one argument, the help string to display. */ 164 It's called with one argument, the help string to display. */
182 165
@@ -1565,7 +1548,6 @@ command_loop_1 ()
1565 int nonundocount; 1548 int nonundocount;
1566 Lisp_Object keybuf[30]; 1549 Lisp_Object keybuf[30];
1567 int i; 1550 int i;
1568 int no_direct;
1569 int prev_modiff = 0; 1551 int prev_modiff = 0;
1570 struct buffer *prev_buffer = NULL; 1552 struct buffer *prev_buffer = NULL;
1571#if 0 /* This shouldn't be necessary anymore. --lorentey */ 1553#if 0 /* This shouldn't be necessary anymore. --lorentey */
@@ -1625,8 +1607,6 @@ command_loop_1 ()
1625 while (pending_malloc_warning) 1607 while (pending_malloc_warning)
1626 display_malloc_warning (); 1608 display_malloc_warning ();
1627 1609
1628 no_direct = 0;
1629
1630 Vdeactivate_mark = Qnil; 1610 Vdeactivate_mark = Qnil;
1631 1611
1632 /* If minibuffer on and echo area in use, 1612 /* If minibuffer on and echo area in use,
@@ -1787,7 +1767,7 @@ command_loop_1 ()
1787 } 1767 }
1788 else 1768 else
1789 { 1769 {
1790 if (NILP (current_kboard->Vprefix_arg) && ! no_direct) 1770 if (NILP (current_kboard->Vprefix_arg))
1791 { 1771 {
1792 /* In case we jump to directly_done. */ 1772 /* In case we jump to directly_done. */
1793 Vcurrent_prefix_arg = current_kboard->Vprefix_arg; 1773 Vcurrent_prefix_arg = current_kboard->Vprefix_arg;
@@ -5558,41 +5538,32 @@ make_lispy_event (event)
5558 { 5538 {
5559 /* A simple keystroke. */ 5539 /* A simple keystroke. */
5560 case ASCII_KEYSTROKE_EVENT: 5540 case ASCII_KEYSTROKE_EVENT:
5561 {
5562 Lisp_Object lispy_c;
5563 int c = event->code & 0377;
5564 /* Turn ASCII characters into control characters
5565 when proper. */
5566 if (event->modifiers & ctrl_modifier)
5567 c = make_ctrl_char (c);
5568
5569 /* Add in the other modifier bits. We took care of ctrl_modifier
5570 just above, and the shift key was taken care of by the X code,
5571 and applied to control characters by make_ctrl_char. */
5572 c |= (event->modifiers
5573 & (meta_modifier | alt_modifier
5574 | hyper_modifier | super_modifier));
5575 /* Distinguish Shift-SPC from SPC. */
5576 if ((event->code & 0377) == 040
5577 && event->modifiers & shift_modifier)
5578 c |= shift_modifier;
5579 button_down_time = 0;
5580 XSETFASTINT (lispy_c, c);
5581 return lispy_c;
5582 }
5583
5584 case MULTIBYTE_CHAR_KEYSTROKE_EVENT: 5541 case MULTIBYTE_CHAR_KEYSTROKE_EVENT:
5585 { 5542 {
5586 Lisp_Object lispy_c; 5543 Lisp_Object lispy_c;
5587 int c = event->code; 5544 int c = event->code;
5545 if (event->kind == ASCII_KEYSTROKE_EVENT)
5546 {
5547 c &= 0377;
5548 eassert (c == event->code);
5549 /* Turn ASCII characters into control characters
5550 when proper. */
5551 if (event->modifiers & ctrl_modifier)
5552 {
5553 c = make_ctrl_char (c);
5554 event->modifiers &= ~ctrl_modifier;
5555 }
5556 }
5588 5557
5589 /* Add in the other modifier bits. We took care of ctrl_modifier 5558 /* Add in the other modifier bits. The shift key was taken care
5590 just above, and the shift key was taken care of by the X code, 5559 of by the X code. */
5591 and applied to control characters by make_ctrl_char. */
5592 c |= (event->modifiers 5560 c |= (event->modifiers
5593 & (meta_modifier | alt_modifier 5561 & (meta_modifier | alt_modifier
5594 | hyper_modifier | super_modifier | ctrl_modifier)); 5562 | hyper_modifier | super_modifier | ctrl_modifier));
5595 /* What about the `shift' modifier ? */ 5563 /* Distinguish Shift-SPC from SPC. */
5564 if ((event->code) == 040
5565 && event->modifiers & shift_modifier)
5566 c |= shift_modifier;
5596 button_down_time = 0; 5567 button_down_time = 0;
5597 XSETFASTINT (lispy_c, c); 5568 XSETFASTINT (lispy_c, c);
5598 return lispy_c; 5569 return lispy_c;
@@ -9619,7 +9590,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
9619 } 9590 }
9620 9591
9621 GROW_RAW_KEYBUF; 9592 GROW_RAW_KEYBUF;
9622 XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; 9593 ASET (raw_keybuf, raw_keybuf_count++, key);
9623 } 9594 }
9624 9595
9625 /* Clicks in non-text areas get prefixed by the symbol 9596 /* Clicks in non-text areas get prefixed by the symbol
@@ -10401,7 +10372,6 @@ a special event, so ignore the prefix argument and don't clear it. */)
10401 register Lisp_Object final; 10372 register Lisp_Object final;
10402 register Lisp_Object tem; 10373 register Lisp_Object tem;
10403 Lisp_Object prefixarg; 10374 Lisp_Object prefixarg;
10404 struct backtrace backtrace;
10405 extern int debug_on_next_call; 10375 extern int debug_on_next_call;
10406 10376
10407 debug_on_next_call = 0; 10377 debug_on_next_call = 0;
@@ -10467,20 +10437,11 @@ a special event, so ignore the prefix argument and don't clear it. */)
10467 } 10437 }
10468 10438
10469 if (CONSP (final) || SUBRP (final) || COMPILEDP (final)) 10439 if (CONSP (final) || SUBRP (final) || COMPILEDP (final))
10470 { 10440 /* Don't call Fcall_interactively directly because we want to make
10471 backtrace.next = backtrace_list; 10441 sure the backtrace has an entry for `call-interactively'.
10472 backtrace_list = &backtrace; 10442 For the same reason, pass `cmd' rather than `final'. */
10473 backtrace.function = &Qcall_interactively; 10443 return call3 (Qcall_interactively, cmd, record_flag, keys);
10474 backtrace.args = &cmd;
10475 backtrace.nargs = 1;
10476 backtrace.evalargs = 0;
10477 backtrace.debug_on_exit = 0;
10478
10479 tem = Fcall_interactively (cmd, record_flag, keys);
10480 10444
10481 backtrace_list = backtrace.next;
10482 return tem;
10483 }
10484 return Qnil; 10445 return Qnil;
10485} 10446}
10486 10447
@@ -10591,7 +10552,7 @@ give to the command you invoke, if it asks for an argument. */)
10591 bindings = Qnil; 10552 bindings = Qnil;
10592 10553
10593 value = Qnil; 10554 value = Qnil;
10594 GCPRO2 (bindings, value); 10555 GCPRO3 (bindings, value, function);
10595 value = Fcommand_execute (function, Qt, Qnil, Qnil); 10556 value = Fcommand_execute (function, Qt, Qnil, Qnil);
10596 10557
10597 /* If the command has a key binding, print it now. */ 10558 /* If the command has a key binding, print it now. */
diff --git a/src/w32fns.c b/src/w32fns.c
index 441ad0f60dc..8ddf8d0f74d 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -2971,7 +2971,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
2971 they don't produce WM_CHAR messages). This ensures that 2971 they don't produce WM_CHAR messages). This ensures that
2972 indicator lights are toggled promptly on Windows 9x, for 2972 indicator lights are toggled promptly on Windows 9x, for
2973 example. */ 2973 example. */
2974 if (lispy_function_keys[wParam] != 0) 2974 if (wParam < 256 && lispy_function_keys[wParam])
2975 { 2975 {
2976 windows_translate = 1; 2976 windows_translate = 1;
2977 goto translate; 2977 goto translate;
@@ -3093,7 +3093,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3093 break; 3093 break;
3094 default: 3094 default:
3095 /* If not defined as a function key, change it to a WM_CHAR message. */ 3095 /* If not defined as a function key, change it to a WM_CHAR message. */
3096 if (lispy_function_keys[wParam] == 0) 3096 if (wParam > 255 || !lispy_function_keys[wParam])
3097 { 3097 {
3098 DWORD modifiers = construct_console_modifiers (); 3098 DWORD modifiers = construct_console_modifiers ();
3099 3099
@@ -8366,7 +8366,7 @@ lookup_vk_code (char *key)
8366 int i; 8366 int i;
8367 8367
8368 for (i = 0; i < 256; i++) 8368 for (i = 0; i < 256; i++)
8369 if (lispy_function_keys[i] != 0 8369 if (lispy_function_keys[i]
8370 && strcmp (lispy_function_keys[i], key) == 0) 8370 && strcmp (lispy_function_keys[i], key) == 0)
8371 return i; 8371 return i;
8372 8372
@@ -8544,7 +8544,7 @@ usage: (w32-reconstruct-hot-key ID) */)
8544 vk_code = HOTKEY_VK_CODE (hotkeyid); 8544 vk_code = HOTKEY_VK_CODE (hotkeyid);
8545 w32_modifiers = HOTKEY_MODIFIERS (hotkeyid); 8545 w32_modifiers = HOTKEY_MODIFIERS (hotkeyid);
8546 8546
8547 if (lispy_function_keys[vk_code]) 8547 if (vk_code < 256 && lispy_function_keys[vk_code])
8548 key = intern (lispy_function_keys[vk_code]); 8548 key = intern (lispy_function_keys[vk_code]);
8549 else 8549 else
8550 key = make_number (vk_code); 8550 key = make_number (vk_code);
diff --git a/src/w32term.c b/src/w32term.c
index 75714a4a118..b489657361c 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4625,6 +4625,8 @@ x_scroll_bar_clear (f)
4625static int temp_index; 4625static int temp_index;
4626static short temp_buffer[100]; 4626static short temp_buffer[100];
4627 4627
4628/* Temporarily store lead byte of DBCS input sequences. */
4629static char dbcs_lead = 0;
4628 4630
4629/* Read events coming from the W32 shell. 4631/* Read events coming from the W32 shell.
4630 This routine is called by the SIGIO handler. 4632 This routine is called by the SIGIO handler.