annotate lisp/progmodes/idlwave.el @ 26956:67b3331ff24c

Major mode for editing files of the Interactive Data Language
author Carsten Dominik <dominik@science.uva.nl>
date Mon, 20 Dec 1999 11:10:02 +0000
parents
children 7b2b73f13427
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>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
8 ;; Version: 3.11
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
9 ;; Date: $Date: 1999/12/16 10:42:46 $
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)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 ;; (autoload 'idlwave-shell "idlwave-shell" "IDLWAVE Shell" t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 ;; (setq auto-mode-alist (cons '("\\.pro\\'" . idlwave-mode) auto-mode-alist))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55 ;; SOURCE
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 ;; ======
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 ;; The newest version of this file is available from the maintainers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 ;; Webpage.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 ;; http://www.strw.leidenuniv.el/~dominik/Tools/idlwave
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63 ;; DOCUMENTATION
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64 ;; =============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 ;; IDLWAVE is documented online in info format.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67 ;; A printable version of the documentation is available from the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68 ;; maintainers webpage (see under SOURCE)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 ;; ACKNOWLEDGMENTS
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 ;; ===============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 ;; Thanks to the following people for their contributions and comments:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76 ;; Ulrik Dickow <dickow@nbi.dk>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 ;; Eric E. Dors <edors@lanl.gov>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78 ;; Stein Vidar H. Haugan <s.v.h.haugan@astro.uio.no>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79 ;; David Huenemoerder <dph@space.mit.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 ;; Kevin Ivory <Kevin.Ivory@linmpi.mpg.de>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 ;; Xuyong Liu <liu@stsci.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 ;; Simon Marshall <Simon.Marshall@esrin.esa.it>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 ;; Laurent Mugnier <mugnier@onera.fr>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 ;; Lubos Pochman <lubos@rsinc.com>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 ;; Patrick M. Ryan <pat@jaameri.gsfc.nasa.gov>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 ;; Marty Ryba <ryba@ll.mit.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87 ;; Phil Williams <williams@irc.chmcc.org>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88 ;; J.D. Smith <jdsmith@astrosun.tn.cornell.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
89 ;; Phil Sterne <sterne@dublin.llnl.gov>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91 ;; CUSTOMIZATION:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92 ;; =============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 ;; IDLWAVE has customize support - so if you want to learn about the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 ;; variables which control the behavior of the mode, use
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96 ;; `M-x idlwave-customize'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 ;; You can set your own preferred values with Customize, or with Lisp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 ;; code in .emacs. For an example of what to put into .emacs, check
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100 ;; the TexInfo documentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102 ;; KNOWN PROBLEMS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103 ;; ==============
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105 ;; Moving the point backwards in conjunction with abbrev expansion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 ;; does not work as I would like it, but this is a problem with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 ;; emacs abbrev expansion done by the self-insert-command. It ends
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 ;; up inserting the character that expanded the abbrev after moving
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 ;; point backward, e.g., "\cl" expanded with a space becomes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 ;; "LONG( )" with point before the close paren. This is solved by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 ;; using a temporary function in `post-command-hook' - not pretty,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 ;; but it works.<
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 ;; Tabs and spaces are treated equally as whitespace when filling a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 ;; comment paragraph. To accomplish this, tabs are permanently
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 ;; replaced by spaces in the text surrounding the paragraph, which
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 ;; may be an undesirable side-effect. Replacing tabs with spaces is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 ;; limited to comments only and occurs only when a comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 ;; paragraph is filled via `idlwave-fill-paragraph'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 ;; "&" is ignored when parsing statements.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 ;; Avoid muti-statement lines (using "&") on block begin and end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 ;; lines. Multi-statement lines can mess up the formatting, for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 ;; example, multiple end statements on a line: endif & endif.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125 ;; Using "&" outside of block begin/end lines should be okay.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127 ;; It is possible that the parser which decides what to complete has
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128 ;; problems with pointer dereferencing statements. I don't use
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 ;; pointers often enough to find out - please report any problems.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 ;; Completion of keywords for SETPROPERTY and GETPROPERTY assumes that
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 ;; all INIT keywords are allowed in these methods as well. In some
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 ;; cases, there are exceptions to this rule and IDLWAVE will offer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 ;; a few illegal keyword parameters.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 ;; Completion and Routine Info do not know about inheritance. Thus,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 ;; Keywords inherited from superclasses are not displayed and cannot
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 ;; completed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140 ;; When forcing completion of method keywords, the initial
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 ;; query for a method has multiple entries for some methods. Would
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 ;; be too difficult to fix this hardly used problem.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 ;;; Code:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 (eval-when-compile (require 'cl))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 (eval-and-compile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 ;; Kludge to allow `defcustom' for Emacs 19.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 (condition-case () (require 'custom) (error nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 nil ;; We've got what we needed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 ;; We have the old or no custom-library, hack around it!
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155 (defmacro defgroup (&rest args) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 (defmacro defcustom (var value doc &rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 (` (defvar (, var) (, value) (, doc))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 (defgroup idlwave nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160 "Major mode for editing IDL/WAVE CL .pro files"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 :tag "IDLWAVE"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 :link '(url-link :tag "Home Page"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 "http://strw.leidenuniv.nl/~dominik/Tools/idlwave")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 :link '(emacs-commentary-link :tag "Commentary in idlwave-shell.el"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 "idlwave-shell.el")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 :link '(emacs-commentary-link :tag "Commentary in idlwave.el" "idlwave.el")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167 :link '(custom-manual "(idlwave)Top")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 :prefix "idlwave"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 :group 'languages)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 ;;; Variables for indentation behavior ---------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
172
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173 (defgroup idlwave-code-formatting nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174 "Indentation and formatting options for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
176
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 (defcustom idlwave-main-block-indent 0
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 "*Extra indentation for the main block of code.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 That is the block between the FUNCTION/PRO statement and the END
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 statement for that program unit."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
182 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184 (defcustom idlwave-block-indent 4
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 "*Extra indentation applied to block lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 If you change this, you probably also want to change `idlwave-end-offset'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 (defcustom idlwave-end-offset -4
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 "*Extra indentation applied to block END lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 A value equal to negative `idlwave-block-indent' will make END lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 line up with the block BEGIN lines."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 (defcustom idlwave-continuation-indent 2
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 "*Extra indentation applied to continuation lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 This extra offset applies to the first of a set of continuation lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 The following lines receive the same indentation as the first.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 Also, the value of this variable applies to continuation lines inside
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 parenthesis. When the current line contains an open unmatched ([{,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 the next line is indented to that parenthesis plus the value of this variable."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 :type 'integer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 (defcustom idlwave-hanging-indent t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208 "*If set non-nil then comment paragraphs are indented under the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 hanging indent given by `idlwave-hang-indent-regexp' match in the first line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210 of the paragraph."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
214 (defcustom idlwave-hang-indent-regexp "- "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215 "*Regular expression matching the position of the hanging indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 in the first line of a comment paragraph. The size of the indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217 extends to the end of the match for the regular expression."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
221 (defcustom idlwave-use-last-hang-indent nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
222 "*If non-nil then use last match on line for `idlwave-indent-regexp'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 (defcustom idlwave-fill-comment-line-only t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
227 "*If non-nil then auto fill will only operate on comment lines."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231 (defcustom idlwave-auto-fill-split-string t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 "*If non-nil then auto fill will split strings with the IDL `+' operator.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 When the line end falls within a string, string concatenation with the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234 '+' operator will be used to distribute a long string over lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 If nil and a string is split then a terminal beep and warning are issued.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
237 This variable is ignored when `idlwave-fill-comment-line-only' is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 non-nil, since in this case code is not auto-filled."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 (defcustom idlwave-split-line-string t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 "*If non-nil then `idlwave-split-line' will split strings with `+'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244 When the splitting point of a line falls inside a string, split the string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245 using the `+' string concatenation operator. If nil and a string is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246 split then a terminal beep and warning are issued."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
247 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 (defcustom idlwave-no-change-comment ";;;"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251 "*The indentation of a comment that starts with this regular
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 expression will not be changed. Note that the indentation of a comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 at the beginning of a line is never changed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 (defcustom idlwave-begin-line-comment nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258 "*A comment anchored at the beginning of line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 A comment matching this regular expression will not have its
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 indentation changed. If nil the default is \"^;\", i.e., any line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 beginning with a \";\". Expressions for comments at the beginning of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 the line should begin with \"^\"."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264 :type '(choice (const :tag "Any line beginning with `;'" nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
265 'regexp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
266
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
267 (defcustom idlwave-code-comment ";;[^;]"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268 "*A comment that starts with this regular expression on a line by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269 itself is indented as if it is a part of IDL code. As a result if
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 the comment is not preceded by whitespace it is unchanged."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271 :group 'idlwave-code-formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 ;; Comments not matching any of the above will be indented as a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275 ;; right-margin comment, i.e., to a minimum of `comment-column'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278 ;;; Routine Info and Completion ---------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 (defgroup idlwave-routine-info-and-completion nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 "Routine info and name/keyword completion options for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 (defcustom idlwave-scan-all-buffers-for-routine-info t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 "*Non-nil means, scan all buffers for IDL programs when updating info.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
286 `idlwave-update-routine-info' scans buffers of the current Emacs session
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287 for routine definitions. When this variable is nil, it only parses the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288 current buffer. When non-nil, all buffers are searched.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 A prefix to \\[idlwave-update-routine-info] toggles the meaning of this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290 variable for the duration of the command."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 (defcustom idlwave-query-shell-for-routine-info t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 "*Non-nil means query the shell for info about compiled routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 Querying the shell is useful to get information about compiled modules,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 and it is turned on by default. However, when you have a complete library
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298 scan, this is not necessary."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
299 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
300 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302 (defcustom idlwave-library-path nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303 "Library path for Windows and MacOS. Not needed under Unix.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
304 When selecting the directories to scan for IDL library routine info,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
305 IDLWAVE can under UNIX query the shell for the exact search path.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306 However, under Windows and MacOS, the IDLWAVE shell does not work. In this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 case, this variable specifies the path where IDLWAVE can find library files.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308 The shell will only be asked when this variable is nil.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309 The value is a list of directories. A directory preceeded by a `+' will
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
310 be search recursively."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
311 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312 :type '(repeat (directory)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
313
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
314 (defcustom idlwave-libinfo-file nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315 "*File for routine information of the IDL library.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
316 When this points to a file, the file will be loaded when IDLWAVE first
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
317 accesses routine info (or does completion).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
318 When you scan the library with `idlwave-create-libinfo-file', this file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
319 will be used to store the result."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
320 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
321 :type 'file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
322
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
323 (eval-and-compile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
324 (defconst idlwave-tmp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
325 '(choice :tag "by applying the function"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
326 (const upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
327 (const downcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
328 (const capitalize)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
329 (const preserve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
330 (symbol :tag "Other"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
331
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
332
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
333 (defcustom idlwave-completion-case '((routine . upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
334 (keyword . upcase)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
335 (class . preserve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
336 (method . preserve))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
337 "Association list setting the case of completed words.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
339 This variable determines the case (UPPER/lower/Capitalized...) of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
340 words inserted into the buffer by completion. The preferred case can
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
341 be specified separately for routine names, keywords, classes and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
342 methods.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
343 This alist should therefore have entries for `routine' (normal
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
344 functions and procedures, i.e. non-methods), `keyword', `class', and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
345 `method'. Plausible values are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
346
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
347 upcase upcase whole word, like `BOX_CURSOR'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
348 downcase downcase whole word, like `read_ppm'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
349 capitalize capitalize each part, like `Widget_Control'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
350 preserve preserve case as is, like `IDLgrView'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
351
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
352 The value can also be any Emacs Lisp function which transforms the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
353 case of characters in a string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
354
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
355 A value of `preserve' means that the case of the completed word is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
356 identical to the way it was written in the definition statement of the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
357 routine. This was implemented to allow for mixed-case completion, in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
358 particular of object classes and methods.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
359 If a completable word is defined in multiple locations, the meaning of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
360 `preserve' is not unique since the different definitions might be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
361 cased differently. Therefore IDLWAVE always takes the case of the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
362 *first* definition it encounters during routine info collection and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
363 uses the case derived from it consistently.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
364
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
365 Note that a lowercase-only string in the buffer will always be completed in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
366 lower case (but see the variable `idlwave-completion-force-default-case').
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
367
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
368 After changing this variable, you need to either restart Emacs or press
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
369 `C-u C-c C-i' to update the internal lists."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
370 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
371 :type `(repeat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
372 (cons (symbol :tag "Derive completion case for")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
373 ,idlwave-tmp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
374
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
375 (defcustom idlwave-completion-force-default-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
376 "*Non-nil means, completion will always honor `idlwave-completion-case'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
377 When nil, only the completion of a mixed case or upper case string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
378 will honor the default settings in `idlwave-completion-case', while
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
379 the completion of lower case strings will be completed entirely in
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
380 lower case."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
381 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
382 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
383
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
384 (defcustom idlwave-complete-empty-string-as-lower-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
385 "*Non-nil means, the empty string is considered downcase for completion.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
386 The case of what is already in the buffer determines the case of completions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
387 When this variable is non-nil, the empty string is considered to be downcase.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
388 Completing on the empty string then offers downcase versions of the possible
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
389 completions."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
390 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
391 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
392
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
393 (defvar idlwave-default-completion-case-is-down nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
394 "Obsolete variable. See `idlwave-complete-empty-string-as-lower-case' and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
395 `idlwave-completion-case'.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
396
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
397 (defcustom idlwave-buffer-case-takes-precedence nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
398 "*Non-nil means, the case of tokens in buffers dominates over system stuff.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
399 To make this possible, we need to re-case everything each time we update
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
400 the routine info from the buffers. This is slow.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
401 The default is to consider the case given in the system and library files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
402 first which makes updating much faster."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
403 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
404 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
405
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
406 (defcustom idlwave-completion-show-classes 1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
407 "*Number of classes to show when completing object methods and keywords.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
408 When completing methods or keywords for an object with unknown class,
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
409 the *Completions* buffer will show the legal classes for each completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
410 like this:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
411
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
412 MyMethod <Class1,Class2,Class3>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
413
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
414 The value of this variable may be nil to inhibit display, or an integer to
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
415 indicate the maximum number of classes to display.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
416
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
417 On XEmacs, a full list of classes will also be placed into a `help-echo'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
418 property on the competion items, so that the list of classes for the current
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
419 item is displayed in the echo area. If the value of this variable is a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
420 negative integer, the `help-echo' property will be suppressed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
421 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
422 :type '(choice (const :tag "Don't show" nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
423 (integer :tag "Number of classes shown" 1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
424
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
425 (defcustom idlwave-completion-fontify-classes t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
426 "*Non-nil means, fontify the classes in completions buffer.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
427 This makes it easier to distinguish the completion items from the extra
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
428 class info listed. See `idlwave-completion-show-classes'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
429 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
430 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
431
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
432 (defcustom idlwave-query-class '((method-default . nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
433 (keyword-default . nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
434 "Association list governing specification of object classes for completion.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
435
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
436 When IDLWAVE is trying to complete items which belong to the object
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
437 oriented part of IDL, it usually cannot determine the class of a given
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
438 object from context. In order to provide the user with a correct list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
439 of methods or keywords, it would have to determine the appropriate
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
440 class. IDLWAVE has two ways to deal with this problem.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
441
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
442 1. One possibility is to combine the items of all available
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
443 classes for the purpose of completion. So when completing a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
444 method, all methods of all classes are available, and when
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
445 completing a keyword, all keywords allowed for this method in any
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
446 class will be possible completions. This behavior is very much
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
447 like normal completion and is therefore the default. It works much
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
448 better than one might think - only for the INIT, GETPROPERTY and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
449 SETPROPERTY the keyword lists become uncomfortably long.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
450 See also `idlwave-completion-show-classes'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
451
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
452 2. The second possibility is to ask the user on each occasion. To
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
453 make this less interruptive, IDLWAVE can store the class as a text
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
454 property on the object operator `->'. For a given object in the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
455 source code, class selection will then be needed only once
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
456 - for example to complete the method. Keywords to the method can
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
457 then be completed directly, because the class is already known.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
458 You will have to turn on the storage of the selected class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
459 explicitly with the variable `idlwave-store-inquired-class'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
460
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
461 This variable allows to configure IDLWAVE's behavior during
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
462 completion. Its value is an alist, which should contain at least two
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
463 elements: (method-default . VALUE) and (keyword-default . VALUE),
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
464 where VALUE is either t or nil. These specify if the class should be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
465 determined during method and keyword completion, respectively.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
466
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
467 The alist may have additional entries specifying exceptions from the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
468 keyword completion rule for specific methods, like INIT or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
469 GETPROPERTY. In order to turn on class specification for the INIT
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
470 method, add an entry (\"INIT\" . t). The method name must be ALL-CAPS."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
471 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
472 :type '(list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
473 (cons (const method-default)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
474 (boolean :tag "Determine class when completing METHODS "))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
475 (cons (const keyword-default)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
476 (boolean :tag "Determine class when completing KEYWORDS "))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
477 (repeat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
478 :tag "Exceptions to defaults"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
479 :inline t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
480 (cons (string :tag "MODULE" :value "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
481 (boolean :tag "Determine class for this method")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
482
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
483 (defcustom idlwave-store-inquired-class nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
484 "*Non-nil means, store class of a method call as text property on `->'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
485 IDLWAVE sometimes has to ask the user for the class associated with a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
486 particular object method call. This happens during the commands
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
487 `idlwave-routine-info' and `idlwave-complete', depending upon the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
488 value of the variable `idlwave-query-class'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
489
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
490 When you specify a class, this information can be stored as a text
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
491 property on the `->' arrow in the source code, so that during the same
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
492 editing session, IDLWAVE will not have to ask again. When this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
493 variable is non-nil, IDLWAVE will store and reuse the class information.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
494 The class stored can be checked and removed with `\\[idlwave-routine-info]'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
495 on the arrow.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
496
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
497 The default of this variable is nil, since the result of commands then
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
498 is more predictable. However, if you know what you are doing, it can
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
499 be nice to turn this on.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
500
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
501 An arrow which knows the class will be highlighted with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
502 `idlwave-class-arrow-face'. The command \\[idlwave-routine-info]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
503 displays (with prefix arg: deletes) the class stored on the arrow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
504 at point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
505 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
506 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
507
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
508 (defcustom idlwave-class-arrow-face 'bold
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
509 "*Face to highlight object operator arrows `->' which carry a class property.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
510 When IDLWAVE stores a class name as text property on an object arrow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
511 (see variable `idlwave-store-inquired-class', it highlights the arrow
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
512 with this font in order to remind the user that this arrow is special."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
513 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
514 :type 'symbol)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
515
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
516 (defcustom idlwave-resize-routine-help-window t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
517 "*Non-nil means, resize the Routine-info *Help* window to fit the content."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
518 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
519 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
520
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
521 (defcustom idlwave-keyword-completion-adds-equal t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
522 "*Non-nil means, completion automatically adds `=' after completed keywords."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
523 :group 'idlwave-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
524 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
525
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
526 (defcustom idlwave-function-completion-adds-paren t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
527 "*Non-nil means, completion automatically adds `(' after completed function.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
528 Nil means, don't add anything.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
529 A value of `2' means, also add the closing parenthesis and position cursor
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
530 between the two."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
531 :group 'idlwave-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
532 :type '(choice (const :tag "Nothing" nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
533 (const :tag "(" t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
534 (const :tag "()" 2)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
535
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
536 (defcustom idlwave-completion-restore-window-configuration t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
537 "*Non-nil means, try to restore the window configuration after completion.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
538 When completion is not unique, Emacs displays a list of completions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
539 This messes up your window configuration. With this variable set, IDLWAVE
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
540 restores the old configuration after successful completion."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
541 :group 'idlwave-routine-info-and-completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
542 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
543
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
544 ;;; Variables for abbrev and action behavior -----------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
545
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
546 (defgroup idlwave-abbrev-and-indent-action nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
547 "IDLWAVE performs actions when expanding abbreviations or indenting lines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
548 The variables in this group govern this."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
549 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
550
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
551 (defcustom idlwave-do-actions nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
552 "*Non-nil means performs actions when indenting.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
553 The actions that can be performed are listed in `idlwave-indent-action-table'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
554 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
555 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
556
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
557 (defcustom idlwave-abbrev-start-char "\\"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
558 "*A single character string used to start abbreviations in abbrev mode.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
559 Possible characters to chose from: ~`\%
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
560 or even '?'. '.' is not a good choice because it can make structure
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
561 field names act like abbrevs in certain circumstances.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
562
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
563 Changes to this in `idlwave-mode-hook' will have no effect. Instead a user
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
564 must set it directly using `setq' in the .emacs file before idlwave.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
565 is loaded."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
566 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
567 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
568
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
569 (defcustom idlwave-surround-by-blank nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
570 "*Non-nil means, enable `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
571 If non-nil, `=',`<',`>',`&',`,' are surrounded with spaces by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
572 `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
573 See help for `idlwave-indent-action-table' for symbols using `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
574
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
575 Also see the default key bindings for keys using `idlwave-surround'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
576 Keys are bound and made into actions calling `idlwave-surround' with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
577 `idlwave-action-and-binding'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
578 See help for `idlwave-action-and-binding' for examples.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
579
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
580 Also see help for `idlwave-surround'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
581 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
582 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
583
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
584 (defcustom idlwave-pad-keyword t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
585 "*Non-nil means pad '=' for keywords like assignments.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
586 Whenever `idlwave-surround' is non-nil then this affects how '=' is padded
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
587 for keywords. If non-nil it is padded the same as for assignments.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
588 If nil then spaces are removed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
589 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
590 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
591
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
592 (defcustom idlwave-show-block t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
593 "*Non-nil means point blinks to block beginning for `idlwave-show-begin'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
594 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
595 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
596
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
597 (defcustom idlwave-expand-generic-end nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
598 "*Non-nil means expand generic END to ENDIF/ENDELSE/ENDWHILE etc."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
599 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
600 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
601
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
602 (defcustom idlwave-abbrev-move t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
603 "*Non-nil means the abbrev hook can move point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
604 Set to nil by `idlwave-expand-region-abbrevs'. To see the abbrev
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
605 definitions, use the command `list-abbrevs', for abbrevs that move
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
606 point. Moving point is useful, for example, to place point between
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
607 parentheses of expanded functions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
608
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
609 See `idlwave-check-abbrev'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
610 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
611 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
612
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
613 (defcustom idlwave-abbrev-change-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
614 "*Non-nil means all abbrevs will be forced to either upper or lower case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
615 If the value t, all expanded abbrevs will be upper case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
616 If the value is 'down then abbrevs will be forced to lower case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
617 If nil, the case will not change.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
618 If `idlwave-reserved-word-upcase' is non-nil, reserved words will always be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
619 upper case, regardless of this variable."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
620 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
621 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
622
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
623 (defcustom idlwave-reserved-word-upcase nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
624 "*Non-nil means, reserved words will be made upper case via abbrev expansion.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
625 If nil case of reserved words is controlled by `idlwave-abbrev-change-case'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
626 Has effect only if in abbrev-mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
627 :group 'idlwave-abbrev-and-indent-action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
628 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
629
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
630 ;;; Action/Expand Tables.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
631 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
632 ;; The average user may have difficulty modifying this directly. It
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
633 ;; can be modified/set in idlwave-mode-hook, but it is easier to use
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
634 ;; idlwave-action-and-binding. See help for idlwave-action-and-binding for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
635 ;; examples of how to add an action.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
636 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
637 ;; The action table is used by `idlwave-indent-line' whereas both the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
638 ;; action and expand tables are used by `idlwave-indent-and-action'. In
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
639 ;; general, the expand table is only used when a line is explicitly
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
640 ;; indented. Whereas, in addition to being used when the expand table
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
641 ;; is used, the action table is used when a line is indirectly
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
642 ;; indented via line splitting, auto-filling or a new line creation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
643 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
644 ;; Example actions:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
645 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
646 ;; Capitalize system vars
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
647 ;; (idlwave-action-and-binding idlwave-sysvar '(capitalize-word 1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
648 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
649 ;; Capitalize procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
650 ;; (idlwave-action-and-binding "\\<\\(pro\\|function\\)\\>[ \t]*\\<"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
651 ;; '(capitalize-word 1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
652 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
653 ;; Capitalize common block name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
654 ;; (idlwave-action-and-binding "\\<common\\>[ \t]+\\<"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
655 ;; '(capitalize-word 1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
656 ;; Capitalize label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
657 ;; (idlwave-action-and-binding (concat "^[ \t]*" idlwave-label)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
658 ;; '(capitalize-word -1) t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
659
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
660 (defvar idlwave-indent-action-table nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
661 "*Associated array containing action lists of search string (car),
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
662 and function as a cdr. This table is used by `idlwave-indent-line'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
663 See documentation for `idlwave-do-action' for a complete description of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
664 the action lists.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
665
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
666 Additions to the table are made with `idlwave-action-and-binding' when a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
667 binding is not requested.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
668 See help on `idlwave-action-and-binding' for examples.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
669
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
670 (defvar idlwave-indent-expand-table nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
671 "*Associated array containing action lists of search string (car),
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
672 and function as a cdr. The table is used by the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
673 `idlwave-indent-and-action' function. See documentation for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
674 `idlwave-do-action' for a complete description of the action lists.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
675
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
676 Additions to the table are made with `idlwave-action-and-binding' when a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
677 binding is requested.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
678 See help on `idlwave-action-and-binding' for examples.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
679
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
680 ;;; Documentation header and history keyword ---------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
681
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
682 (defgroup idlwave-documentation nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
683 "Options for documenting IDLWAVE files."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
684 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
685
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
686 ;; FIXME: make defcustom?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
687 (defvar idlwave-file-header
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
688 (list nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
689 ";+
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
690 ; NAME:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
691 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
692 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
693 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
694 ; PURPOSE:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
695 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
696 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
697 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
698 ; CATEGORY:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
699 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
700 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
701 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
702 ; CALLING SEQUENCE:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
703 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
704 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
705 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
706 ; INPUTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
707 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
708 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
709 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
710 ; OPTIONAL INPUTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
711 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
712 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
713 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
714 ; KEYWORD PARAMETERS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
715 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
716 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
717 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
718 ; OUTPUTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
719 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
720 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
721 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
722 ; OPTIONAL OUTPUTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
723 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
724 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
725 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
726 ; COMMON BLOCKS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
727 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
728 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
729 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
730 ; SIDE EFFECTS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
731 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
732 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
733 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
734 ; RESTRICTIONS:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
735 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
736 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
737 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
738 ; PROCEDURE:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
739 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
740 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
741 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
742 ; EXAMPLE:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
743 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
744 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
745 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
746 ; MODIFICATION HISTORY:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
747 ;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
748 ;-
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
749 ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
750 "*A list (PATHNAME STRING) specifying the doc-header template to use for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
751 summarizing a file. If PATHNAME is non-nil then this file will be included.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
752 Otherwise STRING is used. If NIL, the file summary will be omitted.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
753 For example you might set PATHNAME to the path for the
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
754 lib_template.pro file included in the IDL distribution.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
755
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
756 (defcustom idlwave-timestamp-hook 'idlwave-default-insert-timestamp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
757 "*The hook function used to update the timestamp of a function."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
758 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
759 :type 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
760
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
761 (defcustom idlwave-doc-modifications-keyword "HISTORY"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
762 "*The modifications keyword to use with the log documentation commands.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
763 A ':' is added to the keyword end.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
764 Inserted by doc-header and used to position logs by doc-modification.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
765 If nil it will not be inserted."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
766 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
767 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
768
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
769 (defcustom idlwave-doclib-start "^;+\\+"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
770 "*Regexp matching the start of a document library header."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
771 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
772 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
773
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
774 (defcustom idlwave-doclib-end "^;+-"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
775 "*Regexp matching the end of a document library header."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
776 :group 'idlwave-documentation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
777 :type 'regexp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
778
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
779 ;;; External Programs -------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
780
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
781 (defgroup idlwave-external-programs nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
782 "Miscellaneous options for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
783 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
784
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
785 ;; WARNING: The following variable has recently been moved from
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
786 ;; idlwave-shell.el to this file. I hope this does not break
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
787 ;; anything.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
788
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
789 (defcustom idlwave-shell-explicit-file-name "idl"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
790 "*If non-nil, is the command to run IDL.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
791 Should be an absolute file path or path relative to the current environment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
792 execution search path."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
793 :group 'idlwave-external-programs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
794 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
795
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
796 ;; FIXME: Document a case when is this needed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
797 (defcustom idlwave-shell-command-line-options nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
798 "*A list of command line options for calling the IDL program."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
799 :type '(repeat (string :value ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
800 :group 'idlwave-external-programs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
801
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
802 (defcustom idlwave-help-application "idlhelp"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
803 "*The external application providing reference help for programming."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
804 :group 'idlwave-external-programs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
805 :type 'string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
806
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
807 ;;; Miscellaneous variables -------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
808
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
809 (defgroup idlwave-misc nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
810 "Miscellaneous options for IDLWAVE mode."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
811 :group 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
812
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
813 (defcustom idlwave-startup-message t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
814 "*Non-nil displays a startup message when `idlwave-mode' is first called."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
815 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
816 :type 'boolean)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
817
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
818 (defcustom idlwave-default-font-lock-items
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
819 '(pros-and-functions batch-files idl-keywords label goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
820 common-blocks class-arrows)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
821 "Items which should be fontified on the default fontification level 2.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
822 IDLWAVE defines 3 levels of fontification. Level 1 is very little, level 3
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
823 is everything and level 2 is specified by this list.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
824 This variable must be set before IDLWAVE gets loaded. It is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
825 a list of symbols, the following symbols are allowed.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
826
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
827 pros-and-functions Procedure and Function definitions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
828 batch-files Batch Files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
829 idl-keywords IDL Keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
830 label Statement Labels
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
831 goto Goto Statements
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
832 common-blocks Common Blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
833 keyword-parameters Keyword Parameters in routine definitions and calls
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
834 system-variables System Variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
835 fixme FIXME: Warning in comments (on XEmacs only v. 21.0 and up)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
836 class-arrows Object Arrows with class property"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
837 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
838 :type '(set
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
839 :inline t :greedy t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
840 (const :tag "Procedure and Function definitions" pros-and-functions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
841 (const :tag "Batch Files" batch-files)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
842 (const :tag "IDL Keywords (reserved words)" idl-keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
843 (const :tag "Statement Labels" label)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
844 (const :tag "Goto Statements" goto)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
845 (const :tag "Common Blocks" common-blocks)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
846 (const :tag "Keyword Parameters" keyword-parameters)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
847 (const :tag "System Variables" system-variables)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
848 (const :tag "FIXME: Warning" fixme)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
849 (const :tag "Object Arrows with class property " class-arrows)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
850
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
851 (defcustom idlwave-mode-hook nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
852 "Normal hook. Executed when a buffer is put into `idlwave-mode'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
853 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
854 :type 'hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
855
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
856 (defcustom idlwave-load-hook nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
857 "Normal hook. Executed when idlwave.el is loaded."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
858 :group 'idlwave-misc
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
859 :type 'hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
860
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
861 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
862 ;;; End customization variables section
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
863 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
864
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
865 ;;; Non customization variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
866
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
867 ;;; font-lock mode - Additions by Phil Williams, Ulrik Dickow and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
868 ;;; Simon Marshall <simon@gnu.ai.mit.edu>
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
869 ;;; and Carsten Dominik...
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
870
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
871 (defconst idlwave-font-lock-keywords-1 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
872 "Subdued level highlighting for IDLWAVE mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
873
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
874 (defconst idlwave-font-lock-keywords-2 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
875 "Medium level highlighting for IDLWAVE mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
876
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
877 (defconst idlwave-font-lock-keywords-3 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
878 "Gaudy level highlighting for IDLWAVE mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
879
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
880 (let* ((oldp (or (string-match "Lucid" emacs-version)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
881 (not (boundp 'emacs-minor-version))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
882 (and (<= emacs-major-version 19)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
883 (<= emacs-minor-version 29))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
884
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
885 ;; The following are the reserved words in IDL. Maybe we should
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
886 ;; highlight some more stuff as well?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
887 (idl-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
888 ; '("and" "or" "xor" "not"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
889 ; "eq" "ge" "gt" "le" "lt" "ne"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
890 ; "for" "do" "endfor"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
891 ; "if" "then" "endif" "else" "endelse"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
892 ; "case" "of" "endcase"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
893 ; "begin" "end"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
894 ; "repeat" "until" "endrep"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
895 ; "while" "endwhile"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
896 ; "goto" "return"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
897 ; "inherits" "mod" "on_error" "on_ioerror") ;; on_error is not reserved
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
898 (concat "\\<\\("
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
899 "and\\|begin\\|case\\|do\\|e\\(lse\\|nd\\(case\\|else\\|"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
900 "for\\|if\\|rep\\|while\\)?\\|q\\)\\|for\\|g\\(oto\\|[et]\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
901 "\\|i\\(f\\|nherits\\)\\|l[et]\\|mod\\|n\\(e\\|ot\\)\\|"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
902 "o\\(n_ioerror\\|[fr]\\)\\|re\\(peat\\|turn\\)\\|then\\|"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
903 "until\\|while\\|xor"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
904 "\\)\\>"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
905
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
906 ;; Procedure declarations. Fontify keyword plus procedure name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
907 ;; Function declarations. Fontify keyword plus function name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
908 (pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
909 '("\\<\\(function\\|pro\\)\\>[ \t]+\\(\\sw+\\(::\\sw+\\)?\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
910 (1 font-lock-keyword-face)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
911 (2 font-lock-function-name-face nil t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
912
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
913 ;; Common blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
914 (common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
915 '("\\<\\(common\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*,?"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
916 (1 font-lock-keyword-face) ; "common"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
917 (2 font-lock-reference-face nil t) ; block name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
918 (font-lock-match-c++-style-declaration-item-and-skip-to-next
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
919 ;; Start with point after block name and comma
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
920 (goto-char (match-end 0)) ; needed for XEmacs, could be nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
921 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
922 (1 font-lock-variable-name-face) ; variable names
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
923 )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
924
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
925 ;; Batch files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
926 (batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
927 '("^[ \t]*\\(@[^ \t\n]+\\)" (1 font-lock-string-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
928
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
929 ;; FIXME warning.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
930 (fixme
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
931 '("\\<FIXME:" (0 font-lock-warning-face t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
932
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
933 ;; Labels
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
934 (label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
935 '("^[ \t]*\\([a-zA-Z]\\sw*:\\)" (1 font-lock-reference-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
936
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
937 ;; The goto statement and its label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
938 (goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
939 '("\\(goto\\)[ \t]*,[ \t]*\\([a-zA-Z]\\sw*\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
940 (1 font-lock-keyword-face)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
941 (2 font-lock-reference-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
942
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
943 ;; Named parameters, like /xlog or ,xrange=[]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
944 ;; This is anchored to the comma preceeding the keyword.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
945 ;; With continuation lines, works only during whole buffer fontification.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
946 (keyword-parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
947 '("[(,][ \t]*\\(\\$[ \t]*\n[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
948 (2 font-lock-reference-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
949
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
950 ;; System variables stars with a bang.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
951 (system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
952 '("\\(![a-zA-Z_]+\\(\\.\\sw+\\)?\\)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
953 (1 font-lock-variable-name-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
954
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
955 ;; Special and unusual operators (not used because too noisy)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
956 (special-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
957 '("[<>#]" (0 font-lock-keyword-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
958
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
959 ;; All operators (not used because too noisy)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
960 (all-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
961 '("[-*^#+<>/]" (0 font-lock-keyword-face)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
962
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
963 ;; Arrows with text property `idlwave-class'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
964 (class-arrows
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
965 (list 'idlwave-match-class-arrows
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
966 (list 0 (if (featurep 'xemacs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
967 idlwave-class-arrow-face
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
968 'idlwave-class-arrow-face))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
969
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
970 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
971
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
972 ;; The following lines are just a dummy to make the compiler shut up
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
973 ;; about variables bound but not used.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
974 (setq oldp oldp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
975 idl-keywords idl-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
976 pros-and-functions pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
977 common-blocks common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
978 batch-files batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
979 fixme fixme
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
980 label label
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
981 goto goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
982 keyword-parameters keyword-parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
983 system-variables system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
984 special-operators special-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
985 all-operators all-operators
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
986 class-arrows class-arrows)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
987
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
988 (setq idlwave-font-lock-keywords-1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
989 (list pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
990 batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
991 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
992
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
993 (setq idlwave-font-lock-keywords-2
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
994 (mapcar 'symbol-value idlwave-default-font-lock-items))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
995
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
996 (setq idlwave-font-lock-keywords-3
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
997 (list pros-and-functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
998 batch-files
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
999 idl-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1000 label goto
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1001 common-blocks
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1002 keyword-parameters
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1003 system-variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1004 class-arrows
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1005 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1006 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1007
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1008 (defun idlwave-match-class-arrows (limit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1009 ;; Match an object arrow with class property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1010 (and idlwave-store-inquired-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1011 (re-search-forward "->" limit 'limit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1012 (get-text-property (match-beginning 0) 'idlwave-class)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1013
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1014 (defvar idlwave-font-lock-keywords idlwave-font-lock-keywords-2
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1015 "Default expressions to highlight in IDLWAVE mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1016
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1017 (defvar idlwave-font-lock-defaults
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1018 '((idlwave-font-lock-keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1019 idlwave-font-lock-keywords-1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1020 idlwave-font-lock-keywords-2
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1021 idlwave-font-lock-keywords-3)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1022 nil t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1023 ((?$ . "w") (?_ . "w") (?. . "w"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1024 beginning-of-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1025
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1026 (put 'idlwave-mode 'font-lock-defaults
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1027 idlwave-font-lock-defaults) ; XEmacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1028
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1029 (defconst idlwave-comment-line-start-skip "^[ \t]*;"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1030 "Regexp to match the start of a full-line comment.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1031 That is the _beginning_ of a line containing a comment delimiter `;' preceded
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1032 only by whitespace.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1033
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1034 (defconst idlwave-begin-block-reg "\\<\\(pro\\|function\\|begin\\|case\\)\\>"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1035 "Regular expression to find the beginning of a block. The case does
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1036 not matter. The search skips matches in comments.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1037
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1038 (defconst idlwave-begin-unit-reg "\\<\\(pro\\|function\\)\\>\\|\\`"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1039 "Regular expression to find the beginning of a unit. The case does
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1040 not matter.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1041
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1042 (defconst idlwave-end-unit-reg "\\<\\(pro\\|function\\)\\>\\|\\'"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1043 "Regular expression to find the line that indicates the end of unit.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1044 This line is the end of buffer or the start of another unit. The case does
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1045 not matter. The search skips matches in comments.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1046
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1047 (defconst idlwave-continue-line-reg "\\<\\$"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1048 "Regular expression to match a continued line.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1049
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1050 (defconst idlwave-end-block-reg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1051 "\\<end\\(\\|case\\|else\\|for\\|if\\|rep\\|while\\)\\>"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1052 "Regular expression to find the end of a block. The case does
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1053 not matter. The search skips matches found in comments.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1054
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1055 (defconst idlwave-block-matches
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1056 '(("pro" . "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1057 ("function" . "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1058 ("case" . "endcase")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1059 ("else" . "endelse")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1060 ("for" . "endfor")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1061 ("then" . "endif")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1062 ("repeat" . "endrep")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1063 ("while" . "endwhile"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1064 "Matches between statements and the corresponding END variant.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1065 The cars are the reserved words starting a block. If the block really
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1066 begins with BEGIN, the cars are the reserved words before the begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1067 which can be used to identify the block type.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1068 This is used to check for the correct END type, to close blocks and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1069 to expand generic end statements to their detailed form.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1070
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1071 (defconst idlwave-block-match-regexp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1072 "\\<\\(else\\|for\\|then\\|repeat\\|while\\)\\>"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1073 "Regular expression matching reserved words which can stand before
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1074 blocks starting with a BEGIN statement. The matches must have associations
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1075 `idlwave-block-matches'")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1076
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1077 (defconst idlwave-identifier "[a-zA-Z][a-zA-Z0-9$_]*"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1078 "Regular expression matching an IDL identifier.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1079
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1080 (defconst idlwave-sysvar (concat "!" idlwave-identifier)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1081 "Regular expression matching IDL system variables.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1082
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1083 (defconst idlwave-variable (concat idlwave-identifier "\\|" idlwave-sysvar)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1084 "Regular expression matching IDL variable names.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1085
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1086 (defconst idlwave-label (concat idlwave-identifier ":")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1087 "Regular expression matching IDL labels.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1088
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1089 (defconst idlwave-statement-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1090 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1091 ;; "endif else" is the the only possible "end" that can be
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1092 ;; followed by a statement on the same line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1093 '(endelse . ("end\\(\\|if\\)\\s +else" "end\\(\\|if\\)\\s +else"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1094 ;; all other "end"s can not be followed by a statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1095 (cons 'end (list idlwave-end-block-reg nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1096 '(if . ("if\\>" "then"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1097 '(for . ("for\\>" "do"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1098 '(begin . ("begin\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1099 '(pdef . ("pro\\>\\|function\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1100 '(while . ("while\\>" "do"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1101 '(repeat . ("repeat\\>" "repeat"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1102 '(goto . ("goto\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1103 '(case . ("case\\>" nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1104 (cons 'call (list (concat idlwave-identifier "\\(\\s *$\\|\\s *,\\)") nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1105 '(assign . ("[^=\n]*=" nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1106
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1107 "Associated list of statement matching regular expressions.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1108 Each regular expression matches the start of an IDL statement. The
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1109 first element of each association is a symbol giving the statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1110 type. The associated value is a list. The first element of this list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1111 is a regular expression matching the start of an IDL statement for
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1112 identifying the statement type. The second element of this list is a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1113 regular expression for finding a substatement for the type. The
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1114 substatement starts after the end of the found match modulo
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1115 whitespace. If it is nil then the statement has no substatement. The
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1116 list order matters since matching an assignment statement exactly is
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1117 not possible without parsing. Thus assignment statement become just
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1118 the leftover unidentified statements containing and equal sign. " )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1119
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1120 (defvar idlwave-fill-function 'auto-fill-function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1121 "IDL mode auto fill function.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1122
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1123 (defvar idlwave-comment-indent-function 'comment-indent-function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1124 "IDL mode comment indent function.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1125
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1126 ;; Note that this is documented in the v18 manuals as being a string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1127 ;; of length one rather than a single character.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1128 ;; The code in this file accepts either format for compatibility.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1129 (defvar idlwave-comment-indent-char ?\
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1130 "Character to be inserted for IDL comment indentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1131 Normally a space.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1132
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1133 (defconst idlwave-continuation-char ?$
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1134 "Character which is inserted as a last character on previous line by
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1135 \\[idlwave-split-line] to begin a continuation line. Normally $.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1136
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1137 (defconst idlwave-mode-version " 3.11")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1138
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1139 (defmacro idlwave-keyword-abbrev (&rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1140 "Creates a function for abbrev hooks to call `idlwave-check-abbrev' with args."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1141 (` (quote (lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1142 (, (append '(idlwave-check-abbrev) args))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1143
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1144 ;; If I take the time I can replace idlwave-keyword-abbrev with
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1145 ;; idlwave-code-abbrev and remove the quoted abbrev check from
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1146 ;; idlwave-check-abbrev. Then, e.g, (idlwave-keyword-abbrev 0 t) becomes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1147 ;; (idlwave-code-abbrev idlwave-check-abbrev 0 t). In fact I should change
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1148 ;; the name of idlwave-check-abbrev to something like idlwave-modify-abbrev.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1149
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1150 (defmacro idlwave-code-abbrev (&rest args)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1151 "Creates a function for abbrev hooks that ensures abbrevs are not quoted.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1152 Specifically, if the abbrev is in a comment or string it is unexpanded.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1153 Otherwise ARGS forms a list that is evaluated."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1154 (` (quote (lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1155 (, (prin1-to-string args)) ;; Puts the code in the doc string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1156 (if (idlwave-quoted) (progn (unexpand-abbrev) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1157 (, (append args)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1158
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1159 (defvar idlwave-mode-map (make-sparse-keymap)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1160 "Keymap used in IDL mode.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1161
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1162 (defvar idlwave-mode-syntax-table (make-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1163 "Syntax table in use in `idlwave-mode' buffers.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1164
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1165 (modify-syntax-entry ?+ "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1166 (modify-syntax-entry ?- "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1167 (modify-syntax-entry ?* "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1168 (modify-syntax-entry ?/ "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1169 (modify-syntax-entry ?^ "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1170 (modify-syntax-entry ?# "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1171 (modify-syntax-entry ?= "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1172 (modify-syntax-entry ?% "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1173 (modify-syntax-entry ?< "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1174 (modify-syntax-entry ?> "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1175 (modify-syntax-entry ?\' "\"" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1176 (modify-syntax-entry ?\" "\"" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1177 (modify-syntax-entry ?\\ "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1178 (modify-syntax-entry ?_ "_" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1179 (modify-syntax-entry ?{ "(}" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1180 (modify-syntax-entry ?} "){" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1181 (modify-syntax-entry ?$ "_" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1182 (modify-syntax-entry ?. "." idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1183 (modify-syntax-entry ?\; "<" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1184 (modify-syntax-entry ?\n ">" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1185 (modify-syntax-entry ?\f ">" idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1186
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1187 (defvar idlwave-find-symbol-syntax-table
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1188 (copy-syntax-table idlwave-mode-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1189 "Syntax table that treats symbol characters as word characters.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1190
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1191 (modify-syntax-entry ?$ "w" idlwave-find-symbol-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1192 (modify-syntax-entry ?_ "w" idlwave-find-symbol-syntax-table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1193
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1194 (defun idlwave-action-and-binding (key cmd &optional select)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1195 "KEY and CMD are made into a key binding and an indent action.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1196 KEY is a string - same as for the `define-key' function. CMD is a
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1197 function of no arguments or a list to be evaluated. CMD is bound to
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1198 KEY in `idlwave-mode-map' by defining an anonymous function calling
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1199 `self-insert-command' followed by CMD. If KEY contains more than one
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1200 character a binding will only be set if SELECT is 'both.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1201
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1202 (KEY . CMD\ is also placed in the `idlwave-indent-expand-table',
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1203 replacing any previous value for KEY. If a binding is not set then it
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1204 will instead be placed in `idlwave-indent-action-table'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1205
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1206 If the optional argument SELECT is nil then an action and binding are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1207 created. If SELECT is 'noaction, then a binding is always set and no
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1208 action is created. If SELECT is 'both then an action and binding
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1209 will both be created even if KEY contains more than one character.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1210 Otherwise, if SELECT is non-nil then only an action is created.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1211
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1212 Some examples:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1213 No spaces before and 1 after a comma
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1214 (idlwave-action-and-binding \",\" '(idlwave-surround 0 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1215 A minimum of 1 space before and after `=' (see `idlwave-expand-equal').
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1216 (idlwave-action-and-binding \"=\" '(idlwave-expand-equal -1 -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1217 Capitalize system variables - action only
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1218 (idlwave-action-and-binding idlwave-sysvar '(capitalize-word 1) t)"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1219 (if (not (equal select 'noaction))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1220 ;; Add action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1221 (let* ((table (if select 'idlwave-indent-action-table
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1222 'idlwave-indent-expand-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1223 (cell (assoc key (eval table))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1224 (if cell
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1225 ;; Replace action command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1226 (setcdr cell cmd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1227 ;; New action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1228 (set table (append (eval table) (list (cons key cmd)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1229 ;; Make key binding for action
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1230 (if (or (and (null select) (= (length key) 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1231 (equal select 'noaction)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1232 (equal select 'both))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1233 (define-key idlwave-mode-map key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1234 (append '(lambda ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1235 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1236 (self-insert-command 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1237 (list (if (listp cmd)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1238 cmd
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1239 (list cmd)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1240
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1241 (fset 'idlwave-debug-map (make-sparse-keymap))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1242
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1243 (define-key idlwave-mode-map "'" 'idlwave-show-matching-quote)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1244 (define-key idlwave-mode-map "\"" 'idlwave-show-matching-quote)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1245 (define-key idlwave-mode-map "\C-c;" 'idlwave-toggle-comment-region)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1246 (define-key idlwave-mode-map "\C-\M-a" 'idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1247 (define-key idlwave-mode-map "\C-\M-e" 'idlwave-end-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1248 (define-key idlwave-mode-map "\C-c{" 'idlwave-beginning-of-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1249 (define-key idlwave-mode-map "\C-c}" 'idlwave-end-of-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1250 (define-key idlwave-mode-map "\C-c]" 'idlwave-close-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1251 (define-key idlwave-mode-map "\M-\C-h" 'idlwave-mark-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1252 (define-key idlwave-mode-map "\M-\C-n" 'idlwave-forward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1253 (define-key idlwave-mode-map "\M-\C-p" 'idlwave-backward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1254 (define-key idlwave-mode-map "\M-\C-d" 'idlwave-down-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1255 (define-key idlwave-mode-map "\M-\C-u" 'idlwave-backward-up-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1256 (define-key idlwave-mode-map "\M-\r" 'idlwave-split-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1257 (define-key idlwave-mode-map "\M-\C-q" 'idlwave-indent-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1258 (define-key idlwave-mode-map "\C-c\C-p" 'idlwave-previous-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1259 (define-key idlwave-mode-map "\C-c\C-n" 'idlwave-next-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1260 ;; (define-key idlwave-mode-map "\r" 'idlwave-newline)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1261 ;; (define-key idlwave-mode-map "\t" 'idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1262 (define-key idlwave-mode-map "\C-c\C-a" 'idlwave-auto-fill-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1263 (define-key idlwave-mode-map "\M-q" 'idlwave-fill-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1264 (define-key idlwave-mode-map "\M-s" 'idlwave-edit-in-idlde)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1265 (define-key idlwave-mode-map "\C-c\C-h" 'idlwave-doc-header)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1266 (define-key idlwave-mode-map "\C-c\C-m" 'idlwave-doc-modification)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1267 (define-key idlwave-mode-map "\C-c\C-c" 'idlwave-case)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1268 (define-key idlwave-mode-map "\C-c\C-d" 'idlwave-debug-map)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1269 (define-key idlwave-mode-map "\C-c\C-d\C-c" 'idlwave-shell-save-and-run)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1270 (define-key idlwave-mode-map "\C-c\C-f" 'idlwave-for)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1271 ;; (define-key idlwave-mode-map "\C-c\C-f" 'idlwave-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1272 ;; (define-key idlwave-mode-map "\C-c\C-p" 'idlwave-procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1273 (define-key idlwave-mode-map "\C-c\C-r" 'idlwave-repeat)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1274 (define-key idlwave-mode-map "\C-c\C-w" 'idlwave-while)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1275 (define-key idlwave-mode-map "\C-c\C-s" 'idlwave-shell)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1276 (define-key idlwave-mode-map "\C-c\C-l" 'idlwave-shell-recenter-shell-window)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1277 (autoload 'idlwave-shell-send-command "idlwave-shell")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1278 (autoload 'idlwave-shell-recenter-shell-window "idlwave-shell"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1279 "Run `idlwave-shell' and switch back to current window" t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1280 (autoload 'idlwave-shell-save-and-run "idlwave-shell"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1281 "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
1282 (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
1283 (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
1284 (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
1285 (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
1286 (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
1287 (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
1288
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1289 ;; 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
1290 ;; 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
1291 ;; 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
1292 (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
1293 (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
1294 (idlwave-action-and-binding ">" '(idlwave-surround -1 -1 '(?-)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1295 (idlwave-action-and-binding "," '(idlwave-surround 0 -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1296 ;; 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
1297 (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
1298
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1299 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1300 ;;; Abbrev Section
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1301 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1302 ;;; 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
1303 ;;; 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
1304 ;;; the abbrev).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1305 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1306
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1307 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1308 (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
1309 "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
1310 (error nil))
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 (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
1313 "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
1314 (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
1315 (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
1316 (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
1317 (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
1318 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1319 ;; Templates
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1320 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1321 (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
1322 (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
1323 (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
1324 (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
1325 (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
1326 (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
1327 (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
1328 (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
1329 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1330 ;; 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
1331 ;;
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 "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
1333 (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
1334 (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
1335 (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
1336 (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
1337 (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
1338 (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
1339 (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
1340 (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
1341 (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
1342 (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
1343 (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
1344 (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
1345 (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
1346 (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
1347 (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
1348 (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
1349 (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
1350 (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
1351 (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
1352 (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
1353 (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
1354 (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
1355 (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
1356 (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
1357 (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
1358 (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
1359 (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
1360 (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
1361 (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
1362 (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
1363 (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
1364 (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
1365 (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
1366 (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
1367 (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
1368 (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
1369 (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
1370 (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
1371 (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
1372 (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
1373 (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
1374 (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
1375 (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
1376 (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
1377 (idlwave-keyword-abbrev 11))
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 "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
1379 (idlwave-keyword-abbrev 11))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1380 (define-abbrev tb (concat c "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
1381 (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
1382 (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
1383 (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
1384
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1385 ;; 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
1386 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1387 (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
1388 (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
1389 (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
1390 (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
1391 (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
1392 (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
1393 (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
1394 (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
1395 (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
1396 (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
1397 (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
1398 (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
1399 (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
1400 (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
1401 (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
1402 (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
1403 (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
1404 (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
1405 (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
1406 (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
1407 (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
1408 (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
1409 (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
1410 (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
1411 (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
1412 (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
1413 (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
1414 (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
1415 (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
1416 (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
1417 (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
1418 (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
1419 (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
1420 (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
1421 (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
1422
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1423 (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
1424 (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
1425 (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
1426 (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
1427 (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
1428 ;; 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
1429 (defvar idlwave-mode-menu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1430 (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
1431
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1432 ;;;###autoload
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1433 (defun idlwave-mode ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1434 "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
1435
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1436 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
1437
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1438 1. Indentation and Formatting
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1439 --------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1440 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
1441 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
1442
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1443 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
1444 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
1445 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
1446 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
1447
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1448 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
1449
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1450 `;;;' Indentation remains unchanged.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1451 `;;' 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
1452 `;' 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
1453
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1454 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
1455
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1456 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
1457 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
1458 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
1459 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
1460 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
1461
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1462 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
1463 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
1464 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
1465
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1466 2. Routine Info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1467 ------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1468 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
1469 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
1470 \\[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
1471 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
1472 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
1473 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
1474 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
1475
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1476 3. Completion
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-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
1479 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
1480 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
1481 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
1482 upper case.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1483
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1484 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
1485 --------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1486 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
1487 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
1488
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1489 \\pr PROCEDURE template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1490 \\fu FUNCTION template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1491 \\c CASE statement template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1492 \\f FOR loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1493 \\r REPEAT Loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1494 \\w WHILE loop template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1495 \\i IF statement template
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1496 \\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
1497 \\b BEGIN
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 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
1500 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
1501
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1502 \\[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
1503 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
1504 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
1505
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1506 5. Automatic Case Conversion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1507 -------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1508 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
1509 `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
1510
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1511 6. Automatic END completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1512 ------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1513 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
1514 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
1515
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1516 7. Hooks
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 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
1519 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
1520
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1521 8. Documentation and Customization
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 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
1524 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
1525 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
1526 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
1527 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
1528
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1529 9. Keybindings
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 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
1532 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
1533 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
1534
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1535 \\{idlwave-mode-map}"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1536
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1537 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1538 (kill-all-local-variables)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1539
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1540 (if idlwave-startup-message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1541 (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
1542 (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
1543
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1544 (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
1545 (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
1546
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1547 (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
1548
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1549 (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
1550 (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
1551
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1552 (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
1553 (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
1554 (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
1555 (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
1556 (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
1557 (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
1558
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1559 (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
1560
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1561 (when (featurep 'easymenu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1562 (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
1563 (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
1564
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1565 (setq mode-name "IDLWAVE")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1566 (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
1567 (setq abbrev-mode 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 (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
1570 (setq comment-end "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1571 (set (make-local-variable 'comment-multi-line) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1572 (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
1573 (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
1574 (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
1575 (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
1576
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1577 ;; 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
1578 (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
1579 (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
1580
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1581 ;; 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
1582 ;; 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
1583 ;; 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
1584 (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
1585
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1586 ;; Imenu setup
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1587 (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
1588 '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
1589 (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
1590 'idlwave-unit-name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1591 (set (make-local-variable 'imenu-prev-index-position-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1592 'idlwave-prev-index-position)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1593
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1594 ;; 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
1595 (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
1596 (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
1597
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1598 ;; Run the mode hook
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1599 (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
1600
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1601 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1602 ;; 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
1603 ;; 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
1604 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1605
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1606 (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
1607 "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
1608 (if (fboundp 'iconify-frame)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1609 (apply 'push-mark rest)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1610 (push-mark)))
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 (defun idlwave-hard-tab ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1613 "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
1614 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1615 (insert "\t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1616
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1617 ;;; This stuff is experimental
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1618
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1619 (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
1620 "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
1621 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
1622 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
1623
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1624 (defun idlwave-command-hook ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1625 "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
1626 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
1627 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
1628 (and idlwave-command-hook
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1629 (listp idlwave-command-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1630 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1631 (eval idlwave-command-hook)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1632 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1633 (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
1634
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1635 ;;; End experiment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1636
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1637 ;; 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
1638 ;; versatility.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1639
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1640 (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
1641 "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
1642 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
1643 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
1644 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
1645 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
1646 `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
1647 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
1648 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
1649 made into all lowercase.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1650 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
1651 (if (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1652 (progn (unexpand-abbrev)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1653 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1654 (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
1655 (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
1656 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1657 ((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
1658 (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
1659 (idlwave-abbrev-change-case
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1660 (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
1661 (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
1662 (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
1663 (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
1664 (backward-char arg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1665 t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1666
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1667 (defun idlwave-in-comment ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1668 "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
1669 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1670 (let ((here (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1671 (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
1672
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1673 (defun idlwave-goto-comment ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1674 "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
1675 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
1676 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
1677 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
1678 (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
1679 (data (match-data))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1680 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1681 ;; 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
1682 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1683 (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
1684 (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
1685 (setq found (search-forward comment-start eos 'lim)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1686 (store-match-data data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1687 (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
1688 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1689 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1690 (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1691
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1692 (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
1693 "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
1694 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1695 (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
1696 (inq last-command-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1697 (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
1698 (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
1699 (insert inq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1700 (if (eq inq delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1701 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1702 (goto-char bq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1703 (sit-for 1))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1704 ;; 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
1705 (insert inq))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1706
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1707 (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
1708 "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
1709 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
1710 (if
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 (backward-word 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1713 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1714 (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
1715 (idlwave-show-begin)))
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 ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1718 "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
1719 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
1720 ;; 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
1721 (let* ((pos (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1722 end end1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1723 (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
1724 idlwave-show-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1725 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1726 ;; Move inside current block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1727 (setq end (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1728 (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
1729 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1730 (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1731 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1732 (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
1733 (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
1734 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1735 ((null end1)) ; no-opeartion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1736 ((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
1737 (sit-for 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1738 ((string= (downcase end) "end")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1739 ;; A generic end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1740 (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
1741 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1742 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1743 (backward-char 3)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1744 (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
1745 (delete-char 3)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1746 (sit-for 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1747 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1748 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1749 (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
1750 end1 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1751 (sit-for 1))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1752
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1753 (defun idlwave-block-master ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1754 (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
1755 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1756 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1757 ((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
1758 (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
1759 ((looking-at "begin\\>")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1760 (let ((limit (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1761 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1762 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1763 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1764 ((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
1765 (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
1766 idlwave-block-matches))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1767 ;;((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
1768 ;; ;; 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
1769 ;; '("begin" . "end"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1770 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1771 ;; Just a nromal block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1772 '("begin" . "end")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1773 (t nil)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1774
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1775 (defun idlwave-close-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1776 "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
1777 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1778
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1779 ;; 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
1780 (unless (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1781 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1782 (bolp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1783 (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
1784 (newline-and-indent)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1785
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1786 ;; 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
1787 (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
1788 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1789 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1790 (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
1791 (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
1792 (setq end (cdr end))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1793 (error "Cannot close block")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1794 (insert end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1795 (idlwave-newline)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1796
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1797 (defun idlwave-surround (&optional before after escape-chars)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1798 "Surround the character before point with blanks.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1799 Optional arguments BEFORE and AFTER affect the behavior before and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1800 after the previous character. See description of `idlwave-make-space'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1801
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1802 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
1803 - `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
1804 - the character before point is inside a string or comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1805
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1806 When the character 2 positions before point is a member of
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1807 ESCAPE-CHARS, BEFORE is forced to nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1808
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1809 (if (and idlwave-surround-by-blank
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1810 (not (idlwave-quoted)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1811 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1812 (if (memq (char-after (- (point) 2)) escape-chars)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1813 (setq before nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1814 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1815 (save-restriction
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1816 (let ((here (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1817 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1818 (if (bolp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1819 ;; avoid clobbering indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1820 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1821 (move-to-column (idlwave-calculate-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1822 (if (<= (point) here)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1823 (narrow-to-region (point) here))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1824 (goto-char here)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1825 (idlwave-make-space before))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1826 (skip-chars-forward " \t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1827 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1828 (idlwave-make-space after)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1829 ;; Check to see if the line should auto wrap
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1830 (if (and (equal (char-after (1- (point))) ? )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1831 (> (current-column) fill-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1832 (funcall auto-fill-function)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1833
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1834 (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
1835 "Make space at point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1836 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
1837 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
1838 the contiguous space.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1839 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
1840 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
1841 nil - do nothing.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1842 c > 0 - exactly c spaces.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1843 c < 0 - a minimum of -c spaces, i.e., do not change if there are
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1844 already -c spaces.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1845 0 - no spaces."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1846 (if (integerp n)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1847 (let
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1848 ((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
1849 (left (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1850 (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
1851 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1852 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1853 ((> n 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1854 (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
1855 (goto-char (+ left n)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1856 ((< n 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1857 (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
1858 (goto-char (- left n)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1859 ;; n = 0, done
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1860 ))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1861
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1862 (defun idlwave-newline ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1863 "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
1864 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1865 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1866 ;; 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
1867 ;; 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
1868 ;; will mean unbalanced quotes.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1869 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1870 (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
1871 (progn (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1872 (message "Warning: unbalanced quotes?")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1873 (newline)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1874 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1875 ;; 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
1876 ;; 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
1877 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1878 ;; 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
1879 ;; 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
1880 ;; 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
1881 ;; `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
1882 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1883 (beginning-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1884 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1885 (forward-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1886 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1887
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1888 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1889 ;; 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
1890 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1891 ;; Modeled on lisp.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1892 ;; 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
1893 (defun idlwave-comment-hook ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1894 "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
1895 (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
1896 (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
1897 (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
1898 (looking-at "^;")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1899 (current-column)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1900 (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
1901 (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
1902 ;; 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
1903 (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
1904 (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
1905 ;; 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
1906 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1907 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1908 (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
1909 comment-column))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1910
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1911 (defun idlwave-split-line ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1912 "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
1913 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
1914 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
1915 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
1916 non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1917 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1918 (let (beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1919 (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
1920 ;; 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
1921 ;; 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
1922 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1923 (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
1924 (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
1925 ;; Split the string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1926 (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
1927 idlwave-continuation-char beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1928 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1929 ;; 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
1930 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1931 (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
1932 (insert " " idlwave-continuation-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1933 ;; Not splitting a string.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1934 (insert " " idlwave-continuation-char))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1935 (newline-and-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1936 (indent-new-comment-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1937 ;; Indent previous line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1938 (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
1939 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1940 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1941 (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
1942 ;; Reindent new line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1943 (idlwave-indent-line)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1944
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1945 (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
1946 "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
1947 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1948 (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
1949
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1950 (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
1951 "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
1952 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1953 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1954 (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
1955
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1956 (defun idlwave-mark-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1957 "Mark current IDL statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1958 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1959 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1960 (let ((end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1961 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1962 (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
1963
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1964 (defun idlwave-mark-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1965 "Mark containing block."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1966 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1967 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1968 (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
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 (let ((end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1971 (idlwave-backward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1972 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1973 (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
1974
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1975
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1976 (defun idlwave-mark-subprogram ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1977 "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
1978 The marks are pushed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1979 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1980 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1981 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1982 (let ((beg (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1983 (idlwave-forward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1984 (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
1985 (exchange-point-and-mark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1986
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1987 (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
1988 "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
1989 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
1990 (interactive "p")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1991 (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
1992
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1993 (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
1994 "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
1995 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1996 (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
1997 (forward-word 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1998
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1999 (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
2000 "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
2001 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2002 (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
2003 (backward-word 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2004
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2005 (defun idlwave-forward-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2006 "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
2007 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2008 (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
2009 (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
2010
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2011 (defun idlwave-backward-block ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2012 "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
2013 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2014 (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
2015 (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
2016
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2017 (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
2018 "Go down a block.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2019 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
2020 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
2021 (interactive "p")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2022 (let (status)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2023 (if (< arg 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2024 ;; Backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2025 (let ((eos (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2026 (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
2027 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2028 (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
2029 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
2030 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2031 (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
2032 ;; Forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2033 (let ((eos (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2034 (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
2035 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2036 (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
2037 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
2038 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2039 (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
2040 status))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2041
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2042 (defun idlwave-mark-doclib ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2043 "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
2044 The marks are pushed."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2045 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2046 (let (beg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2047 (here (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2048 (goto-char (point-max))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2049 (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
2050 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2051 (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
2052 (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
2053 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2054 (forward-line 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2055 (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
2056 (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
2057 (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
2058 (goto-char here)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2059
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2060 (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
2061 (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
2062 "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
2063 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
2064 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
2065 actual statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2066 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2067 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2068 ((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
2069 (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
2070 (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
2071 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2072 (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
2073 (idlwave-previous-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2074 (beginning-of-line)))))
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 (defun idlwave-previous-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2077 "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
2078 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
2079 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
2080 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2081 (let (first-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2082 (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
2083 ;; first line in file
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2084 t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2085 ;; 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
2086 (while (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2087 ;; 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
2088 ;; reach another statement.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2089 (setq first-statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2090 (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2091 (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
2092 (looking-at "[ \t]*$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2093 (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
2094 (looking-at "^@")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2095 (= (forward-line -1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2096 ;; skip continuation lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2097 (while (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2098 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2099 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2100 (idlwave-is-continuation-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2101 (= (forward-line -1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2102 first-statement)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2103
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2104 ;; 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
2105 ;; 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
2106 ;; comments, though.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2107 (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
2108 "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
2109 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
2110 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2111 (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
2112 (= (forward-line 1) 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2113 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2114 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2115
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2116 (defun idlwave-next-statement ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2117 "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
2118 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
2119 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
2120 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2121 (let (last-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2122 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2123 ;; 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
2124 (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
2125 ;; 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
2126 ;; 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
2127 (setq last-statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2128 (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2129 (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
2130 (looking-at "[ \t]*$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2131 (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
2132 (looking-at "^@")))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2133 last-statement))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2134
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2135 (defun idlwave-skip-label ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2136 "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
2137 Returns position after label.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2138 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
2139 ;; 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
2140 ;; 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
2141 ;; or case statement element.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2142 (let ((start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2143 (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
2144 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2145 (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
2146 (if (and end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2147 (= (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
2148 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2149 (forward-char)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2150 (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2151 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2152 nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2153
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2154 (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
2155 "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
2156 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
2157 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
2158 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
2159 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
2160 substatement. "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2161 (let ((orig (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2162 (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
2163 (ifnest 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2164 st nst last)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2165 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2166 (idlwave-skip-label)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2167 (setq last (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2168 ;; 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
2169 (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
2170 (setq last (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2171 (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
2172 (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
2173 (cond ((and nst
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2174 (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
2175 (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
2176 ((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
2177 (setq ifnest (1- ifnest))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2178 (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
2179 (t (setq ifnest 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2180 (idlwave-next-statement))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2181 (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
2182 (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2183
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2184 (defun idlwave-statement-type ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2185 "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
2186 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
2187 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
2188 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
2189 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
2190 statement."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2191 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2192 ;; 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
2193 (while (looking-at "[ \t]*\\<\\$")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2194 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2195 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2196 (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
2197 (case-fold-search t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2198 (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
2199 (setq st (cdr st))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2200 (if st
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2201 (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
2202
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2203 (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
2204 "Pad '=' with spaces.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2205 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
2206 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
2207 `idlwave-statement-type'.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2208 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
2209 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
2210 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
2211 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
2212 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
2213 See `idlwave-surround'. "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2214 ;; 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
2215 ;; 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
2216 (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
2217 (let ((st (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2218 (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
2219 (idlwave-statement-type))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2220 (if (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2221 (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
2222 (equal (cdr st) (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2223 idlwave-pad-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2224 ;; An assignment statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2225 (idlwave-surround before after)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2226 (idlwave-surround 0 0)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2227
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2228 (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
2229 "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
2230 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2231 (idlwave-indent-line t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2232 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2233
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2234 (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
2235 "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
2236 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
2237 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
2238 `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
2239 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2240 ;; 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
2241 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2242 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2243 (bolp))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2244 (skip-chars-forward " \t"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2245 (let ((mloc (point-marker)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2246 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2247 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2248 (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
2249 ;; 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
2250 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2251 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2252 (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
2253 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2254 ;; Code Line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2255 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2256 ;; 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
2257 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2258 (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
2259 (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
2260 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2261 (if idlwave-do-actions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2262 (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
2263 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2264 ;; 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
2265 ;; 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
2266 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2267 ;; Indent for code line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2268 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2269 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2270 (if (or
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2271 ;; a label line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2272 (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
2273 ;; a batch command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2274 (looking-at "^[ \t]*@"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2275 ;; leave flush left
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2276 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2277 ;; indent the line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2278 (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
2279 ;; Adjust parallel comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2280 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2281 (if (idlwave-in-comment)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2282 (indent-for-comment))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2283 (goto-char mloc)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2284 ;; Get rid of marker
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2285 (set-marker mloc nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2286 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2287
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2288 (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
2289 "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
2290 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
2291 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
2292 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
2293 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
2294 (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
2295 (action-routine (cdr action)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2296 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2297 (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
2298 (if (listp action-routine)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2299 (eval action-routine)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2300 (funcall action-routine)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2301
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2302 (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
2303 "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
2304 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
2305 (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
2306 (insert-before-markers
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2307 (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
2308
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2309 (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
2310 "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
2311 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
2312 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
2313 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2314 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2315 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2316 (idlwave-indent-to col)))
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-subprogram ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2319 "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
2320 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2321 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2322 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2323 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2324 (let ((beg (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2325 (idlwave-forward-block)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2326 (message "Indenting subprogram...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2327 (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
2328 (message "Indenting subprogram...done.")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2329
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2330 (defun idlwave-calculate-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2331 "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
2332 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2333 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2334 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2335 ;; 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
2336 ;; function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2337 ((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
2338 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2339 ;; Check for continuation line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2340 ((save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2341 (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
2342 (idlwave-is-continuation-line)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2343 (idlwave-calculate-cont-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2344 ;; 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
2345 (t (let ((the-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2346 ;; calculate indent based on previous statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2347 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2348 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2349 ((idlwave-previous-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2350 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2351 ;; Main block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2352 ((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
2353 (+ (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2354 idlwave-main-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2355 ;; Begin block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2356 ((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
2357 (+ (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2358 idlwave-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2359 ((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
2360 (- (idlwave-current-statement-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2361 idlwave-end-offset
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2362 idlwave-block-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2363 ((idlwave-current-statement-indent))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2364 ;; 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
2365 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2366 ;; End block
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2367 ((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
2368 (+ 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
2369 (the-indent)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2370
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2371 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2372 ;; Parenthesses balacing/indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2373 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2374
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2375 (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
2376 "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
2377 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
2378 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
2379 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
2380 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
2381 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2382 (let* (open
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2383 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2384 (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
2385 (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
2386 (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
2387 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2388 ;; 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
2389 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2390 (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
2391 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2392 (forward-sexp 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2393 (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
2394 (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
2395 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2396 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2397 ;; 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
2398 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2399 ;; 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
2400 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2401 (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
2402 ;; Found innermost open paren.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2403 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2404 (goto-char open)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2405 ;; 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
2406 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2407 ;; 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
2408 (close-exp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2409 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2410 ;; 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
2411 ;; the forward-char
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2412 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2413 ;; Skip paren
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2414 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2415 (looking-at "[ \t$]*$"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2416 (+ (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
2417 ;; 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
2418 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2419 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2420 (current-column)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2421 ;; 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
2422 (goto-char beg-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2423 (+ (idlwave-current-indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2424 ;; 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
2425 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2426 ;; Else statement
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2427 ((progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2428 (goto-char end-reg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2429 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2430 (looking-at "else"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2431 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2432 ;; Ordinary continuation
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2433 (idlwave-continuation-indent))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2434
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2435 (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
2436 "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
2437 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
2438 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
2439 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
2440 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
2441 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
2442 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
2443 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
2444 `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
2445 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
2446 (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
2447 (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
2448 (let (found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2449 (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
2450 (case-fold-search t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2451 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2452 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2453 (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
2454 (if (>= dir 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2455 (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
2456 (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
2457 (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2458 (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2459 (not (eobp))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2460 (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
2461 (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
2462 (match-beginning 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2463 (idlwave-quoted)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2464 (not (bobp))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2465 (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
2466 (if found (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2467 (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
2468 (goto-char found)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2469
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2470 (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
2471 "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
2472 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
2473 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
2474 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
2475 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
2476 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
2477 possibility of unbalanced blocks."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2478 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2479 (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
2480 (let* ((here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2481 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2482 (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
2483 (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
2484 idlwave-begin-block-reg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2485 idlwave-end-block-reg))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2486 found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2487 (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
2488 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 (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
2490 (if (< dir 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2491 (idlwave-find-key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2492 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
2493 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2494 (idlwave-find-key
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2495 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
2496 limit)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2497 (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
2498 (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
2499 (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
2500 (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
2501 (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
2502 (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
2503 (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
2504 (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
2505 (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
2506
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2507 (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
2508 "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
2509 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
2510 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2511 (idlwave-current-indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2512
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2513 (defun idlwave-current-indent ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2514 "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
2515 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
2516 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2517 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2518 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2519 ;; 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
2520 (cond ((eolp) 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2521 ((current-column)))))
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-is-continuation-line ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2524 "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
2525 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2526 (idlwave-look-at "\\<\\$")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2527
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2528 (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
2529 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2530 (beginning-of-line 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2531 (looking-at "[ \t]*;")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2532
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2533 (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
2534 "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
2535 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
2536 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
2537 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
2538 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
2539 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
2540 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
2541 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
2542 does not move point."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2543 (let ((here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2544 (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
2545 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2546 eos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2547 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2548 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2549 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2550 (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
2551 (setq eos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2552 (if cont
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2553 (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
2554 (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
2555 (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
2556 (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
2557 (idlwave-quoted))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2558 (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
2559 (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
2560 found))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2561
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2562 (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
2563 "Fills paragraphs in comments.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2564 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
2565 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
2566 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
2567 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
2568 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
2569 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
2570 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
2571 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
2572 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
2573 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
2574 ignored."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2575 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2576 ;; 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
2577 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2578 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2579 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2580 (looking-at comment-start))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2581 (let
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2582 ((indent 999)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2583 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
2584 hang start end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2585 ;; 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
2586 ;; 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
2587 ;; 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
2588 ;; 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
2589 ;; 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
2590 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2591 ;; 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
2592 ;; 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
2593 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2594 (backward-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2595 (setq start (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2596 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2597 (forward-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2598 (setq end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2599 (untabify start end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2600 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2601 (setq here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2602 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2603 (setq bcl (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2604 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2605 (concat "^[ \t]*" comment-start "+")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2606 (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
2607 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2608 ;; 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
2609 (setq pre (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2610 ;; 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
2611 ;; number of consecutive ";".
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2612 (setq fill-prefix-reg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2613 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2614 (setq fill-prefix
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2615 (regexp-quote
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2616 (buffer-substring (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2617 (beginning-of-line) (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2618 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2619 "[^;]"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2620
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2621 ;; 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
2622 (goto-char bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2623 (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
2624 (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
2625 (not (bobp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2626 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2627 ;; 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
2628 (if (/= (point) bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2629 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2630 (setq start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2631 (goto-char bcl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2632 (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
2633 (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
2634 (not (eobp)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2635 (forward-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2636 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2637 (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
2638 (looking-at paragraph-separate))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2639 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2640 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2641 ;; 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
2642 ;; 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
2643 ;; 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
2644 (if (eobp)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2645 (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
2646 ;; 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
2647 ;; 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
2648 (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
2649 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2650 ;; 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
2651 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2652 ;; 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
2653 ;; 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
2654 ;; 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
2655 ;; 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
2656 ;; indentation.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2657 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2658 ;; 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
2659 (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
2660 (setq hang
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2661 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2662 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2663 (idlwave-calc-hanging-indent))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2664 ;; 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
2665 ;; 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
2666 ;; 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
2667 ;; a fill-prefix.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2668 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2669 (setq indent hang)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2670 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2671 (while (> (point) start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2672 (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
2673 (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
2674 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2675 (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
2676 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2677 (if (>= here (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2678 ;; 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
2679 ;; inserted text.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2680 (setq here (+ here diff)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2681 (insert (make-string diff ? ))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2682 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2683 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2684
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2685 ;; 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
2686 ;; after first line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2687 ;; 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
2688 ;; 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
2689 ;; 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
2690 ;; 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
2691 (while (> (point) start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2692 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2693 (setq indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2694 (min indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2695 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2696 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2697 comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2698 (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
2699 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2700 (current-column))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2701 (forward-line -1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2702 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2703 (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
2704 (make-string (- indent pre)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2705 ? )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2706 ;; first-line indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2707 (setq first-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2708 (max
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2709 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2710 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2711 comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2712 (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
2713 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2714 (current-column))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2715 indent))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2716
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2717 ;; 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
2718 (goto-char here)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2719
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2720 ;; 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
2721 ;; 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
2722 ;; 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
2723 ;; (first indent).
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2724 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2725 (setq diff
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2726 (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
2727 (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
2728 (fill-region-as-paragraph
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2729 start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2730 (- (point-max) end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2731 (current-justification)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2732 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2733 (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
2734 (goto-char start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2735 (insert diff))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2736 ;; 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
2737 ;; 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
2738 (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
2739 (setq fill-prefix nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2740
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2741 (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
2742 "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
2743 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
2744 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
2745 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
2746 the line.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2747 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
2748 (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
2749 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2750 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2751 (if (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2752 idlwave-hang-indent-regexp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2753 (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
2754 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2755 (+ (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
2756 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2757 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2758 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2759 idlwave-hang-indent-regexp
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2760 (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
2761 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2762 (current-column)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2763
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2764 (defun idlwave-auto-fill ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2765 "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
2766 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
2767 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
2768 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
2769 `+' 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
2770 (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
2771 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
2772 (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
2773 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2774 ;; Check for comment line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2775 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2776 (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
2777 (let (beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2778 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2779 ;; 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
2780 (let (idlwave-do-actions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2781 (paragraph-start ".")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2782 (paragraph-separate "."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2783 (do-auto-fill))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2784 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2785 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2786 ;; Indent the split line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2787 (idlwave-indent-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2788 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2789 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2790 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2791 (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
2792 ;; A continued line comment
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2793 ;; 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
2794 ;; 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
2795 (if idlwave-hanging-indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2796 (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
2797 (indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2798 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2799 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2800 (idlwave-calc-hanging-indent))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2801 (if indent
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2802 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2803 ;; 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
2804 ;; 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
2805 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2806 (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2807 comment-start-skip
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2808 (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
2809 (delete-horizontal-space)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2810 (idlwave-indent-to indent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2811 (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
2812 )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2813 ;; Split code or comment?
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2814 (if (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2815 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2816 (idlwave-in-comment))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2817 ;; 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
2818 ;; 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
2819 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2820 (save-excursion
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 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2823 ;; 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
2824 (insert " "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2825 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2826 (forward-line -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2827 (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
2828 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2829 (skip-chars-forward "; ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2830 (point))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2831 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2832 ;; 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
2833 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2834 (end-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2835 ;; 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
2836 (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
2837 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
2838 ;; 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
2839 ;; 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
2840 ;; 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
2841 (insert " " (char-after beg) " +"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2842 (insert " $"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2843 (if beg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2844 (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
2845 ;; 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
2846 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2847 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2848 (skip-chars-forward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2849 (insert (char-after beg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2850 ;; Warning
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2851 (beep)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2852 (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
2853 ;; 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
2854 ;; 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
2855 ;; 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
2856 (idlwave-indent-line))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2857 )))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2858
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2859 (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
2860 "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
2861 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
2862 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
2863 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
2864 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2865 (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
2866 (if (if (null arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2867 (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
2868 (> (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
2869 'idlwave-auto-fill
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2870 nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2871 ;; update mode-line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2872 (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
2873
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2874 (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
2875 "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
2876 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
2877 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
2878 is non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2879 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2880 (or nomark (push-mark))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2881 ;; 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
2882 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2883 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2884 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2885 ;; 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
2886 (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
2887 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2888 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2889 (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
2890 (if idlwave-file-header
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2891 (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
2892 (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
2893 ((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
2894 (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
2895
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2896
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2897 (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
2898 "Default timestamp insertion function"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2899 (insert (current-time-string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2900 (insert ", " (user-full-name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2901 (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
2902 ;; 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
2903 (idlwave-fill-paragraph)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2904 ;; 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
2905 ;; 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
2906 (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
2907
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2908 (defun idlwave-doc-modification ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2909 "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
2910 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
2911 `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
2912 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
2913 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
2914 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2915 (push-mark)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2916 ;; 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
2917 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2918 (idlwave-beginning-of-subprogram)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2919 (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
2920 (case-fold-search nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2921 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2922 (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
2923 ;; 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
2924 (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
2925 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2926 (end-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2927 ;; 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
2928 (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
2929 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2930 (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
2931 (forward-line -2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2932 (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
2933 (idlwave-newline)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2934 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2935 (insert ";\n;\t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2936 (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
2937
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2938 ;;; CJC 3/16/93
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2939 ;;; 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
2940 ;;; 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
2941 ;;; 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
2942 ;;; 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
2943 ;;; .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
2944 ;;; 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
2945 ;;; 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
2946 ;;; 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
2947 ;;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2948 (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
2949 "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
2950 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
2951 (interactive "r")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2952 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2953 (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
2954 (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
2955 (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
2956 (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
2957
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2958 (defun idlwave-quoted ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2959 "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
2960 nil otherwise."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2961 (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
2962
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2963 (defun idlwave-in-quote ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2964 "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
2965 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
2966 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
2967 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
2968 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
2969 ;;; 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
2970 ;;; 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
2971 ;;; 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
2972 ;;; quote.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2973 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2974 ;; 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
2975 ;; 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
2976 (let* ((start (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2977 (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
2978 (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
2979 (endq (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2980 (data (match-data))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2981 delim
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2982 found)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2983 (while (< endq start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2984 ;; Find string start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2985 ;; 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
2986 (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
2987 ;; Find the string end.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2988 ;; 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
2989 ;; string act as an
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2990 ;; 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
2991 ;; 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
2992 ;; 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
2993 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2994 ;; 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
2995 (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
2996 (setq bq (1- (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2997 ;; Get the string delimiter
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
2998 (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
2999 ;; Check for null string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3000 (if (looking-at delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3001 (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
3002 ;; 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
3003 (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
3004 (while (looking-at delim)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3005 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3006 (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
3007 (if found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3008 (setq endq (- (point) 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3009 (setq endq (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3010 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3011 (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
3012 (store-match-data data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3013 ;; 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
3014 (if (> start bq) bq))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3015
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3016 ;; Statement templates
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3017
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3018 ;; 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
3019 ;; 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
3020 ;; dmacro.el)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3021
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3022 (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
3023 "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
3024
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3025 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
3026 whitespace. S1 and S2 are strings. S1 is inserted at point followed
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3027 by S2. Point is inserted between S1 and S2. If optional argument
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3028 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
3029 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
3030 expression to enter.
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 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
3033 unless the optional second argument NOINDENT is non-nil."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3034 (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
3035 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3036 (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
3037 (open-line 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3038 (insert s1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3039 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3040 (insert s2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3041 (setq end (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3042 (if (not noindent)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3043 (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
3044 (if (stringp prompt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3045 (message prompt))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3046
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3047 (defun idlwave-elif ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3048 "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
3049 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3050 (idlwave-template "if"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3051 " then begin\n\nendif else begin\n\nendelse"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3052 "Condition expression"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3053
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3054 (defun idlwave-case ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3055 "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
3056 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3057 (idlwave-template "case" " of\n\nendcase" "Selector expression"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3058
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3059 (defun idlwave-for ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3060 "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
3061 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3062 (idlwave-template "for" " do begin\n\nendfor" "Loop expression"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3063
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3064 (defun idlwave-if ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3065 "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
3066 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3067 (idlwave-template "if" " then begin\n\nendif" "Scalar logical expression"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3068
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3069 (defun idlwave-procedure ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3070 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3071 (idlwave-template "pro" "\n\nreturn\nend" "Procedure name"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3072
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3073 (defun idlwave-function ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3074 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3075 (idlwave-template "function" "\n\nreturn\nend" "Function name"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3076
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3077 (defun idlwave-repeat ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3078 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3079 (idlwave-template "repeat begin\n\nendrep until" "" "Exit condition"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3080
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3081 (defun idlwave-while ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3082 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3083 (idlwave-template "while" " do begin\n\nendwhile" "Entry condition"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3084
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3085 (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
3086 "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
3087 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
3088 (or pattern
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3089 (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
3090 (let (parts (start 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3091 (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
3092 (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
3093 start (match-end 0)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3094 (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
3095
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3096 (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
3097 (let* ((start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3098 (last (length string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3099 (ret_string "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3100 end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3101 (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
3102 (setq ret_string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3103 (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
3104 (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
3105 (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
3106
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3107 (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
3108 ;; 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
3109 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3110 ((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
3111 (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
3112 (get-file-buffer file)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3113 ((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
3114 (find-buffer-visiting file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3115 (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
3116
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3117 (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
3118 ;; 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
3119 (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
3120 (find-file-noselect file)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3121
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3122 (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
3123 (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
3124 ;; 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
3125 (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
3126 dir efile)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3127 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3128 (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
3129 (if (file-regular-p
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3130 (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
3131 (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
3132
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3133 (defun idlwave-make-tags ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3134 "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
3135 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
3136 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
3137 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
3138 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
3139 you specify /."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3140 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3141 (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
3142 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
3143
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 ;; Read list of directories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3146 (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
3147 (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
3148 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3149 ;; Set etags command, vars
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3150 (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
3151 \\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
3152 \\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
3153 (setq append " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3154 (setq status 0)
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 ;; For each directory
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3157 (setq numdirs 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3158 (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
3159 (while (and dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3160 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3161 ;; Find the subdirectories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3162 (if (string-match "^[@]\\(.+\\)$" dir)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3163 (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
3164 (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
3165 (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
3166 (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
3167 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3168 (if (and getsubdirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3169 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3170 (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
3171 (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
3172 (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
3173 (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
3174 (set-buffer buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3175 (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
3176 (idlwave-replace-string
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3177 (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
3178 "\n" "/*.pro ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3179 "[ \t]+"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3180 (set-buffer save_buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3181 (kill-buffer buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3182 (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
3183 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3184 ;; For each subdirectory
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3185 (setq numfiles 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3186 (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
3187 (while (and item)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3188 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3189 ;; Call etags
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3190 (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
3191 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3192 (message (concat "Tagging " item "..."))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3193 (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
3194 (setq status (+ status
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3195 (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
3196 (concat cmd append item))))
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 ;; Append additional tags
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3199 (setq append " --append ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3200 (setq numfiles (1+ numfiles))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3201 (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
3202 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3203 (setq numfiles (1+ numfiles))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3204 (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
3205 )))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3206
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3207 (setq numdirs (1+ numdirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3208 (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
3209 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3210 (setq numdirs (1+ numdirs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3211 (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
3212
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3213 (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
3214 (if (= status 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3215 (kill-buffer errbuf))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3216 (message "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3217 ))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3218
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3219 (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
3220 "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
3221 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
3222 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
3223 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
3224 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
3225 blank lines."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3226 (interactive "r\nP")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3227 (if n
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3228 (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
3229 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3230 (goto-char beg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3231 (beginning-of-line)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3232 ;; skip blank lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3233 (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
3234 (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
3235 (comment-region beg end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3236 (- (length (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3237 (match-beginning 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3238 (match-end 1)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3239 (comment-region beg end)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3240
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3241
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3242 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3243 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3244 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3245 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3246 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3247 ;; Completion and Routine Info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3248 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3249
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3250 ;; String "intern" functions
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3251
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3252 ;; 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
3253 ;; 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
3254 ;; 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
3255 ;; 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
3256 ;; 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
3257 ;; 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
3258 ;; 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
3259 ;; 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
3260 ;; 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
3261 ;; "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
3262 ;; 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
3263 ;; 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
3264 ;; 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
3265 ;; 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
3266
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3267 ;; 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
3268
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3269 ;; 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
3270 (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
3271 (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
3272 (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
3273 (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
3274 (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
3275
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3276 (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
3277 "Reset all sintern hashes."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3278 ;; 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
3279 (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
3280 (not (fboundp 'puthash)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3281 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3282 (require 'cl)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3283 (or (fboundp 'puthash)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3284 (defalias 'puthash 'cl-puthash))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3285 (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
3286 (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
3287 (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
3288 (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
3289
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3290 ;; 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
3291 (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
3292 for var = (car entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3293 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
3294
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3295 (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
3296 (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
3297 ;; 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
3298 (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
3299 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
3300 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
3301 (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
3302 (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
3303
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3304 (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
3305 (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
3306 ;; 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
3307 (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
3308 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
3309 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
3310 (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
3311
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3312 (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
3313 (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3314 (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
3315 (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
3316
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3317 (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
3318 (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
3319
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3320 ;;(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
3321 ;; `(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
3322 ;; ((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
3323 ;; ((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
3324 ;; (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
3325 ;; (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3326
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3327 (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
3328 (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
3329 ((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
3330 ((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
3331 (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
3332 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3333 (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
3334 (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
3335 ((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
3336 ((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
3337 (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
3338 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3339 (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
3340 (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
3341 ((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
3342 ((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
3343 (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
3344 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3345 (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
3346 (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
3347 ((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
3348 ((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
3349 (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
3350 (name)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3351
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3352 (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
3353 (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
3354 (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
3355
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3356 (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
3357 (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
3358 'identity))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3359 (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
3360 (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
3361 (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
3362 iname))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3363
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3364 (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
3365 "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
3366 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
3367 (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
3368 (while list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3369 (setq entry (car list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3370 list (cdr list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3371 name (car entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3372 type (nth 1 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3373 class (nth 2 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3374 source (nth 3 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3375 call (nth 4 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3376 kwds (nth 5 entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3377 olh (nth 6 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3378 (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
3379 (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
3380 kwds))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3381 (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3382 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3383 (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
3384 (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
3385 (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
3386 (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
3387 (if (stringp (cdr source))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3388 (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
3389 (setq new (if olh
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3390 (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
3391 (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
3392 (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
3393 (nreverse res)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3394
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3395 ;;---------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3396
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3397
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3398 ;; 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
3399 (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
3400 "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
3401 (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
3402 "Holds the routine-info obtained by scanning buffers.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3403 (defvar idlwave-compiled-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3404 "Holds the 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
3405 (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
3406 "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
3407 (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
3408 "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
3409 (defvar idlwave-routines nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3410 "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
3411 (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
3412 "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
3413 (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
3414 "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
3415 (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
3416 (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
3417 "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
3418
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3419 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3420 ;; 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
3421
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3422 (defvar idlwave-builtin-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3423 (defun idlwave-routines ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3424 "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
3425 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
3426 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
3427 (or idlwave-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3428 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3429 (idlwave-update-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3430 ;; return the current value
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3431 idlwave-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3432
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3433 (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
3434 "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
3435 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
3436 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
3437 about individual routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3438
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3439 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
3440 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
3441 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
3442 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
3443 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
3444
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3445 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
3446 `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
3447 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
3448 for currently compiled routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3449
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3450 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
3451 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
3452 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3453 (if (equal arg '(16))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3454 (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
3455 (let* ((reload (or arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3456 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
3457 (null idlwave-builtin-routines))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3458
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3459 (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
3460 idlwave-compiled-routines nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3461 ;; Reset the appropriate hashes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3462 (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
3463 ((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
3464 (t 'bufsh)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3465
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3466 (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
3467 ;; 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
3468 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3469 (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
3470 (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
3471 ;; 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
3472 (and reload (idlwave-load-system-rinfo))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3473 (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
3474
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3475 ;; 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
3476 (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
3477 (idlwave-shell-is-running)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3478 (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
3479 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
3480
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3481 (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
3482 (not (interactive-p)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3483 ;; 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
3484 ;; concatenation now.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3485 ;; 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
3486 ;; 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
3487 ;; 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
3488 ;; 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
3489 ;; 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
3490 (idlwave-concatenate-rinfo-lists))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3491
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3492 (when ask-shell
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3493 ;; 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
3494 (message "Querying the shell")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3495 (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
3496
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3497 (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
3498 ;; Load and case-treat the system and lib info files.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3499 (load "idlwave-rinfo" t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3500 (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
3501 (setq idlwave-builtin-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3502 (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
3503 (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
3504 (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
3505 (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
3506 (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
3507 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3508 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3509 (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
3510 (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
3511 (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
3512 idlwave-library-routines 'sys))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3513 (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
3514 (error nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3515
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3516 (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
3517 (let (res)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3518 (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
3519 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3520 ;; 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
3521 (message "Scanning all buffers...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3522 (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
3523 (reverse (buffer-list)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3524 ;; Just scan this buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3525 (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
3526 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3527 (message "Scanning current buffer...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3528 (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
3529 (list (current-buffer)))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3530 ;; 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
3531 (setq idlwave-buffer-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3532 (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
3533
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3534 (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
3535 "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
3536 ;; 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
3537 ;; 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
3538 ;; 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
3539 ;; 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
3540 ;; 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
3541 ;; 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
3542 ;; 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
3543 ;; 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
3544 ;; 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
3545 ;; 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
3546 (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
3547 idlwave-compiled-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3548 idlwave-library-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3549 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-class-alist nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3551 (let (class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3552 (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
3553 (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
3554 (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
3555 (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
3556 ;; 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
3557 (message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3558 "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
3559 (length idlwave-buffer-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3560 (length idlwave-compiled-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3561 (length idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3562 (length idlwave-builtin-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3563
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3564 ;;----- Scanning buffers -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3565
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3566 (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
3567 "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
3568 (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
3569 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3570 (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
3571 (set-buffer buf)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3572 (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
3573 ;; 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
3574 (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
3575 (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
3576 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3577 (push res routine-lists)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3578 ;; 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
3579 (apply 'nconc routine-lists)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3580
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3581 (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
3582 "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
3583 (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
3584 routine-list string entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3585 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3586 (save-restriction
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3587 (widen)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3588 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3589 (while (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3590 "^[ \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
3591 (setq string (buffer-substring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3592 (match-beginning 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3593 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3594 (idlwave-end-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3595 (point))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3596 (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
3597 (push entry routine-list))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3598 routine-list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3599
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3600 (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
3601 "Parse a module definition."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3602 (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
3603 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
3604 ;; Remove comments
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3605 (while (string-match ";.*" string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3606 (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
3607 ;; 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
3608 (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
3609 (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
3610 ;; 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
3611 (when (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3612 "\\<\\(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
3613 (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
3614 (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
3615 (if (match-beginning 3)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3616 (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
3617 (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
3618 ;; 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
3619 (while (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3620 ",\\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
3621 string start)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3622 (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
3623 (if (match-beginning 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3624 (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
3625 (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
3626 ;; Normalize and sort.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3627 (setq args (nreverse args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3628 (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
3629 (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
3630 ;; 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
3631 ;; 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
3632 ;; 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
3633 (list name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3634 (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
3635 class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3636 (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
3637 (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
3638 ((string= (downcase
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3639 (file-name-sans-extension
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3640 (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
3641 (downcase name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3642 (list 'lib))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3643 (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
3644 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3645 (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
3646 (if class "Obj ->[%s::]" "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3647 "%s"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3648 (if args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3649 (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3650 (if (string= type "function") "(" ", ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3651 (mapconcat 'identity args ", ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3652 (if (string= type "function") ")" ""))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3653 (if keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3654 (mapcar 'list keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3655 nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3656
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3657 ;;----- Scanning the library -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3658
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3659 (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
3660 "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
3661 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
3662 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
3663 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
3664 routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3665 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
3666 will pop up."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3667 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3668 ;; 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
3669 (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
3670 (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
3671 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3672 (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
3673 (error nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3674 ;; 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
3675 (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
3676 (file-accessible-directory-p
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3677 (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
3678 (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
3679 idlwave-libinfo-file))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3680 (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
3681
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3682 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3683 ((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
3684 ;; Rescan the known directories
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3685 (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
3686 (idlwave-library-path
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3687 ;; 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
3688 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3689 (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
3690 idlwave-scanned-lib-directories))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3691 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3692 ;; 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
3693 (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
3694 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3695 "__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
3696 '(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
3697 'hide))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3698
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3699 (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
3700 ;; 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
3701 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3702 ;; Scan immediately
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3703 (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
3704 ;; Display the widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3705 (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
3706 idlwave-scanned-lib-directories)))
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 (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
3709 (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
3710 ;; 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
3711 (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
3712 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3713 (start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3714 dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3715 (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
3716 (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
3717 (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
3718 (nreverse dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3719
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3720 (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
3721 "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
3722 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
3723 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
3724
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3725 %s
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3726
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3727 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
3728 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
3729 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
3730 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
3731 \n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3732
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3733 (defvar idlwave-widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3734 (defvar widget-keymap)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3735 (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
3736 "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
3737 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3738 (require 'widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3739 (require 'wid-edit)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3740 (unless dirs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3741 (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
3742
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3743 ;; 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
3744 (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
3745 (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
3746 selected-dirs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3747 (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
3748 (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
3749 (kill-all-local-variables)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3750 (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
3751 (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
3752 idlwave-libinfo-file))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3753
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3754 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3755 :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
3756 :help-echo "testing"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3757 "Scan & Save")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3758 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3759 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3760 :notify (lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3761 (kill-buffer (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3762 "Quit")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3763 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3764 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3765 :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
3766 "Delete File")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3767 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3768 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3769 :notify '(lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3770 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3771 (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
3772 (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
3773 "Select All")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3774 (widget-insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3775 (widget-create 'push-button
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3776 :notify '(lambda (&rest ignore)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3777 (idlwave-display-libinfo-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3778 (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
3779 nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3780 "Deselect All")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3781 (widget-insert "\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3782
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3783 (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
3784
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3785 (setq idlwave-widget
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3786 (apply 'widget-create
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3787 'checklist
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3788 :value selected-dirs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3789 :greedy t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3790 :tag "List of directories"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3791 (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
3792 (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
3793 (widget-insert "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3794 (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
3795 (widget-setup)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3796 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3797 (delete-other-windows))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3798
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3799 (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
3800 (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
3801 (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
3802 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3803 (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
3804 (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
3805
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3806 (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
3807 ;; 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
3808 (let* ((widget idlwave-widget)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3809 (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
3810 (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
3811
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3812 (defvar font-lock-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3813 (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
3814 ;; 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
3815 (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
3816 (idlwave-completion-case nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3817 dirs dir files file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3818 (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
3819 (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
3820 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3821 (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
3822 (idlwave-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3823 (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
3824 (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
3825 (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
3826 (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
3827 (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
3828 (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
3829 (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
3830 (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
3831 (message "Scanning %s..." file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3832 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3833 (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
3834 (setq idlwave-library-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3835 (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
3836 (list (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3837 idlwave-library-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3838 )))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3839 (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
3840 (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
3841 (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
3842 (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
3843 (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
3844 font-lock-mode)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3845 (font-lock-mode 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3846 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3847 (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
3848 (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
3849
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3850 ;; 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
3851 (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
3852 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3853 (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
3854 selected-dirs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3855 (insert "))\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3856 ;; 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
3857 (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
3858 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3859 (insert "\n ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3860 (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
3861 idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3862 (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
3863 (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
3864 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3865 ;; Save the buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3866 (save-buffer 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3867 (kill-buffer (current-buffer)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3868 (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
3869 (length idlwave-library-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3870 idlwave-libinfo-file)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3871 (sit-for 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3872 (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
3873
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3874 (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
3875 ;; 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
3876 ;; 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
3877 (message "Expanding path...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3878 (let (path1 dir recursive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3879 (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
3880 (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
3881 (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
3882 (if (and recursive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3883 (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
3884 (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
3885 (if recursive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3886 ;; Expand recursively
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3887 (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
3888 ;; Keep unchanged
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3889 (push dir path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3890 (message "Expanding path...done")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3891 (nreverse path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3892
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3893 (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
3894 ;; 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
3895 (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
3896 (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
3897 (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
3898 (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
3899 (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
3900 (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
3901 (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
3902 (push dir path1)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3903 path1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3904
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3905 ;;----- Asking the shell -------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3906
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3907 ;; 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
3908 ;; defined routines.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3909 (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
3910 "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3911 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
3912 ;; 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
3913 func = keyword_set(func)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3914 methsep = strpos(name,'::')
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3915 meth = methsep ne -1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3916
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3917 ;; Get routine info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3918 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
3919 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
3920 nargs = pars.num_args
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3921 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
3922 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
3923 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
3924
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3925 ;; 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
3926 if meth then begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3927 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
3928 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
3929 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
3930 ;; remove the self argument
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3931 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
3932 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
3933 endif
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3934 endif else begin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3935 ;; 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
3936 class = \"\"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3937 endelse
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3938
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3939 ;; Calling sequence
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3940 cs = \"\"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3941 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
3942 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
3943 cs = cs + '%s'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3944 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
3945 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
3946 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
3947 cs = cs + args(j)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3948 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
3949 endfor
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3950 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3951 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
3952 ;; Keyword arguments
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3953 kwstring = ''
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3954 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
3955 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
3956 kwstring = kwstring + ' ' + kwargs(j)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3957 endfor
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3958 endif
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 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
3961 '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
3962
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3963 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
3964 + sep + cs + sep + kwstring
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3965 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3966
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3967 pro idlwave_routine_info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3968 sep = '<@>'
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3969 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
3970 all = routine_info()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3971 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
3972 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
3973 all = routine_info(/functions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3974 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
3975 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
3976 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
3977 end
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3978 "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3979 "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
3980 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
3981
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3982 (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
3983 "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
3984 (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
3985 (start 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3986 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
3987 ;; Initialize variables
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3988 (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
3989 ;; 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
3990 (if (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3991 "^>>>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
3992 text)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
3993 (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
3994 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
3995 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
3996 (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
3997 (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
3998 (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
3999 (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
4000 ;; Match the output lines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4001 (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
4002 (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
4003 (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
4004 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
4005 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
4006 name (nth 0 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4007 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
4008 file (nth 2 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4009 cs (nth 3 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4010 key (nth 4 specs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4011 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
4012 (not (string-match "\\` *\\'" key)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4013 (mapcar 'list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4014 (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
4015 (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
4016 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
4017 keys (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4018 (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
4019 ;; 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
4020 (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
4021 ;; 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
4022 ;; 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
4023 ;; 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
4024 ;; (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
4025 ;; (setq file nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4026
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4027 ;; 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
4028 ;; 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
4029 ;; version.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4030 ;; 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
4031 ;; 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
4032 ;; 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
4033 ;; 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
4034 ;; 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
4035
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4036 (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
4037 ((and (string= type "PRO")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4038 ;; 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
4039 (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
4040 idlwave-buffer-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4041 ;; 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
4042 ;;(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
4043 ;; idlwave-library-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4044 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4045 (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
4046 idlwave-compiled-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4047 ((and (string= type "FUN")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4048 ;; 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
4049 (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
4050 idlwave-buffer-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4051 ;; 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
4052 ;; (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
4053 ;; idlwave-library-routines))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4054 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4055 (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
4056 idlwave-compiled-routines)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4057 ;; 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
4058 (setq idlwave-compiled-routines
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4059 (nreverse idlwave-compiled-routines)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4060
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4061 (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
4062 (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
4063 "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
4064 ;; 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
4065 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4066 (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
4067 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
4068 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4069 (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
4070 (save-buffer 0))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4071 (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
4072 nil 'hide)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4073
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4074 ;; 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
4075 (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
4076 '(progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4077 (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
4078 (idlwave-concatenate-rinfo-lists))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4079 'hide))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4080
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4081 ;; ---------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4082 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4083 ;; 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
4084
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4085 (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
4086 "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
4087 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
4088 at this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4089 - 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
4090 - 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
4091 - 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
4092 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
4093 - 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
4094
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4095 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
4096 *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
4097 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
4098
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4099 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
4100 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
4101 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
4102 argument to this command.
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 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
4105 `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
4106
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4107 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
4108 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
4109 Possible values are:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4110
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4111 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
4112 1 <=> 'procedure
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4113 2 <=> 'procedure-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4114 3 <=> 'function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4115 4 <=> 'function-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4116 5 <=> 'procedure-method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4117 6 <=> 'procedure-method-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4118 7 <=> 'function-method
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4119 8 <=> 'function-method-keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4120 9 <=> 'class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4121
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4122 For Lisp programmers only:
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4123 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
4124 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
4125 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4126 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4127 (let* ((where-list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4128 (if (and arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4129 (or (integerp arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4130 (symbolp arg)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4131 (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
4132 (idlwave-where)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4133 (what (nth 2 where-list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4134 (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
4135 cwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4136
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4137 (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
4138 (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
4139 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
4140
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4141 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4142
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4143 ((and (null arg)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4144 (eq (car-safe last-command) 'idlwave-display-completion-list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4145 (setq cwin (get-buffer-window "*Completions*")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4146 (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
4147 (idlwave-scroll-completions))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4148
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4149 ((null what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4150 (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
4151
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4152 ((eq what 'class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4153 (idlwave-complete-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4154
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4155 ((eq what 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4156 ;; Complete a procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4157 (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
4158 (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
4159 (type-selector 'pro))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4160 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4161 '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
4162 (idlwave-routines) 'idlwave-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4163 (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
4164 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4165 (if class-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4166 (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
4167 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4168 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4169 'idlwave-attach-method-classes)))
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 ((eq what 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4172 ;; Complete a function name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4173 (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
4174 (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
4175 (type-selector 'fun))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4176 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4177 '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
4178 (idlwave-routines) 'idlwave-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4179 (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
4180 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4181 (if class-selector
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4182 (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
4183 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4184 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4185 'idlwave-attach-method-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4186
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4187 ((eq what 'procedure-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4188 ;; Complete a procedure keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4189 (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
4190 (name (car where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4191 (method-selector name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4192 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4193 (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
4194 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4195 (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
4196 (entry (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4197 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
4198 (list (nth 5 entry)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4199 (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
4200 (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
4201 (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
4202 (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
4203 (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
4204 (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
4205 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4206 'keyword 'keyword list nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4207 (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
4208 (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
4209 (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
4210 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4211 'idlwave-attach-keyword-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4212
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4213 ((eq what 'function-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4214 ;; Complete a function keyword
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4215 (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
4216 (name (car where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4217 (method-selector name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4218 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4219 (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
4220 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4221 (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
4222 (entry (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4223 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
4224 (list (nth 5 entry)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4225 (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
4226 (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
4227 (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
4228 (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
4229 (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
4230 (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
4231 (idlwave-complete-in-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4232 'keyword 'keyword list nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4233 (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
4234 (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
4235 (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
4236 isa
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4237 'idlwave-attach-keyword-classes)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4238
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4239 (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
4240
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4241 (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
4242 ;; 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
4243 ;; 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
4244 ;; 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
4245 ;; 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
4246 ;; 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
4247 (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
4248 ("function") ("function-keyword")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4249 ("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
4250 ("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
4251 ("class")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4252 (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
4253 (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
4254 (what (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4255 ((equal what 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4256 (setq what
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4257 (intern (completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4258 "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
4259 ((integerp what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4260 (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
4261 ((and what
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4262 (symbolp what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4263 (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
4264 what)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4265 (t (error "Illegal WHAT"))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4266 (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
4267 (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
4268
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4269 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4270
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4271 ((eq what 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4272 (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
4273
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4274 ((eq what 'procedure-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4275 (let* ((class-selector nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4276 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4277 (pro (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4278 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4279 "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
4280 (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
4281 (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
4282 (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
4283
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4284 ((eq what 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4285 (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
4286
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4287 ((eq what 'function-keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4288 (let* ((class-selector nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4289 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4290 (func (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4291 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4292 "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
4293 (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
4294 (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
4295 (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
4296
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4297 ((eq what 'procedure-method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4298 (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
4299
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4300 ((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
4301 (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
4302 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4303 (type-selector 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4304 (pro (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4305 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4306 (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
4307 (idlwave-routines) 'idlwave-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4308 (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
4309 (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
4310 (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
4311
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4312 ((eq what 'function-method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4313 (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
4314
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4315 ((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
4316 (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
4317 (class-selector class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4318 (type-selector 'fun)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4319 (func (or module
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4320 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4321 (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
4322 (idlwave-routines) 'idlwave-selector))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4323 (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
4324 (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
4325 (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
4326
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4327 ((eq what 'class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4328 (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
4329
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4330 (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
4331
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4332 (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
4333 ;; Completing read, case insensitive
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4334 (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
4335 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4336 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4337 (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
4338 (apply 'completing-read args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4339 (setq-default completion-ignore-case old-value))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4340
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4341 (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
4342 ;; 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
4343 (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
4344
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4345 (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
4346 ;; 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
4347 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4348 (let (match)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4349 (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
4350 (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
4351 (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
4352 (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
4353 (throw 'exit match))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4354 (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
4355
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4356 (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
4357 "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
4358 (let (rtn elt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4359 (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
4360 (push elt rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4361 (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
4362 (nreverse rtn)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4363
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4364 (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
4365 "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
4366 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
4367 (if (null method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4368 (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
4369 (let (rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4370 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4371 (and (nth 2 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4372 (or (not type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4373 (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
4374 (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
4375 (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
4376 (idlwave-uniquify rtn))))
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 (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
4379 "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
4380 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
4381 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
4382 (if (or (null method)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4383 (null keyword))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4384 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4385 (let (rtn)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4386 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4387 (and (nth 2 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4388 (or (not type)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4389 (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
4390 (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
4391 (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
4392 (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
4393 (idlwave-uniquify rtn))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4394
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4395 (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
4396 ;; 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
4397 ;; `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
4398 ;; 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
4399 ;; 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
4400 ;; 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
4401 ;; 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
4402 ;; 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
4403 (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
4404 (apos (nth 3 info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4405 (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
4406 (upcase (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4407 (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4408 idlwave-query-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4409 (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
4410 idlwave-query-class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4411 (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
4412 (dassoc (cdr dassoc))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4413 (t t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4414 (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
4415 (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
4416 store class-alist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4417 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4418 ((null class) nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4419 ((eq t class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4420 ;; 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
4421 (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
4422 idlwave-store-inquired-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4423 (not force-query))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4424 (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
4425 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
4426 (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
4427 (or force-query query))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4428 (setq class-alist
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4429 (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
4430 (setq class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4431 (idlwave-sintern-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4432 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4433 ((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
4434 (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
4435 ((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
4436 (car (car class-alist)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4437 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4438 (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
4439 (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4440 (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
4441 (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
4442 type (car info))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4443 ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4444 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
4445 (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
4446 ;; 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
4447 (when (and store arrow)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4448 (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
4449 (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
4450 (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
4451 ;; Return the class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4452 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4453 ;; Default as fallback
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4454 (t class))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4455
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4456 (defvar type-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4457 (defvar class-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4458 (defvar method-selector)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4459 (defun idlwave-selector (a)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4460 (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
4461 (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
4462 (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
4463
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4464 (defun idlwave-where ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4465 "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
4466 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
4467 (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
4468
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4469 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
4470 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
4471 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
4472 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
4473 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
4474 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
4475
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4476 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
4477 PRO: Procedure name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4478 FUNC: Function name
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4479 POINT: Where is this
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4480 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
4481 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
4482 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4483 (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
4484 (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
4485 (func (car func-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4486 (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
4487 (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
4488 (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
4489 (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
4490 (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
4491 (pro (car pro-entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4492 (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
4493 (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
4494 (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
4495 (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
4496 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4497 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
4498 (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
4499 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4500 ((string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4501 "\\`[ \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
4502 (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
4503 (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
4504 cw-arrow pro-arrow))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4505 ((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
4506 (buffer-substring bos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4507 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4508 ((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
4509 (buffer-substring bos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4510 (setq cw 'class))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4511 ((and func
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4512 (> func-point pro-point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4513 (= func-level 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4514 (memq last-char '(?\( ?,)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4515 (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
4516 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
4517 ((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
4518 (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
4519 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
4520 ; ((member last-char '(?\' ?\) ?\] ?!))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4521 ; ;; 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
4522 ; ;; 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
4523 ; ;; 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
4524 ; nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4525 ;; 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
4526 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4527 (setq cw 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4528 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4529 (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
4530 (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
4531 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
4532 (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
4533 t))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4534 (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
4535 (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
4536 cw
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4537 (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
4538 last-char)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4539
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4540 (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
4541 ;; 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
4542 (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
4543 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4544 (buffer-substring-no-properties
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4545 (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
4546 (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
4547
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4548 (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
4549 (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
4550 ;; 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
4551 ;; 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
4552 ;; 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
4553
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4554 ;; 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
4555 ;; searches to this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4556
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4557 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4558 (let (pos
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4559 func-point
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4560 (old-syntax (syntax-table))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4561 (cnt 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4562 func arrow-start class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4563 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4564 (save-restriction
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4565 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4566 (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
4567 (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
4568 ;; 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
4569 (while (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4570 (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
4571 (error nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4572 (setq pos (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4573 (incf cnt)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4574 (when (and (= (following-char) ?\()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4575 (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4576 "\\(::\\|\\<\\)\\([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
4577 bound t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4578 (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
4579 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
4580 pos func-point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4581 (if (re-search-backward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4582 "->[ \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
4583 (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
4584 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
4585 (throw
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4586 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4587 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4588 (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
4589 (idlwave-sintern-class class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4590 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
4591 (goto-char pos))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4592 (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4593 (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
4594
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4595 (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
4596 ;; 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
4597 ;; 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
4598
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4599 ;; 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
4600 ;; searches to this point.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4601 (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
4602 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
4603 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4604 (idlwave-beginning-of-statement)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4605 (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
4606 (if (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4607 "\\`[ \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
4608 (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
4609 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
4610 (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
4611 (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
4612 (string-match
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4613 "\\`[ \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
4614 (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
4615 (match-string 4 string))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4616 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
4617 (+ (point) (match-beginning 4))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4618 pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4619 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
4620 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
4621 (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
4622 (idlwave-sintern-class class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4623 arrow-start
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4624 pro-point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4625
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4626 (defun idlwave-skip-object ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4627 ;; 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
4628 (let ((pos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4629 (if (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4630 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4631 (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
4632 (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
4633 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4634 ((looking-at idlwave-identifier)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4635 (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
4636 ((eq (following-char) ?\()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4637 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4638 (t (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4639 (catch 'endwhile
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4640 (while t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4641 (cond ((eq (following-char) ?.)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4642 (forward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4643 (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
4644 (throw 'exit nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4645 (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
4646 ((memq (following-char) '(?\( ?\[))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4647 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4648 (forward-list 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4649 (error (throw 'exit nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4650 (t (throw 'endwhile t)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4651 (if (looking-at "[ \t]*->")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4652 (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
4653 (throw 'exit nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4654 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4655 nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4656
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4657
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4658 (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
4659 "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
4660 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
4661 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
4662 `/' 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
4663 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
4664 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4665 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4666 ;; skip the current identifier
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4667 (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
4668 ;; 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
4669 (if (eq (preceding-char) ?/)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4670 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4671 ;; 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
4672 (while t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4673 (skip-chars-backward " \t")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4674 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4675 ((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
4676 ((eq (preceding-char) ?\n)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4677 (beginning-of-line 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4678 (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
4679 ;; continuation line
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4680 (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
4681 (throw 'exit nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4682 (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
4683
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4684 (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
4685 "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
4686 (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
4687 "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
4688 (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
4689 "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
4690
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4691 (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
4692 &optional prepare-display-function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4693 "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
4694 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
4695 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
4696 (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
4697 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
4698 dpart dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4699
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4700 (unless list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4701 (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
4702
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4703 ;; 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
4704 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4705 (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
4706 (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
4707 beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4708 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
4709 (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
4710 (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
4711 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
4712 (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
4713 (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
4714
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4715 ;; Try a completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4716 (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
4717 dpart (downcase part)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4718 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
4719 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
4720 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
4721 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4722 ((null completion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4723 ;; nothing available.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4724 (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
4725 ((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
4726 (not (eq t completion)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4727 ;; We can add something
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4728 (delete-region beg end)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4729 (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
4730 (or (not (string= part ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4731 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
4732 (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
4733 (insert dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4734 (insert completion))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4735 (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
4736 ;; 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
4737 (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
4738 t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4739 ((or (eq completion t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4740 (and (equal dpart dcompletion)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4741 (= 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
4742 (idlwave-uniquify
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4743 (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
4744 ;; This is already complete
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4745 (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
4746 (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
4747 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4748 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4749 ;; 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
4750 (message "Making completion list...")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4751 (let* ((list all-completions)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4752 (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
4753 (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
4754 (completion-fixup-function ; Emacs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4755 (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
4756 (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
4757 (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
4758 (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
4759 (if prepare-display-function
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4760 (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
4761 (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
4762 (or (not (string= part ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4763 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
4764 (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
4765 (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
4766 (if (listp x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4767 (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
4768 (setq x (downcase x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4769 x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4770 list)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4771 (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
4772 t))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4773
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4774 (defun idlwave-complete-class ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4775 "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
4776 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4777 ;; 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
4778 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4779 ;; Now do the completion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4780 (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
4781 "Select a class" "class"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4782
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4783
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4784 (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
4785 ;; 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
4786 ;; 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
4787 ;; 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
4788 (catch 'exit
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4789 (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
4790 (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
4791 (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
4792 ;; 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
4793 (throw 'exit list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4794
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4795 ;; 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
4796 ;; 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
4797 ;; buffer.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4798 (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
4799 (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
4800 (do-dots (featurep 'xemacs))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4801 (max (abs show-classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4802 (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
4803 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
4804 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4805 (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4806 ;; get the classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4807 (setq classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4808 (if is-kwd
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4809 (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
4810 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
4811 (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
4812 (setq nclasses (length classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4813 ;; 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
4814 (if do-dots
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4815 (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
4816 (setq space " "))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4817 (if do-buf
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4818 ;; 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
4819 (if (<= nclasses max)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4820 (setq class-info (concat
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4821 space
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4822 "<" (mapconcat 'identity classes ",") ">"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4823 (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
4824 (setq class-info nil))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4825 (when do-prop
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4826 ;; We do want properties
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4827 (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
4828 (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
4829 '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
4830 x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4831 (if class-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4832 (list x class-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4833 x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4834 list))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4835
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4836 (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
4837 ;; 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
4838 (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
4839 (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
4840 ;; 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
4841 (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
4842
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4843 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4844 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4845 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4846 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4847 ;;----------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4848
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4849 (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
4850 "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
4851 (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
4852 (win (selected-window)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4853 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4854 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4855 (select-window cwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4856 (condition-case nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4857 (scroll-up)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4858 (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
4859 (nth 2 last-command))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4860 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4861 (select-window win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4862 (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
4863 (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
4864 (and message (message message)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4865 (select-window win))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4866
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4867 (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
4868 "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
4869 (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
4870 (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
4871 (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
4872 (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
4873
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4874 (if (featurep 'xemacs)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4875 (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
4876 (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
4877
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4878 ;; 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
4879 ;; 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
4880 (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
4881
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4882 ;; 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
4883 (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
4884
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4885 ;; Fontify the classes
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4886 (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
4887 (consp (car list)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4888 (idlwave-completion-fontify-classes))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4889
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4890 ;; Display the message
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4891 (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
4892
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4893 (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
4894 "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
4895 (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
4896 (apply function args))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4897 (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
4898
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4899 (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
4900 "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
4901 (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
4902 idlwave-before-completion-wconf
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4903 (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
4904
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4905 (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
4906 "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
4907 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4908 (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
4909 (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
4910
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4911 (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
4912 "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
4913 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4914 (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
4915 (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
4916 (symbol-value var))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4917
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4918 ;; 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
4919
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4920 (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
4921 (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
4922 (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
4923 'idlwave-default-choose-completion)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4924
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4925 (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
4926 "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
4927 (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
4928
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4929 ;; 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
4930 ;; 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
4931
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4932 (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
4933 "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
4934
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4935 (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
4936 "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
4937 (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
4938 (display-completion-list list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4939 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4940 (set-buffer "*Completions*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4941 (use-local-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4942 (or idlwave-completion-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4943 (setq idlwave-completion-map
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4944 (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
4945
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4946 (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
4947 "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
4948 (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
4949 (substitute-key-definition
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4950 '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
4951 (substitute-key-definition
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4952 '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
4953 new-map))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4954
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4955 (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
4956 "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
4957 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4958 (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
4959
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4960 (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
4961 "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
4962 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4963 (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
4964
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 ;;----------------------------------------------------------------------
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-completion-fontify-classes ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4969 "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
4970 (when (featurep 'font-lock)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4971 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4972 (set-buffer "*Completions*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4973 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4974 (goto-char (point-min))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4975 (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
4976 (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
4977 '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
4978
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4979 (defun idlwave-uniquify (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4980 (let (nlist)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4981 (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
4982 (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
4983 nlist))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4984
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4985 (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
4986 "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
4987 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
4988 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4989 ((eq type 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4990 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4991 ((eq type 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4992 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4993 ((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
4994 ((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
4995 (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
4996 (insert "("))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4997 ((equal idlwave-function-completion-adds-paren 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4998 (insert "()")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
4999 (backward-char 1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5000 (t nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5001 ((eq type 'keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5002 (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
5003 (not slash))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5004 (progn (insert "=") t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5005 nil)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5006
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5007 ;; 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
5008
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5009 (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
5010 (and
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5011 (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
5012 (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
5013 "*Completions*") ; cib-buffer
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5014 (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
5015 (current-buffer)) ; buffer OK
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5016 (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
5017 verify))) ; pos OK
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5018 (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
5019 (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
5020 (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
5021
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5022 (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
5023 "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
5024 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
5025 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
5026 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5027 (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
5028
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5029 (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
5030 "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
5031 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
5032 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
5033 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
5034 query.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5035
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5036 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
5037 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
5038 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
5039
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5040 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5041 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5042 (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
5043 (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
5044 (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
5045 ;; 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
5046 (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
5047 ;; arrow has class property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5048 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5049 ;; Remove property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5050 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5051 (backward-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5052 (when (looking-at ".?\\(->\\)")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5053 (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
5054 '(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
5055 (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
5056 ;; Echo class property
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5057 (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
5058 (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
5059 ;; No property found
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5060 (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
5061
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5062 ;; Not on an arrow...
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5063 (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
5064 (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
5065 (module (idlwave-what-module)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5066 (cond ((car module)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5067 (if external
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5068 (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
5069 (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
5070 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5071 (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
5072
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5073 (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
5074 "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
5075 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
5076 ;; 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
5077 ;; 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
5078 ;; 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
5079 ;; cannot enter a space.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5080 (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
5081
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5082 ;; 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
5083 (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
5084 (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
5085 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
5086 (nth 6 (idlwave-rinfo-assq
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5087 name type class idlwave-routines)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5088
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5089 ;; 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
5090 (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
5091 (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
5092 ;; 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
5093 (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
5094 (file-exists-p book))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5095 (setq full ",/FULL_PATH")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5096 (setq full ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5097
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5098 ;; 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
5099 ;; 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
5100 ;; the book name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5101 ;; (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
5102 ;; (class " method")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5103 ;; ((eq type 'pro) " procedure")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5104 ;; ((eq type 'fun) " function")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5105 ;; (t "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5106 (setq extra "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5107
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5108 ;; 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
5109 (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
5110 (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
5111 ;; 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
5112 (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
5113 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
5114 ; 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
5115 (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
5116 (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
5117
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5118 (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
5119 "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
5120 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
5121 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
5122 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
5123 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
5124 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
5125 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
5126 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5127 (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
5128 (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
5129 (module (idlwave-what-module))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5130 (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
5131 (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
5132 (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
5133 (kwd "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5134 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5135 (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
5136 resolve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5137 (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
5138 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
5139 (match-string 3 resolve)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5140 nil)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5141 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
5142 (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
5143 (setq kwd ",/is_function"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5144
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5145 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5146 ((null class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5147 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5148 (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
5149 'idlwave-update-routine-info
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5150 nil t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5151 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5152 (idlwave-shell-send-command
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5153 (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
5154 (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
5155 (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
5156 (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
5157 '(idlwave-update-routine-info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5158 nil t))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5159
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5160 (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
5161 "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
5162 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
5163 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
5164 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
5165 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5166 (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
5167 (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
5168 (module (idlwave-what-module))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5169 (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
5170 (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
5171 (list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5172 (delq nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5173 (mapcar (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5174 (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
5175 ;; 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
5176 nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5177 (cons
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5178 (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
5179 (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
5180 (cdr x))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5181 (idlwave-routines))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5182 (name (idlwave-completing-read
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5183 (format "Module (Default %s): "
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5184 (if default default "none"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5185 list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5186 type class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5187 (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
5188 ;; Nothing, use the default.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5189 (setq name default))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5190 (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
5191 (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
5192 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
5193 (if (string-match "\\(.*\\)::\\(.*\\)" name)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5194 (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
5195 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
5196 (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
5197 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
5198 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
5199 ((equal type "p") 'pro)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5200 (t t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5201 (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
5202
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5203 (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
5204 (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
5205 source buf1 entry
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5206 (buf (current-buffer))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5207 (pos (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5208 (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
5209 source (nth 3 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5210 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5211 ((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
5212 (error "Abort"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5213 ((null entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5214 (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
5215 ((eq (car source) 'system)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5216 (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
5217 name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5218 ((equal (cdr source) "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5219 (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
5220 name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5221 ((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
5222 (setq buf1
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5223 (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
5224 (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
5225 (or (cdr source)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5226 (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
5227 (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
5228 (pop-to-buffer buf1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5229 (goto-char 1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5230 (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
5231 (if (re-search-forward
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5232 (concat "^[ \t]*\\<"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5233 (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
5234 ((equal type "p") "pro")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5235 (t "\\(pro\\|function\\)"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5236 "\\>[ \t]+"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5237 (regexp-quote (downcase name1))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5238 "[^a-zA-Z0-9_$]")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5239 nil t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5240 (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
5241 (pop-to-buffer buf)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5242 (goto-char pos)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5243 (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
5244
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5245 (defun idlwave-what-module ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5246 "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
5247 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
5248 (idlwave-routines)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5249 (let* ((where (idlwave-where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5250 (cw (nth 2 where))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5251 (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
5252 (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
5253 (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
5254 (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
5255 (following-char)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5256 )
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5257 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5258 ((and (eq cw 'procedure)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5259 (not (equal this-word "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5260 (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
5261 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
5262 (list this-word 'pro
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5263 (idlwave-determine-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5264 (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
5265 'pro)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5266 ((and (eq cw 'function)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5267 (not (equal this-word ""))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5268 (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
5269 (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
5270 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
5271 (list this-word 'fun
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5272 (idlwave-determine-class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5273 (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
5274 'fun)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5275 (func
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5276 (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
5277 (pro
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5278 (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
5279 (t nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5280
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5281 (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
5282 ;; 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
5283 (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
5284 name1 type1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5285
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5286 ;; 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
5287 ;; 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
5288 (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
5289 (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
5290 (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
5291 (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
5292 (case-fold-search t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5293 class)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5294 (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
5295 string)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5296 (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
5297 (setq keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5298 (append keywords
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5299 (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
5300 (idlwave-sintern-method "INIT")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5301 'fun
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5302 class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5303 (idlwave-routines))))))))
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 ;; 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
5306 (when (eq class t)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5307 (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
5308 (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
5309 (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
5310 (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
5311 (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
5312 (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
5313 (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
5314 (nth 5 x))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5315 (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
5316 ;; Return the final list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5317 keywords))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5318
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5319 (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
5320 (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
5321 (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
5322 'idlwave-mouse-active-rinfo)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5323 (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
5324 (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
5325 '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
5326 (defvar idlwave-popup-source)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5327
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5328 (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
5329 ;; 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
5330 (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
5331 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
5332 (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
5333 (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
5334 (source (nth 3 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5335 ;;(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
5336 (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
5337 (keywords (nth 5 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5338 (olh (nth 6 entry))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5339 (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
5340 (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
5341 (col 0)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5342 (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
5343 (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
5344 beg props win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5345 (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
5346 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5347 ((null entry)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5348 (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
5349 ((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
5350 (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
5351 ((null calling-seq)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5352 (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
5353 (t
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5354 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5355 (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
5356 (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
5357 (erase-buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5358 (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
5359 (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
5360 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
5361 'help-echo help-echo23
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5362 'data (cons 'usage data)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5363 (insert "Usage: ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5364 (setq beg (point))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5365 (insert (if class
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5366 (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
5367 (format calling-seq name))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5368 "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5369 (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
5370
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5371 (insert "Keywords:")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5372 (if (null keywords)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5373 (insert " No keywords accepted.")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5374 (setq col 9)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5375 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5376 (lambda (x)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5377 (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
5378 (window-width))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5379 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5380 (insert "\n ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5381 (setq col 9)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5382 (insert " ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5383 (setq beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5384 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
5385 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
5386 'data (cons 'keyword data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5387 'help-echo help-echo3
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5388 'keyword (car x)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5389 (insert (car x))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5390 (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
5391 (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
5392 keywords))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5393 (insert "\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5394
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5395 (insert "Origin: ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5396 (setq beg (point)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5397 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
5398 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
5399 'help-echo help-echo23
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5400 'data (cons 'origin data)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5401 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5402 ((eq (car source) 'system)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5403 (insert "system routine"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5404 ((equal source '(lib))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5405 (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
5406 ((eq (car source) 'lib)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5407 (insert "library file ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5408 (insert (cdr source)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5409 ((eq (car source) 'buffer)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5410 (insert "buffer visiting ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5411 (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
5412 ((eq (car source) 'compiled)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5413 (insert "compiled from ")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5414 (insert (cdr source))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5415 (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
5416 (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
5417 (display-buffer "*Help*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5418 (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
5419 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
5420 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5421 (let ((ww (selected-window)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5422 (unwind-protect
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5423 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5424 (select-window win)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5425 (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
5426 (window-height)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5427 (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
5428 (select-window ww)))))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5429
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5430 (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
5431 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5432 (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
5433
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5434 (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
5435 (interactive "e")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5436 (mouse-set-point ev)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5437 (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
5438 (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
5439 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
5440 id (car data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5441 name (nth 1 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5442 type (nth 2 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5443 class (nth 3 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5444 buf (nth 4 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5445 olh (nth 5 data)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5446 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
5447 (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
5448 (if right
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5449 (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
5450 (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
5451 (if idlwave-popup-source
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5452 (condition-case err
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5453 (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
5454 (error
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5455 (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
5456 (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
5457 (error (nth 1 err))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5458 (if bufwin
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5459 (select-window bufwin)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5460 (pop-to-buffer buf)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5461 ((eq id 'keyword)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5462 (if right
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5463 (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
5464 (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
5465
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5466 ;; ----------------------------------------------------------------------------
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5467 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5468 ;; 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
5469 ;; (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
5470 ;;
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5471
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5472 (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
5473 "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
5474 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
5475 (save-match-data
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5476 (cond
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5477 ((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
5478 ;; ((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
5479 (t nil))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5480
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5481 (defun idlwave-unit-name ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5482 "Return the unit name.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5483 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
5484 `idlwave-prev-index-position'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5485 (forward-sexp 2)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5486 (forward-sexp -1)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5487 (let ((begin (point)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5488 (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
5489 (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
5490 (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
5491 (buffer-substring begin (point)))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5492
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5493 (defun idlwave-function-menu ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5494 "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
5495 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5496 (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
5497 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5498 (require 'func-menu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5499 (function-menu))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5500 (require 'imenu)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5501 (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
5502
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5503 ;; 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
5504 ;; 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
5505 ;; 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
5506 (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
5507 (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
5508 '(progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5509 (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
5510 (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
5511 (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
5512 (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
5513 fume-function-name-regexp-alist)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5514 (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
5515 (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
5516 (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
5517 (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
5518 fume-find-function-name-method-alist))))))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5519
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5520 (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
5521 "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
5522 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5523 (start-process "idldeclient" nil
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5524 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
5525 (buffer-file-name) "&"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5526
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5527 (defun idlwave-launch-idlhelp ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5528 "Start the IDLhelp application."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5529 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5530 (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
5531
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5532 ;; Menus - using easymenu.el
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5533 (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
5534 `("IDLWAVE"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5535 ["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
5536 ("Motion"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5537 ["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
5538 ["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
5539 ["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
5540 ["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
5541 ["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
5542 ["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
5543 ["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
5544 ["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
5545 ("Mark"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5546 ["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
5547 ["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
5548 ["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
5549 ("Format"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5550 ["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
5551 ["(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
5552 ["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
5553 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5554 ["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
5555 :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
5556 ("Templates"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5557 ["Procedure" idlwave-procedure t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5558 ["Function" idlwave-function t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5559 ["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
5560 ["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
5561 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5562 ["Case" idlwave-case t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5563 ["For" idlwave-for t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5564 ["Repeat" idlwave-repeat t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5565 ["While" idlwave-while t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5566 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5567 ["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
5568 ("Completion / RInfo"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5569 ["Complete" idlwave-complete t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5570 ("Complete Special"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5571 ["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
5572 ["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
5573 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5574 ["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
5575 ["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
5576 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5577 ["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
5578 ["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
5579 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5580 ["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
5581 ["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
5582 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5583 ["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
5584 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5585 ["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
5586 ["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
5587 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5588 ["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
5589 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5590 ["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
5591 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5592 "IDL Library Routine Info"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5593 ["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
5594 ["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
5595 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5596 ("External"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5597 ["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
5598 ["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
5599 ["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
5600 ["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
5601 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5602 ("Customize"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5603 ["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
5604 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5605 ["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
5606 (fboundp 'customize-menu-create)])
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5607 ("Documentation"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5608 ["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
5609 ["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
5610 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5611 ["Commentary in idlwave.el" idlwave-show-commentary t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5612 ["Commentary in idlwave-shell.el" idlwave-shell-show-commentary t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5613 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5614 ["Info" idlwave-info t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5615 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5616 ["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
5617
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5618 (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
5619 '("Debug"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5620 ["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
5621 ["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
5622 (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
5623 idlwave-shell-automatic-start)]))
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 (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
5626 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5627 (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
5628 "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
5629 idlwave-mode-menu-def)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5630 (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
5631 "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
5632 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
5633
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5634 (defun idlwave-customize ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5635 "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
5636 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5637 ;; 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
5638 ;; as well.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5639 (or (featurep 'idlwave-shell)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5640 (load "idlwave-shell" t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5641 (customize-browse 'idlwave))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5642
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5643 (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
5644 "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
5645 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5646 (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
5647 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5648 ;; 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
5649 ;; as well.
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5650 (or (featurep 'idlwave-shell)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5651 (load "idlwave-shell" t))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5652 (easy-menu-change
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5653 '("IDLWAVE") "Customize"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5654 `(["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
5655 "--"
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5656 ,(customize-menu-create 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5657 ["Set" Custom-set t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5658 ["Save" Custom-save t]
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5659 ["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
5660 ["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
5661 ["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
5662 (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
5663 (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
5664
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5665 (defun idlwave-show-commentary ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5666 "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
5667 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5668 (require 'finder)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5669 (finder-commentary "idlwave.el"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5670
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5671 (defun idlwave-shell-show-commentary ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5672 "Use the finder to view the file documentation from `idlwave-shell.el'."
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5673 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5674 (require 'finder)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5675 (finder-commentary "idlwave-shell.el"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5676
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5677 (defun idlwave-info ()
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5678 "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
5679 (interactive)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5680 (require 'info)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5681 (Info-goto-node "(idlwave)"))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5682
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5683 (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
5684 "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
5685 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
5686 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
5687
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5688 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
5689 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
5690 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
5691
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5692 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
5693
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5694 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
5695
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5696 (interactive "P")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5697 (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
5698 abbrevs
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5699 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
5700 (mapatoms
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5701 (lambda (sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5702 (if (symbol-value sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5703 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5704 (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
5705 rpl (symbol-value sym)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5706 func (symbol-function sym))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5707 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5708 (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
5709 (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
5710 (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
5711 func "")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5712 (setq func "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5713 (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
5714 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5715 (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
5716 (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
5717 (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
5718 table)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5719 ;; sort the list
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5720 (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
5721 ;; Make the format
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5722 (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
5723 (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
5724 (if arg
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5725 (progn
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5726 (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
5727 (princ "=========================================\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5728 (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
5729 (princ (format fmt "---" "-------" "----")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5730 (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
5731 (princ "================================================\n\n")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5732 (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
5733 (princ (format fmt "---" "------" "")))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5734 (mapcar
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5735 (lambda (list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5736 (setq str (car list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5737 rpl (nth 1 list)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5738 func (nth 2 list))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5739 (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
5740 abbrevs)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5741 ;; 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
5742 (save-excursion
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5743 (set-buffer "*Help*")
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5744 (setq truncate-lines t)))
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5745
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5746 (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
5747
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5748 (provide 'idlwave)
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5749
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5750 ;;; idlwave.el ends here
67b3331ff24c Major mode for editing files of the Interactive Data Language
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
5751