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)
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.
36 \f;;*;; Requires and autoloads
37 ;;;=====================================================
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."
50 \f ;;; Function Menu (func-menu) for XEmacs:
52 ;; (if ess-funcmenu-use-p
53 ;; (defvar fume-function-name-regexp-S
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...
64 (defcustom ess-imenu-use-S ess-imenu-use-p
65 "*Non-nil means include an Imenu menu item in S buffers."
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."
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
)
91 ;(defun ess-imenu-XLS (&optional arg)
92 ; "XLispStat Language Imenu support for ESS."
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.
102 ; (and (looking-at "(def")
103 ; (condition-case nil
107 ; (let ((beg (point))
108 ; (end (progn (forward-sexp -1) (point))))
109 ; (buffer-substring beg end)))
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 '())
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)
126 ; (and (looking-at "(def")
130 ; ((looking-at "def\\(var\\|const\\)")
132 ; (push (imenu-example--name-and-position)
134 ; ((looking-at "def\\(un\\|subst\\|macro\\|advice\\)")
136 ; (push (imenu-example--name-and-position)
138 ; ((looking-at "def\\(type\\|struct\\|class\\|ine-condition\\)")
140 ; (if (= (char-after (1- (point))) ?\))
145 ; (push (imenu-example--name-and-position)
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)
155 ; (and index-type-alist
156 ; (push (cons "Types" index-type-alist)
158 ; (and index-unknown-alist
159 ; (push (cons "Syntax-unknown" index-unknown-alist)
163 ;(defun ess-imenu-STA (&optional arg)
164 ; "Stata Language Imenu support for ESS."
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."
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)
188 ; (message "enabling speedbar support")
189 ; (require 'speedbar)
190 ; (ess-S-initialize-speedbar)))
196 (when (featurep 'speedbar
)
197 (message "enabling speedbar support")
199 (defun S-speedbar-buttons (buffer)
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 ( )
211 (ess-S-initialize-speedbar)))
214 \f ; Run load hook and provide package
218 \f ; Local variables section
220 ;;; This file is automatically placed in Outline minor mode.
221 ;;; The file is structured as follows:
224 ;;; Subsections: ;;;*;;;
225 ;;; Components: defuns, defvars, defconsts
226 ;;; Random code beginning with a ;;;;* comment
230 ;;; mode: outline-minor
231 ;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
234 ;;; ess-menu.el ends here