forked from jdtsmith/idlwave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidlw-menus.el
260 lines (239 loc) · 9.07 KB
/
idlw-menus.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
;; IDLWAVE menus and associated code
;; Define - using easymenu.el
(defvar idlwave-mode-menu)
(defvar idlwave-mode-debug-menu)
(defalias 'idlwave-function-menu
(condition-case nil
(progn
(require 'imenu)
'imenu)
(error nil)))
(defvar idlwave-mode-menu-def
`("IDLWAVE"
["PRO/FUNC menu" idlwave-function-menu t]
("Motion"
["Subprogram Start" idlwave-beginning-of-subprogram t]
["Subprogram End" idlwave-end-of-subprogram t]
["Block Start" idlwave-beginning-of-block t]
["Block End" idlwave-end-of-block t]
["Up Block" idlwave-backward-up-block t]
["Down Block" idlwave-down-block t]
["Skip Block Backward" idlwave-backward-block t]
["Skip Block Forward" idlwave-forward-block t])
("Mark"
["Subprogram" idlwave-mark-subprogram t]
["Block" idlwave-mark-block t]
["Header" idlwave-mark-doclib t])
("Format"
["Indent Entire Statement" idlwave-indent-statement
:active t :keys "C-u \\[indent-for-tab-command]" ]
["Indent Subprogram" idlwave-indent-subprogram t]
["(Un)Comment Region" idlwave-toggle-comment-region t]
["Continue/Split line" idlwave-split-line t]
"--"
["Toggle Auto Fill" idlwave-auto-fill-mode :style toggle
:selected (symbol-value idlwave-fill-function)])
("Templates"
["Procedure" idlwave-procedure t]
["Function" idlwave-function t]
["Doc Header" idlwave-doc-header t]
["Log" idlwave-doc-modification t]
"--"
["Case" idlwave-case t]
["For" idlwave-for t]
["Repeat" idlwave-repeat t]
["While" idlwave-while t]
"--"
["Close Block" idlwave-close-block t])
("Completion"
["Complete" idlwave-complete t]
("Complete Specific"
["1 Procedure Name" (idlwave-complete 'procedure) t]
["2 Procedure Keyword" (idlwave-complete 'procedure-keyword) t]
"--"
["3 Function Name" (idlwave-complete 'function) t]
["4 Function Keyword" (idlwave-complete 'function-keyword) t]
"--"
["5 Procedure Method Name" (idlwave-complete 'procedure-method) t]
["6 Procedure Method Keyword" (idlwave-complete 'procedure-method-keyword) t]
"--"
["7 Function Method Name" (idlwave-complete 'function-method) t]
["8 Function Method Keyword" (idlwave-complete 'function-method-keyword) t]
"--"
["9 Class Name" idlwave-complete-class t]))
("Routine Info"
["Show Routine Info" idlwave-routine-info t]
["Online Context Help" idlwave-context-help t]
"--"
["Find Routine Source" idlwave-find-module t]
["Resolve Routine" idlwave-resolve (featurep 'idlw-shell)]
"--"
["Update Routine Info" idlwave-update-routine-info t]
["Rescan XML Help Catalog" idlwave-rescan-xml-routine-info t]
"--"
"IDL User Catalog"
["Select Catalog Directories" (idlwave-create-user-catalog-file nil) t]
["Scan Directories" (idlwave-update-routine-info '(16))
(and idlwave-path-alist (not idlwave-catalog-process))]
["Scan Directories &" (idlwave-update-routine-info '(64))
(and idlwave-path-alist (not idlwave-catalog-process))]
"--"
"Routine Shadows"
["Check Current Buffer" idlwave-list-buffer-load-path-shadows t]
["Check Compiled Routines" idlwave-list-shell-load-path-shadows t]
["Check Everything" idlwave-list-all-load-path-shadows t])
("Misc"
["Kill auto-created buffers" idlwave-kill-autoloaded-buffers t]
"--"
["Insert TAB character" idlwave-hard-tab t])
"--"
("External"
["Start IDL shell" idlwave-shell t]
["Edit file in IDLDE" idlwave-edit-in-idlde t])
"--"
("Customize"
["Browse IDLWAVE Group" idlwave-customize t]
"--"
["Build Full Customize Menu" idlwave-create-customize-menu
(fboundp 'customize-menu-create)])
("Documentation"
["Describe Mode" describe-mode t]
["Abbreviation List" idlwave-list-abbrevs t]
"--"
["Commentary in idlwave.el" idlwave-show-commentary t]
["Commentary in idlw-shell.el" idlwave-shell-show-commentary t]
"--"
["Info" idlwave-info t]
"--"
["Help with Topic" idlwave-help-with-topic t]
["Launch IDL Help" idlwave-launch-idlhelp t])))
(defvar idlwave-mode-debug-menu-def
'("Debug"
["Start IDL shell" idlwave-shell t]
["Save and .RUN buffer" idlwave-shell-save-and-run
(and (boundp 'idlwave-shell-automatic-start)
idlwave-shell-automatic-start)]))
(if (or (featurep 'easymenu) (load "easymenu" t))
(progn
(easy-menu-define idlwave-mode-menu idlwave-mode-map
"IDL and WAVE CL editing menu"
idlwave-mode-menu-def)
(easy-menu-define idlwave-mode-debug-menu idlwave-mode-map
"IDL and WAVE CL editing menu"
idlwave-mode-debug-menu-def)))
;;----------------------------------------------------
;; IDLWAVE menu and support functions
(defun idlwave-customize ()
"Call the customize function with `idlwave' as argument."
(interactive)
;; Try to load the code for the shell, so that we can customize it
;; as well.
(or (featurep 'idlw-shell)
(load "idlw-shell" t))
(customize-browse 'idlwave))
(defun idlwave-create-customize-menu ()
"Create a full customization menu for IDLWAVE, insert it into the menu."
(interactive)
(if (fboundp 'customize-menu-create)
(progn
;; Try to load the code for the shell, so that we can customize it
;; as well.
(or (featurep 'idlw-shell)
(load "idlw-shell" t))
(easy-menu-change
'("IDLWAVE") "Customize"
`(["Browse IDLWAVE group" idlwave-customize t]
"--"
,(customize-menu-create 'idlwave)
["Set" Custom-set t]
["Save" Custom-save t]
["Reset to Current" Custom-reset-current t]
["Reset to Saved" Custom-reset-saved t]
["Reset to Standard Settings" Custom-reset-standard t]))
(message "\"IDLWAVE\"-menu now contains full customization menu"))
(error "Cannot expand menu (outdated version of cus-edit.el)")))
(defun idlwave-show-commentary ()
"Use the finder to view the file documentation from `idlwave.el'."
(interactive)
(finder-commentary "idlwave.el"))
(defun idlwave-shell-show-commentary ()
"Use the finder to view the file documentation from `idlw-shell.el'."
(interactive)
(finder-commentary "idlw-shell.el"))
(defun idlwave-info ()
"Read documentation for IDLWAVE in the info system."
(interactive)
(info "idlwave"))
(defun idlwave-list-abbrevs (arg)
"Show the code abbreviations define in IDLWAVE mode.
This lists all abbrevs where the replacement text differs from the input text.
These are the ones the users want to learn to speed up their writing.
The function does *not* list abbrevs which replace a word with itself
to call a hook. These hooks are used to change the case of words or
to blink the matching `begin', and the user does not need to know them.
With arg, list all abbrevs with the corresponding hook.
This function was written since `list-abbrevs' looks terrible for IDLWAVE mode."
(interactive "P")
(let ((table (symbol-value 'idlwave-mode-abbrev-table))
abbrevs
str rpl func fmt (len-str 0) (len-rpl 0))
(mapatoms
(lambda (sym)
(if (symbol-value sym)
(progn
(setq str (symbol-name sym)
rpl (symbol-value sym)
func (symbol-function sym))
(if arg
(setq func (prin1-to-string func))
(if (and (listp func) (stringp (nth 2 func)))
(setq rpl (concat "EVAL: " (nth 2 func))
func "")
(setq func "")))
(if (or arg (not (string= rpl str)))
(progn
(setq len-str (max len-str (length str)))
(setq len-rpl (max len-rpl (length rpl)))
(setq abbrevs (cons (list str rpl func) abbrevs)))))))
table)
;; sort the list
(setq abbrevs (sort abbrevs (lambda (a b) (string< (car a) (car b)))))
;; Make the format
(setq fmt (format "%%-%ds %%-%ds %%s\n" len-str len-rpl))
(with-output-to-temp-buffer "*Help*"
(if arg
(progn
(princ "Abbreviations and Actions in IDLWAVE-Mode\n")
(princ "=========================================\n\n")
(princ (format fmt "KEY" "REPLACE" "HOOK"))
(princ (format fmt "---" "-------" "----")))
(princ "Code Abbreviations and Templates in IDLWAVE-Mode\n")
(princ "================================================\n\n")
(princ (format fmt "KEY" "ACTION" ""))
(princ (format fmt "---" "------" "")))
(mapcar
(lambda (list)
(setq str (car list)
rpl (nth 1 list)
func (nth 2 list))
(princ (format fmt str rpl func)))
abbrevs)))
;; Make sure each abbreviation uses only one display line
(with-current-buffer "*Help*"
(setq truncate-lines t)))
;;----------------------------------------------------
;; IDLWAVE help menus
;; Define the key bindings for the Help application
;; Define the menu for the Help application
(easy-menu-define
idlwave-help-menu idlwave-help-mode-map
"Menu for Help IDLWAVE system"
'("IDLHelp"
["Definition <-> Help Text" idlwave-help-toggle-header-match-and-def t]
["Find DocLib Header" idlwave-help-find-header t]
["Find First DocLib Header" idlwave-help-find-first-header t]
["Fontify help buffer" idlwave-help-fontify t]
"--"
["Quit" idlwave-help-quit t]))
(provide 'idlw-menus)
(provide 'idlwave-menus)