ESS[SAS]: somebody forgot about the SUM statement (probably me)
[ess.git] / lisp / ess-menu.el
blobbc677eb5dc8dc9bf2d079eaef02ca43444dccfdc
1 ;;; ess-menu.el --- Menu and Speedbar support for statistical
2 ;;; programming and analysis
4 ;; Copyright (C) 2000--2005 A.J. Rossini, Rich M. Heiberger, Martin
5 ;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
7 ;; Original Author: A.J. Rossini
8 ;; Created: September 4, 2000
9 ;; Maintainer: ESS Core Team <ESS-core@stat.math.ethz.ch>
11 ;; Keywords: statistical support
13 ;; Summary: general functions for ESS
15 ;; This file is part of ESS
17 ;; This file is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by
19 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; any later version.
22 ;; This file is distributed in the hope that it will be useful,
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;; GNU General Public License for more details.
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with GNU Emacs; see the file COPYING. If not, write to
29 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
32 ;;; Commentary:
34 ;;; Code:
36 \f;;*;; Requires and autoloads
37 ;;;=====================================================
39 (require 'ess-cust)
40 (if (and (featurep 'xemacs); need this, since require in XEmacs has only 2 arg
41 (not (require 'imenu "imenu.elc")))
42 (message "** warning: 'imenu not available for this version of XEmacs"))
44 ;;(defgroup ess-menu nil
45 ;; "ESS: object menu systems."
46 ;; :group 'ess
47 ;; :prefix "ess-")
50 \f ;;; Function Menu (func-menu) for XEmacs:
52 ;; (if ess-funcmenu-use-p
53 ;; (defvar fume-function-name-regexp-S
54 ;; (append
55 ;; '((s-mode . fume-function-name-regexp-smode)
56 ;; (r-mode . fume-function-name-regexp-smode))
57 ;; fume-function-name-regexp-alist)
58 ;; "Expression to get function names"))
60 \f ;;; Imenu for Emacs/XEmacs...
62 ;;; S imenu support
64 (defcustom ess-imenu-use-S ess-imenu-use-p
65 "*Non-nil means include an Imenu menu item in S buffers."
66 :group 'ess
67 :type 'boolean)
69 (defvar ess-imenu-S-generic-expression
70 '(("Functions" "^\\(.+\\)\\s-*<-[ \t\n]*function[ ]*(" 1)
71 ("Classes" "^.*setClass(\\(.*\\)," 1)
72 ("Coercions" "^.*setAs(\\([^,]+,[^,]*\\)," 1) ; show from and to
73 ("Generics" "^.*setGeneric(\\([^,]*\\)," 1)
74 ("Methods" "^.*set\\(Group\\|Replace\\)?Method(\"\\(.+\\)\"," 2)
75 ;;[ ]*\\(signature=\\)?(\\(.*,?\\)*\\)," 1)
77 ;;("Other" "^\\(.+\\)\\s-*<-[ \t\n]*[^\\(function\\|read\\|.*data\.frame\\)]" 1)
78 ("Package" "^.*\\(library\\|require\\)(\\(.*\\)," 2)
79 ("Data" "^\\(.+\\)\\s-*<-[ \t\n]*\\(read\\|.*data\.frame\\).*(" 1)))
81 (defun ess-imenu-S (&optional arg)
82 "S Language Imenu support for ESS."
83 (interactive)
84 (setq imenu-generic-expression ess-imenu-S-generic-expression)
85 (imenu-add-to-menubar "Imenu-S"))
87 (fset 'ess-imenu-R 'ess-imenu-S)
89 ;;; XLS imenu support
91 ;(defun ess-imenu-XLS (&optional arg)
92 ; "XLispStat Language Imenu support for ESS."
93 ; (interactive)
94 ; (setq imenu-generic-expression
95 ; '( (nil "New one needed" 1)))
96 ; (imenu-add-to-menubar "XLS-fcts"))
98 ;(defun imenu-example--XLS-extract-index-name ()
99 ; ;; Example of a candidate for `imenu-extract-index-name-function'.
100 ; ;; This will generate a flat index of definitions in a lisp file.
101 ; (save-match-data
102 ; (and (looking-at "(def")
103 ; (condition-case nil
104 ; (progn
105 ; (down-list 1)
106 ; (forward-sexp 2)
107 ; (let ((beg (point))
108 ; (end (progn (forward-sexp -1) (point))))
109 ; (buffer-substring beg end)))
110 ; (error nil)))))
112 ;(defun imenu-example--create-XLS-index ()
113 ; ;; Example of a candidate for `imenu-create-index-function'.
114 ; ;; It will generate a nested index of definitions.
115 ; (let ((index-alist '())
116 ; (index-var-alist '())
117 ; (index-type-alist '())
118 ; (index-unknown-alist '())
119 ; prev-pos)
120 ; (goto-char (point-max))
121 ; (imenu-progress-message prev-pos 0)
122 ; ;; Search for the function
123 ; (while (beginning-of-defun)
124 ; (imenu-progress-message prev-pos nil t)
125 ; (save-match-data
126 ; (and (looking-at "(def")
127 ; (save-excursion
128 ; (down-list 1)
129 ; (cond
130 ; ((looking-at "def\\(var\\|const\\)")
131 ; (forward-sexp 2)
132 ; (push (imenu-example--name-and-position)
133 ; index-var-alist))
134 ; ((looking-at "def\\(un\\|subst\\|macro\\|advice\\)")
135 ; (forward-sexp 2)
136 ; (push (imenu-example--name-and-position)
137 ; index-alist))
138 ; ((looking-at "def\\(type\\|struct\\|class\\|ine-condition\\)")
139 ; (forward-sexp 2)
140 ; (if (= (char-after (1- (point))) ?\))
141 ; (progn
142 ; (forward-sexp -1)
143 ; (down-list 1)
144 ; (forward-sexp 1)))
145 ; (push (imenu-example--name-and-position)
146 ; index-type-alist))
147 ; (t
148 ; (forward-sexp 2)
149 ; (push (imenu-example--name-and-position)
150 ; index-unknown-alist)))))))
151 ; (imenu-progress-message prev-pos 100)
152 ; (and index-var-alist
153 ; (push (cons "Variables" index-var-alist)
154 ; index-alist))
155 ; (and index-type-alist
156 ; (push (cons "Types" index-type-alist)
157 ; index-alist))
158 ; (and index-unknown-alist
159 ; (push (cons "Syntax-unknown" index-unknown-alist)
160 ; index-alist))
161 ; index-alist))
163 ;(defun ess-imenu-STA (&optional arg)
164 ; "Stata Language Imenu support for ESS."
165 ; (interactive)
166 ; (setq imenu-generic-expression
167 ; '( (nil "New one needed" 1)))
168 ; (imenu-add-to-menubar "Stata-fcts"))
170 (defun ess-imenu-SAS (&optional arg)
171 "SAS language Imenu support for ESS."
172 (interactive)
173 (setq imenu-generic-expression
174 '( (nil "[ \t\n=]\\([a-zA-Z_][a-zA-Z_0-9]*[.][a-zA-Z_][a-zA-Z_0-9]*\\)[ ,()\t\n;]" 1)))
175 (imenu-add-to-menubar "SAS Datasets"))
177 \f ;;; Speedbar stuff.
179 (defun ess-S-initialize-speedbar ()
180 "Extend to all extensions; see initialization, and edit."
181 (speedbar-add-supported-extension ".R")
182 (speedbar-add-supported-extension ".S")
183 (speedbar-add-supported-extension ".s")
184 (speedbar-add-supported-extension ".q"))
186 ;(if (featurep 'speedbar)
187 ; (progn
188 ; (message "enabling speedbar support")
189 ; (require 'speedbar)
190 ; (ess-S-initialize-speedbar)))
192 (eval-when-compile
193 (condition-case nil
194 (progn
195 (require 'speedbar)
196 (when (featurep 'speedbar)
197 (message "enabling speedbar support")
199 (defun S-speedbar-buttons (buffer)
200 "attempted hack."
202 ;;(speedbar-make-tag-line)
203 ;;(speedbar-insert-button)
204 (speedbar-with-writable))
206 (fset 'R-speedbar-buttons 'S-speedbar-buttons)
208 (defun S-speedbar-menu-items ( )
209 "Need to write.")
211 (ess-S-initialize-speedbar)))
212 (error nil)))
214 \f ; Run load hook and provide package
216 (provide 'ess-menu)
218 \f ; Local variables section
220 ;;; This file is automatically placed in Outline minor mode.
221 ;;; The file is structured as follows:
222 ;;; Chapters: ^L ;
223 ;;; Sections: ;;*;;
224 ;;; Subsections: ;;;*;;;
225 ;;; Components: defuns, defvars, defconsts
226 ;;; Random code beginning with a ;;;;* comment
228 ;;; Local variables:
229 ;;; mode: emacs-lisp
230 ;;; mode: outline-minor
231 ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
232 ;;; End:
234 ;;; ess-menu.el ends here