~ubuntu-branches/ubuntu/raring/ess/raring-proposed

« back to all changes in this revision

Viewing changes to lisp/ess-mous.el

  • Committer: Package Import Robot
  • Author(s): Dirk Eddelbuettel
  • Date: 2012-05-09 08:00:38 UTC
  • mfrom: (1.2.23)
  • Revision ID: package-import@ubuntu.com-20120509080038-7an3nhbtgaj02a17
Tags: 12.04-1-1
New upstream patch version released today

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
;; Copyright (C) 2001 Richard M. Heiberger <rmh@sbm.temple.edu>
4
4
;; Copyright (C) 2002--2004 A.J. Rossini, Rich M. Heiberger, Martin
5
 
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
 
5
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
6
6
 
7
7
;; Original Author: Richard M. Heiberger <rmh@sbm.temple.edu>
8
8
;; Created: 25 Mar 2001
17
17
 
18
18
;; This file is distributed in the hope that it will be useful,
19
19
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
21
;; GNU General Public License for more details.
22
22
 
23
23
;; You should have received a copy of the GNU General Public License
24
 
;; along with GNU Emacs; see the file COPYING.  If not, write to
 
24
;; along with GNU Emacs; see the file COPYING.  If not, write to
25
25
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
26
 
27
27
;;; Commentary:
39
39
;;*;; Requires
40
40
(require 'mouseme)
41
41
;;(if (or (equal window-system 'w32)
42
 
;;      (equal window-system 'win32)
43
 
;;      (equal window-system 'mswindows))
 
42
;;      (equal window-system 'win32)
 
43
;;      (equal window-system 'mswindows))
44
44
;;    (require 'essiw32b))
45
45
 
46
46
(defun ess-mouse-me ()
66
66
        (setq sm (mark t))              ; saved mark
67
67
;;;     (set-buffer (window-buffer (posn-window (event-start event))))
68
68
;;;     (setq mouse (goto-char (posn-point (event-start event))))
69
 
        (setq mouse (point))  ;; ess-mouse-me-helper
 
69
        (setq mouse (point))  ;; ess-mouse-me-helper
70
70
        ;; if there is a region and point is inside it
71
71
        ;; check for sm first incase (null (mark t))
72
72
        ;; set name to either the thing they clicked on or region
116
116
    "----"
117
117
    ("Browser on"  . ess-mouse-me-browser-on)
118
118
    ("Browser off" . ess-mouse-me-browser-off))
119
 
    "*Command menu used by `mouse-me-build-menu'.
 
119
  "*Command menu used by `mouse-me-build-menu'.
120
120
A alist of elements where each element is either a cons cell or a string.
121
121
If a cons cell the car is a string to be displayed in the menu and the
122
122
cdr is either a function to call passing a string to, or a list which evals
149
149
 
150
150
(defun ess-mouse-me-browser-on (string)
151
151
  (if (equal (substring ess-dialect 0 1) "R")
152
 
       (ess-eval-linewise (concat "debug(" string ")"))
153
 
   (ess-mouse-me-eval-expanded string "trace(" ", exit=browser)") nil nil nil))
 
152
      (ess-eval-linewise (concat "debug(" string ")"))
 
153
    (ess-mouse-me-eval-expanded string "trace(" ", exit=browser)") nil nil nil))
154
154
 
155
155
(defun ess-mouse-me-browser-off  (string)
156
156
  (if (equal (substring ess-dialect 0 1) "R")
157
 
       (ess-eval-linewise (concat "undebug(" string ")"))
158
 
   (ess-mouse-me-eval-expanded string "untrace(" ")") nil nil nil))
 
157
      (ess-eval-linewise (concat "undebug(" string ")"))
 
158
    (ess-mouse-me-eval-expanded string "untrace(" ")") nil nil nil))
159
159
 
160
160
 
161
161
 
162
162
(defun ess-mouse-me-eval-expanded (string &optional head tail commands-buffer
163
 
                                          page value-returned)
 
163
                                          page value-returned)
164
164
  "Send the expanded STRING to the inferior-ess process using `ess-command'
165
165
after first concating the HEAD and TAIL.  Put answer in COMMANDS-BUFFER if
166
166
specified and not using ddeclient, otherwise in \"tmp-buffer\".  In either
169
169
the string one more time by embedding it in a \"page()\" command."
170
170
  (interactive)
171
171
  (let* (scommand
172
 
         page-scommand
173
 
         (ess-mouse-customize-alist ess-local-customize-alist))
 
172
         page-scommand
 
173
         (ess-mouse-customize-alist ess-local-customize-alist))
174
174
    (if (not head) (setq head "summary("))
175
175
    (if (not tail) (setq tail ")"))
176
176
    (if (not commands-buffer) (setq commands-buffer
177
 
                                    (get-buffer-create "tmp-buffer")))
 
177
                                    (get-buffer-create "tmp-buffer")))
178
178
    (setq scommand (concat head string tail))
179
179
 
180
180
    (if (ess-ddeclient-p)
181
 
        (progn
182
 
          (setq page-scommand (if page
183
 
                                  (concat "page(" scommand ")")
184
 
                                scommand))
185
 
          (set-buffer-file-coding-system 'undecided-dos)
186
 
          (ess-command page-scommand commands-buffer)
187
 
          (if (not value-returned)
188
 
              nil
189
 
            (sleep-for 2)
190
 
            (switch-to-buffer (car (buffer-list)))))
 
181
        (progn
 
182
          (setq page-scommand (if page
 
183
                                  (concat "page(" scommand ")")
 
184
                                scommand))
 
185
          (set-buffer-file-coding-system 'undecided-dos)
 
186
          (ess-command page-scommand commands-buffer)
 
187
          (if (not value-returned)
 
188
              nil
 
189
            (sleep-for 2)
 
190
            (switch-to-buffer (car (buffer-list)))))
191
191
      (ess-make-buffer-current)
192
192
      (switch-to-buffer commands-buffer)
193
193
      (ess-setq-vars-local (eval ess-mouse-customize-alist) (current-buffer))
195
195
      (ess-command (concat scommand "\n") commands-buffer)
196
196
      (if (not value-returned) (switch-to-buffer (nth 1 (buffer-list)))))
197
197
    (if (not value-returned)
198
 
        nil
 
198
        nil
199
199
      (if ess-microsoft-p                      ;; there ought to be a filter
200
 
          (while (search-forward "\r" nil t)   ;; function to keep the ^M
201
 
            (replace-match "" nil t)))         ;; from showing up at all
 
200
          (while (search-forward "\r" nil t)   ;; function to keep the ^M
 
201
            (replace-match "" nil t)))         ;; from showing up at all
202
202
      (ess-transcript-mode (eval ess-mouse-customize-alist))
203
203
      (setq ess-local-process-name ess-current-process-name)
204
204
      (rename-buffer scommand))))
224
224
;;       (define-key ess-mode-map              [S-mouse-3] 'ess-mouse-me)
225
225
;;       (define-key inferior-ess-mode-map     [S-mouse-3] 'ess-mouse-me)
226
226
;;       (defun ess-S-mouse-me-ess-transcript-mode ()
227
 
;;      (define-key ess-transcript-mode-map [S-mouse-3] 'ess-mouse-me)))
 
227
;;      (define-key ess-transcript-mode-map [S-mouse-3] 'ess-mouse-me)))
228
228
;;   ;; xemacs
229
229
;;   (define-key ess-mode-map              [(shift button3)] 'ess-mouse-me)
230
230
;;   (define-key inferior-ess-mode-map     [(shift button3)] 'ess-mouse-me)