annotate lisp/progmodes/idlwave.el @ 27423:c3199813ea4d

(obj): Add atimer.o. (atimer.o): New target.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 25 Jan 2000 15:52:34 +0000
parents ae5b17b9c403
children 0396e9e8d57b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; idlwave.el --- IDL and WAVE CL editing mode for GNU Emacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2 ;; Copyright (c) 1994-1997 Chris Chase
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3 ;; Copyright (c) 1999 Carsten Dominik
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4 ;; Copyright (c) 1999 Free Software Foundation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
6 ;; Author: Chris Chase <chase@att.com>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
7 ;; Maintainer: Carsten Dominik <dominik@strw.leidenuniv.nl>
27185
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
8 ;; Version: 3.12
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
9 ;; Date: $Date: 2000/01/05 12:39:30 $
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
10 ;; Keywords: languages
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
11
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
12 ;; This file is part of the GNU Emacs.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
13
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
17 ;; any later version.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
18
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
22 ;; GNU General Public License for more details.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
23
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27 ;; Boston, MA 02111-1307, USA.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29 ;;; Commentary:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 ;; In distant past, based on pascal.el. Though bears little
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 ;; resemblance to that now.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 ;; Incorporates many ideas, such as abbrevs, action routines, and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 ;; continuation line indenting, from wave.el.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 ;; wave.el original written by Lubos Pochman, Precision Visuals, Boulder.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 ;; See the mode description ("C-h m" in idlwave-mode or "C-h f idlwave-mode")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 ;; for features, key bindings, and info.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 ;; Also, Info format documentation is available with `M-x idlwave-info'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43 ;; INSTALLATION
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 ;; ============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 ;; Follow the instructions in the INSTALL file of the distribution.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 ;; In short, put this file on your load path and add the following
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48 ;; lines to your .emacs file:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 ;; (autoload 'idlwave-mode "idlwave" "IDLWAVE Mode" t)
27107
7b2b73f13427 Renamed idlwave-*.el into idlw-*.el.
Eli Zaretskii <eliz@gnu.org>
parents: 26956
diff changeset
51 ;; (autoload 'idlwave-shell "idlw-shell" "IDLWAVE Shell" t)
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 ;; (setq auto-mode-alist (cons '("\\.pro\\'" . idlwave-mode) auto-mode-alist))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55 ;; SOURCE
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 ;; ======
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 ;; The newest version of this file is available from the maintainers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 ;; Webpage.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 ;; http://www.strw.leidenuniv.el/~dominik/Tools/idlwave
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63 ;; DOCUMENTATION
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64 ;; =============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 ;; IDLWAVE is documented online in info format.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67 ;; A printable version of the documentation is available from the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68 ;; maintainers webpage (see under SOURCE)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 ;; ACKNOWLEDGMENTS
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 ;; ===============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 ;; Thanks to the following people for their contributions and comments:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76 ;; Ulrik Dickow <dickow@nbi.dk>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 ;; Eric E. Dors <edors@lanl.gov>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78 ;; Stein Vidar H. Haugan <s.v.h.haugan@astro.uio.no>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 ;; David Huenemoerder <dph@space.mit.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 ;; Kevin Ivory <Kevin.Ivory@linmpi.mpg.de>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 ;; Xuyong Liu <liu@stsci.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 ;; Simon Marshall <Simon.Marshall@esrin.esa.it>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 ;; Laurent Mugnier <mugnier@onera.fr>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 ;; Lubos Pochman <lubos@rsinc.com>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 ;; Patrick M. Ryan <pat@jaameri.gsfc.nasa.gov>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 ;; Marty Ryba <ryba@ll.mit.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87 ;; Phil Williams <williams@irc.chmcc.org>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88 ;; J.D. Smith <jdsmith@astrosun.tn.cornell.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
89 ;; Phil Sterne <sterne@dublin.llnl.gov>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91 ;; CUSTOMIZATION:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92 ;; =============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 ;; IDLWAVE has customize support - so if you want to learn about the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 ;; variables which control the behavior of the mode, use
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96 ;; `M-x idlwave-customize'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 ;; You can set your own preferred values with Customize, or with Lisp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 ;; code in .emacs. For an example of what to put into .emacs, check
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 ;; the TexInfo documentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 ;; KNOWN PROBLEMS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103 ;; ==============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 ;; Moving the point backwards in conjunction with abbrev expansion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 ;; does not work as I would like it, but this is a problem with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 ;; emacs abbrev expansion done by the self-insert-command. It ends
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 ;; up inserting the character that expanded the abbrev after moving
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 ;; point backward, e.g., "\cl" expanded with a space becomes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 ;; "LONG( )" with point before the close paren. This is solved by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 ;; using a temporary function in `post-command-hook' - not pretty,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 ;; but it works.<
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 ;; Tabs and spaces are treated equally as whitespace when filling a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 ;; comment paragraph. To accomplish this, tabs are permanently
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 ;; replaced by spaces in the text surrounding the paragraph, which
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 ;; may be an undesirable side-effect. Replacing tabs with spaces is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 ;; limited to comments only and occurs only when a comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 ;; paragraph is filled via `idlwave-fill-paragraph'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 ;; "&" is ignored when parsing statements.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 ;; Avoid muti-statement lines (using "&") on block begin and end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 ;; lines. Multi-statement lines can mess up the formatting, for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 ;; example, multiple end statements on a line: endif & endif.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125 ;; Using "&" outside of block begin/end lines should be okay.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127 ;; It is possible that the parser which decides what to complete has
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 ;; problems with pointer dereferencing statements. I don't use
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 ;; pointers often enough to find out - please report any problems.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 ;; Completion of keywords for SETPROPERTY and GETPROPERTY assumes that
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 ;; all INIT keywords are allowed in these methods as well. In some
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 ;; cases, there are exceptions to this rule and IDLWAVE will offer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 ;; a few illegal keyword parameters.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 ;; Completion and Routine Info do not know about inheritance. Thus,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 ;; Keywords inherited from superclasses are not displayed and cannot
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 ;; completed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140 ;; When forcing completion of method keywords, the initial
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 ;; query for a method has multiple entries for some methods. Would
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 ;; be too difficult to fix this hardly used problem.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 ;;; Code:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 (eval-when-compile (require 'cl))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 (eval-and-compile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 ;; Kludge to allow `defcustom' for Emacs 19.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 (condition-case () (require 'custom) (error nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 nil ;; We've got what we needed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 ;; We have the old or no custom-library, hack around it!
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 (defmacro defgroup (&rest args) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 (defmacro defcustom (var value doc &rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 (` (defvar (, var) (, value) (, doc))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 (defgroup idlwave nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160 "Major mode for editing IDL/WAVE CL .pro files"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 :tag "IDLWAVE"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 :link '(url-link :tag "Home Page"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 "http://strw.leidenuniv.nl/~dominik/Tools/idlwave")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 :link '(emacs-commentary-link :tag "Commentary in idlwave-shell.el"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 "idlwave-shell.el")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 :link '(emacs-commentary-link :tag "Commentary in idlwave.el" "idlwave.el")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167 :link '(custom-manual "(idlwave)Top")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 :prefix "idlwave"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 :group 'languages)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 ;;; Variables for indentation behavior ---------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173 (defgroup idlwave-code-formatting nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 "Indentation and formatting options for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
176
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 (defcustom idlwave-main-block-indent 0
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 "*Extra indentation for the main block of code.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 That is the block between the FUNCTION/PRO statement and the END
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 statement for that program unit."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
182 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184 (defcustom idlwave-block-indent 4
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 "*Extra indentation applied to block lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 If you change this, you probably also want to change `idlwave-end-offset'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 (defcustom idlwave-end-offset -4
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 "*Extra indentation applied to block END lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 A value equal to negative `idlwave-block-indent' will make END lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 line up with the block BEGIN lines."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 (defcustom idlwave-continuation-indent 2
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 "*Extra indentation applied to continuation lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 This extra offset applies to the first of a set of continuation lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 The following lines receive the same indentation as the first.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 Also, the value of this variable applies to continuation lines inside
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 parenthesis. When the current line contains an open unmatched ([{,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 the next line is indented to that parenthesis plus the value of this variable."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 (defcustom idlwave-hanging-indent t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208 "*If set non-nil then comment paragraphs are indented under the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 hanging indent given by `idlwave-hang-indent-regexp' match in the first line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210 of the paragraph."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 (defcustom idlwave-hang-indent-regexp "- "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215 "*Regular expression matching the position of the hanging indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 in the first line of a comment paragraph. The size of the indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 extends to the end of the match for the regular expression."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 (defcustom idlwave-use-last-hang-indent nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 "*If non-nil then use last match on line for `idlwave-indent-regexp'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 (defcustom idlwave-fill-comment-line-only t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
227 "*If non-nil then auto fill will only operate on comment lines."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231 (defcustom idlwave-auto-fill-split-string t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 "*If non-nil then auto fill will split strings with the IDL `+' operator.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 When the line end falls within a string, string concatenation with the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234 '+' operator will be used to distribute a long string over lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 If nil and a string is split then a terminal beep and warning are issued.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
237 This variable is ignored when `idlwave-fill-comment-line-only' is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 non-nil, since in this case code is not auto-filled."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 (defcustom idlwave-split-line-string t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 "*If non-nil then `idlwave-split-line' will split strings with `+'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244 When the splitting point of a line falls inside a string, split the string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245 using the `+' string concatenation operator. If nil and a string is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246 split then a terminal beep and warning are issued."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
247 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 (defcustom idlwave-no-change-comment ";;;"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251 "*The indentation of a comment that starts with this regular
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 expression will not be changed. Note that the indentation of a comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 at the beginning of a line is never changed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 (defcustom idlwave-begin-line-comment nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258 "*A comment anchored at the beginning of line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 A comment matching this regular expression will not have its
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 indentation changed. If nil the default is \"^;\", i.e., any line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 beginning with a \";\". Expressions for comments at the beginning of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 the line should begin with \"^\"."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264 :type '(choice (const :tag "Any line beginning with `;'" nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
265 'regexp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
266
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
267 (defcustom idlwave-code-comment ";;[^;]"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268 "*A comment that starts with this regular expression on a line by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269 itself is indented as if it is a part of IDL code. As a result if
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 the comment is not preceded by whitespace it is unchanged."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 ;; Comments not matching any of the above will be indented as a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275 ;; right-margin comment, i.e., to a minimum of `comment-column'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278 ;;; Routine Info and Completion ---------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 (defgroup idlwave-routine-info-and-completion nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 "Routine info and name/keyword completion options for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 (defcustom idlwave-scan-all-buffers-for-routine-info t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 "*Non-nil means, scan all buffers for IDL programs when updating info.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
286 `idlwave-update-routine-info' scans buffers of the current Emacs session
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287 for routine definitions. When this variable is nil, it only parses the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288 current buffer. When non-nil, all buffers are searched.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 A prefix to \\[idlwave-update-routine-info] toggles the meaning of this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290 variable for the duration of the command."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 (defcustom idlwave-query-shell-for-routine-info t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 "*Non-nil means query the shell for info about compiled routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 Querying the shell is useful to get information about compiled modules,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 and it is turned on by default. However, when you have a complete library
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298 scan, this is not necessary."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
299 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
300 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302 (defcustom idlwave-library-path nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303 "Library path for Windows and MacOS. Not needed under Unix.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
304 When selecting the directories to scan for IDL library routine info,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
305 IDLWAVE can under UNIX query the shell for the exact search path.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306 However, under Windows and MacOS, the IDLWAVE shell does not work. In this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 case, this variable specifies the path where IDLWAVE can find library files.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308 The shell will only be asked when this variable is nil.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309 The value is a list of directories. A directory preceeded by a `+' will
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
310 be search recursively."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
311 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312 :type '(repeat (directory)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
313
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
314 (defcustom idlwave-libinfo-file nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315 "*File for routine information of the IDL library.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
316 When this points to a file, the file will be loaded when IDLWAVE first
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
317 accesses routine info (or does completion).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
318 When you scan the library with `idlwave-create-libinfo-file', this file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
319 will be used to store the result."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
320 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
321 :type 'file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
322
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
323 (eval-and-compile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324 (defconst idlwave-tmp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
325 '(choice :tag "by applying the function"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
326 (const upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
327 (const downcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
328 (const capitalize)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
329 (const preserve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
330 (symbol :tag "Other"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 (defcustom idlwave-completion-case '((routine . upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334 (keyword . upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 (class . preserve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
336 (method . preserve))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
337 "Association list setting the case of completed words.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339 This variable determines the case (UPPER/lower/Capitalized...) of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340 words inserted into the buffer by completion. The preferred case can
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341 be specified separately for routine names, keywords, classes and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
342 methods.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343 This alist should therefore have entries for `routine' (normal
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
344 functions and procedures, i.e. non-methods), `keyword', `class', and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345 `method'. Plausible values are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
346
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
347 upcase upcase whole word, like `BOX_CURSOR'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
348 downcase downcase whole word, like `read_ppm'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
349 capitalize capitalize each part, like `Widget_Control'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
350 preserve preserve case as is, like `IDLgrView'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
352 The value can also be any Emacs Lisp function which transforms the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
353 case of characters in a string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
354
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
355 A value of `preserve' means that the case of the completed word is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
356 identical to the way it was written in the definition statement of the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
357 routine. This was implemented to allow for mixed-case completion, in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
358 particular of object classes and methods.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359 If a completable word is defined in multiple locations, the meaning of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
360 `preserve' is not unique since the different definitions might be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361 cased differently. Therefore IDLWAVE always takes the case of the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
362 *first* definition it encounters during routine info collection and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
363 uses the case derived from it consistently.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
365 Note that a lowercase-only string in the buffer will always be completed in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
366 lower case (but see the variable `idlwave-completion-force-default-case').
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
367
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368 After changing this variable, you need to either restart Emacs or press
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
369 `C-u C-c C-i' to update the internal lists."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 :type `(repeat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
372 (cons (symbol :tag "Derive completion case for")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
373 ,idlwave-tmp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
374
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
375 (defcustom idlwave-completion-force-default-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
376 "*Non-nil means, completion will always honor `idlwave-completion-case'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 When nil, only the completion of a mixed case or upper case string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 will honor the default settings in `idlwave-completion-case', while
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379 the completion of lower case strings will be completed entirely in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 lower case."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
382 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384 (defcustom idlwave-complete-empty-string-as-lower-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 "*Non-nil means, the empty string is considered downcase for completion.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 The case of what is already in the buffer determines the case of completions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
387 When this variable is non-nil, the empty string is considered to be downcase.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 Completing on the empty string then offers downcase versions of the possible
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 completions."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 (defvar idlwave-default-completion-case-is-down nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394 "Obsolete variable. See `idlwave-complete-empty-string-as-lower-case' and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395 `idlwave-completion-case'.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
397 (defcustom idlwave-buffer-case-takes-precedence nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 "*Non-nil means, the case of tokens in buffers dominates over system stuff.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
399 To make this possible, we need to re-case everything each time we update
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 the routine info from the buffers. This is slow.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401 The default is to consider the case given in the system and library files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 first which makes updating much faster."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
404 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
405
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
406 (defcustom idlwave-completion-show-classes 1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 "*Number of classes to show when completing object methods and keywords.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 When completing methods or keywords for an object with unknown class,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 the *Completions* buffer will show the legal classes for each completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 like this:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
411
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
412 MyMethod <Class1,Class2,Class3>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
414 The value of this variable may be nil to inhibit display, or an integer to
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 indicate the maximum number of classes to display.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
416
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
417 On XEmacs, a full list of classes will also be placed into a `help-echo'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
418 property on the competion items, so that the list of classes for the current
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
419 item is displayed in the echo area. If the value of this variable is a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
420 negative integer, the `help-echo' property will be suppressed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
421 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
422 :type '(choice (const :tag "Don't show" nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
423 (integer :tag "Number of classes shown" 1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
424
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425 (defcustom idlwave-completion-fontify-classes t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
426 "*Non-nil means, fontify the classes in completions buffer.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427 This makes it easier to distinguish the completion items from the extra
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 class info listed. See `idlwave-completion-show-classes'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432 (defcustom idlwave-query-class '((method-default . nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
433 (keyword-default . nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
434 "Association list governing specification of object classes for completion.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
436 When IDLWAVE is trying to complete items which belong to the object
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
437 oriented part of IDL, it usually cannot determine the class of a given
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
438 object from context. In order to provide the user with a correct list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439 of methods or keywords, it would have to determine the appropriate
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440 class. IDLWAVE has two ways to deal with this problem.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 1. One possibility is to combine the items of all available
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443 classes for the purpose of completion. So when completing a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444 method, all methods of all classes are available, and when
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 completing a keyword, all keywords allowed for this method in any
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446 class will be possible completions. This behavior is very much
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 like normal completion and is therefore the default. It works much
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 better than one might think - only for the INIT, GETPROPERTY and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 SETPROPERTY the keyword lists become uncomfortably long.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450 See also `idlwave-completion-show-classes'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 2. The second possibility is to ask the user on each occasion. To
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 make this less interruptive, IDLWAVE can store the class as a text
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
454 property on the object operator `->'. For a given object in the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
455 source code, class selection will then be needed only once
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
456 - for example to complete the method. Keywords to the method can
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
457 then be completed directly, because the class is already known.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
458 You will have to turn on the storage of the selected class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
459 explicitly with the variable `idlwave-store-inquired-class'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
460
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
461 This variable allows to configure IDLWAVE's behavior during
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
462 completion. Its value is an alist, which should contain at least two
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
463 elements: (method-default . VALUE) and (keyword-default . VALUE),
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
464 where VALUE is either t or nil. These specify if the class should be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
465 determined during method and keyword completion, respectively.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
466
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
467 The alist may have additional entries specifying exceptions from the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
468 keyword completion rule for specific methods, like INIT or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469 GETPROPERTY. In order to turn on class specification for the INIT
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
470 method, add an entry (\"INIT\" . t). The method name must be ALL-CAPS."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
471 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
472 :type '(list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
473 (cons (const method-default)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474 (boolean :tag "Determine class when completing METHODS "))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 (cons (const keyword-default)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
476 (boolean :tag "Determine class when completing KEYWORDS "))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
477 (repeat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478 :tag "Exceptions to defaults"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 :inline t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 (cons (string :tag "MODULE" :value "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481 (boolean :tag "Determine class for this method")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 (defcustom idlwave-store-inquired-class nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 "*Non-nil means, store class of a method call as text property on `->'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 IDLWAVE sometimes has to ask the user for the class associated with a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 particular object method call. This happens during the commands
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
487 `idlwave-routine-info' and `idlwave-complete', depending upon the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488 value of the variable `idlwave-query-class'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
490 When you specify a class, this information can be stored as a text
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
491 property on the `->' arrow in the source code, so that during the same
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492 editing session, IDLWAVE will not have to ask again. When this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
493 variable is non-nil, IDLWAVE will store and reuse the class information.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
494 The class stored can be checked and removed with `\\[idlwave-routine-info]'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 on the arrow.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 The default of this variable is nil, since the result of commands then
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498 is more predictable. However, if you know what you are doing, it can
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 be nice to turn this on.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
501 An arrow which knows the class will be highlighted with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 `idlwave-class-arrow-face'. The command \\[idlwave-routine-info]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 displays (with prefix arg: deletes) the class stored on the arrow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 at point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
506 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
507
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
508 (defcustom idlwave-class-arrow-face 'bold
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509 "*Face to highlight object operator arrows `->' which carry a class property.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
510 When IDLWAVE stores a class name as text property on an object arrow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 (see variable `idlwave-store-inquired-class', it highlights the arrow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 with this font in order to remind the user that this arrow is special."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
513 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514 :type 'symbol)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (defcustom idlwave-resize-routine-help-window t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 "*Non-nil means, resize the Routine-info *Help* window to fit the content."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521 (defcustom idlwave-keyword-completion-adds-equal t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522 "*Non-nil means, completion automatically adds `=' after completed keywords."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
523 :group 'idlwave-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526 (defcustom idlwave-function-completion-adds-paren t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
527 "*Non-nil means, completion automatically adds `(' after completed function.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528 Nil means, don't add anything.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 A value of `2' means, also add the closing parenthesis and position cursor
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 between the two."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 :group 'idlwave-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 :type '(choice (const :tag "Nothing" nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 (const :tag "(" t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 (const :tag "()" 2)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536 (defcustom idlwave-completion-restore-window-configuration t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 "*Non-nil means, try to restore the window configuration after completion.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 When completion is not unique, Emacs displays a list of completions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 This messes up your window configuration. With this variable set, IDLWAVE
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 restores the old configuration after successful completion."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 ;;; Variables for abbrev and action behavior -----------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546 (defgroup idlwave-abbrev-and-indent-action nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 "IDLWAVE performs actions when expanding abbreviations or indenting lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
548 The variables in this group govern this."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 (defcustom idlwave-do-actions nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 "*Non-nil means performs actions when indenting.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 The actions that can be performed are listed in `idlwave-indent-action-table'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 (defcustom idlwave-abbrev-start-char "\\"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558 "*A single character string used to start abbreviations in abbrev mode.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 Possible characters to chose from: ~`\%
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 or even '?'. '.' is not a good choice because it can make structure
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 field names act like abbrevs in certain circumstances.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 Changes to this in `idlwave-mode-hook' will have no effect. Instead a user
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564 must set it directly using `setq' in the .emacs file before idlwave.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 is loaded."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 (defcustom idlwave-surround-by-blank nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 "*Non-nil means, enable `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 If non-nil, `=',`<',`>',`&',`,' are surrounded with spaces by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 See help for `idlwave-indent-action-table' for symbols using `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 Also see the default key bindings for keys using `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 Keys are bound and made into actions calling `idlwave-surround' with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 `idlwave-action-and-binding'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 See help for `idlwave-action-and-binding' for examples.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
579
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 Also see help for `idlwave-surround'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
581 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 (defcustom idlwave-pad-keyword t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 "*Non-nil means pad '=' for keywords like assignments.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 Whenever `idlwave-surround' is non-nil then this affects how '=' is padded
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 for keywords. If non-nil it is padded the same as for assignments.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 If nil then spaces are removed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592 (defcustom idlwave-show-block t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 "*Non-nil means point blinks to block beginning for `idlwave-show-begin'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597 (defcustom idlwave-expand-generic-end nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 "*Non-nil means expand generic END to ENDIF/ENDELSE/ENDWHILE etc."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
601
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602 (defcustom idlwave-abbrev-move t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 "*Non-nil means the abbrev hook can move point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604 Set to nil by `idlwave-expand-region-abbrevs'. To see the abbrev
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 definitions, use the command `list-abbrevs', for abbrevs that move
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606 point. Moving point is useful, for example, to place point between
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607 parentheses of expanded functions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 See `idlwave-check-abbrev'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
610 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
611 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613 (defcustom idlwave-abbrev-change-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 "*Non-nil means all abbrevs will be forced to either upper or lower case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 If the value t, all expanded abbrevs will be upper case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 If the value is 'down then abbrevs will be forced to lower case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617 If nil, the case will not change.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 If `idlwave-reserved-word-upcase' is non-nil, reserved words will always be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 upper case, regardless of this variable."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
621 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
622
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
623 (defcustom idlwave-reserved-word-upcase nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 "*Non-nil means, reserved words will be made upper case via abbrev expansion.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625 If nil case of reserved words is controlled by `idlwave-abbrev-change-case'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626 Has effect only if in abbrev-mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
628 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
629
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
630 ;;; Action/Expand Tables.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
631 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
632 ;; The average user may have difficulty modifying this directly. It
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
633 ;; can be modified/set in idlwave-mode-hook, but it is easier to use
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
634 ;; idlwave-action-and-binding. See help for idlwave-action-and-binding for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
635 ;; examples of how to add an action.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
636 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
637 ;; The action table is used by `idlwave-indent-line' whereas both the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
638 ;; action and expand tables are used by `idlwave-indent-and-action'. In
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
639 ;; general, the expand table is only used when a line is explicitly
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
640 ;; indented. Whereas, in addition to being used when the expand table
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
641 ;; is used, the action table is used when a line is indirectly
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 ;; indented via line splitting, auto-filling or a new line creation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
643 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
644 ;; Example actions:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
645 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
646 ;; Capitalize system vars
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
647 ;; (idlwave-action-and-binding idlwave-sysvar '(capitalize-word 1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
648 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
649 ;; Capitalize procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
650 ;; (idlwave-action-and-binding "\\<\\(pro\\|function\\)\\>[ \t]*\\<"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
651 ;; '(capitalize-word 1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
653 ;; Capitalize common block name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
654 ;; (idlwave-action-and-binding "\\<common\\>[ \t]+\\<"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655 ;; '(capitalize-word 1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 ;; Capitalize label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
657 ;; (idlwave-action-and-binding (concat "^[ \t]*" idlwave-label)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658 ;; '(capitalize-word -1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 (defvar idlwave-indent-action-table nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661 "*Associated array containing action lists of search string (car),
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 and function as a cdr. This table is used by `idlwave-indent-line'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
663 See documentation for `idlwave-do-action' for a complete description of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 the action lists.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 Additions to the table are made with `idlwave-action-and-binding' when a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 binding is not requested.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668 See help on `idlwave-action-and-binding' for examples.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
669
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
670 (defvar idlwave-indent-expand-table nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
671 "*Associated array containing action lists of search string (car),
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
672 and function as a cdr. The table is used by the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
673 `idlwave-indent-and-action' function. See documentation for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 `idlwave-do-action' for a complete description of the action lists.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
675
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
676 Additions to the table are made with `idlwave-action-and-binding' when a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
677 binding is requested.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
678 See help on `idlwave-action-and-binding' for examples.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
679
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
680 ;;; Documentation header and history keyword ---------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
681
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
682 (defgroup idlwave-documentation nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
683 "Options for documenting IDLWAVE files."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
684 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
685
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
686 ;; FIXME: make defcustom?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
687 (defvar idlwave-file-header
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 (list nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
689 ";+
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
690 ; NAME:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
691 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
692 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694 ; PURPOSE:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
695 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698 ; CATEGORY:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
700 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
701 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
702 ; CALLING SEQUENCE:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
704 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
705 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
706 ; INPUTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
707 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
708 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
709 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
710 ; OPTIONAL INPUTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
711 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
712 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
713 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
714 ; KEYWORD PARAMETERS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
715 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
716 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
717 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
718 ; OUTPUTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
719 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
720 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722 ; OPTIONAL OUTPUTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
724 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
725 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
726 ; COMMON BLOCKS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
727 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
728 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
729 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
730 ; SIDE EFFECTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
732 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
733 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
734 ; RESTRICTIONS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
736 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
737 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738 ; PROCEDURE:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
740 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
741 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 ; EXAMPLE:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 ; MODIFICATION HISTORY:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
747 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 ;-
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
750 "*A list (PATHNAME STRING) specifying the doc-header template to use for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
751 summarizing a file. If PATHNAME is non-nil then this file will be included.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752 Otherwise STRING is used. If NIL, the file summary will be omitted.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 For example you might set PATHNAME to the path for the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
754 lib_template.pro file included in the IDL distribution.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756 (defcustom idlwave-timestamp-hook 'idlwave-default-insert-timestamp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
757 "*The hook function used to update the timestamp of a function."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
758 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
759 :type 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
760
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
761 (defcustom idlwave-doc-modifications-keyword "HISTORY"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762 "*The modifications keyword to use with the log documentation commands.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763 A ':' is added to the keyword end.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764 Inserted by doc-header and used to position logs by doc-modification.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765 If nil it will not be inserted."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
767 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
769 (defcustom idlwave-doclib-start "^;+\\+"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 "*Regexp matching the start of a document library header."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
772 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 (defcustom idlwave-doclib-end "^;+-"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 "*Regexp matching the end of a document library header."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
778
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
779 ;;; External Programs -------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
780
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
781 (defgroup idlwave-external-programs nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 "Miscellaneous options for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
784
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
785 ;; WARNING: The following variable has recently been moved from
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
786 ;; idlwave-shell.el to this file. I hope this does not break
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
787 ;; anything.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 (defcustom idlwave-shell-explicit-file-name "idl"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790 "*If non-nil, is the command to run IDL.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
791 Should be an absolute file path or path relative to the current environment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
792 execution search path."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 :group 'idlwave-external-programs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
794 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
795
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
796 ;; FIXME: Document a case when is this needed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
797 (defcustom idlwave-shell-command-line-options nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 "*A list of command line options for calling the IDL program."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
799 :type '(repeat (string :value ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
800 :group 'idlwave-external-programs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
801
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
802 (defcustom idlwave-help-application "idlhelp"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
803 "*The external application providing reference help for programming."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804 :group 'idlwave-external-programs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
805 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
806
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
807 ;;; Miscellaneous variables -------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
808
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
809 (defgroup idlwave-misc nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
810 "Miscellaneous options for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
811 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
812
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813 (defcustom idlwave-startup-message t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
814 "*Non-nil displays a startup message when `idlwave-mode' is first called."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
816 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
818 (defcustom idlwave-default-font-lock-items
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
819 '(pros-and-functions batch-files idl-keywords label goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
820 common-blocks class-arrows)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
821 "Items which should be fontified on the default fontification level 2.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
822 IDLWAVE defines 3 levels of fontification. Level 1 is very little, level 3
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 is everything and level 2 is specified by this list.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
824 This variable must be set before IDLWAVE gets loaded. It is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
825 a list of symbols, the following symbols are allowed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 pros-and-functions Procedure and Function definitions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828 batch-files Batch Files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829 idl-keywords IDL Keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
830 label Statement Labels
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
831 goto Goto Statements
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
832 common-blocks Common Blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
833 keyword-parameters Keyword Parameters in routine definitions and calls
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
834 system-variables System Variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
835 fixme FIXME: Warning in comments (on XEmacs only v. 21.0 and up)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
836 class-arrows Object Arrows with class property"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
837 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
838 :type '(set
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
839 :inline t :greedy t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
840 (const :tag "Procedure and Function definitions" pros-and-functions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
841 (const :tag "Batch Files" batch-files)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
842 (const :tag "IDL Keywords (reserved words)" idl-keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
843 (const :tag "Statement Labels" label)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
844 (const :tag "Goto Statements" goto)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
845 (const :tag "Common Blocks" common-blocks)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
846 (const :tag "Keyword Parameters" keyword-parameters)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
847 (const :tag "System Variables" system-variables)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
848 (const :tag "FIXME: Warning" fixme)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
849 (const :tag "Object Arrows with class property " class-arrows)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
850
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 (defcustom idlwave-mode-hook nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
852 "Normal hook. Executed when a buffer is put into `idlwave-mode'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
853 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
854 :type 'hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
855
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
856 (defcustom idlwave-load-hook nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
857 "Normal hook. Executed when idlwave.el is loaded."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
858 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
859 :type 'hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
860
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
861 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
862 ;;; End customization variables section
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
864
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
865 ;;; Non customization variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
867 ;;; font-lock mode - Additions by Phil Williams, Ulrik Dickow and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
868 ;;; Simon Marshall <simon@gnu.ai.mit.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
869 ;;; and Carsten Dominik...
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
870
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
871 (defconst idlwave-font-lock-keywords-1 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
872 "Subdued level highlighting for IDLWAVE mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
873
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
874 (defconst idlwave-font-lock-keywords-2 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
875 "Medium level highlighting for IDLWAVE mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
876
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
877 (defconst idlwave-font-lock-keywords-3 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
878 "Gaudy level highlighting for IDLWAVE mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
879
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
880 (let* ((oldp (or (string-match "Lucid" emacs-version)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
881 (not (boundp 'emacs-minor-version))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
882 (and (<= emacs-major-version 19)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
883 (<= emacs-minor-version 29))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
884
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
885 ;; The following are the reserved words in IDL. Maybe we should
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
886 ;; highlight some more stuff as well?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
887 (idl-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
888 ; '("and" "or" "xor" "not"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
889 ; "eq" "ge" "gt" "le" "lt" "ne"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
890 ; "for" "do" "endfor"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
891 ; "if" "then" "endif" "else" "endelse"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
892 ; "case" "of" "endcase"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
893 ; "begin" "end"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
894 ; "repeat" "until" "endrep"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
895 ; "while" "endwhile"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
896 ; "goto" "return"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
897 ; "inherits" "mod" "on_error" "on_ioerror") ;; on_error is not reserved
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
898 (concat "\\<\\("
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
899 "and\\|begin\\|case\\|do\\|e\\(lse\\|nd\\(case\\|else\\|"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
900 "for\\|if\\|rep\\|while\\)?\\|q\\)\\|for\\|g\\(oto\\|[et]\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 "\\|i\\(f\\|nherits\\)\\|l[et]\\|mod\\|n\\(e\\|ot\\)\\|"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902 "o\\(n_ioerror\\|[fr]\\)\\|re\\(peat\\|turn\\)\\|then\\|"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 "until\\|while\\|xor"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
904 "\\)\\>"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
905
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 ;; Procedure declarations. Fontify keyword plus procedure name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
907 ;; Function declarations. Fontify keyword plus function name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
908 (pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
909 '("\\<\\(function\\|pro\\)\\>[ \t]+\\(\\sw+\\(::\\sw+\\)?\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 (1 font-lock-keyword-face)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
911 (2 font-lock-function-name-face nil t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
912
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
913 ;; Common blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
914 (common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
915 '("\\<\\(common\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*,?"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
916 (1 font-lock-keyword-face) ; "common"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917 (2 font-lock-reference-face nil t) ; block name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918 (font-lock-match-c++-style-declaration-item-and-skip-to-next
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 ;; Start with point after block name and comma
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 (goto-char (match-end 0)) ; needed for XEmacs, could be nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
922 (1 font-lock-variable-name-face) ; variable names
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
923 )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
924
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
925 ;; Batch files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 (batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
927 '("^[ \t]*\\(@[^ \t\n]+\\)" (1 font-lock-string-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
928
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
929 ;; FIXME warning.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
930 (fixme
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
931 '("\\<FIXME:" (0 font-lock-warning-face t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
932
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933 ;; Labels
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934 (label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935 '("^[ \t]*\\([a-zA-Z]\\sw*:\\)" (1 font-lock-reference-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
936
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
937 ;; The goto statement and its label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
938 (goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
939 '("\\(goto\\)[ \t]*,[ \t]*\\([a-zA-Z]\\sw*\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
940 (1 font-lock-keyword-face)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
941 (2 font-lock-reference-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
942
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
943 ;; Named parameters, like /xlog or ,xrange=[]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
944 ;; This is anchored to the comma preceeding the keyword.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
945 ;; With continuation lines, works only during whole buffer fontification.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
946 (keyword-parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
947 '("[(,][ \t]*\\(\\$[ \t]*\n[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
948 (2 font-lock-reference-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
949
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
950 ;; System variables stars with a bang.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
951 (system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
952 '("\\(![a-zA-Z_]+\\(\\.\\sw+\\)?\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
953 (1 font-lock-variable-name-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
954
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
955 ;; Special and unusual operators (not used because too noisy)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
956 (special-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
957 '("[<>#]" (0 font-lock-keyword-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
958
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
959 ;; All operators (not used because too noisy)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
960 (all-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
961 '("[-*^#+<>/]" (0 font-lock-keyword-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
962
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963 ;; Arrows with text property `idlwave-class'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964 (class-arrows
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
965 (list 'idlwave-match-class-arrows
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
966 (list 0 (if (featurep 'xemacs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
967 idlwave-class-arrow-face
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
968 'idlwave-class-arrow-face))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
969
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
971
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
972 ;; The following lines are just a dummy to make the compiler shut up
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
973 ;; about variables bound but not used.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974 (setq oldp oldp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
975 idl-keywords idl-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
976 pros-and-functions pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
977 common-blocks common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
978 batch-files batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
979 fixme fixme
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
980 label label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 goto goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
982 keyword-parameters keyword-parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
983 system-variables system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
984 special-operators special-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 all-operators all-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986 class-arrows class-arrows)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
988 (setq idlwave-font-lock-keywords-1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
989 (list pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
990 batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
991 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
992
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
993 (setq idlwave-font-lock-keywords-2
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
994 (mapcar 'symbol-value idlwave-default-font-lock-items))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
995
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
996 (setq idlwave-font-lock-keywords-3
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
997 (list pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
998 batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
999 idl-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1000 label goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1001 common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1002 keyword-parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1003 system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1004 class-arrows
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1005 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1008 (defun idlwave-match-class-arrows (limit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1009 ;; Match an object arrow with class property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1010 (and idlwave-store-inquired-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011 (re-search-forward "->" limit 'limit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012 (get-text-property (match-beginning 0) 'idlwave-class)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 (defvar idlwave-font-lock-keywords idlwave-font-lock-keywords-2
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1015 "Default expressions to highlight in IDLWAVE mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1016
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1017 (defvar idlwave-font-lock-defaults
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1018 '((idlwave-font-lock-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 idlwave-font-lock-keywords-1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1020 idlwave-font-lock-keywords-2
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1021 idlwave-font-lock-keywords-3)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022 nil t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 ((?$ . "w") (?_ . "w") (?. . "w"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1024 beginning-of-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1025
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1026 (put 'idlwave-mode 'font-lock-defaults
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1027 idlwave-font-lock-defaults) ; XEmacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 (defconst idlwave-comment-line-start-skip "^[ \t]*;"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1030 "Regexp to match the start of a full-line comment.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031 That is the _beginning_ of a line containing a comment delimiter `;' preceded
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1032 only by whitespace.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1033
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1034 (defconst idlwave-begin-block-reg "\\<\\(pro\\|function\\|begin\\|case\\)\\>"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1035 "Regular expression to find the beginning of a block. The case does
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1036 not matter. The search skips matches in comments.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1037
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1038 (defconst idlwave-begin-unit-reg "\\<\\(pro\\|function\\)\\>\\|\\`"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1039 "Regular expression to find the beginning of a unit. The case does
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1040 not matter.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1041
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1042 (defconst idlwave-end-unit-reg "\\<\\(pro\\|function\\)\\>\\|\\'"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1043 "Regular expression to find the line that indicates the end of unit.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1044 This line is the end of buffer or the start of another unit. The case does
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1045 not matter. The search skips matches in comments.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1046
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1047 (defconst idlwave-continue-line-reg "\\<\\$"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1048 "Regular expression to match a continued line.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1049
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1050 (defconst idlwave-end-block-reg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1051 "\\<end\\(\\|case\\|else\\|for\\|if\\|rep\\|while\\)\\>"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052 "Regular expression to find the end of a block. The case does
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1053 not matter. The search skips matches found in comments.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1054
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 (defconst idlwave-block-matches
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1056 '(("pro" . "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1057 ("function" . "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1058 ("case" . "endcase")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1059 ("else" . "endelse")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1060 ("for" . "endfor")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1061 ("then" . "endif")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1062 ("repeat" . "endrep")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1063 ("while" . "endwhile"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1064 "Matches between statements and the corresponding END variant.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1065 The cars are the reserved words starting a block. If the block really
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1066 begins with BEGIN, the cars are the reserved words before the begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1067 which can be used to identify the block type.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 This is used to check for the correct END type, to close blocks and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069 to expand generic end statements to their detailed form.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1070
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1071 (defconst idlwave-block-match-regexp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1072 "\\<\\(else\\|for\\|then\\|repeat\\|while\\)\\>"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1073 "Regular expression matching reserved words which can stand before
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1074 blocks starting with a BEGIN statement. The matches must have associations
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1075 `idlwave-block-matches'")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 (defconst idlwave-identifier "[a-zA-Z][a-zA-Z0-9$_]*"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1078 "Regular expression matching an IDL identifier.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1079
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1080 (defconst idlwave-sysvar (concat "!" idlwave-identifier)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1081 "Regular expression matching IDL system variables.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1082
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1083 (defconst idlwave-variable (concat idlwave-identifier "\\|" idlwave-sysvar)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1084 "Regular expression matching IDL variable names.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1085
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1086 (defconst idlwave-label (concat idlwave-identifier ":")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1087 "Regular expression matching IDL labels.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1088
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1089 (defconst idlwave-statement-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1090 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1091 ;; "endif else" is the the only possible "end" that can be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1092 ;; followed by a statement on the same line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1093 '(endelse . ("end\\(\\|if\\)\\s +else" "end\\(\\|if\\)\\s +else"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 ;; all other "end"s can not be followed by a statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095 (cons 'end (list idlwave-end-block-reg nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096 '(if . ("if\\>" "then"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1097 '(for . ("for\\>" "do"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1098 '(begin . ("begin\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1099 '(pdef . ("pro\\>\\|function\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1100 '(while . ("while\\>" "do"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1101 '(repeat . ("repeat\\>" "repeat"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 '(goto . ("goto\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 '(case . ("case\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1104 (cons 'call (list (concat idlwave-identifier "\\(\\s *$\\|\\s *,\\)") nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1105 '(assign . ("[^=\n]*=" nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1107 "Associated list of statement matching regular expressions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1108 Each regular expression matches the start of an IDL statement. The
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1109 first element of each association is a symbol giving the statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1110 type. The associated value is a list. The first element of this list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1111 is a regular expression matching the start of an IDL statement for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1112 identifying the statement type. The second element of this list is a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1113 regular expression for finding a substatement for the type. The
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1114 substatement starts after the end of the found match modulo
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1115 whitespace. If it is nil then the statement has no substatement. The
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1116 list order matters since matching an assignment statement exactly is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1117 not possible without parsing. Thus assignment statement become just
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1118 the leftover unidentified statements containing and equal sign. " )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1119
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1120 (defvar idlwave-fill-function 'auto-fill-function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1121 "IDL mode auto fill function.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1122
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1123 (defvar idlwave-comment-indent-function 'comment-indent-function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1124 "IDL mode comment indent function.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1125
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1126 ;; Note that this is documented in the v18 manuals as being a string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1127 ;; of length one rather than a single character.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1128 ;; The code in this file accepts either format for compatibility.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1129 (defvar idlwave-comment-indent-char ?\
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1130 "Character to be inserted for IDL comment indentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1131 Normally a space.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1132
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1133 (defconst idlwave-continuation-char ?$
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1134 "Character which is inserted as a last character on previous line by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1135 \\[idlwave-split-line] to begin a continuation line. Normally $.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1136
27185
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
1137 (defconst idlwave-mode-version " 3.12")
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1138
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1139 (defmacro idlwave-keyword-abbrev (&rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1140 "Creates a function for abbrev hooks to call `idlwave-check-abbrev' with args."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1141 (` (quote (lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1142 (, (append '(idlwave-check-abbrev) args))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1143
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1144 ;; If I take the time I can replace idlwave-keyword-abbrev with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1145 ;; idlwave-code-abbrev and remove the quoted abbrev check from
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1146 ;; idlwave-check-abbrev. Then, e.g, (idlwave-keyword-abbrev 0 t) becomes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1147 ;; (idlwave-code-abbrev idlwave-check-abbrev 0 t). In fact I should change
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1148 ;; the name of idlwave-check-abbrev to something like idlwave-modify-abbrev.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1149
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1150 (defmacro idlwave-code-abbrev (&rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1151 "Creates a function for abbrev hooks that ensures abbrevs are not quoted.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1152 Specifically, if the abbrev is in a comment or string it is unexpanded.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1153 Otherwise ARGS forms a list that is evaluated."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1154 (` (quote (lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1155 (, (prin1-to-string args)) ;; Puts the code in the doc string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1156 (if (idlwave-quoted) (progn (unexpand-abbrev) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1157 (, (append args)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1158
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1159 (defvar idlwave-mode-map (make-sparse-keymap)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1160 "Keymap used in IDL mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1161
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1162 (defvar idlwave-mode-syntax-table (make-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1163 "Syntax table in use in `idlwave-mode' buffers.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1164
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1165 (modify-syntax-entry ?+ "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1166 (modify-syntax-entry ?- "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1167 (modify-syntax-entry ?* "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1168 (modify-syntax-entry ?/ "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1169 (modify-syntax-entry ?^ "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1170 (modify-syntax-entry ?# "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1171 (modify-syntax-entry ?= "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1172 (modify-syntax-entry ?% "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1173 (modify-syntax-entry ?< "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1174 (modify-syntax-entry ?> "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1175 (modify-syntax-entry ?\' "\"" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1176 (modify-syntax-entry ?\" "\"" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1177 (modify-syntax-entry ?\\ "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1178 (modify-syntax-entry ?_ "_" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1179 (modify-syntax-entry ?{ "(}" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1180 (modify-syntax-entry ?} "){" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1181 (modify-syntax-entry ?$ "_" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1182 (modify-syntax-entry ?. "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1183 (modify-syntax-entry ?\; "<" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1184 (modify-syntax-entry ?\n ">" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1185 (modify-syntax-entry ?\f ">" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1186
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1187 (defvar idlwave-find-symbol-syntax-table
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1188 (copy-syntax-table idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1189 "Syntax table that treats symbol characters as word characters.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1190
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1191 (modify-syntax-entry ?$ "w" idlwave-find-symbol-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1192 (modify-syntax-entry ?_ "w" idlwave-find-symbol-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1193
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1194 (defun idlwave-action-and-binding (key cmd &optional select)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1195 "KEY and CMD are made into a key binding and an indent action.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1196 KEY is a string - same as for the `define-key' function. CMD is a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1197 function of no arguments or a list to be evaluated. CMD is bound to
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1198 KEY in `idlwave-mode-map' by defining an anonymous function calling
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1199 `self-insert-command' followed by CMD. If KEY contains more than one
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1200 character a binding will only be set if SELECT is 'both.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1201
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1202 (KEY . CMD\ is also placed in the `idlwave-indent-expand-table',
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1203 replacing any previous value for KEY. If a binding is not set then it
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1204 will instead be placed in `idlwave-indent-action-table'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1205
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1206 If the optional argument SELECT is nil then an action and binding are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1207 created. If SELECT is 'noaction, then a binding is always set and no
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1208 action is created. If SELECT is 'both then an action and binding
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1209 will both be created even if KEY contains more than one character.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1210 Otherwise, if SELECT is non-nil then only an action is created.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1211
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1212 Some examples:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1213 No spaces before and 1 after a comma
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1214 (idlwave-action-and-binding \",\" '(idlwave-surround 0 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1215 A minimum of 1 space before and after `=' (see `idlwave-expand-equal').
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1216 (idlwave-action-and-binding \"=\" '(idlwave-expand-equal -1 -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1217 Capitalize system variables - action only
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1218 (idlwave-action-and-binding idlwave-sysvar '(capitalize-word 1) t)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1219 (if (not (equal select 'noaction))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1220 ;; Add action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1221 (let* ((table (if select 'idlwave-indent-action-table
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1222 'idlwave-indent-expand-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1223 (cell (assoc key (eval table))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1224 (if cell
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1225 ;; Replace action command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1226 (setcdr cell cmd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1227 ;; New action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1228 (set table (append (eval table) (list (cons key cmd)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1229 ;; Make key binding for action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1230 (if (or (and (null select) (= (length key) 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1231 (equal select 'noaction)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1232 (equal select 'both))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1233 (define-key idlwave-mode-map key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1234 (append '(lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1235 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1236 (self-insert-command 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1237 (list (if (listp cmd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1238 cmd
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1239 (list cmd)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1240
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1241 (fset 'idlwave-debug-map (make-sparse-keymap))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1242
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1243 (define-key idlwave-mode-map "'" 'idlwave-show-matching-quote)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1244 (define-key idlwave-mode-map "\"" 'idlwave-show-matching-quote)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1245 (define-key idlwave-mode-map "\C-c;" 'idlwave-toggle-comment-region)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1246 (define-key idlwave-mode-map "\C-\M-a" 'idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1247 (define-key idlwave-mode-map "\C-\M-e" 'idlwave-end-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1248 (define-key idlwave-mode-map "\C-c{" 'idlwave-beginning-of-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1249 (define-key idlwave-mode-map "\C-c}" 'idlwave-end-of-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1250 (define-key idlwave-mode-map "\C-c]" 'idlwave-close-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1251 (define-key idlwave-mode-map "\M-\C-h" 'idlwave-mark-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1252 (define-key idlwave-mode-map "\M-\C-n" 'idlwave-forward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1253 (define-key idlwave-mode-map "\M-\C-p" 'idlwave-backward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1254 (define-key idlwave-mode-map "\M-\C-d" 'idlwave-down-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1255 (define-key idlwave-mode-map "\M-\C-u" 'idlwave-backward-up-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1256 (define-key idlwave-mode-map "\M-\r" 'idlwave-split-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1257 (define-key idlwave-mode-map "\M-\C-q" 'idlwave-indent-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1258 (define-key idlwave-mode-map "\C-c\C-p" 'idlwave-previous-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1259 (define-key idlwave-mode-map "\C-c\C-n" 'idlwave-next-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1260 ;; (define-key idlwave-mode-map "\r" 'idlwave-newline)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1261 ;; (define-key idlwave-mode-map "\t" 'idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1262 (define-key idlwave-mode-map "\C-c\C-a" 'idlwave-auto-fill-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1263 (define-key idlwave-mode-map "\M-q" 'idlwave-fill-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1264 (define-key idlwave-mode-map "\M-s" 'idlwave-edit-in-idlde)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1265 (define-key idlwave-mode-map "\C-c\C-h" 'idlwave-doc-header)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1266 (define-key idlwave-mode-map "\C-c\C-m" 'idlwave-doc-modification)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1267 (define-key idlwave-mode-map "\C-c\C-c" 'idlwave-case)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1268 (define-key idlwave-mode-map "\C-c\C-d" 'idlwave-debug-map)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1269 (define-key idlwave-mode-map "\C-c\C-d\C-c" 'idlwave-shell-save-and-run)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1270 (define-key idlwave-mode-map "\C-c\C-f" 'idlwave-for)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1271 ;; (define-key idlwave-mode-map "\C-c\C-f" 'idlwave-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1272 ;; (define-key idlwave-mode-map "\C-c\C-p" 'idlwave-procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1273 (define-key idlwave-mode-map "\C-c\C-r" 'idlwave-repeat)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1274 (define-key idlwave-mode-map "\C-c\C-w" 'idlwave-while)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1275 (define-key idlwave-mode-map "\C-c\C-s" 'idlwave-shell)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1276 (define-key idlwave-mode-map "\C-c\C-l" 'idlwave-shell-recenter-shell-window)
27185
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
1277 (autoload 'idlwave-shell "idlw-shell"
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
1278 "Run an inferior IDL, with I/O through buffer `(idlwave-shell-buffer)'." t)
27107
7b2b73f13427 Renamed idlwave-*.el into idlw-*.el.
Eli Zaretskii <eliz@gnu.org>
parents: 26956
diff changeset
1279 (autoload 'idlwave-shell-send-command "idlw-shell")
7b2b73f13427 Renamed idlwave-*.el into idlw-*.el.
Eli Zaretskii <eliz@gnu.org>
parents: 26956
diff changeset
1280 (autoload 'idlwave-shell-recenter-shell-window "idlw-shell"
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1281 "Run `idlwave-shell' and switch back to current window" t)
27107
7b2b73f13427 Renamed idlwave-*.el into idlw-*.el.
Eli Zaretskii <eliz@gnu.org>
parents: 26956
diff changeset
1282 (autoload 'idlwave-shell-save-and-run "idlw-shell"
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1283 "Save and run buffer under the shell." t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1284 (define-key idlwave-mode-map "\C-c\C-v" 'idlwave-find-module)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1285 (define-key idlwave-mode-map "\C-c?" 'idlwave-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1286 (define-key idlwave-mode-map "\M-?" 'idlwave-routine-info-from-idlhelp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1287 (define-key idlwave-mode-map [(meta tab)] 'idlwave-complete)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1288 (define-key idlwave-mode-map "\C-c\C-i" 'idlwave-update-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1289 (define-key idlwave-mode-map "\C-c=" 'idlwave-resolve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1290
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1291 ;; Set action and key bindings.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1292 ;; See description of the function `idlwave-action-and-binding'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1293 ;; Automatically add spaces for the following characters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1294 (idlwave-action-and-binding "&" '(idlwave-surround -1 -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1295 (idlwave-action-and-binding "<" '(idlwave-surround -1 -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1296 (idlwave-action-and-binding ">" '(idlwave-surround -1 -1 '(?-)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1297 (idlwave-action-and-binding "," '(idlwave-surround 0 -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1298 ;; Automatically add spaces to equal sign if not keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1299 (idlwave-action-and-binding "=" '(idlwave-expand-equal -1 -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1300
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1301 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1302 ;;; Abbrev Section
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1303 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1304 ;;; When expanding abbrevs and the abbrev hook moves backward, an extra
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1305 ;;; space is inserted (this is the space typed by the user to expanded
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1306 ;;; the abbrev).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1307 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1308
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1309 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1310 (modify-syntax-entry (string-to-char idlwave-abbrev-start-char)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1311 "w" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1312 (error nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1313
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1314 (defvar idlwave-mode-abbrev-table nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1315 "Abbreviation table used for IDLWAVE mode")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1316 (define-abbrev-table 'idlwave-mode-abbrev-table ())
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1317 (let ((abbrevs-changed nil) ;; mask the current value to avoid save
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1318 (tb idlwave-mode-abbrev-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1319 (c idlwave-abbrev-start-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1320 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1321 ;; Templates
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1322 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1323 (define-abbrev tb (concat c "c") "" (idlwave-code-abbrev idlwave-case))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1324 (define-abbrev tb (concat c "f") "" (idlwave-code-abbrev idlwave-for))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1325 (define-abbrev tb (concat c "fu") "" (idlwave-code-abbrev idlwave-function))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1326 (define-abbrev tb (concat c "pr") "" (idlwave-code-abbrev idlwave-procedure))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1327 (define-abbrev tb (concat c "r") "" (idlwave-code-abbrev idlwave-repeat))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1328 (define-abbrev tb (concat c "w") "" (idlwave-code-abbrev idlwave-while))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1329 (define-abbrev tb (concat c "i") "" (idlwave-code-abbrev idlwave-if))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1330 (define-abbrev tb (concat c "elif") "" (idlwave-code-abbrev idlwave-elif))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1331 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1332 ;; Keywords, system functions, conversion routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1333 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1334 (define-abbrev tb (concat c "b") "begin" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1335 (define-abbrev tb (concat c "co") "common" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1336 (define-abbrev tb (concat c "cb") "byte()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1337 (define-abbrev tb (concat c "cx") "fix()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1338 (define-abbrev tb (concat c "cl") "long()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1339 (define-abbrev tb (concat c "cf") "float()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1340 (define-abbrev tb (concat c "cs") "string()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1341 (define-abbrev tb (concat c "cc") "complex()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1342 (define-abbrev tb (concat c "cd") "double()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1343 (define-abbrev tb (concat c "e") "else" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1344 (define-abbrev tb (concat c "ec") "endcase" 'idlwave-show-begin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1345 (define-abbrev tb (concat c "ee") "endelse" 'idlwave-show-begin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1346 (define-abbrev tb (concat c "ef") "endfor" 'idlwave-show-begin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1347 (define-abbrev tb (concat c "ei") "endif else if" 'idlwave-show-begin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1348 (define-abbrev tb (concat c "el") "endif else" 'idlwave-show-begin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1349 (define-abbrev tb (concat c "en") "endif" 'idlwave-show-begin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1350 (define-abbrev tb (concat c "er") "endrep" 'idlwave-show-begin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1351 (define-abbrev tb (concat c "ew") "endwhile" 'idlwave-show-begin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1352 (define-abbrev tb (concat c "g") "goto," (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1353 (define-abbrev tb (concat c "h") "help," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1354 (define-abbrev tb (concat c "k") "keyword_set()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1355 (define-abbrev tb (concat c "n") "n_elements()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1356 (define-abbrev tb (concat c "on") "on_error," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1357 (define-abbrev tb (concat c "oi") "on_ioerror," (idlwave-keyword-abbrev 0 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1358 (define-abbrev tb (concat c "ow") "openw," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1359 (define-abbrev tb (concat c "or") "openr," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1360 (define-abbrev tb (concat c "ou") "openu," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1361 (define-abbrev tb (concat c "p") "print," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1362 (define-abbrev tb (concat c "pt") "plot," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1363 (define-abbrev tb (concat c "re") "read," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1364 (define-abbrev tb (concat c "rf") "readf," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1365 (define-abbrev tb (concat c "ru") "readu," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1366 (define-abbrev tb (concat c "rt") "return" (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1367 (define-abbrev tb (concat c "sc") "strcompress()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1368 (define-abbrev tb (concat c "sn") "strlen()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1369 (define-abbrev tb (concat c "sl") "strlowcase()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1370 (define-abbrev tb (concat c "su") "strupcase()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1371 (define-abbrev tb (concat c "sm") "strmid()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1372 (define-abbrev tb (concat c "sp") "strpos()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1373 (define-abbrev tb (concat c "st") "strput()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1374 (define-abbrev tb (concat c "sr") "strtrim()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1375 (define-abbrev tb (concat c "t") "then" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1376 (define-abbrev tb (concat c "u") "until" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1377 (define-abbrev tb (concat c "wu") "writeu," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1378 (define-abbrev tb (concat c "ine") "if n_elements() eq 0 then"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1379 (idlwave-keyword-abbrev 11))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1380 (define-abbrev tb (concat c "inn") "if n_elements() ne 0 then"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1381 (idlwave-keyword-abbrev 11))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1382 (define-abbrev tb (concat c "np") "n_params()" (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1383 (define-abbrev tb (concat c "s") "size()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1384 (define-abbrev tb (concat c "wi") "widget_info()" (idlwave-keyword-abbrev 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1385 (define-abbrev tb (concat c "wc") "widget_control," (idlwave-keyword-abbrev 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1386
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1387 ;; This section is reserved words only. (From IDL user manual)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1388 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1389 (define-abbrev tb "and" "and" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1390 (define-abbrev tb "begin" "begin" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1391 (define-abbrev tb "case" "case" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1392 (define-abbrev tb "common" "common" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1393 (define-abbrev tb "do" "do" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1394 (define-abbrev tb "else" "else" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1395 (define-abbrev tb "end" "end" 'idlwave-show-begin-check)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1396 (define-abbrev tb "endcase" "endcase" 'idlwave-show-begin-check)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1397 (define-abbrev tb "endelse" "endelse" 'idlwave-show-begin-check)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1398 (define-abbrev tb "endfor" "endfor" 'idlwave-show-begin-check)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1399 (define-abbrev tb "endif" "endif" 'idlwave-show-begin-check)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1400 (define-abbrev tb "endrep" "endrep" 'idlwave-show-begin-check)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1401 (define-abbrev tb "endwhi" "endwhi" 'idlwave-show-begin-check)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1402 (define-abbrev tb "endwhile" "endwhile" 'idlwave-show-begin-check)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1403 (define-abbrev tb "eq" "eq" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1404 (define-abbrev tb "for" "for" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1405 (define-abbrev tb "function" "function" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1406 (define-abbrev tb "ge" "ge" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1407 (define-abbrev tb "goto" "goto" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1408 (define-abbrev tb "gt" "gt" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1409 (define-abbrev tb "if" "if" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1410 (define-abbrev tb "le" "le" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1411 (define-abbrev tb "lt" "lt" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1412 (define-abbrev tb "mod" "mod" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1413 (define-abbrev tb "ne" "ne" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1414 (define-abbrev tb "not" "not" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1415 (define-abbrev tb "of" "of" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1416 (define-abbrev tb "on_ioerror" "on_ioerror" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1417 (define-abbrev tb "or" "or" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1418 (define-abbrev tb "pro" "pro" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1419 (define-abbrev tb "repeat" "repeat" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1420 (define-abbrev tb "then" "then" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1421 (define-abbrev tb "until" "until" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1422 (define-abbrev tb "while" "while" (idlwave-keyword-abbrev 0 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1423 (define-abbrev tb "xor" "xor" (idlwave-keyword-abbrev 0 t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1424
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1425 (defvar imenu-create-index-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1426 (defvar extract-index-name-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1427 (defvar prev-index-position-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1428 (defvar imenu-extract-index-name-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1429 (defvar imenu-prev-index-position-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1430 ;; defined later - so just make the compiler shut up
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1431 (defvar idlwave-mode-menu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1432 (defvar idlwave-mode-debug-menu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1433
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1434 ;;;###autoload
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1435 (defun idlwave-mode ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1436 "Major mode for editing IDL and WAVE CL .pro files.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1437
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1438 The main features of this mode are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1439
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1440 1. Indentation and Formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1441 --------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1442 Like other Emacs programming modes, C-j inserts a newline and indents.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1443 TAB is used for explicit indentation of the current line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1444
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1445 To start a continuation line, use \\[idlwave-split-line]. This function can also
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1446 be used in the middle of a line to split the line at that point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1447 When used inside a long constant string, the string is split at
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1448 that point with the `+' concatenation operator.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1449
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1450 Comments are indented as follows:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1451
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1452 `;;;' Indentation remains unchanged.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1453 `;;' Indent like the surrounding code
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1454 `;' Indent to a minimum column.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1455
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1456 The indentation of comments starting in column 0 is never changed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1457
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1458 Use \\[idlwave-fill-paragraph] to refill a paragraph inside a comment. The indentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1459 of the second line of the paragraph relative to the first will be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1460 retained. Use \\[idlwave-auto-fill-mode] to toggle auto-fill mode for these comments.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1461 When the variable `idlwave-fill-comment-line-only' is nil, code
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1462 can also be auto-filled and auto-indented (not recommended).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1463
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1464 To convert pre-existing IDL code to your formatting style, mark the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1465 entire buffer with \\[mark-whole-buffer] and execute \\[idlwave-expand-region-abbrevs].
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1466 Then mark the entire buffer again followed by \\[indent-region] (`indent-region').
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1467
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1468 2. Routine Info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1469 ------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1470 IDLWAVE displays information about the calling sequence and the accepted
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1471 keyword parameters of a procedure or function with \\[idlwave-routine-info].
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1472 \\[idlwave-find-module] jumps to the source file of a module.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1473 These commands know about system routines, all routines in idlwave-mode
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1474 buffers and (when the idlwave-shell is active) about all modules
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1475 currently compiled under this shell. Use \\[idlwave-update-routine-info] to update this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1476 information, which is also used for completion (see next item).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1477
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1478 3. Completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1479 ----------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1480 \\[idlwave-complete] completes the names of procedures, functions and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1481 keyword parameters. It is context sensitive and figures out what
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1482 is expected at point (procedure/function/keyword). Lower case
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1483 strings are completed in lower case, other strings in mixed or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1484 upper case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1485
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1486 4. Code Templates and Abbreviations
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1487 --------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1488 Many Abbreviations are predefined to expand to code fragments and templates.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1489 The abbreviations start generally with a `\\`. Some examples
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1490
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1491 \\pr PROCEDURE template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1492 \\fu FUNCTION template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1493 \\c CASE statement template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1494 \\f FOR loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1495 \\r REPEAT Loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1496 \\w WHILE loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1497 \\i IF statement template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1498 \\elif IF-ELSE statement template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1499 \\b BEGIN
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1500
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1501 For a full list, use \\[idlwave-list-abbrevs]. Some templates also have
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1502 direct keybindings - see the list of keybindings below.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1503
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1504 \\[idlwave-doc-header] inserts a documentation header at the beginning of the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1505 current program unit (pro, function or main). Change log entries
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1506 can be added to the current program unit with \\[idlwave-doc-modification].
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1507
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1508 5. Automatic Case Conversion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1509 -------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1510 The case of reserved words and some abbrevs is controlled by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1511 `idlwave-reserved-word-upcase' and `idlwave-abbrev-change-case'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1512
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1513 6. Automatic END completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1514 ------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1515 If the variable `idlwave-expand-generic-end' is non-nil, each END typed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1516 will be converted to the specific version, like ENDIF, ENDFOR, etc.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1517
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1518 7. Hooks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1519 -----
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1520 Loading idlwave.el runs `idlwave-load-hook'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1521 Turning on `idlwave-mode' runs `idlwave-mode-hook'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1522
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1523 8. Documentation and Customization
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1524 -------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1525 Info documentation for this package is available. Use \\[idlwave-info]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1526 to display (complain to your sysadmin if that does not work).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1527 For Postscript and HTML versions of the documentation, check IDLWAVE's
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1528 homepage at `http://www.strw.leidenuniv.nl/~dominik/Tools/idlwave'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1529 IDLWAVE has customize support - see the group `idlwave'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1530
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1531 9. Keybindings
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1532 -----------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1533 Here is a list of all keybindings of this mode.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1534 If some of the key bindings below show with ??, use \\[describe-key]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1535 followed by the key sequence to see what the key sequence does.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1536
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1537 \\{idlwave-mode-map}"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1538
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1539 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1540 (kill-all-local-variables)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1541
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1542 (if idlwave-startup-message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1543 (message "Emacs IDLWAVE mode version %s." idlwave-mode-version))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1544 (setq idlwave-startup-message nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1545
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1546 (setq local-abbrev-table idlwave-mode-abbrev-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1547 (set-syntax-table idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1548
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1549 (set (make-local-variable 'indent-line-function) 'idlwave-indent-and-action)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1550
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1551 (make-local-variable idlwave-comment-indent-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1552 (set idlwave-comment-indent-function 'idlwave-comment-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1553
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1554 (set (make-local-variable 'comment-start-skip) ";+[ \t]*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1555 (set (make-local-variable 'comment-start) ";")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1556 (set (make-local-variable 'require-final-newline) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1557 (set (make-local-variable 'abbrev-all-caps) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1558 (set (make-local-variable 'indent-tabs-mode) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1559 (set (make-local-variable 'completion-ignore-case) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1560
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1561 (use-local-map idlwave-mode-map)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1562
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1563 (when (featurep 'easymenu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1564 (easy-menu-add idlwave-mode-menu idlwave-mode-map)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1565 (easy-menu-add idlwave-mode-debug-menu idlwave-mode-map))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1566
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1567 (setq mode-name "IDLWAVE")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1568 (setq major-mode 'idlwave-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1569 (setq abbrev-mode t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1570
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1571 (set (make-local-variable idlwave-fill-function) 'idlwave-auto-fill)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1572 (setq comment-end "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1573 (set (make-local-variable 'comment-multi-line) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1574 (set (make-local-variable 'paragraph-separate) "[ \t\f]*$\\|[ \t]*;+[ \t]*$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1575 (set (make-local-variable 'paragraph-start) "[ \t\f]\\|[ \t]*;+[ \t]")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1576 (set (make-local-variable 'paragraph-ignore-fill-prefix) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1577 (set (make-local-variable 'parse-sexp-ignore-comments) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1578
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1579 ;; Set tag table list to use IDLTAGS as file name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1580 (if (boundp 'tag-table-alist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1581 (add-to-list 'tag-table-alist '("\\.pro$" . "IDLTAGS")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1582
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1583 ;; Font-lock additions - originally Phil Williams, then Ulrik Dickow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1584 ;; Following line is for Emacs - XEmacs uses the corresponding porperty
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1585 ;; on the `idlwave-mode' symbol.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1586 (set (make-local-variable 'font-lock-defaults) idlwave-font-lock-defaults)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1587
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1588 ;; Imenu setup
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1589 (set (make-local-variable 'imenu-create-index-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1590 'imenu-default-create-index-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1591 (set (make-local-variable 'imenu-extract-index-name-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1592 'idlwave-unit-name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1593 (set (make-local-variable 'imenu-prev-index-position-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1594 'idlwave-prev-index-position)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1595
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1596 ;; Make a local post-command-hook and add our hook to it
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1597 (make-local-hook 'post-command-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1598 (add-hook 'post-command-hook 'idlwave-command-hook nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1599
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1600 ;; Run the mode hook
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1601 (run-hooks 'idlwave-mode-hook))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1602
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1603 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1604 ;; Done with start up and initialization code.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1605 ;; The remaining routines are the code formatting functions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1606 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1607
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1608 (defun idlwave-push-mark (&rest rest)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1609 "Push mark for compatibility with Emacs 18/19."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1610 (if (fboundp 'iconify-frame)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1611 (apply 'push-mark rest)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1612 (push-mark)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1613
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1614 (defun idlwave-hard-tab ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1615 "Inserts TAB in buffer in current position."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1616 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1617 (insert "\t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1618
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1619 ;;; This stuff is experimental
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1620
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1621 (defvar idlwave-command-hook nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1622 "If non-nil, a list that can be evaluated using `eval'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1623 It is evaluated in the lisp function `idlwave-command-hook' which is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1624 placed in `post-command-hook'.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1625
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1626 (defun idlwave-command-hook ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1627 "Command run after every command.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1628 Evaluates a non-nil value of the *variable* `idlwave-command-hook' and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1629 sets the variable to zero afterwards."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1630 (and idlwave-command-hook
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1631 (listp idlwave-command-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1632 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1633 (eval idlwave-command-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1634 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1635 (setq idlwave-command-hook nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1636
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1637 ;;; End experiment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1638
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1639 ;; It would be better to use expand.el for better abbrev handling and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1640 ;; versatility.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1641
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1642 (defun idlwave-check-abbrev (arg &optional reserved)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1643 "Reverses abbrev expansion if in comment or string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1644 Argument ARG is the number of characters to move point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1645 backward if `idlwave-abbrev-move' is non-nil.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1646 If optional argument RESERVED is non-nil then the expansion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1647 consists of reserved words, which will be capitalized if
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1648 `idlwave-reserved-word-upcase' is non-nil.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1649 Otherwise, the abbrev will be capitalized if `idlwave-abbrev-change-case'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1650 is non-nil, unless its value is \`down in which case the abbrev will be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1651 made into all lowercase.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1652 Returns non-nil if abbrev is left expanded."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1653 (if (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1654 (progn (unexpand-abbrev)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1655 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1656 (if (and reserved idlwave-reserved-word-upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1657 (upcase-region last-abbrev-location (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1658 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1659 ((equal idlwave-abbrev-change-case 'down)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1660 (downcase-region last-abbrev-location (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1661 (idlwave-abbrev-change-case
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1662 (upcase-region last-abbrev-location (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1663 (if (and idlwave-abbrev-move (> arg 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1664 (if (boundp 'post-command-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1665 (setq idlwave-command-hook (list 'backward-char (1+ arg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1666 (backward-char arg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1667 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1668
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1669 (defun idlwave-in-comment ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1670 "Returns t if point is inside a comment, nil otherwise."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1671 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1672 (let ((here (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1673 (and (idlwave-goto-comment) (> here (point))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1674
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1675 (defun idlwave-goto-comment ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1676 "Move to start of comment delimiter on current line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1677 Moves to end of line if there is no comment delimiter.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1678 Ignores comment delimiters in strings.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1679 Returns point if comment found and nil otherwise."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1680 (let ((eos (progn (end-of-line) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1681 (data (match-data))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1682 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1683 ;; Look for first comment delimiter not in a string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1684 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1685 (setq found (search-forward comment-start eos 'lim))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1686 (while (and found (idlwave-in-quote))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1687 (setq found (search-forward comment-start eos 'lim)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1688 (store-match-data data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1689 (and found (not (idlwave-in-quote))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1690 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1691 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1692 (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1693
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1694 (defun idlwave-show-matching-quote ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1695 "Insert quote and show matching quote if this is end of a string."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1696 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1697 (let ((bq (idlwave-in-quote))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1698 (inq last-command-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1699 (if (and bq (not (idlwave-in-comment)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1700 (let ((delim (char-after bq)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1701 (insert inq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1702 (if (eq inq delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1703 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1704 (goto-char bq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1705 (sit-for 1))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1706 ;; Not the end of a string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1707 (insert inq))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1708
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1709 (defun idlwave-show-begin-check ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1710 "Ensure that the previous word was a token before `idlwave-show-begin'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1711 An END token must be preceded by whitespace."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1712 (if
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1713 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1714 (backward-word 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1715 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1716 (looking-at "[ \t\n\f]"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1717 (idlwave-show-begin)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1718
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1719 (defun idlwave-show-begin ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1720 "Finds the start of current block and blinks to it for a second.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1721 Also checks if the correct end statement has been used."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1722 ;; All end statements are reserved words
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1723 (let* ((pos (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1724 end end1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1725 (when (and (idlwave-check-abbrev 0 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1726 idlwave-show-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1727 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1728 ;; Move inside current block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1729 (setq end (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1730 (save-excursion (skip-chars-backward "a-zA-Z")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1731 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1732 (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1733 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1734 (idlwave-block-jump-out -1 'nomark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1735 (when (setq end1 (cdr (idlwave-block-master)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1736 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1737 ((null end1)) ; no-opeartion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1738 ((string= (downcase end) (downcase end1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1739 (sit-for 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1740 ((string= (downcase end) "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1741 ;; A generic end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1742 (if idlwave-expand-generic-end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1743 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1744 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1745 (backward-char 3)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1746 (insert (if (string= end "END") (upcase end1) end1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1747 (delete-char 3)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1748 (sit-for 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1749 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1750 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1751 (message "Warning: Shouldn't this be \"%s\" instead of \"%s\"?"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1752 end1 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1753 (sit-for 1))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1754
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1755 (defun idlwave-block-master ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1756 (let ((case-fold-search t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1757 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1758 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1759 ((looking-at "pro\\|case\\|function\\>")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1760 (assoc (downcase (match-string 0)) idlwave-block-matches))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1761 ((looking-at "begin\\>")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1762 (let ((limit (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1763 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1764 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1765 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1766 ((re-search-backward idlwave-block-match-regexp limit t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1767 (assoc (downcase (match-string 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1768 idlwave-block-matches))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1769 ;;((re-search-backward ":[ \t]*\\=" limit t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1770 ;; ;; seems to be a case thing
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1771 ;; '("begin" . "end"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1772 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1773 ;; Just a nromal block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1774 '("begin" . "end")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1775 (t nil)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1776
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1777 (defun idlwave-close-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1778 "Terminate the current block with the correct END statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1779 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1780
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1781 ;; Start new line if we are not in a new line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1782 (unless (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1783 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1784 (bolp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1785 (let ((idlwave-show-block nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1786 (newline-and-indent)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1787
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1788 ;; Check which end is needed and insert it.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1789 (let ((case-fold-search t) end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1790 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1791 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1792 (idlwave-block-jump-out -1 'nomark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1793 (if (setq end (idlwave-block-master))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1794 (setq end (cdr end))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1795 (error "Cannot close block")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1796 (insert end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1797 (idlwave-newline)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1798
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1799 (defun idlwave-surround (&optional before after escape-chars)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1800 "Surround the character before point with blanks.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1801 Optional arguments BEFORE and AFTER affect the behavior before and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1802 after the previous character. See description of `idlwave-make-space'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1803
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1804 The function does nothing if any of the following conditions is true:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1805 - `idlwave-surround-by-blank' is nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1806 - the character before point is inside a string or comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1807
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1808 When the character 2 positions before point is a member of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1809 ESCAPE-CHARS, BEFORE is forced to nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1810
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1811 (if (and idlwave-surround-by-blank
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1812 (not (idlwave-quoted)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1813 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1814 (if (memq (char-after (- (point) 2)) escape-chars)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1815 (setq before nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1816 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1817 (save-restriction
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1818 (let ((here (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1819 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1820 (if (bolp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1821 ;; avoid clobbering indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1822 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1823 (move-to-column (idlwave-calculate-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1824 (if (<= (point) here)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1825 (narrow-to-region (point) here))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1826 (goto-char here)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1827 (idlwave-make-space before))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1828 (skip-chars-forward " \t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1829 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1830 (idlwave-make-space after)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1831 ;; Check to see if the line should auto wrap
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1832 (if (and (equal (char-after (1- (point))) ? )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1833 (> (current-column) fill-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1834 (funcall auto-fill-function)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1835
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1836 (defun idlwave-make-space (n)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1837 "Make space at point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1838 The space affected is all the spaces and tabs around point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1839 If n is non-nil then point is left abs(n) spaces from the beginning of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1840 the contiguous space.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1841 The amount of space at point is determined by N.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1842 If the value of N is:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1843 nil - do nothing.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1844 c > 0 - exactly c spaces.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1845 c < 0 - a minimum of -c spaces, i.e., do not change if there are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1846 already -c spaces.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1847 0 - no spaces."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1848 (if (integerp n)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1849 (let
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1850 ((start-col (progn (skip-chars-backward " \t") (current-column)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1851 (left (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1852 (end-col (progn (skip-chars-forward " \t") (current-column))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1853 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1854 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1855 ((> n 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1856 (idlwave-indent-to (+ start-col n))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1857 (goto-char (+ left n)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1858 ((< n 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1859 (idlwave-indent-to end-col (- n))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1860 (goto-char (- left n)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1861 ;; n = 0, done
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1862 ))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1863
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1864 (defun idlwave-newline ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1865 "Inserts a newline and indents the current and previous line."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1866 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1867 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1868 ;; Handle unterminated single and double quotes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1869 ;; If not in a comment and in a string then insertion of a newline
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1870 ;; will mean unbalanced quotes.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1871 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1872 (if (and (not (idlwave-in-comment)) (idlwave-in-quote))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1873 (progn (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1874 (message "Warning: unbalanced quotes?")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1875 (newline)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1876 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1877 ;; The current line is being split, the cursor should be at the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1878 ;; beginning of the new line skipping the leading indentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1879 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1880 ;; The reason we insert the new line before indenting is that the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1881 ;; indenting could be confused by keywords (e.g. END) on the line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1882 ;; after the split point. This prevents us from just using
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1883 ;; `indent-for-tab-command' followed by `newline-and-indent'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1884 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1885 (beginning-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1886 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1887 (forward-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1888 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1889
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1890 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1891 ;; Use global variable 'comment-column' to set parallel comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1892 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1893 ;; Modeled on lisp.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1894 ;; Emacs Lisp and IDL (Wave CL) have identical comment syntax
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1895 (defun idlwave-comment-hook ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1896 "Compute indent for the beginning of the IDL comment delimiter."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1897 (if (or (looking-at idlwave-no-change-comment)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1898 (if idlwave-begin-line-comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1899 (looking-at idlwave-begin-line-comment)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1900 (looking-at "^;")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1901 (current-column)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1902 (if (looking-at idlwave-code-comment)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1903 (if (save-excursion (skip-chars-backward " \t") (bolp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1904 ;; On line by itself, indent as code
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1905 (let ((tem (idlwave-calculate-indent)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1906 (if (listp tem) (car tem) tem))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1907 ;; after code - do not change
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1908 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1909 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1910 (max (if (bolp) 0 (1+ (current-column)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1911 comment-column))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1912
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1913 (defun idlwave-split-line ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1914 "Continue line by breaking line at point and indent the lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1915 For a code line insert continuation marker. If the line is a line comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1916 then the new line will contain a comment with the same indentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1917 Splits strings with the IDL operator `+' if `idlwave-split-line-string' is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1918 non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1919 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1920 (let (beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1921 (if (not (idlwave-in-comment))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1922 ;; For code line add continuation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1923 ;; Check if splitting a string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1924 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1925 (if (setq beg (idlwave-in-quote))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1926 (if idlwave-split-line-string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1927 ;; Split the string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1928 (progn (insert (setq beg (char-after beg)) " + "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1929 idlwave-continuation-char beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1930 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1931 ;; Do not split the string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1932 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1933 (message "Warning: continuation inside string!!")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1934 (insert " " idlwave-continuation-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1935 ;; Not splitting a string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1936 (insert " " idlwave-continuation-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1937 (newline-and-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1938 (indent-new-comment-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1939 ;; Indent previous line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1940 (setq beg (- (point-max) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1941 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1942 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1943 (goto-char (- (point-max) beg))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1944 ;; Reindent new line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1945 (idlwave-indent-line)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1946
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1947 (defun idlwave-beginning-of-subprogram ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1948 "Moves point to the beginning of the current program unit."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1949 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1950 (idlwave-find-key idlwave-begin-unit-reg -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1951
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1952 (defun idlwave-end-of-subprogram ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1953 "Moves point to the start of the next program unit."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1954 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1955 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1956 (idlwave-find-key idlwave-end-unit-reg 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1957
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1958 (defun idlwave-mark-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1959 "Mark current IDL statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1960 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1961 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1962 (let ((end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1963 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1964 (idlwave-push-mark end nil t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1965
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1966 (defun idlwave-mark-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1967 "Mark containing block."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1968 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1969 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1970 (idlwave-backward-up-block -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1971 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1972 (let ((end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1973 (idlwave-backward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1974 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1975 (idlwave-push-mark end nil t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1976
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1977
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1978 (defun idlwave-mark-subprogram ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1979 "Put mark at beginning of program, point at end.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1980 The marks are pushed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1981 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1982 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1983 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1984 (let ((beg (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1985 (idlwave-forward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1986 (idlwave-push-mark beg nil t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1987 (exchange-point-and-mark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1988
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1989 (defun idlwave-backward-up-block (&optional arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1990 "Move to beginning of enclosing block if prefix ARG >= 0.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1991 If prefix ARG < 0 then move forward to enclosing block end."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1992 (interactive "p")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1993 (idlwave-block-jump-out (- arg) 'nomark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1994
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1995 (defun idlwave-beginning-of-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1996 "Go to the beginning of the current block."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1997 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1998 (idlwave-block-jump-out -1 'nomark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1999 (forward-word 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2000
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2001 (defun idlwave-end-of-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2002 "Go to the beginning of the current block."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2003 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2004 (idlwave-block-jump-out 1 'nomark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2005 (backward-word 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2006
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2007 (defun idlwave-forward-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2008 "Move across next nested block."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2009 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2010 (if (idlwave-down-block 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2011 (idlwave-block-jump-out 1 'nomark)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2012
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2013 (defun idlwave-backward-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2014 "Move backward across previous nested block."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2015 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2016 (if (idlwave-down-block -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2017 (idlwave-block-jump-out -1 'nomark)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2018
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2019 (defun idlwave-down-block (&optional arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2020 "Go down a block.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2021 With ARG: ARG >= 0 go forwards, ARG < 0 go backwards.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2022 Returns non-nil if successfull."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2023 (interactive "p")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2024 (let (status)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2025 (if (< arg 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2026 ;; Backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2027 (let ((eos (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2028 (idlwave-block-jump-out -1 'nomark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2029 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2030 (if (setq status (idlwave-find-key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2031 idlwave-end-block-reg -1 'nomark eos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2032 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2033 (message "No nested block before beginning of containing block.")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2034 ;; Forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2035 (let ((eos (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2036 (idlwave-block-jump-out 1 'nomark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2037 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2038 (if (setq status (idlwave-find-key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2039 idlwave-begin-block-reg 1 'nomark eos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2040 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2041 (message "No nested block before end of containing block."))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2042 status))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2043
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2044 (defun idlwave-mark-doclib ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2045 "Put point at beginning of doc library header, mark at end.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2046 The marks are pushed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2047 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2048 (let (beg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2049 (here (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2050 (goto-char (point-max))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2051 (if (re-search-backward idlwave-doclib-start nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2052 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2053 (setq beg (progn (beginning-of-line) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2054 (if (re-search-forward idlwave-doclib-end nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2055 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2056 (forward-line 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2057 (idlwave-push-mark beg nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2058 (message "Could not find end of doc library header.")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2059 (message "Could not find doc library header start.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2060 (goto-char here)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2061
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2062 (defvar idlwave-shell-prompt-pattern)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2063 (defun idlwave-beginning-of-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2064 "Move to beginning of the current statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2065 Skips back past statement continuations.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2066 Point is placed at the beginning of the line whether or not this is an
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2067 actual statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2068 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2069 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2070 ((eq major-mode 'idlwave-shell-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2071 (if (re-search-backward idlwave-shell-prompt-pattern nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2072 (goto-char (match-end 0))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2073 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2074 (if (save-excursion (forward-line -1) (idlwave-is-continuation-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2075 (idlwave-previous-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2076 (beginning-of-line)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2077
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2078 (defun idlwave-previous-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2079 "Moves point to beginning of the previous statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2080 Returns t if the current line before moving is the beginning of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2081 the first non-comment statement in the file, and nil otherwise."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2082 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2083 (let (first-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2084 (if (not (= (forward-line -1) 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2085 ;; first line in file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2086 t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2087 ;; skip blank lines, label lines, include lines and line comments
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2088 (while (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2089 ;; The current statement is the first statement until we
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2090 ;; reach another statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2091 (setq first-statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2092 (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2093 (looking-at idlwave-comment-line-start-skip)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2094 (looking-at "[ \t]*$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2095 (looking-at (concat "[ \t]*" idlwave-label "[ \t]*$"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2096 (looking-at "^@")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2097 (= (forward-line -1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2098 ;; skip continuation lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2099 (while (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2100 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2101 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2102 (idlwave-is-continuation-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2103 (= (forward-line -1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2104 first-statement)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2105
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2106 ;; FIXME: end-of-statement does not work correctly when comment lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2107 ;; are inside the statement. It does work correctly for line-end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2108 ;; comments, though.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2109 (defun idlwave-end-of-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2110 "Moves point to the end of the current IDL statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2111 If not in a statement just moves to end of line. Returns position."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2112 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2113 (while (and (idlwave-is-continuation-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2114 (= (forward-line 1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2115 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2116 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2117
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2118 (defun idlwave-next-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2119 "Moves point to beginning of the next IDL statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2120 Returns t if that statement is the last
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2121 non-comment IDL statement in the file, and nil otherwise."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2122 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2123 (let (last-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2124 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2125 ;; skip blank lines, label lines, include lines and line comments
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2126 (while (and (= (forward-line 1) 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2127 ;; The current statement is the last statement until
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2128 ;; we reach a new statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2129 (setq last-statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2130 (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2131 (looking-at idlwave-comment-line-start-skip)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2132 (looking-at "[ \t]*$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2133 (looking-at (concat "[ \t]*" idlwave-label "[ \t]*$"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2134 (looking-at "^@")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2135 last-statement))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2136
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2137 (defun idlwave-skip-label ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2138 "Skip label or case statement element.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2139 Returns position after label.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2140 If there is no label point is not moved and nil is returned."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2141 ;; Just look for the first non quoted colon and check to see if it
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2142 ;; is inside a sexp. If is not in a sexp it must be part of a label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2143 ;; or case statement element.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2144 (let ((start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2145 (end (idlwave-find-key ":" 1 'nomark
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2146 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2147 (idlwave-end-of-statement) (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2148 (if (and end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2149 (= (nth 0 (parse-partial-sexp start end)) 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2150 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2151 (forward-char)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2152 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2153 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2154 nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2155
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2156 (defun idlwave-start-of-substatement (&optional pre)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2157 "Move to start of next IDL substatement after point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2158 Uses the type of the current IDL statement to determine if the next
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2159 statement is on a new line or is a subpart of the current statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2160 Returns point at start of substatement modulo whitespace.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2161 If optional argument is non-nil move to beginning of current
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2162 substatement. "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2163 (let ((orig (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2164 (eos (idlwave-end-of-statement))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2165 (ifnest 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2166 st nst last)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2167 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2168 (idlwave-skip-label)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2169 (setq last (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2170 ;; Continue looking for substatements until we are past orig
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2171 (while (and (<= (point) orig) (not (eobp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2172 (setq last (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2173 (setq nst (nth 1 (cdr (setq st (car (idlwave-statement-type))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2174 (if (equal (car st) 'if) (setq ifnest (1+ ifnest)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2175 (cond ((and nst
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2176 (idlwave-find-key nst 1 'nomark eos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2177 (goto-char (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2178 ((and (> ifnest 0) (idlwave-find-key "\\<else\\>" 1 'nomark eos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2179 (setq ifnest (1- ifnest))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2180 (goto-char (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2181 (t (setq ifnest 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2182 (idlwave-next-statement))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2183 (if pre (goto-char last))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2184 (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2185
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2186 (defun idlwave-statement-type ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2187 "Return the type of the current IDL statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2188 Uses `idlwave-statement-match' to return a cons of (type . point) with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2189 point the ending position where the type was determined. Type is the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2190 association from `idlwave-statement-match', i.e. the cons cell from the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2191 list not just the type symbol. Returns nil if not an identifiable
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2192 statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2193 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2194 ;; Skip whitespace within a statement which is spaces, tabs, continuations
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2195 (while (looking-at "[ \t]*\\<\\$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2196 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2197 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2198 (let ((st idlwave-statement-match)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2199 (case-fold-search t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2200 (while (and (not (looking-at (nth 0 (cdr (car st)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2201 (setq st (cdr st))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2202 (if st
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2203 (append st (match-end 0))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2204
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2205 (defun idlwave-expand-equal (&optional before after)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2206 "Pad '=' with spaces.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2207 Two cases: Assignment statement, and keyword assignment.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2208 The case is determined using `idlwave-start-of-substatement' and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2209 `idlwave-statement-type'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2210 The equal sign will be surrounded by BEFORE and AFTER blanks.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2211 If `idlwave-pad-keyword' is non-nil then keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2212 assignment is treated just like assignment statements. Otherwise,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2213 spaces are removed for keyword assignment.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2214 Limits in for loops are treated as keyword assignment.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2215 See `idlwave-surround'. "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2216 ;; Even though idlwave-surround checks `idlwave-surround-by-blank' this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2217 ;; check saves the time of finding the statement type.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2218 (if idlwave-surround-by-blank
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2219 (let ((st (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2220 (idlwave-start-of-substatement t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2221 (idlwave-statement-type))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2222 (if (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2223 (and (equal (car (car st)) 'assign)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2224 (equal (cdr st) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2225 idlwave-pad-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2226 ;; An assignment statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2227 (idlwave-surround before after)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2228 (idlwave-surround 0 0)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2229
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2230 (defun idlwave-indent-and-action ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2231 "Call `idlwave-indent-line' and do expand actions."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2232 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2233 (idlwave-indent-line t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2234 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2235
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2236 (defun idlwave-indent-line (&optional expand)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2237 "Indents current IDL line as code or as a comment.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2238 The actions in `idlwave-indent-action-table' are performed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2239 If the optional argument EXPAND is non-nil then the actions in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2240 `idlwave-indent-expand-table' are performed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2241 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2242 ;; Move point out of left margin.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2243 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2244 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2245 (bolp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2246 (skip-chars-forward " \t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2247 (let ((mloc (point-marker)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2248 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2249 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2250 (if (looking-at idlwave-comment-line-start-skip)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2251 ;; Indentation for a line comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2252 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2253 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2254 (idlwave-indent-left-margin (idlwave-comment-hook)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2255 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2256 ;; Code Line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2257 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2258 ;; Before indenting, run action routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2259 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2260 (if (and expand idlwave-do-actions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2261 (mapcar 'idlwave-do-action idlwave-indent-expand-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2262 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2263 (if idlwave-do-actions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2264 (mapcar 'idlwave-do-action idlwave-indent-action-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2265 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2266 ;; No longer expand abbrevs on the line. The user can do this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2267 ;; manually using expand-region-abbrevs.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2268 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2269 ;; Indent for code line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2270 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2271 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2272 (if (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2273 ;; a label line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2274 (looking-at (concat "^" idlwave-label "[ \t]*$"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2275 ;; a batch command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2276 (looking-at "^[ \t]*@"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2277 ;; leave flush left
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2278 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2279 ;; indent the line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2280 (idlwave-indent-left-margin (idlwave-calculate-indent)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2281 ;; Adjust parallel comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2282 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2283 (if (idlwave-in-comment)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2284 (indent-for-comment))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2285 (goto-char mloc)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2286 ;; Get rid of marker
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2287 (set-marker mloc nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2288 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2289
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2290 (defun idlwave-do-action (action)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2291 "Perform an action repeatedly on a line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2292 ACTION is a list (REG . FUNC). REG is a regular expression. FUNC is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2293 either a function name to be called with `funcall' or a list to be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2294 evaluated with `eval'. The action performed by FUNC should leave point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2295 after the match for REG - otherwise an infinite loop may be entered."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2296 (let ((action-key (car action))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2297 (action-routine (cdr action)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2298 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2299 (while (idlwave-look-at action-key)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2300 (if (listp action-routine)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2301 (eval action-routine)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2302 (funcall action-routine)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2303
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2304 (defun idlwave-indent-to (col &optional min)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2305 "Indent from point with spaces until column COL.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2306 Inserts space before markers at point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2307 (if (not min) (setq min 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2308 (insert-before-markers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2309 (make-string (max min (- col (current-column))) ? )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2310
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2311 (defun idlwave-indent-left-margin (col)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2312 "Indent the current line to column COL.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2313 Indents such that first non-whitespace character is at column COL
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2314 Inserts spaces before markers at point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2315 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2316 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2317 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2318 (idlwave-indent-to col)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2319
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2320 (defun idlwave-indent-subprogram ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2321 "Indents program unit which contains point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2322 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2323 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2324 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2325 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2326 (let ((beg (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2327 (idlwave-forward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2328 (message "Indenting subprogram...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2329 (indent-region beg (point) nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2330 (message "Indenting subprogram...done.")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2331
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2332 (defun idlwave-calculate-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2333 "Return appropriate indentation for current line as IDL code."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2334 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2335 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2336 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2337 ;; Check for beginning of unit - main (beginning of buffer), pro, or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2338 ;; function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2339 ((idlwave-look-at idlwave-begin-unit-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2340 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2341 ;; Check for continuation line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2342 ((save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2343 (and (= (forward-line -1) 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2344 (idlwave-is-continuation-line)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2345 (idlwave-calculate-cont-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2346 ;; calculate indent based on previous and current statements
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2347 (t (let ((the-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2348 ;; calculate indent based on previous statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2349 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2350 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2351 ((idlwave-previous-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2352 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2353 ;; Main block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2354 ((idlwave-look-at idlwave-begin-unit-reg t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2355 (+ (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2356 idlwave-main-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2357 ;; Begin block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2358 ((idlwave-look-at idlwave-begin-block-reg t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2359 (+ (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2360 idlwave-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2361 ((idlwave-look-at idlwave-end-block-reg t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2362 (- (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2363 idlwave-end-offset
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2364 idlwave-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2365 ((idlwave-current-statement-indent))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2366 ;; adjust the indentation based on the current statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2367 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2368 ;; End block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2369 ((idlwave-look-at idlwave-end-block-reg t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2370 (+ the-indent idlwave-end-offset))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2371 (the-indent)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2372
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2373 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2374 ;; Parenthesses balacing/indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2375 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2376
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2377 (defun idlwave-calculate-cont-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2378 "Calculates the IDL continuation indent column from the previous statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2379 Note that here previous statement means the beginning of the current
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2380 statement if this statement is a continuation of the previous line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2381 Intervening comments or comments within the previous statement can
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2382 screw things up if the comments contain parentheses characters."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2383 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2384 (let* (open
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2385 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2386 (end-reg (progn (beginning-of-line) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2387 (close-exp (progn (skip-chars-forward " \t") (looking-at "\\s)")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2388 (beg-reg (progn (idlwave-previous-statement) (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2389 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2390 ;; If PRO or FUNCTION declaration indent after name, and first comma.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2391 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2392 (if (idlwave-look-at "\\<\\(pro\\|function\\)\\>")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2393 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2394 (forward-sexp 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2395 (if (looking-at "[ \t]*,[ \t]*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2396 (goto-char (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2397 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2398 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2399 ;; Not a PRO or FUNCTION
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2400 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2401 ;; Look for innermost unmatched open paren
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2402 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2403 (if (setq open (car (cdr (parse-partial-sexp beg-reg end-reg))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2404 ;; Found innermost open paren.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2405 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2406 (goto-char open)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2407 ;; Line up with next word unless this is a closing paren.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2408 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2409 ;; This is a closed paren - line up under open paren.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2410 (close-exp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2411 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2412 ;; Empty - just add regular indent. Take into account
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2413 ;; the forward-char
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2414 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2415 ;; Skip paren
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2416 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2417 (looking-at "[ \t$]*$"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2418 (+ (current-column) idlwave-continuation-indent -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2419 ;; Line up with first word
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2420 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2421 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2422 (current-column)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2423 ;; No unmatched open paren. Just a simple continuation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2424 (goto-char beg-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2425 (+ (idlwave-current-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2426 ;; Make adjustments based on current line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2427 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2428 ;; Else statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2429 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2430 (goto-char end-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2431 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2432 (looking-at "else"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2433 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2434 ;; Ordinary continuation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2435 (idlwave-continuation-indent))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2436
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2437 (defun idlwave-find-key (key-reg &optional dir nomark limit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2438 "Move in direction of the optional second argument DIR to the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2439 next keyword not contained in a comment or string and occurring before
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2440 optional fourth argument LIMIT. DIR defaults to forward direction. If
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2441 DIR is negative the search is backwards, otherwise, it is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2442 forward. LIMIT defaults to the beginning or end of the buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2443 according to the direction of the search. The keyword is given by the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2444 regular expression argument KEY-REG. The search is case insensitive.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2445 Returns position if successful and nil otherwise. If found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2446 `push-mark' is executed unless the optional third argument NOMARK is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2447 non-nil. If found, the point is left at the keyword beginning."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2448 (or dir (setq dir 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2449 (or limit (setq limit (cond ((>= dir 0) (point-max)) ((point-min)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2450 (let (found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2451 (old-syntax-table (syntax-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2452 (case-fold-search t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2453 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2454 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2455 (set-syntax-table idlwave-find-symbol-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2456 (if (>= dir 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2457 (while (and (setq found (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2458 (re-search-forward key-reg limit t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2459 (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2460 (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2461 (not (eobp))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2462 (while (and (setq found (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2463 (re-search-backward key-reg limit t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2464 (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2465 (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2466 (not (bobp))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2467 (set-syntax-table old-syntax-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2468 (if found (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2469 (if (not nomark) (push-mark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2470 (goto-char found)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2471
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2472 (defun idlwave-block-jump-out (&optional dir nomark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2473 "When optional argument DIR is non-negative, move forward to end of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2474 current block using the `idlwave-begin-block-reg' and `idlwave-end-block-reg'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2475 regular expressions. When DIR is negative, move backwards to block beginning.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2476 Recursively calls itself to skip over nested blocks. DIR defaults to
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2477 forward. Calls `push-mark' unless the optional argument NOMARK is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2478 non-nil. Movement is limited by the start of program units because of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2479 possibility of unbalanced blocks."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2480 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2481 (or dir (setq dir 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2482 (let* ((here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2483 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2484 (limit (if (>= dir 0) (point-max) (point-min)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2485 (block-limit (if (>= dir 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2486 idlwave-begin-block-reg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2487 idlwave-end-block-reg))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2488 found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2489 (block-reg (concat idlwave-begin-block-reg "\\|"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2490 idlwave-end-block-reg))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2491 (unit-limit (or (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2492 (if (< dir 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2493 (idlwave-find-key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2494 idlwave-begin-unit-reg dir t limit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2495 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2496 (idlwave-find-key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2497 idlwave-end-unit-reg dir t limit)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2498 limit)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2499 (if (>= dir 0) (end-of-line)) ;Make sure we are in current block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2500 (if (setq found (idlwave-find-key block-reg dir t unit-limit))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2501 (while (and found (looking-at block-limit))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2502 (if (>= dir 0) (forward-word 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2503 (idlwave-block-jump-out dir t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2504 (setq found (idlwave-find-key block-reg dir t unit-limit))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2505 (if (not nomark) (push-mark here))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2506 (if (not found) (goto-char unit-limit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2507 (if (>= dir 0) (forward-word 1)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2508
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2509 (defun idlwave-current-statement-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2510 "Return indentation of the current statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2511 If in a statement, moves to beginning of statement before finding indent."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2512 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2513 (idlwave-current-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2514
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2515 (defun idlwave-current-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2516 "Return the column of the indentation of the current line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2517 Skips any whitespace. Returns 0 if the end-of-line follows the whitespace."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2518 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2519 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2520 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2521 ;; if we are at the end of blank line return 0
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2522 (cond ((eolp) 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2523 ((current-column)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2524
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2525 (defun idlwave-is-continuation-line ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2526 "Tests if current line is continuation line."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2527 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2528 (idlwave-look-at "\\<\\$")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2529
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2530 (defun idlwave-is-comment-line ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2531 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2532 (beginning-of-line 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2533 (looking-at "[ \t]*;")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2534
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2535 (defun idlwave-look-at (regexp &optional cont beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2536 "Searches current line from current point for the regular expression
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2537 REGEXP. If optional argument CONT is non-nil, searches to the end of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2538 the current statement. If optional arg BEG is non-nil, search starts
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2539 from the beginning of the current statement. Ignores matches that end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2540 in a comment or inside a string expression. Returns point if
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2541 successful, nil otherwise. This function produces unexpected results
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2542 if REGEXP contains quotes or a comment delimiter. The search is case
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2543 insensitive. If successful leaves point after the match, otherwise,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2544 does not move point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2545 (let ((here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2546 (old-syntax-table (syntax-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2547 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2548 eos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2549 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2550 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2551 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2552 (set-syntax-table idlwave-find-symbol-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2553 (setq eos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2554 (if cont
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2555 (save-excursion (idlwave-end-of-statement) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2556 (save-excursion (end-of-line) (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2557 (if beg (idlwave-beginning-of-statement))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2558 (while (and (setq found (re-search-forward regexp eos t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2559 (idlwave-quoted))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2560 (set-syntax-table old-syntax-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2561 (if (not found) (goto-char here))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2562 found))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2563
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2564 (defun idlwave-fill-paragraph (&optional nohang)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2565 "Fills paragraphs in comments.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2566 A paragraph is made up of all contiguous lines having the same comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2567 leader (the leading whitespace before the comment delimiter and the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2568 comment delimiter). In addition, paragraphs are separated by blank
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2569 line comments. The indentation is given by the hanging indent of the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2570 first line, otherwise by the minimum indentation of the lines after
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2571 the first line. The indentation of the first line does not change.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2572 Does not effect code lines. Does not fill comments on the same line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2573 with code. The hanging indent is given by the end of the first match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2574 matching `idlwave-hang-indent-regexp' on the paragraph's first line . If the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2575 optional argument NOHANG is non-nil then the hanging indent is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2576 ignored."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2577 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2578 ;; check if this is a line comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2579 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2580 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2581 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2582 (looking-at comment-start))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2583 (let
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2584 ((indent 999)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2585 pre here diff fill-prefix-reg bcl first-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2586 hang start end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2587 ;; Change tabs to spaces in the surrounding paragraph.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2588 ;; The surrounding paragraph will be the largest containing block of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2589 ;; contiguous line comments. Thus, we may be changing tabs in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2590 ;; a much larger area than is needed, but this is the easiest
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2591 ;; brute force way to do it.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2592 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2593 ;; This has the undesirable side effect of replacing the tabs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2594 ;; permanently without the user's request or knowledge.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2595 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2596 (backward-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2597 (setq start (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2598 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2599 (forward-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2600 (setq end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2601 (untabify start end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2602 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2603 (setq here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2604 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2605 (setq bcl (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2606 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2607 (concat "^[ \t]*" comment-start "+")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2608 (save-excursion (end-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2609 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2610 ;; Get the comment leader on the line and its length
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2611 (setq pre (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2612 ;; the comment leader is the indentation plus exactly the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2613 ;; number of consecutive ";".
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2614 (setq fill-prefix-reg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2615 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2616 (setq fill-prefix
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2617 (regexp-quote
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2618 (buffer-substring (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2619 (beginning-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2620 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2621 "[^;]"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2622
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2623 ;; Mark the beginning and end of the paragraph
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2624 (goto-char bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2625 (while (and (looking-at fill-prefix-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2626 (not (looking-at paragraph-separate))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2627 (not (bobp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2628 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2629 ;; Move to first line of paragraph
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2630 (if (/= (point) bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2631 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2632 (setq start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2633 (goto-char bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2634 (while (and (looking-at fill-prefix-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2635 (not (looking-at paragraph-separate))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2636 (not (eobp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2637 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2638 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2639 (if (or (not (looking-at fill-prefix-reg))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2640 (looking-at paragraph-separate))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2641 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2642 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2643 ;; if at end of buffer add a newline (need this because
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2644 ;; fill-region needs END to be at the beginning of line after
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2645 ;; the paragraph or it will add a line).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2646 (if (eobp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2647 (progn (insert ?\n) (backward-char 1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2648 ;; Set END to the beginning of line after the paragraph
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2649 ;; END is calculated as distance from end of buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2650 (setq end (- (point-max) (point) 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2651 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2652 ;; Calculate the indentation for the paragraph.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2653 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2654 ;; In the following while statements, after one iteration
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2655 ;; point will be at the beginning of a line in which case
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2656 ;; the while will not be executed for the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2657 ;; the first paragraph line and thus will not affect the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2658 ;; indentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2659 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2660 ;; First check to see if indentation is based on hanging indent.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2661 (if (and (not nohang) idlwave-hanging-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2662 (setq hang
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2663 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2664 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2665 (idlwave-calc-hanging-indent))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2666 ;; Adjust lines of paragraph by inserting spaces so that
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2667 ;; each line's indent is at least as great as the hanging
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2668 ;; indent. This is needed for fill-paragraph to work with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2669 ;; a fill-prefix.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2670 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2671 (setq indent hang)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2672 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2673 (while (> (point) start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2674 (re-search-forward comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2675 (save-excursion (end-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2676 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2677 (if (> (setq diff (- indent (current-column))) 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2678 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2679 (if (>= here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2680 ;; adjust the original location for the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2681 ;; inserted text.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2682 (setq here (+ here diff)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2683 (insert (make-string diff ? ))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2684 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2685 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2686
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2687 ;; No hang. Instead find minimum indentation of paragraph
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2688 ;; after first line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2689 ;; For the following while statement, since START is at the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2690 ;; beginning of line and END is at the the end of line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2691 ;; point is greater than START at least once (which would
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2692 ;; be the case for a single line paragraph).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2693 (while (> (point) start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2694 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2695 (setq indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2696 (min indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2697 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2698 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2699 comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2700 (save-excursion (end-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2701 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2702 (current-column))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2703 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2704 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2705 (setq fill-prefix (concat fill-prefix
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2706 (make-string (- indent pre)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2707 ? )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2708 ;; first-line indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2709 (setq first-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2710 (max
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2711 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2712 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2713 comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2714 (save-excursion (end-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2715 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2716 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2717 indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2718
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2719 ;; try to keep point at its original place
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2720 (goto-char here)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2721
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2722 ;; In place of the more modern fill-region-as-paragraph, a hack
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2723 ;; to keep whitespace untouched on the first line within the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2724 ;; indent length and to preserve any indent on the first line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2725 ;; (first indent).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2726 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2727 (setq diff
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2728 (buffer-substring start (+ start first-indent -1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2729 (subst-char-in-region start (+ start first-indent -1) ? ?~ nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2730 (fill-region-as-paragraph
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2731 start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2732 (- (point-max) end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2733 (current-justification)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2734 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2735 (delete-region start (+ start first-indent -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2736 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2737 (insert diff))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2738 ;; When we want the point at the beginning of the comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2739 ;; body fill-region will put it at the beginning of the line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2740 (if (bolp) (skip-chars-forward (concat " \t" comment-start)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2741 (setq fill-prefix nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2742
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2743 (defun idlwave-calc-hanging-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2744 "Calculate the position of the hanging indent for the comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2745 paragraph. The hanging indent position is given by the first match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2746 with the `idlwave-hang-indent-regexp'. If `idlwave-use-last-hang-indent' is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2747 non-nil then use last occurrence matching `idlwave-hang-indent-regexp' on
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2748 the line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2749 If not found returns nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2750 (if idlwave-use-last-hang-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2751 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2752 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2753 (if (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2754 idlwave-hang-indent-regexp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2755 (save-excursion (beginning-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2756 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2757 (+ (current-column) (length idlwave-hang-indent-regexp))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2758 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2759 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2760 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2761 idlwave-hang-indent-regexp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2762 (save-excursion (end-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2763 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2764 (current-column)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2765
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2766 (defun idlwave-auto-fill ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2767 "Called to break lines in auto fill mode.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2768 Only fills comment lines if `idlwave-fill-comment-line-only' is non-nil.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2769 Places a continuation character at the end of the line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2770 if not in a comment. Splits strings with IDL concatenation operator
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2771 `+' if `idlwave-auto-fill-split-string is non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2772 (if (<= (current-column) fill-column)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2773 nil ; do not to fill
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2774 (if (or (not idlwave-fill-comment-line-only)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2775 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2776 ;; Check for comment line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2777 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2778 (looking-at idlwave-comment-line-start-skip)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2779 (let (beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2780 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2781 ;; Prevent actions do-auto-fill which calls indent-line-function.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2782 (let (idlwave-do-actions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2783 (paragraph-start ".")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2784 (paragraph-separate "."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2785 (do-auto-fill))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2786 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2787 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2788 ;; Indent the split line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2789 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2790 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2791 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2792 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2793 (looking-at idlwave-comment-line-start-skip))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2794 ;; A continued line comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2795 ;; We treat continued line comments as part of a comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2796 ;; paragraph. So we check for a hanging indent.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2797 (if idlwave-hanging-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2798 (let ((here (- (point-max) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2799 (indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2800 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2801 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2802 (idlwave-calc-hanging-indent))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2803 (if indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2804 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2805 ;; Remove whitespace between comment delimiter and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2806 ;; text, insert spaces for appropriate indentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2807 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2808 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2809 comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2810 (save-excursion (end-of-line) (point)) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2811 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2812 (idlwave-indent-to indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2813 (goto-char (- (point-max) here)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2814 )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2815 ;; Split code or comment?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2816 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2817 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2818 (idlwave-in-comment))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2819 ;; Splitting a non-line comment.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2820 ;; Insert the comment delimiter from split line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2821 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2822 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2823 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2824 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2825 ;; Insert blank to keep off beginning of line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2826 (insert " "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2827 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2828 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2829 (buffer-substring (idlwave-goto-comment)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2830 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2831 (skip-chars-forward "; ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2832 (point))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2833 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2834 ;; Split code line - add continuation character
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2835 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2836 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2837 ;; Check to see if we split a string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2838 (if (and (setq beg (idlwave-in-quote))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2839 idlwave-auto-fill-split-string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2840 ;; Split the string and concatenate.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2841 ;; The first extra space is for the space
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2842 ;; the line was split. That space was removed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2843 (insert " " (char-after beg) " +"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2844 (insert " $"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2845 (if beg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2846 (if idlwave-auto-fill-split-string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2847 ;; Make the second part of continued string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2848 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2849 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2850 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2851 (insert (char-after beg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2852 ;; Warning
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2853 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2854 (message "Warning: continuation inside a string.")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2855 ;; Although do-auto-fill (via indent-new-comment-line) calls
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2856 ;; idlwave-indent-line for the new line, re-indent again
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2857 ;; because of the addition of the continuation character.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2858 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2859 )))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2860
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2861 (defun idlwave-auto-fill-mode (arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2862 "Toggle auto-fill mode for IDL mode.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2863 With arg, turn auto-fill mode on if arg is positive.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2864 In auto-fill mode, inserting a space at a column beyond `fill-column'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2865 automatically breaks the line at a previous space."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2866 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2867 (prog1 (set idlwave-fill-function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2868 (if (if (null arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2869 (not (symbol-value idlwave-fill-function))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2870 (> (prefix-numeric-value arg) 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2871 'idlwave-auto-fill
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2872 nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2873 ;; update mode-line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2874 (set-buffer-modified-p (buffer-modified-p))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2875
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2876 (defun idlwave-doc-header (&optional nomark )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2877 "Insert a documentation header at the beginning of the unit.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2878 Inserts the value of the variable idlwave-file-header. Sets mark before
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2879 moving to do insertion unless the optional prefix argument NOMARK
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2880 is non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2881 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2882 (or nomark (push-mark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2883 ;; make sure we catch the current line if it begins the unit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2884 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2885 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2886 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2887 ;; skip function or procedure line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2888 (if (idlwave-look-at "\\<\\(pro\\|function\\)\\>")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2889 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2890 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2891 (if (> (forward-line 1) 0) (insert "\n"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2892 (if idlwave-file-header
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2893 (cond ((car idlwave-file-header)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2894 (insert-file (car idlwave-file-header)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2895 ((stringp (car (cdr idlwave-file-header)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2896 (insert (car (cdr idlwave-file-header)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2897
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2898
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2899 (defun idlwave-default-insert-timestamp ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2900 "Default timestamp insertion function"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2901 (insert (current-time-string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2902 (insert ", " (user-full-name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2903 (insert " <" (user-login-name) "@" (system-name) ">")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2904 ;; Remove extra spaces from line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2905 (idlwave-fill-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2906 ;; Insert a blank line comment to separate from the date entry -
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2907 ;; will keep the entry from flowing onto date line if re-filled.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2908 (insert "\n;\n;\t\t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2909
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2910 (defun idlwave-doc-modification ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2911 "Insert a brief modification log at the beginning of the current program.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2912 Looks for an occurrence of the value of user variable
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2913 `idlwave-doc-modifications-keyword' if non-nil. Inserts time and user name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2914 and places the point for the user to add a log. Before moving, saves
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2915 location on mark ring so that the user can return to previous point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2916 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2917 (push-mark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2918 ;; make sure we catch the current line if it begins the unit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2919 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2920 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2921 (let ((pro (idlwave-look-at "\\<\\(function\\|pro\\)\\>"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2922 (case-fold-search nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2923 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2924 (concat idlwave-doc-modifications-keyword ":")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2925 ;; set search limit at next unit beginning
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2926 (save-excursion (idlwave-end-of-subprogram) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2927 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2928 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2929 ;; keyword not present, insert keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2930 (if pro (idlwave-next-statement)) ; skip past pro or function statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2931 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2932 (insert "\n" comment-start "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2933 (forward-line -2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2934 (insert comment-start " " idlwave-doc-modifications-keyword ":")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2935 (idlwave-newline)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2936 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2937 (insert ";\n;\t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2938 (run-hooks 'idlwave-timestamp-hook))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2939
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2940 ;;; CJC 3/16/93
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2941 ;;; Interface to expand-region-abbrevs which did not work when the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2942 ;;; abbrev hook associated with an abbrev moves point backwards
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2943 ;;; after abbrev expansion, e.g., as with the abbrev '.n'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2944 ;;; The original would enter an infinite loop in attempting to expand
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2945 ;;; .n (it would continually expand and unexpand the abbrev without expanding
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2946 ;;; because the point would keep going back to the beginning of the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2947 ;;; abbrev instead of to the end of the abbrev). We now keep the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2948 ;;; abbrev hook from moving backwards.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2949 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2950 (defun idlwave-expand-region-abbrevs (start end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2951 "Expand each abbrev occurrence in the region.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2952 Calling from a program, arguments are START END."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2953 (interactive "r")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2954 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2955 (goto-char (min start end))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2956 (let ((idlwave-show-block nil) ;Do not blink
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2957 (idlwave-abbrev-move nil)) ;Do not move
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2958 (expand-region-abbrevs start end 'noquery))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2959
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2960 (defun idlwave-quoted ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2961 "Returns t if point is in a comment or quoted string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2962 nil otherwise."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2963 (or (idlwave-in-comment) (idlwave-in-quote)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2964
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2965 (defun idlwave-in-quote ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2966 "Returns location of the opening quote
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2967 if point is in a IDL string constant, nil otherwise.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2968 Ignores comment delimiters on the current line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2969 Properly handles nested quotation marks and octal
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2970 constants - a double quote followed by an octal digit."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2971 ;;; Treat an octal inside an apostrophe to be a normal string. Treat a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2972 ;;; double quote followed by an octal digit to be an octal constant
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2973 ;;; rather than a string. Therefore, there is no terminating double
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2974 ;;; quote.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2975 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2976 ;; Because single and double quotes can quote each other we must
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2977 ;; search for the string start from the beginning of line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2978 (let* ((start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2979 (eol (progn (end-of-line) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2980 (bq (progn (beginning-of-line) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2981 (endq (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2982 (data (match-data))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2983 delim
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2984 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2985 (while (< endq start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2986 ;; Find string start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2987 ;; Don't find an octal constant beginning with a double quote
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2988 (if (re-search-forward "\"[^0-7]\\|'\\|\"$" eol 'lim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2989 ;; Find the string end.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2990 ;; In IDL, two consecutive delimiters after the start of a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2991 ;; string act as an
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2992 ;; escape for the delimiter in the string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2993 ;; Two consecutive delimiters alone (i.e., not after the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2994 ;; start of a string) is the the null string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2995 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2996 ;; Move to position after quote
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2997 (goto-char (1+ (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2998 (setq bq (1- (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2999 ;; Get the string delimiter
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3000 (setq delim (char-to-string (preceding-char)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3001 ;; Check for null string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3002 (if (looking-at delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3003 (progn (setq endq (point)) (forward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3004 ;; Look for next unpaired delimiter
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3005 (setq found (search-forward delim eol 'lim))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3006 (while (looking-at delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3007 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3008 (setq found (search-forward delim eol 'lim)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3009 (if found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3010 (setq endq (- (point) 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3011 (setq endq (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3012 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3013 (progn (setq bq (point)) (setq endq (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3014 (store-match-data data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3015 ;; return string beginning position or nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3016 (if (> start bq) bq))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3017
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3018 ;; Statement templates
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3019
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3020 ;; Replace these with a general template function, something like
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3021 ;; expand.el (I think there was also something with a name similar to
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3022 ;; dmacro.el)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3023
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3024 (defun idlwave-template (s1 s2 &optional prompt noindent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3025 "Build a template with optional prompt expression.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3026
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3027 Opens a line if point is not followed by a newline modulo intervening
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3028 whitespace. S1 and S2 are strings. S1 is inserted at point followed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3029 by S2. Point is inserted between S1 and S2. If optional argument
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3030 PROMPT is a string then it is displayed as a message in the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3031 minibuffer. The PROMPT serves as a reminder to the user of an
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3032 expression to enter.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3033
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3034 The lines containing S1 and S2 are reindented using `indent-region'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3035 unless the optional second argument NOINDENT is non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3036 (let ((beg (save-excursion (beginning-of-line) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3037 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3038 (if (not (looking-at "\\s-*\n"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3039 (open-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3040 (insert s1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3041 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3042 (insert s2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3043 (setq end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3044 (if (not noindent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3045 (indent-region beg end nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3046 (if (stringp prompt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3047 (message prompt))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3048
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3049 (defun idlwave-elif ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3050 "Build skeleton IDL if-else block."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3051 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3052 (idlwave-template "if"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3053 " then begin\n\nendif else begin\n\nendelse"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3054 "Condition expression"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3055
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3056 (defun idlwave-case ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3057 "Build skeleton IDL case statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3058 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3059 (idlwave-template "case" " of\n\nendcase" "Selector expression"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3060
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3061 (defun idlwave-for ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3062 "Build skeleton for loop statment."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3063 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3064 (idlwave-template "for" " do begin\n\nendfor" "Loop expression"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3065
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3066 (defun idlwave-if ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3067 "Build skeleton for loop statment."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3068 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3069 (idlwave-template "if" " then begin\n\nendif" "Scalar logical expression"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3070
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3071 (defun idlwave-procedure ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3072 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3073 (idlwave-template "pro" "\n\nreturn\nend" "Procedure name"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3074
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3075 (defun idlwave-function ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3076 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3077 (idlwave-template "function" "\n\nreturn\nend" "Function name"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3078
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3079 (defun idlwave-repeat ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3080 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3081 (idlwave-template "repeat begin\n\nendrep until" "" "Exit condition"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3082
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3083 (defun idlwave-while ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3084 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3085 (idlwave-template "while" " do begin\n\nendwhile" "Entry condition"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3086
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3087 (defun idlwave-split-string (string &optional pattern)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3088 "Return a list of substrings of STRING which are separated by PATTERN.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3089 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3090 (or pattern
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3091 (setq pattern "[ \f\t\n\r\v]+"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3092 (let (parts (start 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3093 (while (string-match pattern string start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3094 (setq parts (cons (substring string start (match-beginning 0)) parts)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3095 start (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3096 (nreverse (cons (substring string start) parts))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3097
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3098 (defun idlwave-replace-string (string replace_string replace_with)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3099 (let* ((start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3100 (last (length string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3101 (ret_string "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3102 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3103 (while (setq end (string-match replace_string string start))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3104 (setq ret_string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3105 (concat ret_string (substring string start end) replace_with))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3106 (setq start (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3107 (setq ret_string (concat ret_string (substring string start last)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3108
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3109 (defun idlwave-get-buffer-visiting (file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3110 ;; Return the buffer currently visiting FILE
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3111 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3112 ((boundp 'find-file-compare-truenames) ; XEmacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3113 (let ((find-file-compare-truenames t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3114 (get-file-buffer file)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3115 ((fboundp 'find-buffer-visiting) ; Emacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3116 (find-buffer-visiting file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3117 (t (error "This should not happen (idlwave-get-buffer-visiting)"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3118
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3119 (defun idlwave-find-file-noselect (file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3120 ;; Return a buffer visiting file.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3121 (or (idlwave-get-buffer-visiting file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3122 (find-file-noselect file)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3123
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3124 (defvar idlwave-scanned-lib-directories)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3125 (defun idlwave-find-lib-file-noselet (file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3126 ;; Find FILE on the scanned lib path and return a buffer visiting it
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3127 (let* ((dirs idlwave-scanned-lib-directories)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3128 dir efile)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3129 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3130 (while (setq dir (pop dirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3131 (if (file-regular-p
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3132 (setq efile (expand-file-name file dir)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3133 (throw 'exit (idlwave-find-file-noselect efile)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3134
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3135 (defun idlwave-make-tags ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3136 "Creates the IDL tags file IDLTAGS in the current directory from
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3137 the list of directories specified in the minibuffer. Directories may be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3138 for example: . /usr/local/rsi/idl/lib. All the subdirectories of the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3139 specified top directories are searched if the directory name is prefixed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3140 by @. Specify @ directories with care, it may take a long, long time if
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3141 you specify /."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3142 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3143 (let (directory directories cmd append status numdirs dir getsubdirs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3144 buffer save_buffer files numfiles item errbuf)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3145
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3146 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3147 ;; Read list of directories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3148 (setq directory (read-string "Tag Directories: " "."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3149 (setq directories (idlwave-split-string directory "[ \t]+"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3150 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3151 ;; Set etags command, vars
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3152 (setq cmd "etags --output=IDLTAGS --language=none --regex='/[
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3153 \\t]*[pP][Rr][Oo][ \\t]+\\([^ \\t,]+\\)/' --regex='/[
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3154 \\t]*[Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn][ \\t]+\\([^ \\t,]+\\)/' ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3155 (setq append " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3156 (setq status 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3157 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3158 ;; For each directory
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3159 (setq numdirs 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3160 (setq dir (nth numdirs directories))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3161 (while (and dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3162 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3163 ;; Find the subdirectories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3164 (if (string-match "^[@]\\(.+\\)$" dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3165 (setq getsubdirs t) (setq getsubdirs nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3166 (if (and getsubdirs) (setq dir (substring dir 1 (length dir))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3167 (setq dir (expand-file-name dir))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3168 (if (file-directory-p dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3169 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3170 (if (and getsubdirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3171 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3172 (setq buffer (get-buffer-create "*idltags*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3173 (call-process "sh" nil buffer nil "-c"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3174 (concat "find " dir " -type d -print"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3175 (setq save_buffer (current-buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3176 (set-buffer buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3177 (setq files (idlwave-split-string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3178 (idlwave-replace-string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3179 (buffer-substring 1 (point-max))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3180 "\n" "/*.pro ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3181 "[ \t]+"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3182 (set-buffer save_buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3183 (kill-buffer buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3184 (setq files (list (concat dir "/*.pro"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3185 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3186 ;; For each subdirectory
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3187 (setq numfiles 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3188 (setq item (nth numfiles files))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3189 (while (and item)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3190 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3191 ;; Call etags
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3192 (if (not (string-match "^[ \\t]*$" item))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3193 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3194 (message (concat "Tagging " item "..."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3195 (setq errbuf (get-buffer-create "*idltags-error*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3196 (setq status (+ status
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3197 (call-process "sh" nil errbuf nil "-c"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3198 (concat cmd append item))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3199 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3200 ;; Append additional tags
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3201 (setq append " --append ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3202 (setq numfiles (1+ numfiles))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3203 (setq item (nth numfiles files)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3204 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3205 (setq numfiles (1+ numfiles))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3206 (setq item (nth numfiles files))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3207 )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3208
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3209 (setq numdirs (1+ numdirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3210 (setq dir (nth numdirs directories)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3211 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3212 (setq numdirs (1+ numdirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3213 (setq dir (nth numdirs directories)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3214
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3215 (setq errbuf (get-buffer-create "*idltags-error*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3216 (if (= status 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3217 (kill-buffer errbuf))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3218 (message "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3219 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3220
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3221 (defun idlwave-toggle-comment-region (beg end &optional n)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3222 "Comment the lines in the region if the first non-blank line is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3223 commented, and conversely, uncomment region. If optional prefix arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3224 N is non-nil, then for N positive, add N comment delimiters or for N
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3225 negative, remove N comment delimiters.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3226 Uses `comment-region' which does not place comment delimiters on
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3227 blank lines."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3228 (interactive "r\nP")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3229 (if n
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3230 (comment-region beg end (prefix-numeric-value n))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3231 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3232 (goto-char beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3233 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3234 ;; skip blank lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3235 (skip-chars-forward " \t\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3236 (if (looking-at (concat "[ \t]*\\(" comment-start "+\\)"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3237 (comment-region beg end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3238 (- (length (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3239 (match-beginning 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3240 (match-end 1)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3241 (comment-region beg end)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3242
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3243
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3244 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3245 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3246 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3247 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3248 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3249 ;; Completion and Routine Info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3250 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3251
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3252 ;; String "intern" functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3253
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3254 ;; For the completion and routine info function, we want to normalize
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3255 ;; the case of procedure names etc. We do this by "interning" these
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3256 ;; string is a hand-crafted way. Hashes are used to map the downcase
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3257 ;; version of the strings to the cased versions. Since these cased
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3258 ;; versions are really lisp objects, we can use `eq' to search, which
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3259 ;; is a large performance boost.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3260 ;; All new strings need to be "sinterned". We do this as early as
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3261 ;; possible after getting these strings from completion or buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3262 ;; substrings. So most of the code can simply assume to deal with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3263 ;; "sinterned" strings. The only exception is that the functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3264 ;; which scan whole buffers for routine information do not intern the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3265 ;; grabbed strings. This is only done afterwards. Therefore in these
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3266 ;; functions it is *not* save to assume the strings can be compared
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3267 ;; with `eq' and be fed into the routine assq functions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3268
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3269 ;; Here we define the hashing functions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3270
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3271 ;; The variables which hold the hashes.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3272 (defvar idlwave-sint-routines '(nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3273 (defvar idlwave-sint-keywords '(nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3274 (defvar idlwave-sint-methods '(nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3275 (defvar idlwave-sint-classes '(nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3276 (defvar idlwave-sint-files '(nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3277
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3278 (defun idlwave-reset-sintern (&optional what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3279 "Reset all sintern hashes."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3280 ;; Make sure the hash functions are accessible.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3281 (if (or (not (fboundp 'gethash))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3282 (not (fboundp 'puthash)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3283 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3284 (require 'cl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3285 (or (fboundp 'puthash)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3286 (defalias 'puthash 'cl-puthash))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3287 (let ((entries '((idlwave-sint-routines 1000 10)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3288 (idlwave-sint-keywords 1000 10)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3289 (idlwave-sint-methods 100 10)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3290 (idlwave-sint-classes 10 10))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3291
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3292 ;; Make sure these are lists
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3293 (loop for entry in entries
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3294 for var = (car entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3295 do (if (not (consp (symbol-value var))) (set var (list nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3296
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3297 (when (or (eq what t) (eq what 'syslib)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3298 (null (cdr idlwave-sint-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3299 ;; Reset the system & library hash
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3300 (loop for entry in entries
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3301 for var = (car entry) for size = (nth 1 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3302 do (setcdr (symbol-value var)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3303 (make-hash-table ':size size ':test 'equal)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3304 (setq idlwave-sint-files nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3305
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3306 (when (or (eq what t) (eq what 'bufsh)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3307 (null (car idlwave-sint-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3308 ;; Reset the buffer & shell hash
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3309 (loop for entry in entries
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3310 for var = (car entry) for size = (nth 1 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3311 do (setcar (symbol-value var)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3312 (make-hash-table ':size size ':test 'equal))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3313
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3314 (defun idlwave-sintern-routine-or-method (name &optional class set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3315 (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3316 (idlwave-sintern-method name set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3317 (idlwave-sintern-routine name set)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3318
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3319 (defun idlwave-sintern (stype &rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3320 (apply (intern (concat "idlwave-sintern-" (symbol-name stype))) args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3321
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3322 ;;(defmacro idlwave-sintern (type var)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3323 ;; `(cond ((not (stringp name)) name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3324 ;; ((gethash (downcase name) (cdr ,var)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3325 ;; ((gethash (downcase name) (car ,var)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3326 ;; (set (idlwave-sintern-set name ,type ,var set))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3327 ;; (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3328
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3329 (defun idlwave-sintern-routine (name &optional set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3330 (cond ((not (stringp name)) name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3331 ((gethash (downcase name) (cdr idlwave-sint-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3332 ((gethash (downcase name) (car idlwave-sint-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3333 (set (idlwave-sintern-set name 'routine idlwave-sint-routines set))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3334 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3335 (defun idlwave-sintern-keyword (name &optional set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3336 (cond ((not (stringp name)) name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3337 ((gethash (downcase name) (cdr idlwave-sint-keywords)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3338 ((gethash (downcase name) (car idlwave-sint-keywords)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3339 (set (idlwave-sintern-set name 'keyword idlwave-sint-keywords set))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3340 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3341 (defun idlwave-sintern-method (name &optional set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3342 (cond ((not (stringp name)) name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3343 ((gethash (downcase name) (cdr idlwave-sint-methods)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3344 ((gethash (downcase name) (car idlwave-sint-methods)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3345 (set (idlwave-sintern-set name 'method idlwave-sint-methods set))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3346 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3347 (defun idlwave-sintern-class (name &optional set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3348 (cond ((not (stringp name)) name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3349 ((gethash (downcase name) (cdr idlwave-sint-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3350 ((gethash (downcase name) (car idlwave-sint-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3351 (set (idlwave-sintern-set name 'class idlwave-sint-classes set))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3352 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3353
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3354 (defun idlwave-sintern-file (name &optional set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3355 (car (or (member name idlwave-sint-files)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3356 (setq idlwave-sint-files (cons name idlwave-sint-files)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3357
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3358 (defun idlwave-sintern-set (name type tables set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3359 (let* ((func (or (cdr (assq type idlwave-completion-case))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3360 'identity))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3361 (iname (funcall (if (eq func 'preserve) 'identity func) name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3362 (table (if (eq set 'sys) (cdr tables) (car tables))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3363 (puthash (downcase name) iname table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3364 iname))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3365
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3366 (defun idlwave-sintern-rinfo-list (list &optional set)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3367 "Sintern all strings in the rinfo LIST. With optional parameter SET:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3368 also set new patterns. Probably this will always have to be t."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3369 (let (entry name type class kwds res source call olh new)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3370 (while list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3371 (setq entry (car list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3372 list (cdr list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3373 name (car entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3374 type (nth 1 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3375 class (nth 2 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3376 source (nth 3 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3377 call (nth 4 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3378 kwds (nth 5 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3379 olh (nth 6 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3380 (setq kwds (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3381 (list (idlwave-sintern-keyword (car x) set)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3382 kwds))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3383 (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3384 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3385 (if (symbolp class) (setq class (symbol-name class)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3386 (setq class (idlwave-sintern-class class set))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3387 (setq name (idlwave-sintern-method name set)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3388 (setq name (idlwave-sintern-routine name set)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3389 (if (stringp (cdr source))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3390 (setcdr source (idlwave-sintern-file (cdr source) t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3391 (setq new (if olh
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3392 (list name type class source call kwds olh)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3393 (list name type class source call kwds)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3394 (setq res (cons new res)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3395 (nreverse res)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3396
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3397 ;;---------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3398
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3399
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3400 ;; The variables which hold the information
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3401 (defvar idlwave-builtin-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3402 "Holds the routine-info obtained by scanning buffers.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3403 (defvar idlwave-buffer-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3404 "Holds the routine-info obtained by scanning buffers.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3405 (defvar idlwave-compiled-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3406 "Holds the procedure routine-info obtained by asking the shell.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3407 (defvar idlwave-library-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3408 "Holds the procedure routine-info from the library scan.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3409 (defvar idlwave-scanned-lib-directories nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3410 "The directories scanned to get libinfo.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3411 (defvar idlwave-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3412 "Holds the combinded procedure routine-info.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3413 (defvar idlwave-class-alist nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3414 "Holds the class names known to IDLWAVE.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3415 (defvar idlwave-class-history nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3416 "The history of classes selected with the minibuffer.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3417 (defvar idlwave-force-class-query nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3418 (defvar idlwave-before-completion-wconf nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3419 "The window configuration just before the completion buffer was displayed.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3420
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3421 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3422 ;; The code to get routine info from different sources.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3423
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3424 (defvar idlwave-builtin-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3425 (defun idlwave-routines ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3426 "Provide a list of IDL routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3427 This routine loads the builtin routines on the first call. Later it
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3428 only returns the value of the variable."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3429 (or idlwave-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3430 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3431 (idlwave-update-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3432 ;; return the current value
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3433 idlwave-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3434
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3435 (defun idlwave-update-routine-info (&optional arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3436 "Update the internal routine-info lists.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3437 These lists are used by `idlwave-routine-info' (\\[idlwave-routine-info])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3438 and by `idlwave-complete' (\\[idlwave-complete]) to provide information
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3439 about individual routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3440
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3441 The information can come from 4 sources:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3442 1. IDL programs in the current editing session
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3443 2. Compiled modules in an IDL shell running as Emacs subprocess
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3444 3. A list which covers the IDL system routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3445 4. A list which covers the prescanned library files.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3446
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3447 Scans all IDLWAVE-mode buffers of the current editing session (see
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3448 `idlwave-scan-all-buffers-for-routine-info').
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3449 When an IDL shell is running, this command also queries the IDL program
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3450 for currently compiled routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3451
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3452 With prefix ARG, also reload the system and library lists.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3453 With two prefix ARG's, also rescans the library tree."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3454 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3455 (if (equal arg '(16))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3456 (idlwave-create-libinfo-file t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3457 (let* ((reload (or arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3458 idlwave-buffer-case-takes-precedence
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3459 (null idlwave-builtin-routines))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3460
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3461 (setq idlwave-buffer-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3462 idlwave-compiled-routines nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3463 ;; Reset the appropriate hashes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3464 (idlwave-reset-sintern (cond (reload t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3465 ((null idlwave-builtin-routines) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3466 (t 'bufsh)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3467
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3468 (if idlwave-buffer-case-takes-precedence
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3469 ;; We can safely scan the buffer stuff first
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3470 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3471 (idlwave-update-buffer-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3472 (and reload (idlwave-load-system-rinfo)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3473 ;; We first do the system info, and then the buffers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3474 (and reload (idlwave-load-system-rinfo))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3475 (idlwave-update-buffer-routine-info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3476
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3477 ;; Let's see if there is a shell
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3478 (let* ((shell-is-running (and (fboundp 'idlwave-shell-is-running)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3479 (idlwave-shell-is-running)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3480 (ask-shell (and shell-is-running
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3481 idlwave-query-shell-for-routine-info)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3482
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3483 (if (or (not ask-shell)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3484 (not (interactive-p)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3485 ;; 1. If we are not going to ask the shell, we need to do the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3486 ;; concatenation now.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3487 ;; 2. When this function is called non-interactively, it means
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3488 ;; that someone needs routine info *now*. The shell update
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3489 ;; causes the concatenation *delayed*, so not in time for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3490 ;; the current command. Therefore, we do a concatenation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3491 ;; now, even though the shell might do it again.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3492 (idlwave-concatenate-rinfo-lists))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3493
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3494 (when ask-shell
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3495 ;; Ask the shell about the routines it knows.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3496 (message "Querying the shell")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3497 (idlwave-shell-update-routine-info))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3498
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3499 (defun idlwave-load-system-rinfo ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3500 ;; Load and case-treat the system and lib info files.
27185
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
3501 (load "idlw-rinfo" t)
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3502 (message "Normalizing idlwave-builtin-routines...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3503 (setq idlwave-builtin-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3504 (idlwave-sintern-rinfo-list idlwave-builtin-routines 'sys))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3505 (message "Normalizing idlwave-builtin-routines...done")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3506 (setq idlwave-routines idlwave-builtin-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3507 (when (and (stringp idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3508 (file-regular-p idlwave-libinfo-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3509 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3510 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3511 (load-file idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3512 (message "Normalizing idlwave-library-routines...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3513 (setq idlwave-library-routines (idlwave-sintern-rinfo-list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3514 idlwave-library-routines 'sys))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3515 (message "Normalizing idlwave-library-routines...done"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3516 (error nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3517
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3518 (defun idlwave-update-buffer-routine-info ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3519 (let (res)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3520 (if idlwave-scan-all-buffers-for-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3521 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3522 ;; Scan all buffers, current buffer last
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3523 (message "Scanning all buffers...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3524 (setq res (idlwave-get-routine-info-from-buffers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3525 (reverse (buffer-list)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3526 ;; Just scan this buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3527 (if (eq major-mode 'idlwave-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3528 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3529 (message "Scanning current buffer...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3530 (setq res (idlwave-get-routine-info-from-buffers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3531 (list (current-buffer)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3532 ;; Put the result into the correct variable
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3533 (setq idlwave-buffer-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3534 (idlwave-sintern-rinfo-list res t))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3535
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3536 (defun idlwave-concatenate-rinfo-lists ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3537 "Put the different sources for routine information together."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3538 ;; The sequence here is important because earlier definitions shadow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3539 ;; later ones. We assume that if things in the buffers are newer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3540 ;; then in the shell of the system, it is meant to be different.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3541 ;; FIXME: should the builtin stuff be before the library?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3542 ;; This is how IDL searches, the user may also have
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3543 ;; functions overloading system stuff, and then the lib
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3544 ;; should be first. Difficult to find a general solution.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3545 ;; FIXME: can't we use nconc here in some way, to save memory?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3546 ;; This is possible for buffer abd shell stuff, but these are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3547 ;; small anyway, and so it is not so critical.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3548 (setq idlwave-routines (append idlwave-buffer-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3549 idlwave-compiled-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3550 idlwave-library-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3551 idlwave-builtin-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3552 (setq idlwave-class-alist nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3553 (let (class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3554 (loop for x in idlwave-routines do
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3555 (when (and (setq class (nth 2 x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3556 (not (assq class idlwave-class-alist)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3557 (push (list class) idlwave-class-alist))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3558 ;; Give a message with information about the number of routines we have.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3559 (message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3560 "Routine info updated: buffer(%d) compiled(%d) library(%d) system(%d)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3561 (length idlwave-buffer-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3562 (length idlwave-compiled-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3563 (length idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3564 (length idlwave-builtin-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3565
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3566 ;;----- Scanning buffers -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3567
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3568 (defun idlwave-get-routine-info-from-buffers (buffers)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3569 "Call `idlwave-get-buffer-routine-info' on idlwave-mode buffers in BUFFERS."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3570 (let (buf routine-lists res)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3571 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3572 (while (setq buf (pop buffers))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3573 (set-buffer buf)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3574 (if (eq major-mode 'idlwave-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3575 ;; yes, this buffer has the right mode.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3576 (progn (setq res (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3577 (idlwave-get-buffer-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3578 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3579 (push res routine-lists)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3580 ;; Concatenate the individual lists and return the result
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3581 (apply 'nconc routine-lists)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3582
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3583 (defun idlwave-get-buffer-routine-info ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3584 "Scan the current buffer for routine info. Return (PRO-LIST FUNC-LIST)."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3585 (let* ((case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3586 routine-list string entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3587 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3588 (save-restriction
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3589 (widen)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3590 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3591 (while (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3592 "^[ \t]*\\<\\(pro\\|function\\)\\>" nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3593 (setq string (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3594 (match-beginning 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3595 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3596 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3597 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3598 (setq entry (idlwave-parse-definition string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3599 (push entry routine-list))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3600 routine-list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3601
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3602 (defun idlwave-parse-definition (string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3603 "Parse a module definition."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3604 (let ((case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3605 start name args type keywords class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3606 ;; Remove comments
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3607 (while (string-match ";.*" string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3608 (setq string (replace-match "" t t string)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3609 ;; Remove the continuation line stuff
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3610 (while (string-match "\\([^a-zA-Z0-9$_]\\)\\$[ \t]*\n" string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3611 (setq string (replace-match "\\1 " t nil string)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3612 ;; Match the name and type.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3613 (when (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3614 "\\<\\(pro\\|function\\)\\>\\s-+\\(\\([a-zA-Z0-9$_]+\\)::\\)?\\([a-zA-Z0-9$_]+\\)" string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3615 (setq start (match-end 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3616 (setq type (downcase (match-string 1 string)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3617 (if (match-beginning 3)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3618 (setq class (match-string 3 string)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3619 (setq name (match-string 4 string)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3620 ;; Match normal args and keyword args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3621 (while (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3622 ",\\s-*\\([a-zA-Z][a-zA-Z0-9$_]*\\|_extra\\)\\s-*\\(=\\)?"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3623 string start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3624 (setq start (match-end 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3625 (if (match-beginning 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3626 (push (match-string 1 string) keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3627 (push (match-string 1 string) args)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3628 ;; Normalize and sort.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3629 (setq args (nreverse args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3630 (setq keywords (sort keywords (lambda (a b)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3631 (string< (downcase a) (downcase b)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3632 ;; Make and return the entry
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3633 ;; We don't know which argument are optional, so this information
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3634 ;; will not be contained in the calling sequence.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3635 (list name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3636 (if (equal type "pro") 'pro 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3637 class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3638 (cond ((not (boundp 'idlwave-scanning-lib))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3639 (cons 'buffer (buffer-file-name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3640 ((string= (downcase
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3641 (file-name-sans-extension
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3642 (file-name-nondirectory (buffer-file-name))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3643 (downcase name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3644 (list 'lib))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3645 (t (cons 'lib (file-name-nondirectory (buffer-file-name)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3646 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3647 (if (string= type "function") "Result = " "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3648 (if class "Obj ->[%s::]" "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3649 "%s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3650 (if args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3651 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3652 (if (string= type "function") "(" ", ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3653 (mapconcat 'identity args ", ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3654 (if (string= type "function") ")" ""))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3655 (if keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3656 (mapcar 'list keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3657 nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3658
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3659 ;;----- Scanning the library -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3660
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3661 (defun idlwave-create-libinfo-file (&optional arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3662 "Scan all files on selected dirs of IDL search path for routine information.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3663 A widget checklist will allow you to choose the directories.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3664 Write the result as a file `idlwave-libinfo-file'. When this file exists,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3665 will be automatically loaded to give routine information about library
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3666 routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3667 With ARG, just rescan the same directories as last time - so no widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3668 will pop up."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3669 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3670 ;; Make sure the file is loaded if it exists.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3671 (if (and (stringp idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3672 (file-regular-p idlwave-libinfo-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3673 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3674 (load-file idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3675 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3676 ;; Make sure the file name makes sense
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3677 (unless (and (stringp idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3678 (file-accessible-directory-p
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3679 (file-name-directory idlwave-libinfo-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3680 (not (string= "" (file-name-nondirectory
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3681 idlwave-libinfo-file))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3682 (error "`idlwave-libinfo-file' does not point to file in accessible directory."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3683
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3684 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3685 ((and arg idlwave-scanned-lib-directories)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3686 ;; Rescan the known directories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3687 (idlwave-scan-lib-files idlwave-scanned-lib-directories))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3688 (idlwave-library-path
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3689 ;; Get the directories from that variable
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3690 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3691 (idlwave-expand-path idlwave-library-path)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3692 idlwave-scanned-lib-directories))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3693 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3694 ;; Ask the shell for the path and run the widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3695 (message "Asking the shell for IDL path...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3696 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3697 "__pa=expand_path(!path,/array)&for i=0,n_elements(__pa)-1 do print,'PATH:',__pa[i]"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3698 '(idlwave-libinfo-command-hook nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3699 'hide))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3700
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3701 (defun idlwave-libinfo-command-hook (&optional arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3702 ;; Command hook used by `idlwave-create-libinfo-file'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3703 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3704 ;; Scan immediately
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3705 (idlwave-scan-lib-files idlwave-scanned-lib-directories)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3706 ;; Display the widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3707 (idlwave-display-libinfo-widget (idlwave-shell-path-filter)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3708 idlwave-scanned-lib-directories)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3709
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3710 (defvar idlwave-shell-command-output)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3711 (defun idlwave-shell-path-filter ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3712 ;; Convert the output of the path query into a list of directories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3713 (let ((path-string idlwave-shell-command-output)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3714 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3715 (start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3716 dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3717 (while (string-match "^PATH:[ \t]*\\(.*\\)\n" path-string start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3718 (push (match-string 1 path-string) dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3719 (setq start (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3720 (nreverse dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3721
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3722 (defconst idlwave-libinfo-widget-help-string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3723 "This is the front-end to the creation of IDLWAVE library routine info.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3724 Please select below the directories on IDL's search path from which you
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3725 would like to extract routine information, which will be stored in the file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3726
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3727 %s
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3728
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3729 If this is not the correct file, first set variable `idlwave-libinfo-file'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3730 Then call this command again.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3731 After selecting the directories, choose [Scan & Save] to scan the library
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3732 directories and save the routine info.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3733 \n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3734
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3735 (defvar idlwave-widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3736 (defvar widget-keymap)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3737 (defun idlwave-display-libinfo-widget (dirs selected-dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3738 "Create the widget to select IDL search path directories for scanning."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3739 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3740 (require 'widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3741 (require 'wid-edit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3742 (unless dirs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3743 (error "Don't know IDL's search path"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3744
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3745 ;; Allow only those directories to be selected which are in the path.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3746 (setq selected-dirs (delq nil (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3747 (if (member x dirs) x nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3748 selected-dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3749 (kill-buffer (get-buffer-create "*IDLWAVE Widget*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3750 (switch-to-buffer (get-buffer-create "*IDLWAVE Widget*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3751 (kill-all-local-variables)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3752 (make-local-variable 'idlwave-widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3753 (widget-insert (format idlwave-libinfo-widget-help-string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3754 idlwave-libinfo-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3755
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3756 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3757 :notify 'idlwave-widget-scan-lib-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3758 :help-echo "testing"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3759 "Scan & Save")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3760 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3761 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3762 :notify (lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3763 (kill-buffer (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3764 "Quit")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3765 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3766 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3767 :notify 'idlwave-delete-libinfo-file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3768 "Delete File")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3769 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3770 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3771 :notify '(lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3772 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3773 (widget-get idlwave-widget :path-dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3774 (widget-get idlwave-widget :path-dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3775 "Select All")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3776 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3777 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3778 :notify '(lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3779 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3780 (widget-get idlwave-widget :path-dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3781 nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3782 "Deselect All")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3783 (widget-insert "\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3784
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3785 (widget-insert "Select Directories\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3786
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3787 (setq idlwave-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3788 (apply 'widget-create
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3789 'checklist
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3790 :value selected-dirs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3791 :greedy t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3792 :tag "List of directories"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3793 (mapcar (lambda (x) (list 'item x)) dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3794 (widget-put idlwave-widget :path-dirs dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3795 (widget-insert "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3796 (use-local-map widget-keymap)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3797 (widget-setup)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3798 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3799 (delete-other-windows))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3800
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3801 (defun idlwave-delete-libinfo-file (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3802 (if (yes-or-no-p
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3803 (format "Delete file %s " idlwave-libinfo-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3804 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3805 (delete-file idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3806 (message "%s has been deleted" idlwave-libinfo-file))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3807
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3808 (defun idlwave-widget-scan-lib-files (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3809 ;; Call `idlwave-scan-lib-files' with data taken from the widget.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3810 (let* ((widget idlwave-widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3811 (selected-dirs (widget-value widget)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3812 (idlwave-scan-lib-files selected-dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3813
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3814 (defvar font-lock-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3815 (defun idlwave-scan-lib-files (selected-dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3816 ;; Scan the files in SELECTED-DIRS and store the info in a file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3817 (let* ((idlwave-scanning-lib t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3818 (idlwave-completion-case nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3819 dirs dir files file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3820 (setq idlwave-library-routines nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3821 (setq idlwave-scanned-lib-directories selected-dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3822 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3823 (set-buffer (get-buffer-create "*idlwave-scan.pro*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3824 (idlwave-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3825 (setq dirs (reverse selected-dirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3826 (while (setq dir (pop dirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3827 (when (file-directory-p dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3828 (setq files (directory-files dir 'full "\\.[pP][rR][oO]\\'"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3829 (while (setq file (pop files))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3830 (when (file-regular-p file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3831 (if (not (file-readable-p file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3832 (message "Skipping %s (no read permission)" file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3833 (message "Scanning %s..." file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3834 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3835 (insert-file-contents file 'visit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3836 (setq idlwave-library-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3837 (append (idlwave-get-routine-info-from-buffers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3838 (list (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3839 idlwave-library-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3840 )))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3841 (kill-buffer "*idlwave-scan.pro*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3842 (kill-buffer (get-buffer-create "*IDLWAVE Widget*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3843 (let ((font-lock-maximum-size 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3844 (find-file idlwave-libinfo-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3845 (if (and (boundp 'font-lock-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3846 font-lock-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3847 (font-lock-mode 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3848 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3849 (insert ";; IDLWAVE libinfo file\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3850 (insert (format ";; Created %s\n\n" (current-time-string)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3851
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3852 ;; Define the variable which contains a list of all scanned directories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3853 (insert "\n(setq idlwave-scanned-lib-directories\n '(")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3854 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3855 (insert (format "\n \"%s\"" x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3856 selected-dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3857 (insert "))\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3858 ;; Define the routine info list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3859 (insert "\n(setq idlwave-library-routines\n '(")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3860 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3861 (insert "\n ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3862 (insert (with-output-to-string (prin1 x))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3863 idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3864 (insert (format "))\n\n;;; %s ends here\n"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3865 (file-name-nondirectory idlwave-libinfo-file)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3866 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3867 ;; Save the buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3868 (save-buffer 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3869 (kill-buffer (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3870 (message "Info for %d routines saved in %s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3871 (length idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3872 idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3873 (sit-for 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3874 (idlwave-update-routine-info t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3875
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3876 (defun idlwave-expand-path (path &optional default-dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3877 ;; Expand parts of path starting with '+' recursively into directory list.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3878 ;; Relative recursive path elements are expanded relative to DEFAULT-DIR.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3879 (message "Expanding path...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3880 (let (path1 dir recursive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3881 (while (setq dir (pop path))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3882 (if (setq recursive (string= (substring dir 0 1) "+"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3883 (setq dir (substring dir 1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3884 (if (and recursive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3885 (not (file-name-absolute-p dir)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3886 (setq dir (expand-file-name dir default-dir)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3887 (if recursive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3888 ;; Expand recursively
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3889 (setq path1 (append (idlwave-recursive-directory-list dir) path1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3890 ;; Keep unchanged
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3891 (push dir path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3892 (message "Expanding path...done")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3893 (nreverse path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3894
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3895 (defun idlwave-recursive-directory-list (dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3896 ;; Return a list of all directories below DIR, including DIR itself
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3897 (let ((path (list dir)) path1 file files)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3898 (while (setq dir (pop path))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3899 (when (file-directory-p dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3900 (setq files (nreverse (directory-files dir t "[^.]")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3901 (while (setq file (pop files))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3902 (if (file-directory-p file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3903 (push (file-name-as-directory file) path)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3904 (push dir path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3905 path1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3906
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3907 ;;----- Asking the shell -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3908
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3909 ;; First, here is the idl program which can be used to query IDL for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3910 ;; defined routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3911 (defconst idlwave-routine-info.pro
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3912 "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3913 function idlwave_make_info_entry,name,func=func,separator=sep
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3914 ;; See if it's an object method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3915 func = keyword_set(func)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3916 methsep = strpos(name,'::')
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3917 meth = methsep ne -1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3918
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3919 ;; Get routine info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3920 pars = routine_info(name,/parameters,functions=func)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3921 source = routine_info(name,/source,functions=func)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3922 nargs = pars.num_args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3923 nkw = pars.num_kw_args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3924 if nargs gt 0 then args = pars.args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3925 if nkw gt 0 then kwargs = pars.kw_args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3926
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3927 ;; Trim the class, and make the name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3928 if meth then begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3929 class = strmid(name,0,methsep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3930 name = strmid(name,methsep+2,strlen(name)-1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3931 if nargs gt 0 then begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3932 ;; remove the self argument
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3933 wh = where(args ne 'SELF',nargs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3934 if nargs gt 0 then args = args(wh)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3935 endif
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3936 endif else begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3937 ;; No class, just a normal routine.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3938 class = \"\"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3939 endelse
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3940
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3941 ;; Calling sequence
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3942 cs = \"\"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3943 if func then cs = 'Result = '
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3944 if meth then cs = cs + 'Obj -> [' + '%s' + '::]'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3945 cs = cs + '%s'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3946 if func then cs = cs + '(' else if nargs gt 0 then cs = cs + ', '
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3947 if nargs gt 0 then begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3948 for j=0,nargs-1 do begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3949 cs = cs + args(j)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3950 if j lt nargs-1 then cs = cs + ', '
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3951 endfor
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3952 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3953 if func then cs = cs + ')'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3954 ;; Keyword arguments
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3955 kwstring = ''
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3956 if nkw gt 0 then begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3957 for j=0,nkw-1 do begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3958 kwstring = kwstring + ' ' + kwargs(j)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3959 endfor
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3960 endif
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3961
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3962 ret=(['IDLWAVE-PRO','IDLWAVE-FUN', $
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3963 'IDLWAVE-PRO','IDLWAVE-FUN'])(func+2*meth)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3964
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3965 return,ret + ': ' + name + sep + class + sep + source(0).path $
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3966 + sep + cs + sep + kwstring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3967 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3968
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3969 pro idlwave_routine_info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3970 sep = '<@>'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3971 print,'>>>BEGIN OF IDLWAVE ROUTINE INFO (\"' + sep + '\" IS THE SEPARATOR)'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3972 all = routine_info()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3973 for i=0,n_elements(all)-1 do $
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3974 print,idlwave_make_info_entry(all(i),separator=sep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3975 all = routine_info(/functions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3976 for i=0,n_elements(all)-1 do $
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3977 print,idlwave_make_info_entry(all(i),/func,separator=sep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3978 print,'>>>END OF IDLWAVE ROUTINE INFO'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3979 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3980 "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3981 "The idl program to get the routine info stuff.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3982 The output of this program is parsed by `idlwave-shell-routine-info-filter'.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3983
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3984 (defun idlwave-shell-routine-info-filter ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3985 "Function which parses the special output from idlwave_routine_info.pro."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3986 (let ((text idlwave-shell-command-output)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3987 (start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3988 sep sep-re file type spec specs name cs key keys class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3989 ;; Initialize variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3990 (setq idlwave-compiled-routines nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3991 ;; Cut out the correct part of the output.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3992 (if (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3993 "^>>>BEGIN OF IDLWAVE ROUTINE INFO (\"\\(.+\\)\" IS THE SEPARATOR.*"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3994 text)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3995 (setq sep (match-string 1 text)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3996 sep-re (concat (regexp-quote sep) " *")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3997 text (substring text (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3998 (error "Routine Info error: No match for BEGIN line"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3999 (if (string-match "^>>>END OF IDLWAVE ROUTINE INFO.*" text)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4000 (setq text (substring text 0 (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4001 (error "Routine Info error: No match for END line"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4002 ;; Match the output lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4003 (while (string-match "^IDLWAVE-\\(PRO\\|FUN\\): \\(.*\\)" text start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4004 (setq start (match-end 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4005 (setq type (match-string 1 text)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4006 spec (match-string 2 text)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4007 specs (idlwave-split-string spec sep-re)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4008 name (nth 0 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4009 class (if (equal (nth 1 specs) "") nil (nth 1 specs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4010 file (nth 2 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4011 cs (nth 3 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4012 key (nth 4 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4013 keys (if (and (stringp key)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4014 (not (string-match "\\` *\\'" key)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4015 (mapcar 'list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4016 (delete "" (idlwave-split-string key " +")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4017 (setq name (idlwave-sintern-routine-or-method name class t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4018 class (idlwave-sintern-class class t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4019 keys (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4020 (list (idlwave-sintern-keyword (car x) t))) keys))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4021 ;; Make sure we use the same string object for the same file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4022 (setq file (idlwave-sintern-file file t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4023 ;; FIXME: What should I do with routines from the temp file???
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4024 ;; Maybe just leave it in - there is a chance that the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4025 ;; routine is still in there.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4026 ;; (if (equal file idlwave-shell-temp-pro-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4027 ;; (setq file nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4028
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4029 ;; In the following ignore routines already defined in buffers,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4030 ;; assuming that if the buffer stuff differs, it is a "new"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4031 ;; version.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4032 ;; We could do the same for the library to avoid duplicates -
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4033 ;; but I think frequently a user might have several versions of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4034 ;; the same function in different programs, and in this case the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4035 ;; compiled one will be the best guess of all version.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4036 ;; Therefore, we leave duplicates of library routines in.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4037
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4038 (cond ((string= name "$MAIN$")) ; ignore this one
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4039 ((and (string= type "PRO")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4040 ;; FIXME: is it OK to make the buffer routines dominate?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4041 (not (idlwave-rinfo-assq name 'pro class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4042 idlwave-buffer-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4043 ;; FIXME: is it OK to make the library routines dominate?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4044 ;;(not (idlwave-rinfo-assq name 'pro class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4045 ;; idlwave-library-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4046 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4047 (push (list name 'pro class (cons 'compiled file) cs keys)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4048 idlwave-compiled-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4049 ((and (string= type "FUN")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4050 ;; FIXME: is it OK to make the buffer routines dominate?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4051 (not (idlwave-rinfo-assq name 'fun class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4052 idlwave-buffer-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4053 ;; FIXME: is it OK to make the library routines dominate?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4054 ;; (not (idlwave-rinfo-assq name 'fun class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4055 ;; idlwave-library-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4056 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4057 (push (list name 'fun class (cons 'compiled file) cs keys)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4058 idlwave-compiled-routines)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4059 ;; Reverse the definitions so that they are alphabetically sorted.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4060 (setq idlwave-compiled-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4061 (nreverse idlwave-compiled-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4062
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4063 (defvar idlwave-shell-temp-pro-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4064 (defun idlwave-shell-update-routine-info ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4065 "Query the shell for routine_info of compiled modules and update the lists."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4066 ;; Save and compile the procedure
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4067 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4068 (set-buffer (idlwave-find-file-noselect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4069 idlwave-shell-temp-pro-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4070 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4071 (insert idlwave-routine-info.pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4072 (save-buffer 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4073 (idlwave-shell-send-command (concat ".run " idlwave-shell-temp-pro-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4074 nil 'hide)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4075
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4076 ;; Execute the procedure and analyze the output
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4077 (idlwave-shell-send-command "idlwave_routine_info"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4078 '(progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4079 (idlwave-shell-routine-info-filter)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4080 (idlwave-concatenate-rinfo-lists))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4081 'hide))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4082
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4083 ;; ---------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4084 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4085 ;; Completion and displaying routine calling sequences
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4086
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4087 (defun idlwave-complete (&optional arg module class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4088 "Complete a function, procedure or keyword name at point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4089 This function is smart and figures out what can be legally completed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4090 at this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4091 - At the beginning of a statement it completes procedure names.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4092 - In the middle of a statement it completes function names.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4093 - after a `(' or `,' in the argument list of a function or procedure,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4094 it completes a keyword of the relevant function or procedure.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4095 - In the first arg of `OBJ_NEW', it completes a class name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4096
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4097 When several completions are possible, a list will be displayed in the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4098 *Completions* buffer. If this list is too long to fit into the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4099 window, scrolling can be achieved by repeatedly pressing \\[idlwave-complete].
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4100
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4101 The function also knows about object methods. When it needs a class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4102 name, the action depends upon `idlwave-query-class', which see. You
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4103 can force IDLWAVE to ask you for a class name with a \\[universal-argument] prefix
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4104 argument to this command.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4105
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4106 See also the variables `idlwave-keyword-completion-adds-equal' and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4107 `idlwave-function-completion-adds-paren'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4108
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4109 The optional ARG can be used to specify the completion type in order
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4110 to override IDLWAVE's idea of what should be completed at point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4111 Possible values are:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4112
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4113 0 <=> query for the completion type
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4114 1 <=> 'procedure
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4115 2 <=> 'procedure-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4116 3 <=> 'function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4117 4 <=> 'function-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4118 5 <=> 'procedure-method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4119 6 <=> 'procedure-method-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4120 7 <=> 'function-method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4121 8 <=> 'function-method-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4122 9 <=> 'class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4123
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4124 For Lisp programmers only:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4125 When we force a keyword, optional argument MODULE can contain the module name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4126 When we force a method or a method keyword, CLASS can specify the class."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4127 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4128 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4129 (let* ((where-list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4130 (if (and arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4131 (or (integerp arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4132 (symbolp arg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4133 (idlwave-make-force-complete-where-list arg module class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4134 (idlwave-where)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4135 (what (nth 2 where-list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4136 (idlwave-force-class-query (equal arg '(4)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4137 cwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4138
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4139 (if (and module (string-match "::" module))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4140 (setq class (substring module 0 (match-beginning 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4141 module (substring module (match-end 0))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4142
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4143 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4144
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4145 ((and (null arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4146 (eq (car-safe last-command) 'idlwave-display-completion-list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4147 (setq cwin (get-buffer-window "*Completions*")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4148 (setq this-command last-command)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4149 (idlwave-scroll-completions))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4150
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4151 ((null what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4152 (error "Nothing to complete here"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4153
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4154 ((eq what 'class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4155 (idlwave-complete-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4156
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4157 ((eq what 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4158 ;; Complete a procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4159 (let* ((class-selector (idlwave-determine-class (nth 3 where-list) 'pro))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4160 (isa (concat "procedure" (if class-selector "-method" "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4161 (type-selector 'pro))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4162 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4163 'procedure (if class-selector 'method 'routine)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4164 (idlwave-routines) 'idlwave-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4165 (format "Select a %s name%s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4166 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4167 (if class-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4168 (format " (class is %s)" class-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4169 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4170 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4171 'idlwave-attach-method-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4172
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4173 ((eq what 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4174 ;; Complete a function name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4175 (let* ((class-selector (idlwave-determine-class (nth 3 where-list) 'fun))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4176 (isa (concat "function" (if class-selector "-method" "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4177 (type-selector 'fun))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4178 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4179 'function (if class-selector 'method 'routine)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4180 (idlwave-routines) 'idlwave-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4181 (format "Select a %s name%s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4182 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4183 (if class-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4184 (format " (class is %s)" class-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4185 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4186 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4187 'idlwave-attach-method-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4188
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4189 ((eq what 'procedure-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4190 ;; Complete a procedure keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4191 (let* ((where (nth 3 where-list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4192 (name (car where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4193 (method-selector name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4194 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4195 (class (idlwave-determine-class where 'pro))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4196 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4197 (isa (format "procedure%s-keyword" (if class "-method" "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4198 (entry (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4199 name 'pro class (idlwave-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4200 (list (nth 5 entry)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4201 (unless (or entry (eq class t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4202 (error "Nothing known about procedure %s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4203 (idlwave-make-full-name class name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4204 (setq list (idlwave-fix-keywords name 'pro class list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4205 (unless list (error (format "No keywords available for procedure %s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4206 (idlwave-make-full-name class name))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4207 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4208 'keyword 'keyword list nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4209 (format "Select keyword for procedure %s%s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4210 (idlwave-make-full-name class name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4211 (if (member '("_EXTRA") list) " (note _EXTRA)" ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4212 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4213 'idlwave-attach-keyword-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4214
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4215 ((eq what 'function-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4216 ;; Complete a function keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4217 (let* ((where (nth 3 where-list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4218 (name (car where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4219 (method-selector name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4220 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4221 (class (idlwave-determine-class where 'fun))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4222 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4223 (isa (format "function%s-keyword" (if class "-method" "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4224 (entry (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4225 name 'fun class (idlwave-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4226 (list (nth 5 entry)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4227 (unless (or entry (eq class t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4228 (error "Nothing known about function %s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4229 (idlwave-make-full-name class name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4230 (setq list (idlwave-fix-keywords name 'fun class list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4231 (unless list (error (format "No keywords available for function %s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4232 (idlwave-make-full-name class name))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4233 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4234 'keyword 'keyword list nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4235 (format "Select keyword for function %s%s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4236 (idlwave-make-full-name class name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4237 (if (member '("_EXTRA") list) " (note _EXTRA)" ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4238 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4239 'idlwave-attach-keyword-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4240
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4241 (t (error "This should not happen (idlwave-complete)")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4242
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4243 (defun idlwave-make-force-complete-where-list (what &optional module class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4244 ;; Return an artificial WHERE specification to force the completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4245 ;; routine to complete a specific item independent of context.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4246 ;; WHAT is the prefix arg of `idlwave-complete', see there for details.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4247 ;; MODULE and CLASS can be used to specify the routine name and class.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4248 ;; The class name will also be found in MODULE if that is like "class::mod".
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4249 (let* ((what-list '(("procedure") ("procedure-keyword")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4250 ("function") ("function-keyword")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4251 ("procedure-method") ("procedure-method-keyword")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4252 ("function-method") ("function-method-keyword")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4253 ("class")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4254 (module (idlwave-sintern-routine-or-method module class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4255 (class (idlwave-sintern-class class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4256 (what (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4257 ((equal what 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4258 (setq what
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4259 (intern (completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4260 "Complete what? " what-list nil t))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4261 ((integerp what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4262 (setq what (intern (car (nth (1- what) what-list)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4263 ((and what
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4264 (symbolp what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4265 (assoc (symbol-name what) what-list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4266 what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4267 (t (error "Illegal WHAT"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4268 (nil-list '(nil nil nil nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4269 (class-list (list nil nil (or class t) nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4270
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4271 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4272
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4273 ((eq what 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4274 (list nil-list nil-list 'procedure nil-list nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4275
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4276 ((eq what 'procedure-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4277 (let* ((class-selector nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4278 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4279 (pro (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4280 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4281 "Procedure: " (idlwave-routines) 'idlwave-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4282 (setq pro (idlwave-sintern-routine pro))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4283 (list nil-list nil-list 'procedure-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4284 (list pro nil nil nil) nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4285
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4286 ((eq what 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4287 (list nil-list nil-list 'function nil-list nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4288
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4289 ((eq what 'function-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4290 (let* ((class-selector nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4291 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4292 (func (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4293 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4294 "Function: " (idlwave-routines) 'idlwave-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4295 (setq func (idlwave-sintern-routine func))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4296 (list nil-list nil-list 'function-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4297 (list func nil nil nil) nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4298
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4299 ((eq what 'procedure-method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4300 (list nil-list nil-list 'procedure class-list nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4301
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4302 ((eq what 'procedure-method-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4303 (let* ((class (idlwave-determine-class class-list 'pro))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4304 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4305 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4306 (pro (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4307 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4308 (format "Procedure in %s class: " class-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4309 (idlwave-routines) 'idlwave-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4310 (setq pro (idlwave-sintern-method pro))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4311 (list nil-list nil-list 'procedure-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4312 (list pro nil class nil) nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4313
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4314 ((eq what 'function-method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4315 (list nil-list nil-list 'function class-list nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4316
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4317 ((eq what 'function-method-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4318 (let* ((class (idlwave-determine-class class-list 'fun))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4319 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4320 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4321 (func (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4322 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4323 (format "Function in %s class: " class-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4324 (idlwave-routines) 'idlwave-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4325 (setq func (idlwave-sintern-method func))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4326 (list nil-list nil-list 'function-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4327 (list func nil class nil) nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4328
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4329 ((eq what 'class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4330 (list nil-list nil-list 'class nil-list nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4331
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4332 (t (error "Illegal value for WHAT")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4333
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4334 (defun idlwave-completing-read (&rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4335 ;; Completing read, case insensitive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4336 (let ((old-value (default-value 'completion-ignore-case)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4337 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4338 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4339 (setq-default completion-ignore-case t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4340 (apply 'completing-read args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4341 (setq-default completion-ignore-case old-value))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4342
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4343 (defun idlwave-make-full-name (class name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4344 ;; Make a fully qualified module name including the class name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4345 (concat (if class (format "%s::" class) "") name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4346
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4347 (defun idlwave-rinfo-assq (name type class list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4348 ;; Works like assq, but also checks type and class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4349 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4350 (let (match)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4351 (while (setq match (assq name list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4352 (and (or (eq type t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4353 (eq (nth 1 match) type))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4354 (eq (nth 2 match) class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4355 (throw 'exit match))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4356 (setq list (cdr (memq match list)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4357
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4358 (defun idlwave-all-assq (key list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4359 "Return a list of all associations of Key in LIST."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4360 (let (rtn elt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4361 (while (setq elt (assq key list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4362 (push elt rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4363 (setq list (cdr (memq elt list))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4364 (nreverse rtn)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4365
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4366 (defun idlwave-all-method-classes (method &optional type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4367 "Return all classes which have a method METHOD. TYPE is 'fun or 'pro.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4368 When TYPE is not specified, both procedures and functions will be considered."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4369 (if (null method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4370 (mapcar 'car idlwave-class-alist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4371 (let (rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4372 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4373 (and (nth 2 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4374 (or (not type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4375 (eq type (nth 1 x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4376 (push (nth 2 x) rtn)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4377 (idlwave-all-assq method (idlwave-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4378 (idlwave-uniquify rtn))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4379
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4380 (defun idlwave-all-method-keyword-classes (method keyword &optional type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4381 "Return all classes which have a method METHOD with keyword KEYWORD.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4382 TYPE is 'fun or 'pro.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4383 When TYPE is not specified, both procedures and functions will be considered."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4384 (if (or (null method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4385 (null keyword))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4386 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4387 (let (rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4388 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4389 (and (nth 2 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4390 (or (not type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4391 (eq type (nth 1 x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4392 (assoc keyword (nth 5 x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4393 (push (nth 2 x) rtn)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4394 (idlwave-all-assq method (idlwave-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4395 (idlwave-uniquify rtn))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4396
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4397 (defun idlwave-determine-class (info type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4398 ;; Determine the class of a routine call. INFO is the structure returned
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4399 ;; `idlwave-what-function' or `idlwave-what-procedure'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4400 ;; The third element in this structure is the class. When nil, we return nil.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4401 ;; When t, try to get the class from text properties at the arrow,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4402 ;; otherwise prompt the user for a class name. Also stores the selected
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4403 ;; class as a text property at the arrow.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4404 ;; TYPE is 'fun or 'pro.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4405 (let* ((class (nth 2 info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4406 (apos (nth 3 info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4407 (nassoc (assoc (if (stringp (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4408 (upcase (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4409 (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4410 idlwave-query-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4411 (dassoc (assq (if (car info) 'keyword-default 'method-default)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4412 idlwave-query-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4413 (query (cond (nassoc (cdr nassoc))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4414 (dassoc (cdr dassoc))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4415 (t t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4416 (arrow (and apos (string= (buffer-substring apos (+ 2 apos)) "->")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4417 (force-query idlwave-force-class-query)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4418 store class-alist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4419 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4420 ((null class) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4421 ((eq t class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4422 ;; There is an object which would like to know its class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4423 (if (and arrow (get-text-property apos 'idlwave-class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4424 idlwave-store-inquired-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4425 (not force-query))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4426 (setq class (get-text-property apos 'idlwave-class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4427 class (idlwave-sintern-class class)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4428 (when (and (eq class t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4429 (or force-query query))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4430 (setq class-alist
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4431 (mapcar 'list (idlwave-all-method-classes (car info) type)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4432 (setq class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4433 (idlwave-sintern-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4434 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4435 ((and (= (length class-alist) 0) (not force-query))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4436 (error "No classes available with method %s" (car info)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4437 ((and (= (length class-alist) 1) (not force-query))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4438 (car (car class-alist)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4439 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4440 (setq store idlwave-store-inquired-class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4441 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4442 (format "Class%s: " (if (stringp (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4443 (format " for %s method %s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4444 type (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4445 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4446 class-alist nil nil nil 'idlwave-class-history))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4447 (when (and class (not (eq t class)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4448 ;; We have a real class here
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4449 (when (and store arrow)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4450 (put-text-property apos (+ apos 2) 'idlwave-class class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4451 (put-text-property apos (+ apos 2) 'face idlwave-class-arrow-face))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4452 (setf (nth 2 info) class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4453 ;; Return the class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4454 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4455 ;; Default as fallback
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4456 (t class))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4457
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4458 (defvar type-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4459 (defvar class-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4460 (defvar method-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4461 (defun idlwave-selector (a)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4462 (and (eq (nth 1 a) type-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4463 (or (and (nth 2 a) (eq class-selector t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4464 (eq (nth 2 a) class-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4465
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4466 (defun idlwave-where ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4467 "Find out where we are.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4468 The return value is a list with the following stuff:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4469 (PRO-LIST FUNC-LIST COMPLETE-WHAT CW-LIST LAST-CHAR)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4470
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4471 PRO-LIST (PRO POINT CLASS ARROW)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4472 FUNC-LIST (FUNC POINT CLASS ARROW)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4473 COMPLETE-WHAT a symbol indicating what kind of completion makes sense here
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4474 CW-LIST Like PRO-LIST, for what can be copmpleted here.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4475 LAST-CHAR last relevant character before point (non-white non-comment,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4476 not part of current identifier or leading slash).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4477
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4478 In the lists, we have these meanings:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4479 PRO: Procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4480 FUNC: Function name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4481 POINT: Where is this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4482 CLASS: What class has the routine (nil=no, t=is method, but class unknown)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4483 ARROW: Where is the arrow?"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4484 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4485 (let* ((bos (save-excursion (idlwave-beginning-of-statement) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4486 (func-entry (idlwave-what-function bos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4487 (func (car func-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4488 (func-class (nth 1 func-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4489 (func-arrow (nth 2 func-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4490 (func-point (or (nth 3 func-entry) 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4491 (func-level (or (nth 4 func-entry) 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4492 (pro-entry (idlwave-what-procedure bos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4493 (pro (car pro-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4494 (pro-class (nth 1 pro-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4495 (pro-arrow (nth 2 pro-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4496 (pro-point (or (nth 3 pro-entry) 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4497 (last-char (idlwave-last-valid-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4498 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4499 cw cw-mod cw-arrow cw-class cw-point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4500 (if (< func-point pro-point) (setq func nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4501 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4502 ((string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4503 "\\`[ \t]*\\([a-zA-Z][a-zA-Z0-9$_]*\\)?\\'"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4504 (buffer-substring (if (> pro-point 0) pro-point bos) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4505 (setq cw 'procedure cw-class pro-class cw-point pro-point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4506 cw-arrow pro-arrow))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4507 ((string-match "\\`[ \t]*\\(pro\\|function\\)\\>"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4508 (buffer-substring bos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4509 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4510 ((string-match "OBJ_NEW([ \t]*'\\([a-zA-Z][a-zA-Z0-9$_]*\\)?\\'"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4511 (buffer-substring bos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4512 (setq cw 'class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4513 ((and func
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4514 (> func-point pro-point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4515 (= func-level 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4516 (memq last-char '(?\( ?,)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4517 (setq cw 'function-keyword cw-mod func cw-point func-point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4518 cw-class func-class cw-arrow func-arrow))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4519 ((and pro (eq last-char ?,))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4520 (setq cw 'procedure-keyword cw-mod pro cw-point pro-point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4521 cw-class pro-class cw-arrow pro-arrow))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4522 ; ((member last-char '(?\' ?\) ?\] ?!))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4523 ; ;; after these chars, a function makes no sense
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4524 ; ;; FIXME: I am sure there can be more in this list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4525 ; ;; FIXME: Do we want to do this at all?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4526 ; nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4527 ;; Everywhere else we try a function.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4528 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4529 (setq cw 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4530 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4531 (if (re-search-backward "->[ \t]*\\(\\([$a-zA-Z0-9_]+\\)::\\)?[$a-zA-Z0-9_]*\\=" bos t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4532 (setq cw-arrow (match-beginning 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4533 cw-class (if (match-end 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4534 (idlwave-sintern-class (match-string 2))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4535 t))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4536 (list (list pro pro-point pro-class pro-arrow)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4537 (list func func-point func-class func-arrow)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4538 cw
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4539 (list cw-mod cw-point cw-class cw-arrow)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4540 last-char)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4541
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4542 (defun idlwave-this-word (&optional class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4543 ;; Grab the word around point. CLASS is for the `skip-chars=...' functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4544 (setq class (or class "a-zA-Z0-9$_"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4545 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4546 (buffer-substring-no-properties
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4547 (progn (skip-chars-backward class) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4548 (progn (skip-chars-forward class) (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4549
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4550 (defvar idlwave-find-symbol-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4551 (defun idlwave-what-function (&optional bound)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4552 ;; Find out if point is within the argument list of a function.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4553 ;; The return value is ("function-name" (point) level).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4554 ;; Level is 1 on the to level parenthesis, higher further down.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4555
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4556 ;; If the optional BOUND is an integer, bound backwards directed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4557 ;; searches to this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4558
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4559 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4560 (let (pos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4561 func-point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4562 (old-syntax (syntax-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4563 (cnt 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4564 func arrow-start class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4565 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4566 (save-restriction
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4567 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4568 (set-syntax-table idlwave-find-symbol-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4569 (narrow-to-region (max 1 (or bound 0)) (point-max))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4570 ;; move back out of the current parenthesis
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4571 (while (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4572 (progn (up-list -1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4573 (error nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4574 (setq pos (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4575 (incf cnt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4576 (when (and (= (following-char) ?\()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4577 (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4578 "\\(::\\|\\<\\)\\([a-zA-Z][a-zA-Z0-9$_]*\\)\\="
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4579 bound t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4580 (setq func (match-string 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4581 func-point (goto-char (match-beginning 2))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4582 pos func-point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4583 (if (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4584 "->[ \t]*\\(\\([a-zA-Z][a-zA-Z0-9$_]*\\)::\\)?\\=" bound t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4585 (setq arrow-start (match-beginning 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4586 class (or (match-string 2) t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4587 (throw
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4588 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4589 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4590 (idlwave-sintern-routine-or-method func class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4591 (idlwave-sintern-class class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4592 arrow-start func-point cnt)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4593 (goto-char pos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4594 (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4595 (set-syntax-table old-syntax)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4596
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4597 (defun idlwave-what-procedure (&optional bound)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4598 ;; Find out if point is within the argument list of a procedure.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4599 ;; The return value is ("procedure-name" class arrow-pos (point)).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4600
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4601 ;; If the optional BOUND is an integer, bound backwards directed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4602 ;; searches to this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4603 (let ((pos (point)) pro-point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4604 pro class arrow-start string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4605 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4606 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4607 (setq string (buffer-substring (point) pos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4608 (if (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4609 "\\`[ \t]*\\([a-zA-Z][a-zA-Z0-9$_]*\\)[ \t]*\\(,\\|\\'\\)" string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4610 (setq pro (match-string 1 string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4611 pro-point (+ (point) (match-beginning 1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4612 (if (and (idlwave-skip-object)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4613 (setq string (buffer-substring (point) pos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4614 (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4615 "\\`[ \t]*\\(->\\)[ \t]*\\(\\([a-zA-Z][a-zA-Z0-9$_]*\\)::\\)?\\([a-zA-Z][a-zA-Z0-9$_]*\\)?[ \t]*\\(,\\|\\'\\)" string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4616 (setq pro (if (match-beginning 4)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4617 (match-string 4 string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4618 pro-point (if (match-beginning 4)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4619 (+ (point) (match-beginning 4))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4620 pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4621 arrow-start (+ (point) (match-beginning 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4622 class (or (match-string 3 string) t)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4623 (list (idlwave-sintern-routine-or-method pro class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4624 (idlwave-sintern-class class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4625 arrow-start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4626 pro-point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4627
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4628 (defun idlwave-skip-object ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4629 ;; If there is an object at point, move over it and return t.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4630 (let ((pos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4631 (if (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4632 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4633 (skip-chars-forward " ") ; white space
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4634 (skip-chars-forward "*") ; de-reference
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4635 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4636 ((looking-at idlwave-identifier)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4637 (goto-char (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4638 ((eq (following-char) ?\()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4639 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4640 (t (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4641 (catch 'endwhile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4642 (while t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4643 (cond ((eq (following-char) ?.)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4644 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4645 (if (not (looking-at idlwave-identifier))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4646 (throw 'exit nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4647 (goto-char (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4648 ((memq (following-char) '(?\( ?\[))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4649 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4650 (forward-list 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4651 (error (throw 'exit nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4652 (t (throw 'endwhile t)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4653 (if (looking-at "[ \t]*->")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4654 (throw 'exit (setq pos (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4655 (throw 'exit nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4656 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4657 nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4658
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4659
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4660 (defun idlwave-last-valid-char ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4661 "Return the last character before point which is not white or a comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4662 and also not part of the current identifier. Since we do this in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4663 order to identify places where keywords are, we consider the initial
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4664 `/' of a keyword as part of the identifier.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4665 This function is not general, can only be used for completion stuff."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4666 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4667 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4668 ;; skip the current identifier
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4669 (skip-chars-backward "a-zA-Z0-9_$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4670 ;; also skip a leading slash which might be belong to the keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4671 (if (eq (preceding-char) ?/)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4672 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4673 ;; FIXME: does not check if this is a valid identifier
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4674 (while t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4675 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4676 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4677 ((memq (preceding-char) '(?\; ?\$)) (throw 'exit nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4678 ((eq (preceding-char) ?\n)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4679 (beginning-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4680 (if (looking-at "\\([^;]\\)*\\$[ \t]*\\(;.*\\)?\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4681 ;; continuation line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4682 (goto-char (match-end 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4683 (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4684 (t (throw 'exit (preceding-char))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4685
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4686 (defvar idlwave-complete-after-success-form nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4687 "A form to evaluate after successful completion.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4688 (defvar idlwave-complete-after-success-form-force nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4689 "A form to evaluate after completion selection in *Completions* buffer.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4690 (defconst idlwave-completion-mark (make-marker)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4691 "A mark pointing to the beginning of the completion string.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4692
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4693 (defun idlwave-complete-in-buffer (type stype list selector prompt isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4694 &optional prepare-display-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4695 "Perform TYPE completion of word before point against LIST.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4696 SELECTOR is the PREDICATE argument for the completion function.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4697 Show PROMPT in echo area. TYPE is one of 'function, 'procedure or 'keyword."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4698 (let* ((completion-ignore-case t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4699 beg (end (point)) slash part spart completion all-completions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4700 dpart dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4701
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4702 (unless list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4703 (error (concat prompt ": No completions available")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4704
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4705 ;; What is already in the buffer?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4706 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4707 (skip-chars-backward "a-zA-Z0-9_$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4708 (setq slash (eq (preceding-char) ?/)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4709 beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4710 idlwave-complete-after-success-form
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4711 (list 'idlwave-after-successful-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4712 (list 'quote type) slash beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4713 idlwave-complete-after-success-form-force
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4714 (list 'idlwave-after-successful-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4715 (list 'quote type) slash (list 'quote 'force))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4716
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4717 ;; Try a completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4718 (setq part (buffer-substring beg end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4719 dpart (downcase part)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4720 spart (idlwave-sintern stype part)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4721 completion (try-completion part list selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4722 dcompletion (if (stringp completion) (downcase completion)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4723 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4724 ((null completion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4725 ;; nothing available.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4726 (error "Can't find %s completion for \"%s\"" isa part))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4727 ((and (not (equal dpart dcompletion))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4728 (not (eq t completion)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4729 ;; We can add something
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4730 (delete-region beg end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4731 (if (and (string= part dpart)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4732 (or (not (string= part ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4733 idlwave-complete-empty-string-as-lower-case)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4734 (not idlwave-completion-force-default-case))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4735 (insert dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4736 (insert completion))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4737 (if (eq t (try-completion completion list selector))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4738 ;; Now this is a unique match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4739 (idlwave-after-successful-completion type slash beg))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4740 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4741 ((or (eq completion t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4742 (and (equal dpart dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4743 (= 1 (length (setq all-completions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4744 (idlwave-uniquify
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4745 (all-completions part list selector)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4746 ;; This is already complete
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4747 (idlwave-after-successful-completion type slash beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4748 (message "%s is already the complete %s" part isa)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4749 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4750 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4751 ;; We cannot add something - offer a list.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4752 (message "Making completion list...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4753 (let* ((list all-completions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4754 (complete (memq spart all-completions))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4755 (completion-highlight-first-word-only t) ; XEmacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4756 (completion-fixup-function ; Emacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4757 (lambda () (and (eq (preceding-char) ?>)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4758 (re-search-backward " <" beg t)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4759 (setq list (sort list (lambda (a b)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4760 (string< (downcase a) (downcase b)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4761 (if prepare-display-function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4762 (setq list (funcall prepare-display-function list)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4763 (if (and (string= part dpart)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4764 (or (not (string= part ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4765 idlwave-complete-empty-string-as-lower-case)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4766 (not idlwave-completion-force-default-case))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4767 (setq list (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4768 (if (listp x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4769 (setcar x (downcase (car x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4770 (setq x (downcase x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4771 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4772 list)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4773 (idlwave-display-completion-list list prompt beg complete))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4774 t))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4775
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4776 (defun idlwave-complete-class ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4777 "Complete a class at point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4778 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4779 ;; Call `idlwave-routines' to make sure the class list will be available
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4780 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4781 ;; Now do the completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4782 (idlwave-complete-in-buffer 'class 'class idlwave-class-alist nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4783 "Select a class" "class"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4784
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4785
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4786 (defun idlwave-attach-classes (list is-kwd show-classes)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4787 ;; attach the proper class list to a LIST of completion items.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4788 ;; IS-KWD, when non-nil, shows its keywords - otherwise its methods
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4789 ;; SHOW-CLASSES is the value of `idlwave-completion-show-classes'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4790 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4791 (if (or (null show-classes) ; don't wnat to see classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4792 (null class-selector) ; not a method call
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4793 (stringp class-selector)) ; the class is already known
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4794 ;; In these cases, we do not have to do anything
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4795 (throw 'exit list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4796
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4797 ;; The property and dots stuff currently only make sense with XEmacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4798 ;; because Emacs drops text properties when filling the *Completions*
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4799 ;; buffer.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4800 (let* ((do-prop (and (featurep 'xemacs) (>= show-classes 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4801 (do-buf (not (= show-classes 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4802 (do-dots (featurep 'xemacs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4803 (max (abs show-classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4804 (lmax (if do-dots (apply 'max (mapcar 'length list))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4805 classes nclasses class-info space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4806 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4807 (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4808 ;; get the classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4809 (setq classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4810 (if is-kwd
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4811 (idlwave-all-method-keyword-classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4812 method-selector x type-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4813 (idlwave-all-method-classes x type-selector)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4814 (setq nclasses (length classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4815 ;; Make the separator between item and class-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4816 (if do-dots
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4817 (setq space (concat " " (make-string (- lmax (length x)) ?.)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4818 (setq space " "))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4819 (if do-buf
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4820 ;; We do want info in the buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4821 (if (<= nclasses max)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4822 (setq class-info (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4823 space
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4824 "<" (mapconcat 'identity classes ",") ">"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4825 (setq class-info (format "%s<%d classes>" space nclasses)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4826 (setq class-info nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4827 (when do-prop
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4828 ;; We do want properties
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4829 (setq x (copy-sequence x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4830 (put-text-property 0 (length x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4831 'help-echo (mapconcat 'identity classes " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4832 x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4833 (if class-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4834 (list x class-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4835 x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4836 list))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4837
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4838 (defun idlwave-attach-method-classes (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4839 ;; Call idlwave-attach-classes with method parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4840 (idlwave-attach-classes list nil idlwave-completion-show-classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4841 (defun idlwave-attach-keyword-classes (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4842 ;; Call idlwave-attach-classes with keyword parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4843 (idlwave-attach-classes list t idlwave-completion-show-classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4844
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4845 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4846 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4847 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4848 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4849 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4850
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4851 (defun idlwave-scroll-completions (&optional message)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4852 "Scroll the completion window on this frame."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4853 (let ((cwin (get-buffer-window "*Completions*" 'visible))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4854 (win (selected-window)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4855 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4856 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4857 (select-window cwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4858 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4859 (scroll-up)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4860 (error (if (and (listp last-command)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4861 (nth 2 last-command))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4862 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4863 (select-window win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4864 (eval idlwave-complete-after-success-form))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4865 (set-window-start cwin (point-min)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4866 (and message (message message)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4867 (select-window win))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4868
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4869 (defun idlwave-display-completion-list (list &optional message beg complete)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4870 "Display the completions in LIST in the completions buffer and echo MESSAGE."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4871 (unless (and (get-buffer-window "*Completions*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4872 (idlwave-local-value 'idlwave-completion-p "*Completions*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4873 (move-marker idlwave-completion-mark beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4874 (setq idlwave-before-completion-wconf (current-window-configuration)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4875
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4876 (if (featurep 'xemacs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4877 (idlwave-display-completion-list-xemacs list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4878 (idlwave-display-completion-list-emacs list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4879
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4880 ;; Store a special value in `this-command'. When `idlwave-complete'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4881 ;; finds this in `last-command', it will scroll the *Completions* buffer.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4882 (setq this-command (list 'idlwave-display-completion-list message complete))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4883
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4884 ;; Mark the completions buffer as created by cib
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4885 (idlwave-set-local 'idlwave-completion-p t "*Completions*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4886
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4887 ;; Fontify the classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4888 (if (and idlwave-completion-fontify-classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4889 (consp (car list)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4890 (idlwave-completion-fontify-classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4891
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4892 ;; Display the message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4893 (message (or message "Making completion list...done")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4894
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4895 (defun idlwave-choose (function &rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4896 "Call FUNCTION as a completion chooser and pass ARGS to it."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4897 (let ((completion-ignore-case t)) ; install correct value
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4898 (apply function args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4899 (eval idlwave-complete-after-success-form-force))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4900
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4901 (defun idlwave-restore-wconf-after-completion ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4902 "Restore the old (before completion) window configuration."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4903 (and idlwave-completion-restore-window-configuration
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4904 idlwave-before-completion-wconf
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4905 (set-window-configuration idlwave-before-completion-wconf)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4906
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4907 (defun idlwave-set-local (var value &optional buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4908 "Set the buffer-local value of VAR in BUFFER to VALUE."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4909 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4910 (set-buffer (or buffer (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4911 (set (make-local-variable var) value)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4912
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4913 (defun idlwave-local-value (var &optional buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4914 "Return the value of VAR in BUFFER, but only if VAR is local to BUFFER."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4915 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4916 (set-buffer (or buffer (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4917 (and (local-variable-p var (current-buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4918 (symbol-value var))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4919
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4920 ;; In XEmacs, we can use :activate-callback directly
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4921
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4922 (defun idlwave-display-completion-list-xemacs (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4923 (with-output-to-temp-buffer "*Completions*"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4924 (display-completion-list list :activate-callback
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4925 'idlwave-default-choose-completion)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4926
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4927 (defun idlwave-default-choose-completion (&rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4928 "Execute `default-choose-completion' and then restore the win-conf."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4929 (apply 'idlwave-choose 'default-choose-completion args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4930
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4931 ;; In Emacs we have to replace the keymap in the *Completions* buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4932 ;; in order to install our wrappers.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4933
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4934 (defvar idlwave-completion-map nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4935 "Keymap for completion-list-mode with idlwave-complete.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4936
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4937 (defun idlwave-display-completion-list-emacs (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4938 "Display completion list and install the choose wrappers."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4939 (with-output-to-temp-buffer "*Completions*"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4940 (display-completion-list list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4941 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4942 (set-buffer "*Completions*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4943 (use-local-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4944 (or idlwave-completion-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4945 (setq idlwave-completion-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4946 (idlwave-make-modified-completion-map (current-local-map)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4947
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4948 (defun idlwave-make-modified-completion-map (old-map)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4949 "Replace `choose-completion' and `mouse-choose-completion' in OLD-MAP."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4950 (let ((new-map (copy-keymap old-map)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4951 (substitute-key-definition
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4952 'choose-completion 'idlwave-choose-completion new-map)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4953 (substitute-key-definition
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4954 'mouse-choose-completion 'idlwave-mouse-choose-completion new-map)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4955 new-map))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4957 (defun idlwave-choose-completion (&rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4958 "Choose the completion that point is in or next to."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4959 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4960 (apply 'idlwave-choose 'choose-completion args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4961
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4962 (defun idlwave-mouse-choose-completion (&rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4963 "Click on an alternative in the `*Completions*' buffer to choose it."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4964 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4965 (apply 'idlwave-choose 'mouse-choose-completion args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4966
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4967 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4968 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4969
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4970 (defun idlwave-completion-fontify-classes ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4971 "Goto the *Completions* buffer and fontify the class info."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4972 (when (featurep 'font-lock)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4973 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4974 (set-buffer "*Completions*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4975 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4976 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4977 (while (re-search-forward "\\.*<[^>]+>" nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4978 (put-text-property (match-beginning 0) (match-end 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4979 'face 'font-lock-string-face))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4980
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4981 (defun idlwave-uniquify (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4982 (let (nlist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4983 (loop for x in list do
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4984 (add-to-list 'nlist x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4985 nlist))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4986
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4987 (defun idlwave-after-successful-completion (type slash &optional verify)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4988 "Add `=' or `(' after successful completion of keyword and function.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4989 Restore the pre-completion window configuration if possible."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4990 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4991 ((eq type 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4992 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4993 ((eq type 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4994 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4995 ((equal idlwave-function-completion-adds-paren nil) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4996 ((or (equal idlwave-function-completion-adds-paren t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4997 (equal idlwave-function-completion-adds-paren 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4998 (insert "("))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4999 ((equal idlwave-function-completion-adds-paren 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5000 (insert "()")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5001 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5002 (t nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5003 ((eq type 'keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5004 (if (and idlwave-keyword-completion-adds-equal
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5005 (not slash))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5006 (progn (insert "=") t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5007 nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5008
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5009 ;; Restore the pre-completion window configuration if this is safe.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5010
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5011 (if (or (eq verify 'force) ; force
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5012 (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5013 (get-buffer-window "*Completions*") ; visible
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5014 (idlwave-local-value 'idlwave-completion-p
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5015 "*Completions*") ; cib-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5016 (eq (marker-buffer idlwave-completion-mark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5017 (current-buffer)) ; buffer OK
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5018 (equal (marker-position idlwave-completion-mark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5019 verify))) ; pos OK
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5020 (idlwave-restore-wconf-after-completion))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5021 (move-marker idlwave-completion-mark nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5022 (setq idlwave-before-completion-wconf nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5023
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5024 (defun idlwave-routine-info-from-idlhelp (&optional arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5025 "Make IDLHELP display the online documentation about the routine at point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5026 Sends the command `? MODULE' to the IDLWAVE-Shell. Shell must be running,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5027 it does not autostart for this task."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5028 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5029 (idlwave-routine-info arg 'external))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5030
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5031 (defun idlwave-routine-info (&optional arg external)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5032 "Display a routines calling sequence and list of keywords.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5033 When point is on the name a function or procedure, or in the argument
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5034 list of a function or procedure, this command displays a help buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5035 with the information. When called with prefix arg, enforce class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5036 query.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5037
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5038 When point is on an object operator `->', display the class stored in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5039 this arrow, if any (see `idlwave-store-inquired-class'). With a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5040 prefix arg, the class property is cleared out."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5041
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5042 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5043 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5044 (if (string-match "->" (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5045 (max (point-min) (1- (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5046 (min (+ 2 (point)) (point-max))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5047 ;; Cursor is on an arrow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5048 (if (get-text-property (point) 'idlwave-class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5049 ;; arrow has class property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5050 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5051 ;; Remove property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5052 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5053 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5054 (when (looking-at ".?\\(->\\)")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5055 (remove-text-properties (match-beginning 1) (match-end 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5056 '(idlwave-class nil face nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5057 (message "Class property removed from arrow")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5058 ;; Echo class property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5059 (message "Arrow has text property identifying object to be class %s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5060 (get-text-property (point) 'idlwave-class)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5061 ;; No property found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5062 (message "Arrow has no class text property"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5063
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5064 ;; Not on an arrow...
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5065 (let* ((idlwave-query-class nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5066 (idlwave-force-class-query (equal arg '(4)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5067 (module (idlwave-what-module)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5068 (cond ((car module)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5069 (if external
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5070 (apply 'idlwave-search-online-help module)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5071 (apply 'idlwave-display-calling-sequence module)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5072 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5073 (error "Don't know which calling sequence to show."))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5074
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5075 (defun idlwave-search-online-help (name &optional type class olh)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5076 "Tell IDL to lookup CLASS::NAME with type TYPE in the online help.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5077 If TYPE and CLASS are both nil, just look up NAME in the default help file."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5078 ;; If only the IDLHELP application was better designed, so that
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5079 ;; we could make it open the right thing right away. As things are,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5080 ;; we need to pipe the stuff through the help search engine, and we
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5081 ;; cannot enter a space.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5082 (let* (extra book full string cmd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5083
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5084 ;; Try to find a clue for the right help book
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5085 (if (and type (not olh))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5086 (setq olh (or (nth 6 (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5087 name type class idlwave-builtin-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5088 (nth 6 (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5089 name type class idlwave-routines)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5090
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5091 ;; Sometimes the book is given as a symbol - make it a string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5092 (if (and olh (symbolp olh)) (setq olh (symbol-name olh)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5093 (setq book (or olh "idl")) ; We need a default
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5094 ;; Add the FULL_PATH keyword if appropriate
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5095 (if (and (file-name-absolute-p book)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5096 (file-exists-p book))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5097 (setq full ",/FULL_PATH")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5098 (setq full ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5099
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5100 ;; We would like to add "Method" or so, but stupid IDL online help
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5101 ;; command treats a space as a separator and interprets the next thing as
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5102 ;; the book name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5103 ;; (setq extra (cond ((eq type 'kwd) " keyword")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5104 ;; (class " method")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5105 ;; ((eq type 'pro) " procedure")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5106 ;; ((eq type 'fun) " function")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5107 ;; (t "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5108 (setq extra "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5109
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5110 ;; Methods are subitems of classes, the separator is a single `:'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5111 (if (and name class (not (eq type 'kwd)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5112 (setq name (concat class ":" name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5113 ;; FIXME: We used to use book, but in idl5.3, all help is in idl.hlp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5114 (setq string (concat name extra)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5115 cmd (format "ONLINE_HELP,'%s',BOOK='%s'%s" string "idl" full))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5116 ; cmd (format "ONLINE_HELP,'%s',BOOK='%s'%s" string book full))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5117 (message "Sending to IDL: %s" cmd) (sit-for 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5118 (idlwave-shell-send-command cmd)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5119
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5120 (defun idlwave-resolve (&optional arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5121 "Call RESOLVE on the module name at point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5122 Like `idlwave-routine-info', this looks for a routine call at point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5123 After confirmation in the minibuffer, it will use the shell to issue
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5124 a RESOLVE call for this routine, to attempt to make it defined and its
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5125 routine info available for IDLWAVE. If the routine is a method call,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5126 both `class__method' and `class__define' will be tried.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5127 With ARG, enforce query for the class of object methods."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5128 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5129 (let* ((idlwave-query-class nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5130 (idlwave-force-class-query (equal arg '(4)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5131 (module (idlwave-what-module))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5132 (name (idlwave-make-full-name (nth 2 module) (car module)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5133 (type (if (eq (nth 1 module) 'pro) "pro" "function"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5134 (resolve (read-string "Resolve: " (format "%s %s" type name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5135 (kwd "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5136 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5137 (if (string-match "\\(pro\\|function\\)[ \t]+\\(\\(.*\\)::\\)?\\(.*\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5138 resolve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5139 (setq type (match-string 1 resolve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5140 class (if (match-beginning 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5141 (match-string 3 resolve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5142 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5143 name (match-string 4 resolve)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5144 (if (string= (downcase type) "function")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5145 (setq kwd ",/is_function"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5146
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5147 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5148 ((null class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5149 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5150 (format "resolve_routine,'%s'%s" (downcase name) kwd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5151 'idlwave-update-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5152 nil t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5153 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5154 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5155 (format "resolve_routine,'%s__define'%s" (downcase class) kwd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5156 (list 'idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5157 (format "resolve_routine,'%s__%s'%s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5158 (downcase class) (downcase name) kwd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5159 '(idlwave-update-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5160 nil t))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5161
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5162 (defun idlwave-find-module (&optional arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5163 "Find the source code of an IDL module.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5164 Works for modules for which IDLWAVE has routine info available.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5165 The function offers as default the module name `idlwave-routine-info' would
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5166 use. With ARG force class query for object methods."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5167 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5168 (let* ((idlwave-query-class nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5169 (idlwave-force-class-query (equal arg '(4)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5170 (module (idlwave-what-module))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5171 (default (concat (idlwave-make-full-name (nth 2 module) (car module))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5172 (if (eq (nth 1 module) 'pro) "<p>" "<f>")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5173 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5174 (delq nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5175 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5176 (if (eq 'system (car-safe (nth 3 x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5177 ;; Take out system routines with no source.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5178 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5179 (cons
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5180 (concat (idlwave-make-full-name (nth 2 x) (car x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5181 (if (eq (nth 1 x) 'pro) "<p>" "<f>"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5182 (cdr x))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5183 (idlwave-routines))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5184 (name (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5185 (format "Module (Default %s): "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5186 (if default default "none"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5187 list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5188 type class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5189 (if (string-match "\\`\\s-*\\'" name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5190 ;; Nothing, use the default.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5191 (setq name default))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5192 (if (string-match "<[fp]>" name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5193 (setq type (substring name -2 -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5194 name (substring name 0 -3)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5195 (if (string-match "\\(.*\\)::\\(.*\\)" name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5196 (setq class (match-string 1 name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5197 name (match-string 2 name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5198 (setq name (idlwave-sintern-routine-or-method name class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5199 class (idlwave-sintern-class class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5200 type (cond ((equal type "f") 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5201 ((equal type "p") 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5202 (t t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5203 (idlwave-do-find-module name type class)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5204
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5205 (defun idlwave-do-find-module (name type class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5206 (let ((name1 (idlwave-make-full-name class name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5207 source buf1 entry
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5208 (buf (current-buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5209 (pos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5210 (setq entry (idlwave-rinfo-assq name type class (idlwave-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5211 source (nth 3 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5212 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5213 ((or (null name) (equal name ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5214 (error "Abort"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5215 ((null entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5216 (error "Nothing known about a module %s" name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5217 ((eq (car source) 'system)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5218 (error "Source code for system routine %s is not available."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5219 name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5220 ((equal (cdr source) "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5221 (error "Source code for routine %s is not available."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5222 name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5223 ((memq (car source) '(buffer lib compiled))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5224 (setq buf1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5225 (if (eq (car source) 'lib)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5226 (idlwave-find-lib-file-noselet
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5227 (or (cdr source)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5228 (format "%s.pro" (downcase name))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5229 (idlwave-find-file-noselect (cdr source))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5230 (pop-to-buffer buf1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5231 (goto-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5232 (let ((case-fold-search t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5233 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5234 (concat "^[ \t]*\\<"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5235 (cond ((equal type "f") "function")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5236 ((equal type "p") "pro")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5237 (t "\\(pro\\|function\\)"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5238 "\\>[ \t]+"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5239 (regexp-quote (downcase name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5240 "[^a-zA-Z0-9_$]")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5241 nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5242 (goto-char (match-beginning 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5243 (pop-to-buffer buf)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5244 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5245 (error "Could not find routine %s" name1)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5246
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5247 (defun idlwave-what-module ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5248 "Return a default module for stuff near point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5249 Used by `idlwave-routine-info' and `idlwave-find-module'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5250 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5251 (let* ((where (idlwave-where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5252 (cw (nth 2 where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5253 (pro (car (nth 0 where)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5254 (func (car (nth 1 where)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5255 (this-word (idlwave-this-word "a-zA-Z0-9$_"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5256 (next-char (save-excursion (skip-chars-forward "a-zA-Z0-9$_")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5257 (following-char)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5258 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5259 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5260 ((and (eq cw 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5261 (not (equal this-word "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5262 (setq this-word (idlwave-sintern-routine-or-method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5263 this-word (nth 2 (nth 3 where))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5264 (list this-word 'pro
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5265 (idlwave-determine-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5266 (cons this-word (cdr (nth 3 where)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5267 'pro)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5268 ((and (eq cw 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5269 (not (equal this-word ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5270 (eq next-char ?\()) ; exclude arrays, vars.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5271 (setq this-word (idlwave-sintern-routine-or-method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5272 this-word (nth 2 (nth 3 where))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5273 (list this-word 'fun
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5274 (idlwave-determine-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5275 (cons this-word (cdr (nth 3 where)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5276 'fun)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5277 (func
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5278 (list func 'fun (idlwave-determine-class (nth 1 where) 'fun)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5279 (pro
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5280 (list pro 'pro (idlwave-determine-class (nth 0 where) 'pro)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5281 (t nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5282
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5283 (defun idlwave-fix-keywords (name type class keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5284 ;; This fixes the list of keywords.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5285 (let ((case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5286 name1 type1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5287
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5288 ;; If this is the OBJ_NEW function, try to figure out the class and use
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5289 ;; the keywords from the corresponding INIT method.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5290 (if (and (equal name "OBJ_NEW")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5291 (eq major-mode 'idlwave-mode))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5292 (let* ((bos (save-excursion (idlwave-beginning-of-statement) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5293 (string (buffer-substring bos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5294 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5295 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5296 (and (string-match "obj_new([^'\"]*['\"]\\([a-zA-Z0-9_]+\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5297 string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5298 (setq class (idlwave-sintern-class (match-string 1 string)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5299 (setq keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5300 (append keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5301 (nth 5 (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5302 (idlwave-sintern-method "INIT")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5303 'fun
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5304 class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5305 (idlwave-routines))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5306
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5307 ;; If the class is `t', combine all keywords of all methods NAME
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5308 (when (eq class t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5309 (loop for x in (idlwave-routines) do
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5310 (and (nth 2 x) ; non-nil class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5311 (or (and (eq (nth 1 x) type) ; default type
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5312 (eq (car x) name)) ; default name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5313 (and (eq (nth 1 x) type1) ; backup type
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5314 (eq (car x) name1))) ; backup name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5315 (mapcar (lambda (k) (add-to-list 'keywords k))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5316 (nth 5 x))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5317 (setq keywords (idlwave-uniquify keywords)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5318 ;; Return the final list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5319 keywords))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5320
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5321 (defvar idlwave-rinfo-map (make-sparse-keymap))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5322 (define-key idlwave-rinfo-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5323 (if (featurep 'xemacs) [button2] [mouse-2])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5324 'idlwave-mouse-active-rinfo)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5325 (define-key idlwave-rinfo-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5326 (if (featurep 'xemacs) [button3] [mouse-3])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5327 'idlwave-mouse-active-rinfo-right)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5328 (defvar idlwave-popup-source)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5329
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5330 (defun idlwave-display-calling-sequence (name type class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5331 ;; Display the calling sequence of module NAME, type TYPE in class CLASS.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5332 (let* ((entry (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5333 name type class (idlwave-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5334 (name (or (car entry) name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5335 (class (or (nth 2 entry) class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5336 (source (nth 3 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5337 ;;(system (eq (car source) 'system))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5338 (calling-seq (nth 4 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5339 (keywords (nth 5 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5340 (olh (nth 6 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5341 (help-echo3 " Button3: IDL Online Help")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5342 (help-echo23 "Button2: Pop to source and back. Button3: IDL Online Help")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5343 (col 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5344 (data (list name type class (current-buffer) olh))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5345 (km-prop (if (featurep 'xemacs) 'keymap 'local-map))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5346 beg props win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5347 (setq keywords (idlwave-fix-keywords name type class keywords))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5348 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5349 ((null entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5350 (error "No %s %s known" type name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5351 ((or (null name) (equal name ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5352 (error "No function or procedure call at point."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5353 ((null calling-seq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5354 (error "Calling sequence of %s %s is not available" type name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5355 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5356 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5357 (set-buffer (get-buffer-create "*Help*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5358 (setq buffer-read-only nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5359 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5360 (set (make-local-variable 'idlwave-popup-source) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5361 (setq props (list 'mouse-face 'highlight
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5362 km-prop idlwave-rinfo-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5363 'help-echo help-echo23
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5364 'data (cons 'usage data)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5365 (insert "Usage: ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5366 (setq beg (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5367 (insert (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5368 (format calling-seq class name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5369 (format calling-seq name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5370 "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5371 (add-text-properties beg (point) props)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5372
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5373 (insert "Keywords:")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5374 (if (null keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5375 (insert " No keywords accepted.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5376 (setq col 9)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5377 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5378 (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5379 (if (>= (+ col 1 (length (car x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5380 (window-width))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5381 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5382 (insert "\n ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5383 (setq col 9)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5384 (insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5385 (setq beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5386 props (list 'mouse-face 'highlight
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5387 km-prop idlwave-rinfo-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5388 'data (cons 'keyword data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5389 'help-echo help-echo3
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5390 'keyword (car x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5391 (insert (car x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5392 (add-text-properties beg (point) props)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5393 (setq col (+ col 1 (length (car x)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5394 keywords))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5395 (insert "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5396
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5397 (insert "Origin: ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5398 (setq beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5399 props (list 'mouse-face 'highlight
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5400 km-prop idlwave-rinfo-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5401 'help-echo help-echo23
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5402 'data (cons 'origin data)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5403 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5404 ((eq (car source) 'system)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5405 (insert "system routine"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5406 ((equal source '(lib))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5407 (insert (format "library file %s.pro" (downcase name))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5408 ((eq (car source) 'lib)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5409 (insert "library file ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5410 (insert (cdr source)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5411 ((eq (car source) 'buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5412 (insert "buffer visiting ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5413 (insert (abbreviate-file-name (cdr source))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5414 ((eq (car source) 'compiled)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5415 (insert "compiled from ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5416 (insert (cdr source))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5417 (add-text-properties beg (point) props)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5418 (setq buffer-read-only t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5419 (display-buffer "*Help*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5420 (if (and (setq win (get-buffer-window "*Help*"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5421 idlwave-resize-routine-help-window)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5422 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5423 (let ((ww (selected-window)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5424 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5425 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5426 (select-window win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5427 (enlarge-window (- (/ (frame-height) 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5428 (window-height)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5429 (shrink-window-if-larger-than-buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5430 (select-window ww)))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5431
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5432 (defun idlwave-mouse-active-rinfo-right (ev)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5433 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5434 (idlwave-mouse-active-rinfo ev 'right))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5435
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5436 (defun idlwave-mouse-active-rinfo (ev &optional right)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5437 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5438 (mouse-set-point ev)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5439 (let (data id name type class buf keyword olh bufwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5440 (setq data (get-text-property (point) 'data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5441 keyword (get-text-property (point) 'keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5442 id (car data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5443 name (nth 1 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5444 type (nth 2 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5445 class (nth 3 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5446 buf (nth 4 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5447 olh (nth 5 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5448 bufwin (get-buffer-window buf t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5449 (cond ((or (eq id 'usage) (eq id 'origin))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5450 (if right
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5451 (idlwave-search-online-help name type class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5452 (setq idlwave-popup-source (not idlwave-popup-source))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5453 (if idlwave-popup-source
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5454 (condition-case err
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5455 (idlwave-do-find-module name type class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5456 (error
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5457 (setq idlwave-popup-source nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5458 (if (window-live-p bufwin) (select-window bufwin))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5459 (error (nth 1 err))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5460 (if bufwin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5461 (select-window bufwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5462 (pop-to-buffer buf)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5463 ((eq id 'keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5464 (if right
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5465 (idlwave-search-online-help keyword 'kwd class olh)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5466 (error "Button2 not active for keywords"))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5467
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5468 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5469 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5470 ;; Additions for use with imenu.el and func-menu.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5471 ;; (pop-up a list of IDL units in the current file).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5472 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5473
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5474 (defun idlwave-prev-index-position ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5475 "Search for the previous procedure or function.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5476 Return nil if not found. For use with imenu.el."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5477 (save-match-data
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5478 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5479 ((idlwave-find-key "\\<\\(pro\\|function\\)\\>" -1 'nomark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5480 ;; ((idlwave-find-key idlwave-begin-unit-reg 1 'nomark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5481 (t nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5482
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5483 (defun idlwave-unit-name ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5484 "Return the unit name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5485 Assumes that point is at the beginning of the unit as found by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5486 `idlwave-prev-index-position'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5487 (forward-sexp 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5488 (forward-sexp -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5489 (let ((begin (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5490 (re-search-forward "[a-zA-Z][a-zA-Z0-9$_]+\\(::[a-zA-Z][a-zA-Z0-9$_]+\\)?")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5491 (if (fboundp 'buffer-substring-no-properties)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5492 (buffer-substring-no-properties begin (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5493 (buffer-substring begin (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5494
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5495 (defun idlwave-function-menu ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5496 "Use `imenu' or `function-menu' to jump to a procedure or function."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5497 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5498 (if (string-match "XEmacs" emacs-version)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5499 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5500 (require 'func-menu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5501 (function-menu))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5502 (require 'imenu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5503 (imenu (imenu-choose-buffer-index))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5504
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5505 ;; Here we kack func-menu.el in order to support this new mode.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5506 ;; The latest versions of func-menu.el already have this stuff in, so
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5507 ;; we hack only if it is not already there.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5508 (when (fboundp 'eval-after-load)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5509 (eval-after-load "func-menu"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5510 '(progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5511 (or (assq 'idlwave-mode fume-function-name-regexp-alist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5512 (not (boundp 'fume-function-name-regexp-idl)) ; avoid problems
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5513 (setq fume-function-name-regexp-alist
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5514 (cons '(idlwave-mode . fume-function-name-regexp-idl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5515 fume-function-name-regexp-alist)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5516 (or (assq 'idlwave-mode fume-find-function-name-method-alist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5517 (not (fboundp 'fume-find-next-idl-function-name)) ; avoid problems
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5518 (setq fume-find-function-name-method-alist
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5519 (cons '(idlwave-mode . fume-find-next-idl-function-name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5520 fume-find-function-name-method-alist))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5521
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5522 (defun idlwave-edit-in-idlde ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5523 "Edit the current file in IDL Development environment."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5524 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5525 (start-process "idldeclient" nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5526 idlwave-shell-explicit-file-name "-c" "-e"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5527 (buffer-file-name) "&"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5528
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5529 (defun idlwave-launch-idlhelp ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5530 "Start the IDLhelp application."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5531 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5532 (start-process "idlhelp" nil idlwave-help-application))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5533
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5534 ;; Menus - using easymenu.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5535 (defvar idlwave-mode-menu-def
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5536 `("IDLWAVE"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5537 ["PRO/FUNC menu" idlwave-function-menu t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5538 ("Motion"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5539 ["Subprogram Start" idlwave-beginning-of-subprogram t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5540 ["Subprogram End" idlwave-end-of-subprogram t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5541 ["Block Start" idlwave-beginning-of-block t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5542 ["Block End" idlwave-end-of-block t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5543 ["Up Block" idlwave-backward-up-block t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5544 ["Down Block" idlwave-down-block t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5545 ["Skip Block Backward" idlwave-backward-block t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5546 ["Skip Block Forward" idlwave-forward-block t])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5547 ("Mark"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5548 ["Subprogram" idlwave-mark-subprogram t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5549 ["Block" idlwave-mark-block t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5550 ["Header" idlwave-mark-doclib t])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5551 ("Format"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5552 ["Indent Subprogram" idlwave-indent-subprogram t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5553 ["(Un)Comment Region" idlwave-toggle-comment-region "C-c ;"]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5554 ["Continue/Split line" idlwave-split-line t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5555 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5556 ["Toggle Auto Fill" idlwave-auto-fill-mode :style toggle
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5557 :selected (symbol-value idlwave-fill-function)])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5558 ("Templates"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5559 ["Procedure" idlwave-procedure t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5560 ["Function" idlwave-function t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5561 ["Doc Header" idlwave-doc-header t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5562 ["Log" idlwave-doc-modification t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5563 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5564 ["Case" idlwave-case t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5565 ["For" idlwave-for t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5566 ["Repeat" idlwave-repeat t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5567 ["While" idlwave-while t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5568 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5569 ["Close Block" idlwave-close-block t])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5570 ("Completion / RInfo"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5571 ["Complete" idlwave-complete t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5572 ("Complete Special"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5573 ["1 Procedure Name" (idlwave-complete 'procedure) t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5574 ["2 Procedure Keyword" (idlwave-complete 'procedure-keyword) t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5575 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5576 ["3 Function Name" (idlwave-complete 'function) t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5577 ["4 Function Keyword" (idlwave-complete 'function-keyword) t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5578 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5579 ["5 Procedure Method Name" (idlwave-complete 'procedure-method) t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5580 ["6 Procedure Method Keyword" (idlwave-complete 'procedure-method-keyword) t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5581 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5582 ["7 Function Method Name" (idlwave-complete 'function-method) t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5583 ["8 Function Method Keyword" (idlwave-complete 'function-method-keyword) t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5584 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5585 ["9 Class Name" idlwave-complete-class t])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5586 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5587 ["Show Routine Info" idlwave-routine-info t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5588 ["Show Routine Doc with IDLHELP" idlwave-routine-info-from-idlhelp t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5589 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5590 ["Find Routine Source" idlwave-find-module t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5591 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5592 ["Update Routine Info" idlwave-update-routine-info t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5593 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5594 "IDL Library Routine Info"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5595 ["Select Library Directories" idlwave-create-libinfo-file t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5596 ["Scan Directories" (idlwave-update-routine-info '(16)) idlwave-scanned-lib-directories])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5597 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5598 ("External"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5599 ["Generate IDL tags" idlwave-make-tags t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5600 ["Start IDL shell" idlwave-shell t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5601 ["Edit file in IDLDE" idlwave-edit-in-idlde t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5602 ["Launch IDL Help" idlwave-launch-idlhelp t])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5603 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5604 ("Customize"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5605 ["Browse IDLWAVE Group" idlwave-customize t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5606 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5607 ["Build Full Customize Menu" idlwave-create-customize-menu
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5608 (fboundp 'customize-menu-create)])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5609 ("Documentation"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5610 ["Describe Mode" describe-mode t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5611 ["Abbreviation List" idlwave-list-abbrevs t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5612 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5613 ["Commentary in idlwave.el" idlwave-show-commentary t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5614 ["Commentary in idlwave-shell.el" idlwave-shell-show-commentary t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5615 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5616 ["Info" idlwave-info t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5617 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5618 ["Launch IDL Help" idlwave-launch-idlhelp t])))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5619
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5620 (defvar idlwave-mode-debug-menu-def
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5621 '("Debug"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5622 ["Start IDL shell" idlwave-shell t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5623 ["Save and .RUN buffer" idlwave-shell-save-and-run
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5624 (and (boundp 'idlwave-shell-automatic-start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5625 idlwave-shell-automatic-start)]))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5626
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5627 (if (or (featurep 'easymenu) (load "easymenu" t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5628 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5629 (easy-menu-define idlwave-mode-menu idlwave-mode-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5630 "IDL and WAVE CL editing menu"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5631 idlwave-mode-menu-def)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5632 (easy-menu-define idlwave-mode-debug-menu idlwave-mode-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5633 "IDL and WAVE CL editing menu"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5634 idlwave-mode-debug-menu-def)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5635
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5636 (defun idlwave-customize ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5637 "Call the customize function with idlwave as argument."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5638 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5639 ;; Try to load the code for the shell, so that we can customize it
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5640 ;; as well.
27185
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
5641 (or (featurep 'idlw-shell)
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
5642 (load "idlw-shell" t))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5643 (customize-browse 'idlwave))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5644
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5645 (defun idlwave-create-customize-menu ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5646 "Create a full customization menu for IDLWAVE, insert it into the menu."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5647 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5648 (if (fboundp 'customize-menu-create)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5649 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5650 ;; Try to load the code for the shell, so that we can customize it
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5651 ;; as well.
27185
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
5652 (or (featurep 'idlw-shell)
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
5653 (load "idlw-shell" t))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5654 (easy-menu-change
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5655 '("IDLWAVE") "Customize"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5656 `(["Browse IDLWAVE group" idlwave-customize t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5657 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5658 ,(customize-menu-create 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5659 ["Set" Custom-set t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5660 ["Save" Custom-save t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5661 ["Reset to Current" Custom-reset-current t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5662 ["Reset to Saved" Custom-reset-saved t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5663 ["Reset to Standard Settings" Custom-reset-standard t]))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5664 (message "\"IDLWAVE\"-menu now contains full customization menu"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5665 (error "Cannot expand menu (outdated version of cus-edit.el)")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5666
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5667 (defun idlwave-show-commentary ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5668 "Use the finder to view the file documentation from `idlwave.el'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5669 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5670 (require 'finder)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5671 (finder-commentary "idlwave.el"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5672
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5673 (defun idlwave-shell-show-commentary ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5674 "Use the finder to view the file documentation from `idlwave-shell.el'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5675 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5676 (require 'finder)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5677 (finder-commentary "idlwave-shell.el"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5678
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5679 (defun idlwave-info ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5680 "Read documentation for IDLWAVE in the info system."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5681 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5682 (require 'info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5683 (Info-goto-node "(idlwave)"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5684
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5685 (defun idlwave-list-abbrevs (arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5686 "Show the code abbreviations define in IDLWAVE mode.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5687 This lists all abbrevs where the replacement text differs from the input text.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5688 These are the ones the users want to learn to speed up their writing.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5689
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5690 The function does *not* list abbrevs which replace a word with itself
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5691 to call a hook. These hooks are used to change the case of words or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5692 to blink the matching `begin', and the user does not need to know them.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5693
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5694 With arg, list all abbrevs with the corresponding hook.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5695
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5696 This function was written since `list-abbrevs' looks terrible for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5697
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5698 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5699 (let ((table (symbol-value 'idlwave-mode-abbrev-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5700 abbrevs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5701 str rpl func fmt (len-str 0) (len-rpl 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5702 (mapatoms
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5703 (lambda (sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5704 (if (symbol-value sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5705 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5706 (setq str (symbol-name sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5707 rpl (symbol-value sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5708 func (symbol-function sym))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5709 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5710 (setq func (prin1-to-string func))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5711 (if (and (listp func) (stringp (nth 2 func)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5712 (setq rpl (concat "EVAL: " (nth 2 func))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5713 func "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5714 (setq func "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5715 (if (or arg (not (string= rpl str)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5716 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5717 (setq len-str (max len-str (length str)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5718 (setq len-rpl (max len-rpl (length rpl)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5719 (setq abbrevs (cons (list str rpl func) abbrevs)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5720 table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5721 ;; sort the list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5722 (setq abbrevs (sort abbrevs (lambda (a b) (string< (car a) (car b)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5723 ;; Make the format
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5724 (setq fmt (format "%%-%ds %%-%ds %%s\n" len-str len-rpl))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5725 (with-output-to-temp-buffer "*Help*"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5726 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5727 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5728 (princ "Abbreviations and Actions in IDLWAVE-Mode\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5729 (princ "=========================================\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5730 (princ (format fmt "KEY" "REPLACE" "HOOK"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5731 (princ (format fmt "---" "-------" "----")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5732 (princ "Code Abbreviations and Templates in IDLWAVE-Mode\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5733 (princ "================================================\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5734 (princ (format fmt "KEY" "ACTION" ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5735 (princ (format fmt "---" "------" "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5736 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5737 (lambda (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5738 (setq str (car list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5739 rpl (nth 1 list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5740 func (nth 2 list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5741 (princ (format fmt str rpl func)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5742 abbrevs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5743 ;; Make sure each abbreviation uses only one display line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5744 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5745 (set-buffer "*Help*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5746 (setq truncate-lines t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5747
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5748 (run-hooks 'idlwave-load-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5749
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5750 (provide 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5751
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5752 ;;; idlwave.el ends here
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5753