annotate lisp/progmodes/idlwave.el @ 29345:a4d9a2ab3c73

(newline): Don't bind before-change-function, after-change-function.
author Dave Love <fx@gnu.org>
date Wed, 31 May 2000 22:50:41 +0000
parents 0396e9e8d57b
children 8eff9cc9cbae
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>
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
8 ;; Version: 3.15
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
9 ;; Date: $Date: 2000/02/04 09:19:36 $
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,
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
112 ;; but it works.
26956
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 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
132 ;; 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
133 ;; completed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 ;; 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
136 ;; query for a method has multiple entries for some methods. Would
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
137 ;; be too difficult to fix this hardly used case.
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 ;;
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 ;;; Code:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 (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
143
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 (eval-and-compile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 ;; 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
146 (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
147 (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
148 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
149 ;; 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
150 (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
151 (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
152 (` (defvar (, var) (, value) (, doc))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 (defgroup idlwave nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 "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
156 :tag "IDLWAVE"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 :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
158 "http://strw.leidenuniv.nl/~dominik/Tools/idlwave")
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
159 :link '(emacs-commentary-link :tag "Commentary in idlw-shell.el"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
160 "idlw-shell.el")
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 :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
162 :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
163 :prefix "idlwave"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 :group 'languages)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 ;;; Variables for indentation behavior ---------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 (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
169 "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
170 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172 (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
173 "*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
174 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
175 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
176 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 (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
180 "*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
181 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
182 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 (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
186 "*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
187 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
188 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
189 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 (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
193 "*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
194 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
195 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
196 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
197 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
198 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
199 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 (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
203 "*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
204 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
205 of the paragraph."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 (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
210 "*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
211 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
212 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
213 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 (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
217 "*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
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 'boolean)
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-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
222 "*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
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-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
227 "*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
228 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
229 '+' 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
230 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
231
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 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
233 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
234 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 :type 'boolean)
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 (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
238 "*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
239 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
240 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
241 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
242 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245 (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
246 "*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
247 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
248 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
249 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 (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
253 "*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
254 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
255 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
256 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
257 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
258 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 :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
260 'regexp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 (defcustom idlwave-code-comment ";;[^;]"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 "*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
264 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
265 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
266 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
267 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269 ;; 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
270 ;; 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
271
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 ;;; Routine Info and Completion ---------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275 (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
276 "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
277 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279 (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
280 "*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
281 `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
282 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
283 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
284 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
285 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
286 :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
287 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 (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
290 "*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
291 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
292 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
293 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
294 :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
295 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 (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
298 "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
299 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
300 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
301 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
302 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
303 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
304 The value is a list of directories. A directory preceeded by a `+' will
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
305 be searched recursively. If you set this variable on a UNIX system, the shell
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
306 will not be asked."
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 :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
308 :type '(repeat (directory)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
310 (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
311 "*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
312 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
313 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
314 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
315 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
316 :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
317 :type 'file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
318
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
319 (eval-and-compile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
320 (defconst idlwave-tmp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
321 '(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
322 (const upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
323 (const downcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324 (const capitalize)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
325 (const preserve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
326 (symbol :tag "Other"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
327
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
328
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
329 (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
330 (keyword . upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331 (class . preserve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332 (method . preserve))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 "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
334
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 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
336 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
337 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
338 methods.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339 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
340 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
341 `method'. Plausible values are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
342
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343 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
344 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
345 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
346 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
347
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
348 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
349 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
350
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351 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
352 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
353 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
354 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
355 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
356 `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
357 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
358 *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
359 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
360
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361 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
362 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
363
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364 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
365 `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
366 :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
367 :type `(repeat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368 (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
369 ,idlwave-tmp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 (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
372 "*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
373 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
374 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
375 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
376 lower case."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 :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
378 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 (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
381 "*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
382 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
383 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
384 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
385 completions."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 :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
387 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 (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
390 "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
391 `idlwave-completion-case'.")
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 (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
394 "*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
395 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
396 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
397 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
398 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
399 :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
400 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 (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
403 "*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
404 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
405 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
406 like this:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 MyMethod <Class1,Class2,Class3>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 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
411 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
412
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413 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
414 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
415 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
416 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
417 :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
418 :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
419 (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
420
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
421 (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
422 "*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
423 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
424 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
425 :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
426 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 (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
429 (keyword-default . nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 "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
431
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432 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
433 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
434 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
435 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
436 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
437
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
438 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
439 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
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 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
449 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
450 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
451 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
452 - 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
453 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
454 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
455 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
456
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
457 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
458 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
459 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
460 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
461 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
462
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
463 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
464 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
465 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
466 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
467 :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
468 :type '(list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469 (cons (const method-default)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
470 (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
471 (cons (const keyword-default)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
472 (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
473 (repeat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474 :tag "Exceptions to defaults"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 :inline t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
476 (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
477 (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
478
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 (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
480 "*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
481 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
482 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
483 `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
484 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
485
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 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
487 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
488 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
489 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
490 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
491 on the arrow.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
493 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
494 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
495 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
496
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 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
498 `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
499 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
500 at point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
501 :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
502 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 (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
505 "*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
506 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
507 (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
508 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
509 :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
510 :type 'symbol)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 (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
513 "*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
514 :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
515 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 (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
518 "*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
519 :group 'idlwave-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522 (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
523 "*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
524 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
525 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
526 between the two."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
527 :group 'idlwave-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528 :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
529 (const :tag "(" t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 (const :tag "()" 2)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 (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
533 "*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
534 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
535 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
536 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
537 :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
538 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 ;;; 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
541
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542 (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
543 "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
544 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
545 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 (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
548 "*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
549 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
550 :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
551 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 (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
554 "*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
555 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
556 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
557 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
558
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 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
560 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
561 is loaded."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562 :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
563 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 (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
566 "*Non-nil means, enable `idlwave-surround'.
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
567 If non-nil, `=',`<',`>',`&',`,', `->' are surrounded with spaces by
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568 `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 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
570
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 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
572 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
573 `idlwave-action-and-binding'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574 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
575
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 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
577 :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
578 :type 'boolean)
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 (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
581 "*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
582 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
583 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
584 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
585 :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
586 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 (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
589 "*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
590 :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
591 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 (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
594 "*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
595 :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
596 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 (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
599 "*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
600 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
601 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
602 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
603 parentheses of expanded functions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 See `idlwave-check-abbrev'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606 :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
607 :type 'boolean)
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 (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
610 "*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
611 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
612 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
613 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
614 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
615 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
616 :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
617 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 (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
620 "*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
621 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
622 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
623 :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
624 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626 ;;; Action/Expand Tables.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
628 ;; 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
629 ;; 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
630 ;; 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
631 ;; 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
632 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
633 ;; 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
634 ;; 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
635 ;; 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
636 ;; 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
637 ;; 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
638 ;; 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
639 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
640 ;; Example actions:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
641 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 ;; Capitalize system vars
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
643 ;; (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
644 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
645 ;; Capitalize procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
646 ;; (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
647 ;; '(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 common block 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 "\\<common\\>[ \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 ;; Capitalize label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
653 ;; (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
654 ;; '(capitalize-word -1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 (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
657 "*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
658 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
659 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
660 the action lists.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 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
663 binding is not requested.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 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
665
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 (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
667 "*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
668 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
669 `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
670 `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
671
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
672 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
673 binding is requested.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 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
675
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
676 ;;; 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
677
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
678 (defgroup idlwave-documentation nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
679 "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
680 :group 'idlwave)
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 ;; FIXME: make defcustom?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
683 (defvar idlwave-file-header
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
684 (list nil
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 ; NAME:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
687 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 ;
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 ; PURPOSE:
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 ; CATEGORY:
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 ; CALLING SEQUENCE:
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 ; INPUTS:
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 ; OPTIONAL 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 ; KEYWORD PARAMETERS:
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 ; OUTPUTS:
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 ; OPTIONAL 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 ; COMMON BLOCKS:
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 ; SIDE EFFECTS:
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 ; RESTRICTIONS:
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 ; PROCEDURE:
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 ; EXAMPLE:
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 ; MODIFICATION HISTORY:
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 "*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
747 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
748 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
749 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
750 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
751
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752 (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
753 "*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
754 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755 :type 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
757 (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
758 "*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
759 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
760 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
761 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
762 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765 (defcustom idlwave-doclib-start "^;+\\+"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 "*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
767 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
769
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 (defcustom idlwave-doclib-end "^;+-"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 "*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
772 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 ;;; External Programs -------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777 (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
778 "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
779 :group 'idlwave)
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 ;; WARNING: The following variable has recently been moved from
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
782 ;; idlw-shell.el to this file. I hope this does not break
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783 ;; anything.
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 (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
786 "*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
787 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
788 execution search path."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 :group 'idlwave-external-programs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
791
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
792 ;; 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
793 (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
794 "*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
795 :type '(repeat (string :value ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
796 :group 'idlwave-external-programs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
797
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 (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
799 "*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
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 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
802
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
803 ;;; Miscellaneous variables -------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
805 (defgroup idlwave-misc nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
806 "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
807 :group 'idlwave)
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 (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
810 "*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
811 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
812 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
814 (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
815 '(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
816 common-blocks class-arrows)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817 "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
818 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
819 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
820 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
821 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
822
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 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
824 batch-files Batch Files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
825 idl-keywords IDL Keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826 label Statement Labels
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 goto Goto Statements
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828 common-blocks Common Blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829 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
830 system-variables System Variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
831 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
832 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
833 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
834 :type '(set
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
835 :inline t :greedy t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
836 (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
837 (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
838 (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
839 (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
840 (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
841 (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
842 (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
843 (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
844 (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
845 (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
846
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
847 (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
848 "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
849 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
850 :type 'hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
852 (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
853 "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
854 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
855 :type 'hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
856
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
857 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
858 ;;; End customization variables section
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
859 ;;;
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 ;;; Non customization variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
862
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863 ;;; 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
864 ;;; 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
865 ;;; and Carsten Dominik...
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 (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
868 "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
869
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
870 (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
871 "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
872
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
873 (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
874 "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
875
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
876 (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
877 (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
878 (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
879 (<= emacs-minor-version 29))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
880
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
881 ;; 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
882 ;; 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
883 (idl-keywords
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
884 ;; To update this regexp, update the list of keywords and
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
885 ;; evaluate the form.
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
886 ; (insert
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
887 ; (concat
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
888 ; "\"\\\\<"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
889 ; (regexp-opt
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
890 ; '("and" "or" "xor" "not"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
891 ; "eq" "ge" "gt" "le" "lt" "ne"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
892 ; "for" "do" "endfor"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
893 ; "if" "then" "endif" "else" "endelse"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
894 ; "case" "of" "endcase"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
895 ; "begin" "end"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
896 ; "repeat" "until" "endrep"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
897 ; "while" "endwhile"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
898 ; "goto" "return"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
899 ; "inherits" "mod"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
900 ; "on_error" "on_ioerror")) ; on_error is not officially reserved
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
901 ; "\\\\>\""))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902 (concat "\\<\\("
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 "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
904 "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
905 "\\|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
906 "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
907 "until\\|while\\|xor"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
908 "\\)\\>"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
909
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 ;; 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
911 ;; 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
912 (pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
913 '("\\<\\(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
914 (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
915 (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
916
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917 ;; Common blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918 (common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 '("\\<\\(common\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*,?"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 (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
921 (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
922 (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
923 ;; 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
924 (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
925 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 (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
927 )))
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 ;; Batch files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
930 (batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
931 '("^[ \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
932
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933 ;; FIXME warning.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934 (fixme
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935 '("\\<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
936
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
937 ;; Labels
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
938 (label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
939 '("^[ \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
940
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
941 ;; 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
942 (goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
943 '("\\(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
944 (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
945 (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
946
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
947 ;; 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
948 ;; This is anchored to the comma preceeding the keyword.
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
949 ;; Treats continuation lines, works only during whole buffer
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
950 ;; fontification. Slow, use it only in fancy fontification.
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
951 (keyword-parameters
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
952 '("[(,][ \t]*\\(\\$[ \t]*\\(;.*\\)?\\(\n[ \t]*;.*\\)*\n[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)"
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
953 (4 font-lock-reference-face)))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
954
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
955 ;; System variables start with a bang.
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
956 (system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
957 '("\\(![a-zA-Z_]+\\(\\.\\sw+\\)?\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
958 (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
959
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
960 ;; 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
961 (special-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
962 '("[<>#]" (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
963
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964 ;; 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
965 (all-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
966 '("[-*^#+<>/]" (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
967
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
968 ;; 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
969 (class-arrows
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 (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
971 (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
972 idlwave-class-arrow-face
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
973 'idlwave-class-arrow-face))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
975 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
976
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
977 ;; 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
978 ;; 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
979 (setq oldp oldp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
980 idl-keywords idl-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 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
982 common-blocks common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
983 batch-files batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
984 fixme fixme
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 label label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986 goto goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987 keyword-parameters keyword-parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
988 system-variables system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
989 special-operators special-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
990 all-operators all-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
991 class-arrows class-arrows)
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-1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
994 (list pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
995 batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
996 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
997
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
998 (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
999 (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
1000
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1001 (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
1002 (list pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1003 batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1004 idl-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1005 label goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006 common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007 keyword-parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1008 system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1009 class-arrows
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1010 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013 (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
1014 ;; 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
1015 (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
1016 (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
1017 (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
1018
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 (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
1020 "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
1021
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022 (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
1023 '((idlwave-font-lock-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1024 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
1025 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
1026 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
1027 nil t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028 ((?$ . "w") (?_ . "w") (?. . "w"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 beginning-of-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1030
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031 (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
1032 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
1033
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1034 (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
1035 "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
1036 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
1037 only by whitespace.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1038
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1039 (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
1040 "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
1041 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
1042
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1043 (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
1044 "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
1045 not matter.")
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-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
1048 "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
1049 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
1050 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
1051
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052 (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
1053 "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
1054
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 (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
1056 "\\<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
1057 "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
1058 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
1059
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1060 (defconst idlwave-block-matches
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1061 '(("pro" . "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1062 ("function" . "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1063 ("case" . "endcase")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1064 ("else" . "endelse")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1065 ("for" . "endfor")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1066 ("then" . "endif")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1067 ("repeat" . "endrep")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 ("while" . "endwhile"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069 "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
1070 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
1071 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
1072 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
1073 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
1074 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
1075
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076 (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
1077 "\\<\\(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
1078 "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
1079 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
1080 `idlwave-block-matches'")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1081
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1082 (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
1083 "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
1084
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1085 (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
1086 "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
1087
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1088 (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
1089 "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
1090
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1091 (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
1092 "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
1093
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 (defconst idlwave-statement-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096 ;; "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
1097 ;; 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
1098 '(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
1099 ;; 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
1100 (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
1101 '(if . ("if\\>" "then"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 '(for . ("for\\>" "do"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 '(begin . ("begin\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1104 '(pdef . ("pro\\>\\|function\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1105 '(while . ("while\\>" "do"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106 '(repeat . ("repeat\\>" "repeat"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1107 '(goto . ("goto\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1108 '(case . ("case\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1109 (cons 'call (list (concat idlwave-identifier "\\(\\s *$\\|\\s *,\\)") nil))
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1110 '(assign . ("[^=>\n]*=" nil)))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1111
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1112 "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
1113 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
1114 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
1115 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
1116 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
1117 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
1118 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
1119 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
1120 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
1121 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
1122 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
1123 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
1124
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1125 (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
1126 "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
1127
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1128 (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
1129 "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
1130
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1131 ;; 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
1132 ;; 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
1133 ;; 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
1134 (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
1135 "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
1136 Normally a space.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1137
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1138 (defconst idlwave-continuation-char ?$
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1139 "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
1140 \\[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
1141
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1142 (defconst idlwave-mode-version " 3.15")
26956
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 (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
1145 "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
1146 (` (quote (lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1147 (, (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
1148
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1149 ;; 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
1150 ;; 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
1151 ;; 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
1152 ;; (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
1153 ;; 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
1154
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1155 (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
1156 "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
1157 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
1158 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
1159 (` (quote (lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1160 (, (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
1161 (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
1162 (, (append args)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1163
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1164 (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
1165 "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
1166
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1167 (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
1168 "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
1169
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 ?{ "(}" 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 ?} "){" 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 (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
1187 (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
1188 (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
1189 (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
1190 (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
1191
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1192 (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
1193 (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
1194 "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
1195
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1196 (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
1197 (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
1198
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1199 (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
1200 "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
1201 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
1202 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
1203 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
1204 `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
1205 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
1206
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1207 (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
1208 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
1209 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
1210
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1211 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
1212 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
1213 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
1214 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
1215 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
1216
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1217 Some examples:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1218 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
1219 (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
1220 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
1221 (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
1222 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
1223 (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
1224 (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
1225 ;; Add action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1226 (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
1227 'idlwave-indent-expand-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1228 (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
1229 (if cell
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1230 ;; Replace action command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1231 (setcdr cell cmd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1232 ;; New action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1233 (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
1234 ;; 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
1235 (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
1236 (equal select 'noaction)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1237 (equal select 'both))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1238 (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
1239 (append '(lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1240 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1241 (self-insert-command 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1242 (list (if (listp cmd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1243 cmd
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1244 (list cmd)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1245
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1246 (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
1247
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1248 (define-key idlwave-mode-map "\C-c " 'idlwave-hard-tab)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1249 ;(define-key idlwave-mode-map "\C-c\C- " 'idlwave-hard-tab)
26956
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 "'" 'idlwave-show-matching-quote)
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 "\"" 'idlwave-show-matching-quote)
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 "\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
1253 (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
1254 (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
1255 (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
1256 (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
1257 (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
1258 (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
1259 (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
1260 (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
1261 (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
1262 (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
1263 (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
1264 (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
1265 (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
1266 (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
1267 ;; (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
1268 ;; (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
1269 (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
1270 (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
1271 (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
1272 (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
1273 (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
1274 (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
1275 (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
1276 (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
1277 (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
1278 ;; (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
1279 ;; (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
1280 (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
1281 (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
1282 (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
1283 (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
1284 (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
1285 "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
1286 (autoload 'idlwave-shell-send-command "idlw-shell")
7b2b73f13427 Renamed idlwave-*.el into idlw-*.el.
Eli Zaretskii <eliz@gnu.org>
parents: 26956
diff changeset
1287 (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
1288 "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
1289 (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
1290 "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
1291 (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
1292 (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
1293 (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
1294 (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
1295 (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
1296 (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
1297
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1298 ;; 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
1299 ;; 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
1300 ;; 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
1301 (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
1302 (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
1303 (idlwave-action-and-binding ">" '(idlwave-surround -1 -1 '(?-)))
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1304 (idlwave-action-and-binding "->" '(idlwave-surround -1 -1 nil 2))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1305 (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
1306 ;; 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
1307 (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
1308
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1309 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1310 ;;; Abbrev Section
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1311 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1312 ;;; 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
1313 ;;; 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
1314 ;;; the abbrev).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1315 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1316
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1317 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1318 (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
1319 "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
1320 (error nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1321
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1322 (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
1323 "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
1324 (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
1325 (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
1326 (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
1327 (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
1328 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1329 ;; Templates
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1330 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1331 (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
1332 (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
1333 (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
1334 (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
1335 (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
1336 (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
1337 (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
1338 (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
1339 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1340 ;; 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
1341 ;;
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 "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
1343 (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
1344 (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
1345 (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
1346 (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
1347 (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
1348 (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
1349 (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
1350 (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
1351 (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
1352 (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
1353 (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
1354 (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
1355 (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
1356 (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
1357 (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
1358 (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
1359 (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
1360 (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
1361 (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
1362 (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
1363 (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
1364 (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
1365 (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
1366 (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
1367 (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
1368 (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
1369 (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
1370 (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
1371 (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
1372 (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
1373 (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
1374 (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
1375 (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
1376 (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
1377 (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
1378 (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
1379 (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
1380 (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
1381 (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
1382 (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
1383 (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
1384 (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
1385 (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
1386 (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
1387 (idlwave-keyword-abbrev 11))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1388 (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
1389 (idlwave-keyword-abbrev 11))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1390 (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
1391 (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
1392 (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
1393 (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
1394
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1395 ;; 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
1396 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1397 (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
1398 (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
1399 (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
1400 (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
1401 (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
1402 (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
1403 (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
1404 (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
1405 (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
1406 (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
1407 (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
1408 (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
1409 (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
1410 (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
1411 (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
1412 (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
1413 (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
1414 (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
1415 (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
1416 (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
1417 (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
1418 (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
1419 (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
1420 (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
1421 (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
1422 (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
1423 (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
1424 (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
1425 (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
1426 (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
1427 (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
1428 (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
1429 (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
1430 (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
1431 (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
1432
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1433 (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
1434 (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
1435 (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
1436 (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
1437 (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
1438 ;; 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
1439 (defvar idlwave-mode-menu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1440 (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
1441
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1442 ;;;###autoload
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1443 (defun idlwave-mode ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1444 "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
1445
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1446 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
1447
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1448 1. Indentation and Formatting
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 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
1451 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
1452
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1453 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
1454 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
1455 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
1456 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
1457
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1458 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
1459
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1460 `;;;' Indentation remains unchanged.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1461 `;;' 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
1462 `;' 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
1463
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1464 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
1465
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1466 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
1467 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
1468 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
1469 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
1470 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
1471
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1472 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
1473 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
1474 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
1475
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1476 2. Routine Info
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 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
1479 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
1480 \\[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
1481 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
1482 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
1483 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
1484 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
1485
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1486 3. Completion
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 \\[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
1489 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
1490 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
1491 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
1492 upper case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1493
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1494 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
1495 --------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1496 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
1497 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
1498
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1499 \\pr PROCEDURE template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1500 \\fu FUNCTION template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1501 \\c CASE statement template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1502 \\f FOR loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1503 \\r REPEAT Loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1504 \\w WHILE loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1505 \\i IF statement template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1506 \\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
1507 \\b BEGIN
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1508
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1509 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
1510 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
1511
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1512 \\[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
1513 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
1514 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
1515
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1516 5. Automatic Case Conversion
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 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
1519 `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
1520
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1521 6. Automatic END completion
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 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
1524 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
1525
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1526 7. Hooks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1527 -----
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1528 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
1529 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
1530
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1531 8. Documentation and Customization
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 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
1534 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
1535 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
1536 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
1537 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
1538
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1539 9. Keybindings
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1540 -----------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1541 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
1542 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
1543 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
1544
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1545 \\{idlwave-mode-map}"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1546
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1547 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1548 (kill-all-local-variables)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1549
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1550 (if idlwave-startup-message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1551 (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
1552 (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
1553
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1554 (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
1555 (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
1556
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 '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
1558
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1559 (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
1560 (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
1561
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1562 (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
1563 (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
1564 (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
1565 (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
1566 (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
1567 (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
1568
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1569 (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
1570
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1571 (when (featurep 'easymenu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1572 (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
1573 (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
1574
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1575 (setq mode-name "IDLWAVE")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1576 (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
1577 (setq abbrev-mode t)
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 (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
1580 (setq comment-end "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1581 (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
1582 (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
1583 (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
1584 (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
1585 (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
1586
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1587 ;; 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
1588 (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
1589 (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
1590
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1591 ;; 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
1592 ;; 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
1593 ;; 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
1594 (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
1595
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1596 ;; Imenu setup
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1597 (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
1598 '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
1599 (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
1600 'idlwave-unit-name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1601 (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
1602 'idlwave-prev-index-position)
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 ;; 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
1605 (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
1606 (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
1607
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1608 ;; Run the mode hook
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1609 (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
1610
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1611 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1612 ;; 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
1613 ;; 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
1614 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1615
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1616 (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
1617 "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
1618 (if (fboundp 'iconify-frame)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1619 (apply 'push-mark rest)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1620 (push-mark)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1621
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1622 (defun idlwave-hard-tab ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1623 "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
1624 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1625 (insert "\t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1626
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1627 ;;; This stuff is experimental
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1628
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1629 (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
1630 "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
1631 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
1632 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
1633
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1634 (defun idlwave-command-hook ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1635 "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
1636 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
1637 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
1638 (and idlwave-command-hook
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1639 (listp idlwave-command-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1640 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1641 (eval idlwave-command-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1642 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1643 (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
1644
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1645 ;;; End experiment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1646
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1647 ;; 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
1648 ;; versatility.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1649
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1650 (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
1651 "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
1652 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
1653 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
1654 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
1655 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
1656 `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
1657 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
1658 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
1659 made into all lowercase.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1660 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
1661 (if (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1662 (progn (unexpand-abbrev)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1663 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1664 (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
1665 (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
1666 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1667 ((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
1668 (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
1669 (idlwave-abbrev-change-case
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1670 (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
1671 (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
1672 (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
1673 (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
1674 (backward-char arg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1675 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1676
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1677 (defun idlwave-in-comment ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1678 "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
1679 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1680 (let ((here (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1681 (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
1682
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1683 (defun idlwave-goto-comment ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1684 "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
1685 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
1686 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
1687 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
1688 (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
1689 (data (match-data))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1690 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1691 ;; 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
1692 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1693 (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
1694 (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
1695 (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
1696 (store-match-data data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1697 (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
1698 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1699 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1700 (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1701
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1702 (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
1703 "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
1704 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1705 (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
1706 (inq last-command-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1707 (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
1708 (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
1709 (insert inq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1710 (if (eq inq delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1711 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1712 (goto-char bq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1713 (sit-for 1))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1714 ;; 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
1715 (insert inq))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1716
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1717 (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
1718 "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
1719 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
1720 (if
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1721 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1722 (backward-word 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1723 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1724 (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
1725 (idlwave-show-begin)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1726
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1727 (defun idlwave-show-begin ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1728 "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
1729 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
1730 ;; 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
1731 (let* ((pos (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1732 end end1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1733 (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
1734 idlwave-show-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1735 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1736 ;; Move inside current block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1737 (setq end (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1738 (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
1739 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1740 (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1741 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1742 (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
1743 (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
1744 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1745 ((null end1)) ; no-opeartion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1746 ((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
1747 (sit-for 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1748 ((string= (downcase end) "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1749 ;; A generic end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1750 (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
1751 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1752 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1753 (backward-char 3)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1754 (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
1755 (delete-char 3)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1756 (sit-for 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1757 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1758 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1759 (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
1760 end1 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1761 (sit-for 1))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1762
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1763 (defun idlwave-block-master ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1764 (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
1765 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1766 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1767 ((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
1768 (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
1769 ((looking-at "begin\\>")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1770 (let ((limit (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1771 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1772 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1773 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1774 ((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
1775 (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
1776 idlwave-block-matches))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1777 ;;((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
1778 ;; ;; 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
1779 ;; '("begin" . "end"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1780 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1781 ;; Just a nromal block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1782 '("begin" . "end")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1783 (t nil)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1784
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1785 (defun idlwave-close-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1786 "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
1787 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1788
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1789 ;; 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
1790 (unless (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1791 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1792 (bolp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1793 (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
1794 (newline-and-indent)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1795
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1796 ;; 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
1797 (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
1798 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1799 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1800 (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
1801 (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
1802 (setq end (cdr end))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1803 (error "Cannot close block")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1804 (insert end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1805 (idlwave-newline)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1806
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1807 (defun idlwave-surround (&optional before after escape-chars length)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1808 "Surround the LENGTH characters before point with blanks.
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1809 LENGTH defaults to 1.
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1810 Optional arguments BEFORE and AFTER affect the behavior before and
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1811 after the characters (see also description of `idlwave-make-space'):
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1812
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1813 nil do nothing
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1814 0 force no spaces
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1815 integer > 0 force exactly n spaces
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1816 integer < 0 at least |n| spaces
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1817
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1818 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
1819 - `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
1820 - the character before point is inside a string or comment
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1821 - the char preceeding the string to be surrounded is a member of ESCAPE-CHARS.
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1822 This hack is used to avoid padding of `>' when it is part of
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1823 the '->' operator. In this case, ESCAPE-CHARS would be '(?-)."
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1824
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1825 (setq length (or length 1)) ; establish a default for LENGTH
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1826
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1827 (when (and idlwave-surround-by-blank
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1828 (not (idlwave-quoted))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1829 (not (memq (char-after (- (point) (1+ length))) escape-chars)))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1830 (backward-char length)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1831 (save-restriction
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1832 (let ((here (point)))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1833 (skip-chars-backward " \t")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1834 (if (bolp)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1835 ;; avoid clobbering indent
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1836 (progn
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1837 (move-to-column (idlwave-calculate-indent))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1838 (if (<= (point) here)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1839 (narrow-to-region (point) here))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1840 (goto-char here)))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1841 (idlwave-make-space before))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1842 (skip-chars-forward " \t"))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1843 (forward-char length)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1844 (idlwave-make-space after)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1845 ;; Check to see if the line should auto wrap
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1846 (if (and (equal (char-after (1- (point))) ? )
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1847 (> (current-column) fill-column))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1848 (funcall auto-fill-function))))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1849
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1850 (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
1851 "Make space at point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1852 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
1853 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
1854 the contiguous space.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1855 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
1856 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
1857 nil - do nothing.
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1858 > 0 - exactly N spaces.
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1859 < 0 - a minimum of -N spaces, i.e., do not change if there are
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1860 already -N spaces.
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
1861 0 - no spaces (i.e. remove any existing space)."
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1862 (if (integerp n)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1863 (let
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1864 ((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
1865 (left (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1866 (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
1867 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1868 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1869 ((> n 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1870 (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
1871 (goto-char (+ left n)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1872 ((< n 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1873 (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
1874 (goto-char (- left n)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1875 ;; n = 0, done
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
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1878 (defun idlwave-newline ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1879 "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
1880 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1881 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1882 ;; 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
1883 ;; 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
1884 ;; will mean unbalanced quotes.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1885 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1886 (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
1887 (progn (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1888 (message "Warning: unbalanced quotes?")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1889 (newline)
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 ;; 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
1892 ;; 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
1893 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1894 ;; 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
1895 ;; 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
1896 ;; 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
1897 ;; `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
1898 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1899 (beginning-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1900 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1901 (forward-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1902 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1903
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1904 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1905 ;; 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
1906 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1907 ;; Modeled on lisp.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1908 ;; 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
1909 (defun idlwave-comment-hook ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1910 "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
1911 (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
1912 (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
1913 (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
1914 (looking-at "^;")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1915 (current-column)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1916 (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
1917 (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
1918 ;; 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
1919 (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
1920 (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
1921 ;; 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
1922 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1923 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1924 (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
1925 comment-column))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1926
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1927 (defun idlwave-split-line ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1928 "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
1929 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
1930 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
1931 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
1932 non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1933 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1934 (let (beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1935 (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
1936 ;; 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
1937 ;; 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
1938 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1939 (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
1940 (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
1941 ;; Split the string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1942 (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
1943 idlwave-continuation-char beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1944 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1945 ;; 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
1946 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1947 (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
1948 (insert " " idlwave-continuation-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1949 ;; Not splitting a string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1950 (insert " " idlwave-continuation-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1951 (newline-and-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1952 (indent-new-comment-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1953 ;; Indent previous line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1954 (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
1955 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1956 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1957 (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
1958 ;; Reindent new line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1959 (idlwave-indent-line)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1960
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1961 (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
1962 "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
1963 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1964 (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
1965
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1966 (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
1967 "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
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-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
1971
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1972 (defun idlwave-mark-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1973 "Mark current IDL statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1974 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1975 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1976 (let ((end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1977 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1978 (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
1979
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1980 (defun idlwave-mark-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1981 "Mark containing block."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1982 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1983 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1984 (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
1985 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1986 (let ((end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1987 (idlwave-backward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1988 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1989 (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
1990
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1991
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1992 (defun idlwave-mark-subprogram ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1993 "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
1994 The marks are pushed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1995 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1996 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1997 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1998 (let ((beg (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1999 (idlwave-forward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2000 (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
2001 (exchange-point-and-mark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2002
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2003 (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
2004 "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
2005 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
2006 (interactive "p")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2007 (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
2008
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2009 (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
2010 "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
2011 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2012 (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
2013 (forward-word 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2014
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2015 (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
2016 "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
2017 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2018 (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
2019 (backward-word 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2020
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2021 (defun idlwave-forward-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2022 "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
2023 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2024 (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
2025 (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
2026
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2027 (defun idlwave-backward-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2028 "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
2029 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2030 (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
2031 (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
2032
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2033 (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
2034 "Go down a block.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2035 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
2036 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
2037 (interactive "p")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2038 (let (status)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2039 (if (< arg 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2040 ;; Backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2041 (let ((eos (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2042 (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
2043 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2044 (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
2045 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
2046 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2047 (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
2048 ;; Forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2049 (let ((eos (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2050 (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
2051 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2052 (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
2053 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
2054 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2055 (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
2056 status))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2057
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2058 (defun idlwave-mark-doclib ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2059 "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
2060 The marks are pushed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2061 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2062 (let (beg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2063 (here (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2064 (goto-char (point-max))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2065 (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
2066 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2067 (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
2068 (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
2069 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2070 (forward-line 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2071 (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
2072 (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
2073 (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
2074 (goto-char here)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2075
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2076 (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
2077 (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
2078 "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
2079 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
2080 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
2081 actual statement."
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 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2084 ((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
2085 (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
2086 (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
2087 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2088 (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
2089 (idlwave-previous-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2090 (beginning-of-line)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2091
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2092 (defun idlwave-previous-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2093 "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
2094 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
2095 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
2096 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2097 (let (first-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2098 (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
2099 ;; first line in file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2100 t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2101 ;; 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
2102 (while (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2103 ;; 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
2104 ;; reach another statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2105 (setq first-statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2106 (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2107 (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
2108 (looking-at "[ \t]*$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2109 (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
2110 (looking-at "^@")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2111 (= (forward-line -1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2112 ;; skip continuation lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2113 (while (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2114 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2115 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2116 (idlwave-is-continuation-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2117 (= (forward-line -1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2118 first-statement)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2119
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2120 ;; 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
2121 ;; 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
2122 ;; comments, though.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2123 (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
2124 "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
2125 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
2126 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2127 (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
2128 (= (forward-line 1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2129 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2130 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2131
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2132 (defun idlwave-next-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2133 "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
2134 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
2135 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
2136 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2137 (let (last-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2138 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2139 ;; 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
2140 (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
2141 ;; 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
2142 ;; 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
2143 (setq last-statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2144 (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2145 (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
2146 (looking-at "[ \t]*$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2147 (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
2148 (looking-at "^@")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2149 last-statement))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2150
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2151 (defun idlwave-skip-label ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2152 "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
2153 Returns position after label.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2154 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
2155 ;; 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
2156 ;; 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
2157 ;; or case statement element.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2158 (let ((start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2159 (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
2160 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2161 (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
2162 (if (and end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2163 (= (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
2164 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2165 (forward-char)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2166 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2167 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2168 nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2169
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2170 (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
2171 "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
2172 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
2173 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
2174 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
2175 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
2176 substatement. "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2177 (let ((orig (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2178 (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
2179 (ifnest 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2180 st nst last)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2181 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2182 (idlwave-skip-label)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2183 (setq last (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2184 ;; 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
2185 (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
2186 (setq last (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2187 (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
2188 (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
2189 (cond ((and nst
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2190 (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
2191 (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
2192 ((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
2193 (setq ifnest (1- ifnest))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2194 (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
2195 (t (setq ifnest 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2196 (idlwave-next-statement))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2197 (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
2198 (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2199
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2200 (defun idlwave-statement-type ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2201 "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
2202 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
2203 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
2204 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
2205 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
2206 statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2207 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2208 ;; 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
2209 (while (looking-at "[ \t]*\\<\\$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2210 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2211 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2212 (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
2213 (case-fold-search t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2214 (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
2215 (setq st (cdr st))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2216 (if st
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2217 (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
2218
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2219 (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
2220 "Pad '=' with spaces.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2221 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
2222 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
2223 `idlwave-statement-type'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2224 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
2225 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
2226 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
2227 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
2228 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
2229 See `idlwave-surround'. "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2230 ;; 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
2231 ;; 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
2232 (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
2233 (let ((st (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2234 (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
2235 (idlwave-statement-type))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2236 (if (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2237 (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
2238 (equal (cdr st) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2239 idlwave-pad-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2240 ;; An assignment statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2241 (idlwave-surround before after)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2242 (idlwave-surround 0 0)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2243
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2244 (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
2245 "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
2246 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2247 (idlwave-indent-line t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2248 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2249
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2250 (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
2251 "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
2252 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
2253 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
2254 `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
2255 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2256 ;; 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
2257 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2258 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2259 (bolp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2260 (skip-chars-forward " \t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2261 (let ((mloc (point-marker)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2262 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2263 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2264 (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
2265 ;; 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
2266 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2267 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2268 (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
2269 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2270 ;; Code Line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2271 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2272 ;; 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
2273 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2274 (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
2275 (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
2276 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2277 (if idlwave-do-actions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2278 (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
2279 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2280 ;; 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
2281 ;; 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
2282 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2283 ;; Indent for code line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2284 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2285 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2286 (if (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2287 ;; a label line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2288 (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
2289 ;; a batch command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2290 (looking-at "^[ \t]*@"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2291 ;; leave flush left
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2292 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2293 ;; indent the line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2294 (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
2295 ;; Adjust parallel comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2296 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2297 (if (idlwave-in-comment)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2298 (indent-for-comment))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2299 (goto-char mloc)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2300 ;; Get rid of marker
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2301 (set-marker mloc nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2302 ))
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-do-action (action)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2305 "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
2306 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
2307 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
2308 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
2309 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
2310 (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
2311 (action-routine (cdr action)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2312 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2313 (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
2314 (if (listp action-routine)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2315 (eval action-routine)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2316 (funcall action-routine)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2317
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2318 (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
2319 "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
2320 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
2321 (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
2322 (insert-before-markers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2323 (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
2324
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2325 (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
2326 "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
2327 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
2328 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
2329 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2330 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2331 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2332 (idlwave-indent-to col)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2333
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2334 (defun idlwave-indent-subprogram ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2335 "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
2336 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2337 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2338 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2339 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2340 (let ((beg (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2341 (idlwave-forward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2342 (message "Indenting subprogram...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2343 (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
2344 (message "Indenting subprogram...done.")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2345
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2346 (defun idlwave-calculate-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2347 "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
2348 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2349 (beginning-of-line)
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 ;; 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
2352 ;; function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2353 ((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
2354 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2355 ;; Check for continuation line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2356 ((save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2357 (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
2358 (idlwave-is-continuation-line)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2359 (idlwave-calculate-cont-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2360 ;; 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
2361 (t (let ((the-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2362 ;; 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
2363 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2364 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2365 ((idlwave-previous-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2366 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2367 ;; Main block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2368 ((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
2369 (+ (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2370 idlwave-main-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2371 ;; Begin block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2372 ((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
2373 (+ (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2374 idlwave-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2375 ((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
2376 (- (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2377 idlwave-end-offset
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2378 idlwave-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2379 ((idlwave-current-statement-indent))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2380 ;; 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
2381 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2382 ;; End block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2383 ((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
2384 (+ 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
2385 (the-indent)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2386
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2387 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2388 ;; Parenthesses balacing/indent
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
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2391 (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
2392 "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
2393 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
2394 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
2395 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
2396 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
2397 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2398 (let* (open
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2399 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2400 (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
2401 (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
2402 (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
2403 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2404 ;; 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
2405 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2406 (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
2407 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2408 (forward-sexp 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2409 (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
2410 (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
2411 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2412 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2413 ;; 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
2414 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2415 ;; 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
2416 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2417 (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
2418 ;; Found innermost open paren.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2419 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2420 (goto-char open)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2421 ;; 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
2422 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2423 ;; 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
2424 (close-exp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2425 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2426 ;; 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
2427 ;; the forward-char
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2428 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2429 ;; Skip paren
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2430 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2431 (looking-at "[ \t$]*$"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2432 (+ (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
2433 ;; 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
2434 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2435 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2436 (current-column)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2437 ;; 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
2438 (goto-char beg-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2439 (+ (idlwave-current-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2440 ;; 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
2441 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2442 ;; Else statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2443 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2444 (goto-char end-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2445 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2446 (looking-at "else"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2447 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2448 ;; Ordinary continuation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2449 (idlwave-continuation-indent))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2450
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2451 (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
2452 "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
2453 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
2454 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
2455 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
2456 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
2457 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
2458 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
2459 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
2460 `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
2461 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
2462 (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
2463 (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
2464 (let (found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2465 (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
2466 (case-fold-search t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2467 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2468 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2469 (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
2470 (if (>= dir 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2471 (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
2472 (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
2473 (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2474 (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2475 (not (eobp))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2476 (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
2477 (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
2478 (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2479 (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2480 (not (bobp))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2481 (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
2482 (if found (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2483 (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
2484 (goto-char found)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2485
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2486 (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
2487 "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
2488 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
2489 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
2490 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
2491 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
2492 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
2493 possibility of unbalanced blocks."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2494 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2495 (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
2496 (let* ((here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2497 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2498 (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
2499 (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
2500 idlwave-begin-block-reg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2501 idlwave-end-block-reg))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2502 found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2503 (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
2504 idlwave-end-block-reg))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2505 (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
2506 (if (< dir 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2507 (idlwave-find-key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2508 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
2509 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2510 (idlwave-find-key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2511 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
2512 limit)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2513 (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
2514 (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
2515 (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
2516 (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
2517 (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
2518 (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
2519 (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
2520 (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
2521 (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
2522
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2523 (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
2524 "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
2525 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
2526 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2527 (idlwave-current-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2528
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2529 (defun idlwave-current-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2530 "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
2531 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
2532 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2533 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2534 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2535 ;; 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
2536 (cond ((eolp) 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2537 ((current-column)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2538
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2539 (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
2540 "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
2541 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2542 (idlwave-look-at "\\<\\$")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2543
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2544 (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
2545 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2546 (beginning-of-line 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2547 (looking-at "[ \t]*;")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2548
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2549 (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
2550 "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
2551 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
2552 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
2553 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
2554 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
2555 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
2556 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
2557 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
2558 does not move point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2559 (let ((here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2560 (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
2561 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2562 eos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2563 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2564 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2565 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2566 (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
2567 (setq eos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2568 (if cont
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2569 (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
2570 (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
2571 (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
2572 (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
2573 (idlwave-quoted))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2574 (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
2575 (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
2576 found))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2577
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2578 (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
2579 "Fills paragraphs in comments.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2580 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
2581 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
2582 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
2583 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
2584 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
2585 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
2586 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
2587 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
2588 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
2589 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
2590 ignored."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2591 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2592 ;; 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
2593 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2594 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2595 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2596 (looking-at comment-start))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2597 (let
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2598 ((indent 999)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2599 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
2600 hang start end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2601 ;; 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
2602 ;; 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
2603 ;; 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
2604 ;; 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
2605 ;; 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
2606 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2607 ;; 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
2608 ;; 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
2609 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2610 (backward-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2611 (setq start (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2612 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2613 (forward-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2614 (setq end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2615 (untabify start end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2616 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2617 (setq here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2618 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2619 (setq bcl (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2620 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2621 (concat "^[ \t]*" comment-start "+")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2622 (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
2623 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2624 ;; 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
2625 (setq pre (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2626 ;; 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
2627 ;; number of consecutive ";".
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2628 (setq fill-prefix-reg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2629 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2630 (setq fill-prefix
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2631 (regexp-quote
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2632 (buffer-substring (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2633 (beginning-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2634 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2635 "[^;]"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2636
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2637 ;; 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
2638 (goto-char bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2639 (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
2640 (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
2641 (not (bobp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2642 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2643 ;; 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
2644 (if (/= (point) bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2645 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2646 (setq start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2647 (goto-char bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2648 (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
2649 (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
2650 (not (eobp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2651 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2652 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2653 (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
2654 (looking-at paragraph-separate))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2655 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2656 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2657 ;; 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
2658 ;; 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
2659 ;; 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
2660 (if (eobp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2661 (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
2662 ;; 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
2663 ;; 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
2664 (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
2665 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2666 ;; 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
2667 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2668 ;; 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
2669 ;; 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
2670 ;; 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
2671 ;; 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
2672 ;; indentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2673 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2674 ;; 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
2675 (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
2676 (setq hang
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2677 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2678 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2679 (idlwave-calc-hanging-indent))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2680 ;; 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
2681 ;; 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
2682 ;; 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
2683 ;; a fill-prefix.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2684 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2685 (setq indent hang)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2686 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2687 (while (> (point) start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2688 (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
2689 (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
2690 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2691 (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
2692 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2693 (if (>= here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2694 ;; 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
2695 ;; inserted text.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2696 (setq here (+ here diff)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2697 (insert (make-string diff ? ))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2698 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2699 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2700
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2701 ;; 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
2702 ;; after first line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2703 ;; 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
2704 ;; 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
2705 ;; 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
2706 ;; 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
2707 (while (> (point) start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2708 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2709 (setq indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2710 (min indent
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 (forward-line -1))
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 (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
2720 (make-string (- indent pre)
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 ;; first-line indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2723 (setq first-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2724 (max
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2725 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2726 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2727 comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2728 (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
2729 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2730 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2731 indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2732
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2733 ;; 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
2734 (goto-char here)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2735
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2736 ;; 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
2737 ;; 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
2738 ;; 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
2739 ;; (first indent).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2740 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2741 (setq diff
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2742 (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
2743 (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
2744 (fill-region-as-paragraph
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2745 start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2746 (- (point-max) end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2747 (current-justification)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2748 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2749 (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
2750 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2751 (insert diff))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2752 ;; 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
2753 ;; 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
2754 (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
2755 (setq fill-prefix nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2756
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2757 (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
2758 "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
2759 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
2760 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
2761 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
2762 the line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2763 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
2764 (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
2765 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2766 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2767 (if (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2768 idlwave-hang-indent-regexp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2769 (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
2770 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2771 (+ (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
2772 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2773 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2774 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2775 idlwave-hang-indent-regexp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2776 (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
2777 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2778 (current-column)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2779
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2780 (defun idlwave-auto-fill ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2781 "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
2782 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
2783 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
2784 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
2785 `+' 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
2786 (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
2787 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
2788 (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
2789 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2790 ;; Check for comment line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2791 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2792 (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
2793 (let (beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2794 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2795 ;; 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
2796 (let (idlwave-do-actions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2797 (paragraph-start ".")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2798 (paragraph-separate "."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2799 (do-auto-fill))
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 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2802 ;; Indent the split line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2803 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2804 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2805 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2806 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2807 (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
2808 ;; A continued line comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2809 ;; 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
2810 ;; 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
2811 (if idlwave-hanging-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2812 (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
2813 (indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2814 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2815 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2816 (idlwave-calc-hanging-indent))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2817 (if indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2818 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2819 ;; 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
2820 ;; 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
2821 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2822 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2823 comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2824 (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
2825 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2826 (idlwave-indent-to indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2827 (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
2828 )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2829 ;; Split code or comment?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2830 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2831 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2832 (idlwave-in-comment))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2833 ;; 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
2834 ;; 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
2835 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2836 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2837 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2838 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2839 ;; 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
2840 (insert " "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2841 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2842 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2843 (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
2844 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2845 (skip-chars-forward "; ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2846 (point))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2847 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2848 ;; 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
2849 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2850 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2851 ;; 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
2852 (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
2853 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
2854 ;; 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
2855 ;; 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
2856 ;; 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
2857 (insert " " (char-after beg) " +"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2858 (insert " $"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2859 (if beg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2860 (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
2861 ;; 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
2862 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2863 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2864 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2865 (insert (char-after beg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2866 ;; Warning
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2867 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2868 (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
2869 ;; 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
2870 ;; 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
2871 ;; 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
2872 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2873 )))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2874
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2875 (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
2876 "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
2877 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
2878 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
2879 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
2880 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2881 (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
2882 (if (if (null arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2883 (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
2884 (> (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
2885 'idlwave-auto-fill
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2886 nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2887 ;; update mode-line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2888 (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
2889
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2890 (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
2891 "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
2892 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
2893 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
2894 is non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2895 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2896 (or nomark (push-mark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2897 ;; 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
2898 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2899 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2900 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2901 ;; 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
2902 (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
2903 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2904 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2905 (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
2906 (if idlwave-file-header
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2907 (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
2908 (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
2909 ((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
2910 (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
2911
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2912
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2913 (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
2914 "Default timestamp insertion function"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2915 (insert (current-time-string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2916 (insert ", " (user-full-name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2917 (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
2918 ;; 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
2919 (idlwave-fill-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2920 ;; 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
2921 ;; 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
2922 (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
2923
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2924 (defun idlwave-doc-modification ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2925 "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
2926 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
2927 `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
2928 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
2929 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
2930 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2931 (push-mark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2932 ;; 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
2933 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2934 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2935 (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
2936 (case-fold-search nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2937 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2938 (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
2939 ;; 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
2940 (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
2941 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2942 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2943 ;; 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
2944 (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
2945 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2946 (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
2947 (forward-line -2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2948 (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
2949 (idlwave-newline)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2950 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2951 (insert ";\n;\t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2952 (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
2953
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2954 ;;; CJC 3/16/93
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2955 ;;; 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
2956 ;;; 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
2957 ;;; 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
2958 ;;; 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
2959 ;;; .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
2960 ;;; 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
2961 ;;; 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
2962 ;;; 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
2963 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2964 (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
2965 "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
2966 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
2967 (interactive "r")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2968 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2969 (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
2970 (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
2971 (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
2972 (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
2973
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2974 (defun idlwave-quoted ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2975 "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
2976 nil otherwise."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2977 (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
2978
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2979 (defun idlwave-in-quote ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2980 "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
2981 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
2982 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
2983 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
2984 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
2985 ;;; 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
2986 ;;; 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
2987 ;;; 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
2988 ;;; quote.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2989 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2990 ;; 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
2991 ;; 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
2992 (let* ((start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2993 (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
2994 (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
2995 (endq (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2996 (data (match-data))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2997 delim
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2998 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2999 (while (< endq start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3000 ;; Find string start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3001 ;; 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
3002 (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
3003 ;; Find the string end.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3004 ;; 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
3005 ;; string act as an
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3006 ;; 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
3007 ;; 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
3008 ;; 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
3009 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3010 ;; 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
3011 (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
3012 (setq bq (1- (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3013 ;; Get the string delimiter
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3014 (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
3015 ;; Check for null string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3016 (if (looking-at delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3017 (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
3018 ;; 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
3019 (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
3020 (while (looking-at delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3021 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3022 (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
3023 (if found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3024 (setq endq (- (point) 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3025 (setq endq (point)))
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 (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
3028 (store-match-data data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3029 ;; 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
3030 (if (> start bq) bq))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3031
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3032 ;; Statement templates
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 ;; 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
3035 ;; 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
3036 ;; dmacro.el)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3037
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3038 (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
3039 "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
3040
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3041 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
3042 whitespace. S1 and S2 are strings. S1 is inserted at point followed
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3043 by S2. Point is inserted between S1 and S2. The case of S1 and S2 is
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3044 adjusted according to `idlwave-abbrev-change-case'. If optional argument
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3045 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
3046 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
3047 expression to enter.
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 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
3050 unless the optional second argument NOINDENT is non-nil."
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3051 (cond ((eq idlwave-abbrev-change-case 'down)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3052 (setq s1 (downcase s1) s2 (downcase s2)))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3053 (idlwave-abbrev-change-case
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3054 (setq s1 (upcase s1) s2 (upcase s2))))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3055 (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
3056 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3057 (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
3058 (open-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3059 (insert s1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3060 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3061 (insert s2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3062 (setq end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3063 (if (not noindent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3064 (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
3065 (if (stringp prompt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3066 (message prompt))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3067
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3068 (defun idlwave-rw-case (string)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3069 "Make STRING have the case required by `idlwave-reserved-word-upcase'."
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3070 (if idlwave-reserved-word-upcase
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3071 (upcase string)
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3072 string))
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3073
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3074 (defun idlwave-elif ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3075 "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
3076 (interactive)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3077 (idlwave-template
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3078 (idlwave-rw-case "if")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3079 (idlwave-rw-case " then begin\n\nendif else begin\n\nendelse")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3080 "Condition expression"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3081
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3082 (defun idlwave-case ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3083 "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
3084 (interactive)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3085 (idlwave-template
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3086 (idlwave-rw-case "case")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3087 (idlwave-rw-case " of\n\nendcase")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3088 "Selector expression"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3089
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3090 (defun idlwave-for ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3091 "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
3092 (interactive)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3093 (idlwave-template
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3094 (idlwave-rw-case "for")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3095 (idlwave-rw-case " do begin\n\nendfor")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3096 "Loop expression"))
26956
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-if ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3099 "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
3100 (interactive)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3101 (idlwave-template
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3102 (idlwave-rw-case "if")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3103 (idlwave-rw-case " then begin\n\nendif")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3104 "Scalar logical expression"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3105
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3106 (defun idlwave-procedure ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3107 (interactive)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3108 (idlwave-template
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3109 (idlwave-rw-case "pro")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3110 (idlwave-rw-case "\n\nreturn\nend")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3111 "Procedure name"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3112
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3113 (defun idlwave-function ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3114 (interactive)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3115 (idlwave-template
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3116 (idlwave-rw-case "function")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3117 (idlwave-rw-case "\n\nreturn\nend")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3118 "Function name"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3119
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3120 (defun idlwave-repeat ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3121 (interactive)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3122 (idlwave-template
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3123 (idlwave-rw-case "repeat begin\n\nendrep until")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3124 (idlwave-rw-case "")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3125 "Exit condition"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3126
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3127 (defun idlwave-while ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3128 (interactive)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3129 (idlwave-template
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3130 (idlwave-rw-case "while")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3131 (idlwave-rw-case " do begin\n\nendwhile")
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
3132 "Entry condition"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3133
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3134 (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
3135 "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
3136 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
3137 (or pattern
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3138 (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
3139 (let (parts (start 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3140 (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
3141 (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
3142 start (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3143 (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
3144
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3145 (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
3146 (let* ((start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3147 (last (length string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3148 (ret_string "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3149 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3150 (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
3151 (setq ret_string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3152 (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
3153 (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
3154 (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
3155
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3156 (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
3157 ;; 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
3158 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3159 ((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
3160 (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
3161 (get-file-buffer file)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3162 ((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
3163 (find-buffer-visiting file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3164 (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
3165
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3166 (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
3167 ;; 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
3168 (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
3169 (find-file-noselect file)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3170
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3171 (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
3172 (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
3173 ;; 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
3174 (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
3175 dir efile)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3176 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3177 (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
3178 (if (file-regular-p
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3179 (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
3180 (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
3181
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3182 (defun idlwave-make-tags ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3183 "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
3184 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
3185 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
3186 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
3187 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
3188 you specify /."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3189 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3190 (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
3191 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
3192
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3193 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3194 ;; Read list of directories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3195 (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
3196 (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
3197 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3198 ;; Set etags command, vars
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3199 (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
3200 \\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
3201 \\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
3202 (setq append " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3203 (setq status 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3204 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3205 ;; For each directory
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3206 (setq numdirs 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3207 (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
3208 (while (and dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3209 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3210 ;; Find the subdirectories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3211 (if (string-match "^[@]\\(.+\\)$" dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3212 (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
3213 (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
3214 (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
3215 (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
3216 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3217 (if (and getsubdirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3218 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3219 (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
3220 (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
3221 (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
3222 (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
3223 (set-buffer buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3224 (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
3225 (idlwave-replace-string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3226 (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
3227 "\n" "/*.pro ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3228 "[ \t]+"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3229 (set-buffer save_buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3230 (kill-buffer buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3231 (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
3232 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3233 ;; For each subdirectory
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3234 (setq numfiles 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3235 (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
3236 (while (and item)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3237 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3238 ;; Call etags
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3239 (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
3240 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3241 (message (concat "Tagging " item "..."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3242 (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
3243 (setq status (+ status
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3244 (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
3245 (concat cmd append item))))
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 ;; Append additional tags
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3248 (setq append " --append ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3249 (setq numfiles (1+ numfiles))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3250 (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
3251 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3252 (setq numfiles (1+ numfiles))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3253 (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
3254 )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3255
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3256 (setq numdirs (1+ numdirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3257 (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
3258 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3259 (setq numdirs (1+ numdirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3260 (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
3261
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3262 (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
3263 (if (= status 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3264 (kill-buffer errbuf))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3265 (message "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3266 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3267
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3268 (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
3269 "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
3270 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
3271 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
3272 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
3273 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
3274 blank lines."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3275 (interactive "r\nP")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3276 (if n
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3277 (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
3278 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3279 (goto-char beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3280 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3281 ;; skip blank lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3282 (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
3283 (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
3284 (comment-region beg end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3285 (- (length (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3286 (match-beginning 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3287 (match-end 1)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3288 (comment-region beg end)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3289
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3290
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 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3293 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3294 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3295 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3296 ;; Completion and Routine Info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3297 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3298
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3299 ;; String "intern" functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3300
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3301 ;; 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
3302 ;; 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
3303 ;; 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
3304 ;; 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
3305 ;; 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
3306 ;; 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
3307 ;; 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
3308 ;; 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
3309 ;; 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
3310 ;; "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
3311 ;; 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
3312 ;; 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
3313 ;; 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
3314 ;; 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
3315
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3316 ;; 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
3317
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3318 ;; 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
3319 (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
3320 (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
3321 (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
3322 (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
3323 (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
3324
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3325 (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
3326 "Reset all sintern hashes."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3327 ;; 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
3328 (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
3329 (not (fboundp 'puthash)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3330 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3331 (require 'cl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3332 (or (fboundp 'puthash)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3333 (defalias 'puthash 'cl-puthash))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3334 (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
3335 (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
3336 (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
3337 (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
3338
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3339 ;; 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
3340 (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
3341 for var = (car entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3342 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
3343
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3344 (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
3345 (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
3346 ;; 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
3347 (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
3348 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
3349 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
3350 (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
3351 (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
3352
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3353 (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
3354 (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
3355 ;; 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
3356 (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
3357 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
3358 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
3359 (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
3360
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3361 (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
3362 (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3363 (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
3364 (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
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 (stype &rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3367 (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
3368
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3369 ;;(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
3370 ;; `(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
3371 ;; ((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
3372 ;; ((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
3373 ;; (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
3374 ;; (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3375
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3376 (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
3377 (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
3378 ((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
3379 ((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
3380 (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
3381 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3382 (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
3383 (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
3384 ((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
3385 ((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
3386 (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
3387 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3388 (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
3389 (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
3390 ((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
3391 ((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
3392 (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
3393 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3394 (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
3395 (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
3396 ((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
3397 ((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
3398 (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
3399 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3400
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3401 (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
3402 (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
3403 (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
3404
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3405 (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
3406 (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
3407 'identity))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3408 (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
3409 (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
3410 (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
3411 iname))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3412
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3413 (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
3414 "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
3415 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
3416 (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
3417 (while list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3418 (setq entry (car list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3419 list (cdr list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3420 name (car entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3421 type (nth 1 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3422 class (nth 2 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3423 source (nth 3 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3424 call (nth 4 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3425 kwds (nth 5 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3426 olh (nth 6 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3427 (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
3428 (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
3429 kwds))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3430 (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3431 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3432 (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
3433 (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
3434 (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
3435 (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
3436 (if (stringp (cdr source))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3437 (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
3438 (setq new (if olh
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3439 (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
3440 (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
3441 (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
3442 (nreverse res)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3443
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3444 ;;---------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3445
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 ;; 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
3448 (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
3449 "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
3450 (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
3451 "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
3452 (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
3453 "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
3454 (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
3455 "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
3456 (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
3457 "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
3458 (defvar idlwave-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3459 "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
3460 (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
3461 "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
3462 (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
3463 "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
3464 (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
3465 (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
3466 "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
3467
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3468 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3469 ;; 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
3470
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3471 (defvar idlwave-builtin-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3472 (defun idlwave-routines ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3473 "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
3474 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
3475 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
3476 (or idlwave-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3477 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3478 (idlwave-update-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3479 ;; return the current value
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3480 idlwave-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3481
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3482 (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
3483 "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
3484 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
3485 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
3486 about individual routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3487
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3488 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
3489 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
3490 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
3491 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
3492 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
3493
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3494 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
3495 `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
3496 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
3497 for currently compiled routines.
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 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
3500 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
3501 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3502 (if (equal arg '(16))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3503 (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
3504 (let* ((reload (or arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3505 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
3506 (null idlwave-builtin-routines))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3507
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3508 (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
3509 idlwave-compiled-routines nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3510 ;; Reset the appropriate hashes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3511 (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
3512 ((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
3513 (t 'bufsh)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3514
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3515 (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
3516 ;; 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
3517 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3518 (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 (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
3520 ;; 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
3521 (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
3522 (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
3523
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3524 ;; 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
3525 (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
3526 (idlwave-shell-is-running)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3527 (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
3528 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
3529
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3530 (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
3531 (not (interactive-p)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3532 ;; 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
3533 ;; concatenation now.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3534 ;; 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
3535 ;; 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
3536 ;; 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
3537 ;; 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
3538 ;; 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
3539 (idlwave-concatenate-rinfo-lists))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3540
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3541 (when ask-shell
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3542 ;; 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
3543 (message "Querying the shell")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3544 (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
3545
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3546 (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
3547 ;; 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
3548 (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
3549 (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
3550 (setq idlwave-builtin-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3551 (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
3552 (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
3553 (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
3554 (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
3555 (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
3556 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3557 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3558 (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
3559 (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
3560 (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
3561 idlwave-library-routines 'sys))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3562 (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
3563 (error nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3564
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3565 (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
3566 (let (res)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3567 (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
3568 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3569 ;; 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
3570 (message "Scanning all buffers...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3571 (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
3572 (reverse (buffer-list)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3573 ;; Just scan this buffer
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 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3576 (message "Scanning current buffer...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3577 (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
3578 (list (current-buffer)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3579 ;; 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
3580 (setq idlwave-buffer-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3581 (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
3582
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3583 (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
3584 "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
3585 ;; 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
3586 ;; 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
3587 ;; 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
3588 ;; 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
3589 ;; 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
3590 ;; 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
3591 ;; 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
3592 ;; 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
3593 ;; 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
3594 ;; 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
3595 (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
3596 idlwave-compiled-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3597 idlwave-library-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3598 idlwave-builtin-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3599 (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
3600 (let (class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3601 (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
3602 (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
3603 (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
3604 (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
3605 ;; 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
3606 (message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3607 "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
3608 (length idlwave-buffer-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3609 (length idlwave-compiled-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3610 (length idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3611 (length idlwave-builtin-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3612
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3613 ;;----- Scanning buffers -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3614
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3615 (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
3616 "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
3617 (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
3618 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3619 (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
3620 (set-buffer buf)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3621 (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
3622 ;; 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
3623 (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
3624 (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
3625 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3626 (push res routine-lists)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3627 ;; 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
3628 (apply 'nconc routine-lists)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3629
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3630 (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
3631 "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
3632 (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
3633 routine-list string entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3634 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3635 (save-restriction
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3636 (widen)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3637 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3638 (while (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3639 "^[ \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
3640 (setq string (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3641 (match-beginning 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3642 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3643 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3644 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3645 (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
3646 (push entry routine-list))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3647 routine-list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3648
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3649 (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
3650 "Parse a module definition."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3651 (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
3652 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
3653 ;; Remove comments
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3654 (while (string-match ";.*" string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3655 (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
3656 ;; 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
3657 (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
3658 (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
3659 ;; 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
3660 (when (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3661 "\\<\\(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
3662 (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
3663 (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
3664 (if (match-beginning 3)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3665 (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
3666 (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
3667 ;; 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
3668 (while (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3669 ",\\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
3670 string start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3671 (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
3672 (if (match-beginning 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3673 (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
3674 (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
3675 ;; Normalize and sort.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3676 (setq args (nreverse args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3677 (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
3678 (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
3679 ;; 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
3680 ;; 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
3681 ;; 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
3682 (list name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3683 (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
3684 class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3685 (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
3686 (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
3687 ((string= (downcase
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3688 (file-name-sans-extension
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3689 (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
3690 (downcase name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3691 (list 'lib))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3692 (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
3693 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3694 (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
3695 (if class "Obj ->[%s::]" "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3696 "%s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3697 (if args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3698 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3699 (if (string= type "function") "(" ", ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3700 (mapconcat 'identity args ", ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3701 (if (string= type "function") ")" ""))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3702 (if keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3703 (mapcar 'list keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3704 nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3705
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3706 ;;----- Scanning the library -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3707
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3708 (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
3709 "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
3710 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
3711 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
3712 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
3713 routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3714 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
3715 will pop up."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3716 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3717 ;; 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
3718 (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
3719 (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
3720 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3721 (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
3722 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3723 ;; 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
3724 (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
3725 (file-accessible-directory-p
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3726 (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
3727 (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
3728 idlwave-libinfo-file))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3729 (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
3730
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3731 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3732 ((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
3733 ;; Rescan the known directories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3734 (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
3735 (idlwave-library-path
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3736 ;; 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
3737 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3738 (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
3739 idlwave-scanned-lib-directories))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3740 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3741 ;; 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
3742 (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
3743 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3744 "__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
3745 '(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
3746 'hide))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3747
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3748 (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
3749 ;; 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
3750 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3751 ;; Scan immediately
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3752 (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
3753 ;; Display the widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3754 (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
3755 idlwave-scanned-lib-directories)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3756
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3757 (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
3758 (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
3759 ;; 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
3760 (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
3761 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3762 (start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3763 dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3764 (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
3765 (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
3766 (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
3767 (nreverse dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3768
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3769 (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
3770 "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
3771 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
3772 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
3773
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3774 %s
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3775
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3776 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
3777 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
3778 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
3779 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
3780 \n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3781
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3782 (defvar idlwave-widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3783 (defvar widget-keymap)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3784 (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
3785 "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
3786 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3787 (require 'widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3788 (require 'wid-edit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3789 (unless dirs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3790 (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
3791
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3792 ;; 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
3793 (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
3794 (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
3795 selected-dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3796 (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
3797 (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
3798 (kill-all-local-variables)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3799 (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
3800 (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
3801 idlwave-libinfo-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3802
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3803 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3804 :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
3805 :help-echo "testing"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3806 "Scan & Save")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3807 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3808 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3809 :notify (lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3810 (kill-buffer (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3811 "Quit")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3812 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3813 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3814 :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
3815 "Delete File")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3816 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3817 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3818 :notify '(lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3819 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3820 (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
3821 (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
3822 "Select All")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3823 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3824 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3825 :notify '(lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3826 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3827 (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
3828 nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3829 "Deselect All")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3830 (widget-insert "\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3831
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3832 (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
3833
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3834 (setq idlwave-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3835 (apply 'widget-create
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3836 'checklist
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3837 :value selected-dirs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3838 :greedy t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3839 :tag "List of directories"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3840 (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
3841 (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
3842 (widget-insert "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3843 (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
3844 (widget-setup)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3845 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3846 (delete-other-windows))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3847
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3848 (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
3849 (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
3850 (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
3851 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3852 (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
3853 (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
3854
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3855 (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
3856 ;; 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
3857 (let* ((widget idlwave-widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3858 (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
3859 (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
3860
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3861 (defvar font-lock-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3862 (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
3863 ;; 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
3864 (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
3865 (idlwave-completion-case nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3866 dirs dir files file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3867 (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
3868 (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
3869 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3870 (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
3871 (idlwave-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3872 (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
3873 (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
3874 (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
3875 (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
3876 (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
3877 (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
3878 (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
3879 (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
3880 (message "Scanning %s..." file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3881 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3882 (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
3883 (setq idlwave-library-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3884 (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
3885 (list (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3886 idlwave-library-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3887 )))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3888 (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
3889 (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
3890 (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
3891 (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
3892 (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
3893 font-lock-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3894 (font-lock-mode 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3895 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3896 (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
3897 (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
3898
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3899 ;; 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
3900 (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
3901 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3902 (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
3903 selected-dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3904 (insert "))\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3905 ;; 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
3906 (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
3907 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3908 (insert "\n ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3909 (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
3910 idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3911 (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
3912 (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
3913 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3914 ;; Save the buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3915 (save-buffer 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3916 (kill-buffer (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3917 (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
3918 (length idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3919 idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3920 (sit-for 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3921 (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
3922
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3923 (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
3924 ;; 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
3925 ;; 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
3926 (message "Expanding path...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3927 (let (path1 dir recursive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3928 (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
3929 (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
3930 (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
3931 (if (and recursive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3932 (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
3933 (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
3934 (if recursive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3935 ;; Expand recursively
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3936 (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
3937 ;; Keep unchanged
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3938 (push dir path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3939 (message "Expanding path...done")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3940 (nreverse path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3941
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3942 (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
3943 ;; 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
3944 (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
3945 (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
3946 (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
3947 (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
3948 (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
3949 (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
3950 (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
3951 (push dir path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3952 path1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3953
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3954 ;;----- Asking the shell -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3955
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3956 ;; 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
3957 ;; defined routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3958 (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
3959 "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3960 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
3961 ;; 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
3962 func = keyword_set(func)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3963 methsep = strpos(name,'::')
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3964 meth = methsep ne -1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3965
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3966 ;; Get routine info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3967 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
3968 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
3969 nargs = pars.num_args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3970 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
3971 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
3972 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
3973
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3974 ;; 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
3975 if meth then begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3976 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
3977 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
3978 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
3979 ;; remove the self argument
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3980 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
3981 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
3982 endif
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3983 endif else begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3984 ;; 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
3985 class = \"\"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3986 endelse
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3987
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3988 ;; Calling sequence
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3989 cs = \"\"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3990 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
3991 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
3992 cs = cs + '%s'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3993 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
3994 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
3995 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
3996 cs = cs + args(j)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3997 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
3998 endfor
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3999 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4000 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
4001 ;; Keyword arguments
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4002 kwstring = ''
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4003 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
4004 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
4005 kwstring = kwstring + ' ' + kwargs(j)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4006 endfor
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4007 endif
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4008
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4009 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
4010 '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
4011
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4012 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
4013 + sep + cs + sep + kwstring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4014 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4015
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4016 pro idlwave_routine_info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4017 sep = '<@>'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4018 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
4019 all = routine_info()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4020 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
4021 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
4022 all = routine_info(/functions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4023 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
4024 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
4025 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
4026 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4027 "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4028 "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
4029 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
4030
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4031 (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
4032 "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
4033 (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
4034 (start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4035 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
4036 ;; Initialize variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4037 (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
4038 ;; 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
4039 (if (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4040 "^>>>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
4041 text)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4042 (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
4043 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
4044 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
4045 (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
4046 (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
4047 (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
4048 (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
4049 ;; Match the output lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4050 (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
4051 (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
4052 (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
4053 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
4054 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
4055 name (nth 0 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4056 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
4057 file (nth 2 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4058 cs (nth 3 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4059 key (nth 4 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4060 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
4061 (not (string-match "\\` *\\'" key)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4062 (mapcar 'list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4063 (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
4064 (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
4065 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
4066 keys (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4067 (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
4068 ;; 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
4069 (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
4070 ;; 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
4071 ;; 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
4072 ;; 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
4073 ;; (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
4074 ;; (setq file nil))
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 ;; 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
4077 ;; 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
4078 ;; version.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4079 ;; 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
4080 ;; 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
4081 ;; 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
4082 ;; 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
4083 ;; 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
4084
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4085 (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
4086 ((and (string= type "PRO")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4087 ;; 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
4088 (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
4089 idlwave-buffer-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4090 ;; 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
4091 ;;(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
4092 ;; idlwave-library-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4093 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4094 (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
4095 idlwave-compiled-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4096 ((and (string= type "FUN")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4097 ;; 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
4098 (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
4099 idlwave-buffer-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4100 ;; 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
4101 ;; (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
4102 ;; idlwave-library-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4103 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4104 (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
4105 idlwave-compiled-routines)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4106 ;; 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
4107 (setq idlwave-compiled-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4108 (nreverse idlwave-compiled-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4109
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4110 (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
4111 (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
4112 "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
4113 ;; 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
4114 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4115 (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
4116 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
4117 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4118 (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
4119 (save-buffer 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4120 (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
4121 nil 'hide)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4122
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4123 ;; 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
4124 (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
4125 '(progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4126 (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
4127 (idlwave-concatenate-rinfo-lists))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4128 'hide))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4129
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4130 ;; ---------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4131 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4132 ;; 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
4133
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4134 (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
4135 "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
4136 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
4137 at this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4138 - 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
4139 - 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
4140 - 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
4141 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
4142 - 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
4143
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4144 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
4145 *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
4146 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
4147
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4148 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
4149 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
4150 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
4151 argument to this command.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4152
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4153 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
4154 `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
4155
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4156 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
4157 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
4158 Possible values are:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4159
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4160 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
4161 1 <=> 'procedure
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4162 2 <=> 'procedure-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4163 3 <=> 'function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4164 4 <=> 'function-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4165 5 <=> 'procedure-method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4166 6 <=> 'procedure-method-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4167 7 <=> 'function-method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4168 8 <=> 'function-method-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4169 9 <=> 'class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4170
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4171 For Lisp programmers only:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4172 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
4173 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
4174 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4175 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4176 (let* ((where-list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4177 (if (and arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4178 (or (integerp arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4179 (symbolp arg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4180 (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
4181 (idlwave-where)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4182 (what (nth 2 where-list))
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
4183 (idlwave-force-class-query (equal arg '(4))))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4184
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4185 (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
4186 (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
4187 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
4188
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4189 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4190
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4191 ((and (null arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4192 (eq (car-safe last-command) 'idlwave-display-completion-list)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
4193 (get-buffer-window "*Completions*"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4194 (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
4195 (idlwave-scroll-completions))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4196
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4197 ((null what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4198 (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
4199
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4200 ((eq what 'class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4201 (idlwave-complete-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4202
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4203 ((eq what 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4204 ;; Complete a procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4205 (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
4206 (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
4207 (type-selector 'pro))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4208 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4209 '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
4210 (idlwave-routines) 'idlwave-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4211 (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
4212 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4213 (if class-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4214 (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
4215 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4216 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4217 'idlwave-attach-method-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4218
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4219 ((eq what 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4220 ;; Complete a function name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4221 (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
4222 (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
4223 (type-selector 'fun))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4224 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4225 '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
4226 (idlwave-routines) 'idlwave-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4227 (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
4228 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4229 (if class-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4230 (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
4231 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4232 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4233 'idlwave-attach-method-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4234
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4235 ((eq what 'procedure-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4236 ;; Complete a procedure keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4237 (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
4238 (name (car where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4239 (method-selector name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4240 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4241 (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
4242 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4243 (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
4244 (entry (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4245 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
4246 (list (nth 5 entry)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4247 (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
4248 (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
4249 (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
4250 (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
4251 (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
4252 (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
4253 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4254 'keyword 'keyword list nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4255 (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
4256 (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
4257 (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
4258 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4259 'idlwave-attach-keyword-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4260
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4261 ((eq what 'function-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4262 ;; Complete a function keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4263 (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
4264 (name (car where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4265 (method-selector name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4266 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4267 (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
4268 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4269 (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
4270 (entry (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4271 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
4272 (list (nth 5 entry)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4273 (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
4274 (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
4275 (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
4276 (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
4277 (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
4278 (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
4279 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4280 'keyword 'keyword list nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4281 (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
4282 (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
4283 (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
4284 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4285 'idlwave-attach-keyword-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4286
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4287 (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
4288
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4289 (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
4290 ;; 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
4291 ;; 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
4292 ;; 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
4293 ;; 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
4294 ;; 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
4295 (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
4296 ("function") ("function-keyword")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4297 ("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
4298 ("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
4299 ("class")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4300 (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
4301 (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
4302 (what (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4303 ((equal what 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4304 (setq what
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4305 (intern (completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4306 "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
4307 ((integerp what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4308 (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
4309 ((and what
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4310 (symbolp what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4311 (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
4312 what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4313 (t (error "Illegal WHAT"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4314 (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
4315 (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
4316
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4317 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4318
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4319 ((eq what 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4320 (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
4321
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4322 ((eq what 'procedure-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4323 (let* ((class-selector nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4324 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4325 (pro (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4326 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4327 "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
4328 (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
4329 (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
4330 (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
4331
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4332 ((eq what 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4333 (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
4334
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4335 ((eq what 'function-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4336 (let* ((class-selector nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4337 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4338 (func (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4339 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4340 "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
4341 (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
4342 (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
4343 (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
4344
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4345 ((eq what 'procedure-method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4346 (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
4347
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4348 ((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
4349 (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
4350 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4351 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4352 (pro (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4353 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4354 (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
4355 (idlwave-routines) 'idlwave-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4356 (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
4357 (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
4358 (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
4359
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4360 ((eq what 'function-method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4361 (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
4362
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4363 ((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
4364 (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
4365 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4366 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4367 (func (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4368 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4369 (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
4370 (idlwave-routines) 'idlwave-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4371 (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
4372 (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
4373 (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
4374
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4375 ((eq what 'class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4376 (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
4377
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4378 (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
4379
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4380 (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
4381 ;; Completing read, case insensitive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4382 (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
4383 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4384 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4385 (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
4386 (apply 'completing-read args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4387 (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
4388
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4389 (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
4390 ;; 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
4391 (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
4392
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4393 (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
4394 ;; 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
4395 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4396 (let (match)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4397 (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
4398 (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
4399 (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
4400 (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
4401 (throw 'exit match))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4402 (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
4403
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4404 (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
4405 "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
4406 (let (rtn elt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4407 (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
4408 (push elt rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4409 (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
4410 (nreverse rtn)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4411
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4412 (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
4413 "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
4414 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
4415 (if (null method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4416 (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
4417 (let (rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4418 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4419 (and (nth 2 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4420 (or (not type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4421 (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
4422 (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
4423 (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
4424 (idlwave-uniquify rtn))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4425
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4426 (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
4427 "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
4428 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
4429 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
4430 (if (or (null method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4431 (null keyword))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4432 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4433 (let (rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4434 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4435 (and (nth 2 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4436 (or (not type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4437 (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
4438 (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
4439 (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
4440 (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
4441 (idlwave-uniquify rtn))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4442
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4443 (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
4444 ;; 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
4445 ;; `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
4446 ;; 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
4447 ;; 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
4448 ;; 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
4449 ;; 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
4450 ;; 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
4451 (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
4452 (apos (nth 3 info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4453 (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
4454 (upcase (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4455 (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4456 idlwave-query-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4457 (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
4458 idlwave-query-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4459 (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
4460 (dassoc (cdr dassoc))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4461 (t t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4462 (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
4463 (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
4464 store class-alist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4465 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4466 ((null class) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4467 ((eq t class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4468 ;; 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
4469 (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
4470 idlwave-store-inquired-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4471 (not force-query))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4472 (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
4473 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
4474 (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
4475 (or force-query query))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4476 (setq class-alist
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4477 (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
4478 (setq class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4479 (idlwave-sintern-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4480 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4481 ((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
4482 (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
4483 ((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
4484 (car (car class-alist)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4485 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4486 (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
4487 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4488 (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
4489 (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
4490 type (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4491 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4492 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
4493 (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
4494 ;; 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
4495 (when (and store arrow)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4496 (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
4497 (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
4498 (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
4499 ;; Return the class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4500 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4501 ;; Default as fallback
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4502 (t class))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4503
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4504 (defvar type-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4505 (defvar class-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4506 (defvar method-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4507 (defun idlwave-selector (a)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4508 (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
4509 (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
4510 (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
4511
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4512 (defun idlwave-where ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4513 "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
4514 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
4515 (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
4516
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4517 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
4518 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
4519 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
4520 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
4521 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
4522 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
4523
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4524 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
4525 PRO: Procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4526 FUNC: Function name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4527 POINT: Where is this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4528 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
4529 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
4530 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4531 (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
4532 (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
4533 (func (car func-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4534 (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
4535 (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
4536 (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
4537 (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
4538 (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
4539 (pro (car pro-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4540 (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
4541 (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
4542 (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
4543 (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
4544 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4545 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
4546 (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
4547 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4548 ((string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4549 "\\`[ \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
4550 (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
4551 (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
4552 cw-arrow pro-arrow))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4553 ((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
4554 (buffer-substring bos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4555 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4556 ((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
4557 (buffer-substring bos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4558 (setq cw 'class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4559 ((and func
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4560 (> func-point pro-point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4561 (= func-level 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4562 (memq last-char '(?\( ?,)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4563 (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
4564 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
4565 ((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
4566 (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
4567 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
4568 ; ((member last-char '(?\' ?\) ?\] ?!))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4569 ; ;; 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
4570 ; ;; 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
4571 ; ;; 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
4572 ; nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4573 ;; 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
4574 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4575 (setq cw 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4576 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4577 (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
4578 (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
4579 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
4580 (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
4581 t))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4582 (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
4583 (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
4584 cw
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4585 (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
4586 last-char)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4587
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4588 (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
4589 ;; 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
4590 (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
4591 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4592 (buffer-substring-no-properties
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4593 (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
4594 (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
4595
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4596 (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
4597 (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
4598 ;; 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
4599 ;; 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
4600 ;; 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
4601
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4602 ;; 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
4603 ;; searches to this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4604
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4605 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4606 (let (pos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4607 func-point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4608 (old-syntax (syntax-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4609 (cnt 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4610 func arrow-start class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4611 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4612 (save-restriction
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4613 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4614 (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
4615 (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
4616 ;; 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
4617 (while (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4618 (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
4619 (error nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4620 (setq pos (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4621 (incf cnt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4622 (when (and (= (following-char) ?\()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4623 (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4624 "\\(::\\|\\<\\)\\([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
4625 bound t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4626 (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
4627 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
4628 pos func-point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4629 (if (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4630 "->[ \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
4631 (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
4632 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
4633 (throw
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4634 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4635 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4636 (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
4637 (idlwave-sintern-class class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4638 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
4639 (goto-char pos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4640 (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4641 (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
4642
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4643 (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
4644 ;; 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
4645 ;; 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
4646
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4647 ;; 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
4648 ;; searches to this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4649 (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
4650 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
4651 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4652 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4653 (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
4654 (if (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4655 "\\`[ \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
4656 (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
4657 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
4658 (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
4659 (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
4660 (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4661 "\\`[ \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
4662 (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
4663 (match-string 4 string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4664 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
4665 (+ (point) (match-beginning 4))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4666 pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4667 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
4668 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
4669 (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
4670 (idlwave-sintern-class class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4671 arrow-start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4672 pro-point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4673
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4674 (defun idlwave-skip-object ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4675 ;; 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
4676 (let ((pos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4677 (if (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4678 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4679 (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
4680 (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
4681 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4682 ((looking-at idlwave-identifier)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4683 (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
4684 ((eq (following-char) ?\()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4685 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4686 (t (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4687 (catch 'endwhile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4688 (while t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4689 (cond ((eq (following-char) ?.)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4690 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4691 (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
4692 (throw 'exit nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4693 (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
4694 ((memq (following-char) '(?\( ?\[))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4695 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4696 (forward-list 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4697 (error (throw 'exit nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4698 (t (throw 'endwhile t)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4699 (if (looking-at "[ \t]*->")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4700 (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
4701 (throw 'exit nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4702 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4703 nil)))
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
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4706 (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
4707 "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
4708 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
4709 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
4710 `/' 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
4711 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
4712 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4713 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4714 ;; skip the current identifier
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4715 (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
4716 ;; 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
4717 (if (eq (preceding-char) ?/)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4718 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4719 ;; 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
4720 (while t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4721 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4722 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4723 ((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
4724 ((eq (preceding-char) ?\n)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4725 (beginning-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4726 (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
4727 ;; continuation line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4728 (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
4729 (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4730 (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
4731
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4732 (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
4733 "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
4734 (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
4735 "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
4736 (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
4737 "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
4738
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4739 (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
4740 &optional prepare-display-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4741 "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
4742 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
4743 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
4744 (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
4745 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
4746 dpart dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4747
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4748 (unless list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4749 (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
4750
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4751 ;; 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
4752 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4753 (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
4754 (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
4755 beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4756 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
4757 (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
4758 (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
4759 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
4760 (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
4761 (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
4762
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4763 ;; Try a completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4764 (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
4765 dpart (downcase part)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4766 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
4767 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
4768 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
4769 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4770 ((null completion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4771 ;; nothing available.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4772 (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
4773 ((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
4774 (not (eq t completion)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4775 ;; We can add something
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4776 (delete-region beg end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4777 (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
4778 (or (not (string= part ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4779 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
4780 (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
4781 (insert dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4782 (insert completion))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4783 (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
4784 ;; 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
4785 (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
4786 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4787 ((or (eq completion t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4788 (and (equal dpart dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4789 (= 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
4790 (idlwave-uniquify
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4791 (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
4792 ;; This is already complete
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4793 (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
4794 (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
4795 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4796 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4797 ;; 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
4798 (message "Making completion list...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4799 (let* ((list all-completions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4800 (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
4801 (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
4802 (completion-fixup-function ; Emacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4803 (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
4804 (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
4805 (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
4806 (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
4807 (if prepare-display-function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4808 (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
4809 (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
4810 (or (not (string= part ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4811 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
4812 (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
4813 (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
4814 (if (listp x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4815 (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
4816 (setq x (downcase x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4817 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4818 list)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4819 (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
4820 t))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4821
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4822 (defun idlwave-complete-class ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4823 "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
4824 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4825 ;; 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
4826 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4827 ;; Now do the completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4828 (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
4829 "Select a class" "class"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4830
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4831
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4832 (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
4833 ;; 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
4834 ;; 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
4835 ;; 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
4836 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4837 (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
4838 (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
4839 (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
4840 ;; 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
4841 (throw 'exit list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4842
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4843 ;; 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
4844 ;; 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
4845 ;; buffer.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4846 (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
4847 (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
4848 (do-dots (featurep 'xemacs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4849 (max (abs show-classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4850 (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
4851 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
4852 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4853 (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4854 ;; get the classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4855 (setq classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4856 (if is-kwd
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4857 (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
4858 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
4859 (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
4860 (setq nclasses (length classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4861 ;; 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
4862 (if do-dots
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4863 (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
4864 (setq space " "))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4865 (if do-buf
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4866 ;; 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
4867 (if (<= nclasses max)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4868 (setq class-info (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4869 space
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4870 "<" (mapconcat 'identity classes ",") ">"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4871 (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
4872 (setq class-info nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4873 (when do-prop
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4874 ;; We do want properties
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4875 (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
4876 (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
4877 '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
4878 x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4879 (if class-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4880 (list x class-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4881 x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4882 list))))
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 (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
4885 ;; 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
4886 (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
4887 (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
4888 ;; 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
4889 (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
4890
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 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4893 ;;----------------------------------------------------------------------
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 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4896
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4897 (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
4898 "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
4899 (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
4900 (win (selected-window)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4901 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4902 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4903 (select-window cwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4904 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4905 (scroll-up)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4906 (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
4907 (nth 2 last-command))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4908 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4909 (select-window win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4910 (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
4911 (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
4912 (and message (message message)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4913 (select-window win))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4914
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4915 (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
4916 "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
4917 (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
4918 (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
4919 (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
4920 (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
4921
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4922 (if (featurep 'xemacs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4923 (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
4924 (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
4925
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4926 ;; 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
4927 ;; 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
4928 (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
4929
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4930 ;; 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
4931 (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
4932
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4933 ;; Fontify the classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4934 (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
4935 (consp (car list)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4936 (idlwave-completion-fontify-classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4937
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4938 ;; Display the message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4939 (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
4940
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4941 (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
4942 "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
4943 (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
4944 (apply function args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4945 (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
4946
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4947 (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
4948 "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
4949 (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
4950 idlwave-before-completion-wconf
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4951 (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
4952
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4953 (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
4954 "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
4955 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4956 (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
4957 (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
4958
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4959 (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
4960 "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
4961 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4962 (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
4963 (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
4964 (symbol-value var))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4965
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4966 ;; 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
4967
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4968 (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
4969 (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
4970 (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
4971 'idlwave-default-choose-completion)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4972
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4973 (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
4974 "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
4975 (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
4976
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4977 ;; 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
4978 ;; 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
4979
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4980 (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
4981 "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
4982
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4983 (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
4984 "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
4985 (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
4986 (display-completion-list list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4987 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4988 (set-buffer "*Completions*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4989 (use-local-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4990 (or idlwave-completion-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4991 (setq idlwave-completion-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4992 (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
4993
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4994 (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
4995 "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
4996 (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
4997 (substitute-key-definition
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4998 '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
4999 (substitute-key-definition
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5000 '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
5001 new-map))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5002
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5003 (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
5004 "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
5005 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5006 (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
5007
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5008 (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
5009 "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
5010 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5011 (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
5012
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5013 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5014 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5015
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5016 (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
5017 "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
5018 (when (featurep 'font-lock)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5019 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5020 (set-buffer "*Completions*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5021 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5022 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5023 (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
5024 (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
5025 '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
5026
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5027 (defun idlwave-uniquify (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5028 (let (nlist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5029 (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
5030 (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
5031 nlist))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5032
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5033 (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
5034 "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
5035 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
5036 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5037 ((eq type 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5038 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5039 ((eq type 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5040 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5041 ((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
5042 ((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
5043 (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
5044 (insert "("))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5045 ((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
5046 (insert "()")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5047 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5048 (t nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5049 ((eq type 'keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5050 (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
5051 (not slash))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5052 (progn (insert "=") t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5053 nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5054
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5055 ;; 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
5056
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5057 (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
5058 (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5059 (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
5060 (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
5061 "*Completions*") ; cib-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5062 (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
5063 (current-buffer)) ; buffer OK
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5064 (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
5065 verify))) ; pos OK
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5066 (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
5067 (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
5068 (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
5069
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5070 (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
5071 "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
5072 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
5073 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
5074 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5075 (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
5076
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5077 (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
5078 "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
5079 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
5080 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
5081 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
5082 query.
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 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
5085 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
5086 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
5087
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5088 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5089 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5090 (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
5091 (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
5092 (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
5093 ;; 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
5094 (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
5095 ;; arrow has class property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5096 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5097 ;; Remove property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5098 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5099 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5100 (when (looking-at ".?\\(->\\)")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5101 (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
5102 '(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
5103 (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
5104 ;; Echo class property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5105 (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
5106 (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
5107 ;; No property found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5108 (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
5109
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5110 ;; Not on an arrow...
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5111 (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
5112 (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
5113 (module (idlwave-what-module)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5114 (cond ((car module)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5115 (if external
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5116 (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
5117 (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
5118 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5119 (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
5120
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5121 (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
5122 "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
5123 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
5124 ;; 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
5125 ;; 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
5126 ;; 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
5127 ;; cannot enter a space.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5128 (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
5129
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5130 ;; 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
5131 (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
5132 (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
5133 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
5134 (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
5135 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
5136
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5137 ;; 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
5138 (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
5139 (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
5140 ;; 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
5141 (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
5142 (file-exists-p book))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5143 (setq full ",/FULL_PATH")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5144 (setq full ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5145
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5146 ;; 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
5147 ;; 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
5148 ;; the book name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5149 ;; (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
5150 ;; (class " method")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5151 ;; ((eq type 'pro) " procedure")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5152 ;; ((eq type 'fun) " function")
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 (setq extra "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5155
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5156 ;; 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
5157 (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
5158 (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
5159 ;; 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
5160 (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
5161 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
5162 ; 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
5163 (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
5164 (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
5165
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5166 (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
5167 "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
5168 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
5169 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
5170 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
5171 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
5172 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
5173 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
5174 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5175 (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
5176 (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
5177 (module (idlwave-what-module))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5178 (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
5179 (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
5180 (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
5181 (kwd "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5182 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5183 (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
5184 resolve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5185 (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
5186 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
5187 (match-string 3 resolve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5188 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5189 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
5190 (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
5191 (setq kwd ",/is_function"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5192
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5193 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5194 ((null class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5195 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5196 (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
5197 'idlwave-update-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5198 nil t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5199 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5200 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5201 (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
5202 (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
5203 (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
5204 (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
5205 '(idlwave-update-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5206 nil t))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5207
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5208 (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
5209 "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
5210 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
5211 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
5212 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
5213 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5214 (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
5215 (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
5216 (module (idlwave-what-module))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5217 (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
5218 (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
5219 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5220 (delq nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5221 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5222 (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
5223 ;; 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
5224 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5225 (cons
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5226 (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
5227 (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
5228 (cdr x))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5229 (idlwave-routines))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5230 (name (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5231 (format "Module (Default %s): "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5232 (if default default "none"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5233 list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5234 type class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5235 (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
5236 ;; Nothing, use the default.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5237 (setq name default))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5238 (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
5239 (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
5240 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
5241 (if (string-match "\\(.*\\)::\\(.*\\)" name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5242 (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
5243 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
5244 (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
5245 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
5246 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
5247 ((equal type "p") 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5248 (t t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5249 (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
5250
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5251 (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
5252 (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
5253 source buf1 entry
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5254 (buf (current-buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5255 (pos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5256 (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
5257 source (nth 3 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5258 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5259 ((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
5260 (error "Abort"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5261 ((null entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5262 (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
5263 ((eq (car source) 'system)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5264 (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
5265 name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5266 ((equal (cdr source) "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5267 (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
5268 name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5269 ((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
5270 (setq buf1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5271 (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
5272 (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
5273 (or (cdr source)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5274 (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
5275 (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
5276 (pop-to-buffer buf1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5277 (goto-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5278 (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
5279 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5280 (concat "^[ \t]*\\<"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5281 (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
5282 ((equal type "p") "pro")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5283 (t "\\(pro\\|function\\)"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5284 "\\>[ \t]+"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5285 (regexp-quote (downcase name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5286 "[^a-zA-Z0-9_$]")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5287 nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5288 (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
5289 (pop-to-buffer buf)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5290 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5291 (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
5292
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5293 (defun idlwave-what-module ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5294 "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
5295 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
5296 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5297 (let* ((where (idlwave-where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5298 (cw (nth 2 where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5299 (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
5300 (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
5301 (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
5302 (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
5303 (following-char)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5304 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5305 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5306 ((and (eq cw 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5307 (not (equal this-word "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5308 (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
5309 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
5310 (list this-word 'pro
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5311 (idlwave-determine-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5312 (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
5313 'pro)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5314 ((and (eq cw 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5315 (not (equal this-word ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5316 (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
5317 (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
5318 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
5319 (list this-word 'fun
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5320 (idlwave-determine-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5321 (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
5322 'fun)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5323 (func
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5324 (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
5325 (pro
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5326 (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
5327 (t nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5328
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5329 (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
5330 ;; 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
5331 (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
5332 name1 type1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5333
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5334 ;; 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
5335 ;; 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
5336 (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
5337 (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
5338 (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
5339 (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
5340 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5341 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5342 (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
5343 string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5344 (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
5345 (setq keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5346 (append keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5347 (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
5348 (idlwave-sintern-method "INIT")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5349 'fun
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5350 class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5351 (idlwave-routines))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5352
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5353 ;; 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
5354 (when (eq class t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5355 (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
5356 (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
5357 (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
5358 (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
5359 (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
5360 (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
5361 (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
5362 (nth 5 x))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5363 (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
5364 ;; Return the final list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5365 keywords))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5366
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5367 (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
5368 (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
5369 (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
5370 'idlwave-mouse-active-rinfo)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5371 (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
5372 (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
5373 '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
5374 (defvar idlwave-popup-source)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5375
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5376 (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
5377 ;; 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
5378 (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
5379 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
5380 (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
5381 (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
5382 (source (nth 3 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5383 ;;(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
5384 (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
5385 (keywords (nth 5 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5386 (olh (nth 6 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5387 (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
5388 (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
5389 (col 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5390 (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
5391 (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
5392 beg props win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5393 (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
5394 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5395 ((null entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5396 (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
5397 ((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
5398 (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
5399 ((null calling-seq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5400 (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
5401 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5402 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5403 (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
5404 (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
5405 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5406 (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
5407 (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
5408 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
5409 'help-echo help-echo23
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5410 'data (cons 'usage data)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5411 (insert "Usage: ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5412 (setq beg (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5413 (insert (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5414 (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
5415 (format calling-seq name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5416 "\n")
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
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5419 (insert "Keywords:")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5420 (if (null keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5421 (insert " No keywords accepted.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5422 (setq col 9)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5423 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5424 (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5425 (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
5426 (window-width))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5427 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5428 (insert "\n ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5429 (setq col 9)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5430 (insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5431 (setq beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5432 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
5433 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
5434 'data (cons 'keyword data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5435 'help-echo help-echo3
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5436 'keyword (car x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5437 (insert (car x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5438 (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
5439 (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
5440 keywords))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5441 (insert "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5442
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5443 (insert "Origin: ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5444 (setq beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5445 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
5446 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
5447 'help-echo help-echo23
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5448 'data (cons 'origin data)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5449 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5450 ((eq (car source) 'system)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5451 (insert "system routine"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5452 ((equal source '(lib))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5453 (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
5454 ((eq (car source) 'lib)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5455 (insert "library file ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5456 (insert (cdr source)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5457 ((eq (car source) 'buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5458 (insert "buffer visiting ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5459 (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
5460 ((eq (car source) 'compiled)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5461 (insert "compiled from ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5462 (insert (cdr source))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5463 (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
5464 (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
5465 (display-buffer "*Help*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5466 (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
5467 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
5468 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5469 (let ((ww (selected-window)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5470 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5471 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5472 (select-window win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5473 (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
5474 (window-height)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5475 (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
5476 (select-window ww)))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5477
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5478 (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
5479 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5480 (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
5481
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5482 (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
5483 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5484 (mouse-set-point ev)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5485 (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
5486 (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
5487 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
5488 id (car data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5489 name (nth 1 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5490 type (nth 2 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5491 class (nth 3 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5492 buf (nth 4 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5493 olh (nth 5 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5494 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
5495 (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
5496 (if right
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5497 (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
5498 (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
5499 (if idlwave-popup-source
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5500 (condition-case err
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5501 (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
5502 (error
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5503 (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
5504 (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
5505 (error (nth 1 err))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5506 (if bufwin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5507 (select-window bufwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5508 (pop-to-buffer buf)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5509 ((eq id 'keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5510 (if right
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5511 (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
5512 (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
5513
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5514 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5515 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5516 ;; 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
5517 ;; (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
5518 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5519
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5520 (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
5521 "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
5522 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
5523 (save-match-data
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5524 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5525 ((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
5526 ;; ((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
5527 (t nil))))
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-unit-name ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5530 "Return the unit name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5531 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
5532 `idlwave-prev-index-position'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5533 (forward-sexp 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5534 (forward-sexp -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5535 (let ((begin (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5536 (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
5537 (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
5538 (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
5539 (buffer-substring begin (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5540
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5541 (defun idlwave-function-menu ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5542 "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
5543 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5544 (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
5545 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5546 (require 'func-menu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5547 (function-menu))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5548 (require 'imenu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5549 (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
5550
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5551 ;; 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
5552 ;; 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
5553 ;; 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
5554 (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
5555 (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
5556 '(progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5557 (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
5558 (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
5559 (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
5560 (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
5561 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
5562 (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
5563 (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
5564 (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
5565 (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
5566 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
5567
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5568 (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
5569 "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
5570 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5571 (start-process "idldeclient" nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5572 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
5573 (buffer-file-name) "&"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5574
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5575 (defun idlwave-launch-idlhelp ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5576 "Start the IDLhelp application."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5577 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5578 (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
5579
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5580 ;; Menus - using easymenu.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5581 (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
5582 `("IDLWAVE"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5583 ["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
5584 ("Motion"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5585 ["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
5586 ["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
5587 ["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
5588 ["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
5589 ["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
5590 ["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
5591 ["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
5592 ["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
5593 ("Mark"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5594 ["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
5595 ["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
5596 ["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
5597 ("Format"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5598 ["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
5599 ["(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
5600 ["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
5601 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5602 ["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
5603 :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
5604 ("Templates"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5605 ["Procedure" idlwave-procedure t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5606 ["Function" idlwave-function t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5607 ["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
5608 ["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
5609 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5610 ["Case" idlwave-case t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5611 ["For" idlwave-for t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5612 ["Repeat" idlwave-repeat t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5613 ["While" idlwave-while t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5614 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5615 ["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
5616 ("Completion / RInfo"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5617 ["Complete" idlwave-complete t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5618 ("Complete Special"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5619 ["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
5620 ["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
5621 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5622 ["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
5623 ["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
5624 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5625 ["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
5626 ["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
5627 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5628 ["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
5629 ["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
5630 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5631 ["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
5632 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5633 ["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
5634 ["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
5635 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5636 ["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
5637 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5638 ["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
5639 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5640 "IDL Library Routine Info"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5641 ["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
5642 ["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
5643 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5644 ("External"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5645 ["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
5646 ["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
5647 ["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
5648 ["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
5649 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5650 ("Customize"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5651 ["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
5652 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5653 ["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
5654 (fboundp 'customize-menu-create)])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5655 ("Documentation"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5656 ["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
5657 ["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
5658 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5659 ["Commentary in idlwave.el" idlwave-show-commentary t]
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
5660 ["Commentary in idlw-shell.el" idlwave-shell-show-commentary t]
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5661 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5662 ["Info" idlwave-info t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5663 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5664 ["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
5665
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5666 (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
5667 '("Debug"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5668 ["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
5669 ["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
5670 (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
5671 idlwave-shell-automatic-start)]))
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 (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
5674 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5675 (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
5676 "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
5677 idlwave-mode-menu-def)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5678 (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
5679 "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
5680 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
5681
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5682 (defun idlwave-customize ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5683 "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
5684 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5685 ;; 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
5686 ;; as well.
27185
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
5687 (or (featurep 'idlw-shell)
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
5688 (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
5689 (customize-browse 'idlwave))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5690
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5691 (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
5692 "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
5693 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5694 (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
5695 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5696 ;; 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
5697 ;; as well.
27185
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
5698 (or (featurep 'idlw-shell)
ae5b17b9c403 fixed some bugs associated with the new file names
Carsten Dominik <dominik@science.uva.nl>
parents: 27107
diff changeset
5699 (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
5700 (easy-menu-change
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5701 '("IDLWAVE") "Customize"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5702 `(["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
5703 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5704 ,(customize-menu-create 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5705 ["Set" Custom-set t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5706 ["Save" Custom-save t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5707 ["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
5708 ["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
5709 ["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
5710 (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
5711 (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
5712
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5713 (defun idlwave-show-commentary ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5714 "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
5715 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5716 (require 'finder)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5717 (finder-commentary "idlwave.el"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5718
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5719 (defun idlwave-shell-show-commentary ()
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
5720 "Use the finder to view the file documentation from `idlw-shell.el'."
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5721 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5722 (require 'finder)
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
5723 (finder-commentary "idlw-shell.el"))
26956
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5724
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5725 (defun idlwave-info ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5726 "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
5727 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5728 (require 'info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5729 (Info-goto-node "(idlwave)"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5730
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5731 (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
5732 "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
5733 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
5734 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
5735
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5736 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
5737 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
5738 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
5739
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5740 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
5741
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5742 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
5743
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5744 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5745 (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
5746 abbrevs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5747 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
5748 (mapatoms
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5749 (lambda (sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5750 (if (symbol-value sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5751 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5752 (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
5753 rpl (symbol-value sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5754 func (symbol-function sym))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5755 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5756 (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
5757 (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
5758 (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
5759 func "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5760 (setq func "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5761 (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
5762 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5763 (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
5764 (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
5765 (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
5766 table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5767 ;; sort the list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5768 (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
5769 ;; Make the format
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5770 (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
5771 (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
5772 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5773 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5774 (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
5775 (princ "=========================================\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5776 (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
5777 (princ (format fmt "---" "-------" "----")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5778 (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
5779 (princ "================================================\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5780 (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
5781 (princ (format fmt "---" "------" "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5782 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5783 (lambda (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5784 (setq str (car list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5785 rpl (nth 1 list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5786 func (nth 2 list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5787 (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
5788 abbrevs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5789 ;; 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
5790 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5791 (set-buffer "*Help*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5792 (setq truncate-lines t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5793
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5794 (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
5795
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5796 (provide 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5797
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5798 ;;; idlwave.el ends here
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5799
27606
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
5800
0396e9e8d57b (idlwave-template): Respect `idlwave-abbrev-change-case'.
Carsten Dominik <dominik@science.uva.nl>
parents: 27185
diff changeset
5801