~ubuntu-branches/ubuntu/gutsy/ess/gutsy

« back to all changes in this revision

Viewing changes to lisp/ess-trns.el

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2005-03-22 13:48:07 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050322134807-9mpmbb799jugf248
Tags: 5.2.6-1
* New upstream release
* chmod -R u+w on orig source

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; ess-trns.el --- Support for manipulating S transcript files
2
2
 
3
 
;; Copyright (C) 1989-1994 Bates, Kademan, Ritter and Smith
4
 
;; Copyright (C) 1997-2000 Richard M. Heiberger <rmh@fisher.stat.temple.edu>
5
 
;;                              Kurt Hornik <hornik@ci.tuwien.ac.at>
6
 
;;                              Martin Maechler <maechler@stat.math.ethz.ch>
7
 
;;                              A.J. (Tony) Rossini <rossini@stat.sc.edu>
 
3
;; Copyright (C) 1989--1994 Bates, Kademan, Ritter and Smith
 
4
;; Copyright (C) 1997--2004 A.J. Rossini, Rich M. Heiberger, Martin
 
5
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
8
6
 
9
 
;; Author: David Smith <dsmith@stats.adelaide.edu.au>
10
 
;; Maintainer: A.J. Rossini <rossini@stat.sc.edu>
11
 
;; Created: 7 Jan 1994
12
 
;; Modified: $Date: 2002/01/15 01:52:54 $
13
 
;; Version: $Revision: 5.10 $
14
 
;; RCS: $Id: ess-trns.el,v 5.10 2002/01/15 01:52:54 rmh Exp $
 
7
;; Original Author: David Smith <dsmith@stats.adelaide.edu.au>
 
8
;; Maintainers: ESS-core <ESS-core@stat.math.ethz.ch>
15
9
 
16
10
;; This file is part of ESS
17
11
 
75
69
(if ess-transcript-mode-map
76
70
    nil
77
71
 
78
 
  (cond (ess-running-xemacs
 
72
  (cond ((featurep 'xemacs)
79
73
         ;; Code for XEmacs
80
74
         (setq ess-transcript-mode-map (make-keymap))
81
75
         (set-keymap-parent ess-transcript-mode-map text-mode-map))
82
 
        ((not ess-running-xemacs)
 
76
        ((not (featurep 'xemacs))
83
77
         ;; Code for GNU Emacs
84
78
         (setq ess-transcript-mode-map (make-sparse-keymap))))
85
79
 
104
98
  (define-key ess-transcript-mode-map "\C-c\C-d" 'ess-dump-object-into-edit-buffer)
105
99
  (define-key ess-transcript-mode-map "\C-c\C-t" 'ess-execute-in-tb)
106
100
  (define-key ess-transcript-mode-map "\C-c\t"   'ess-complete-object-name)
 
101
  (define-key ess-transcript-mode-map "\C-a"     'comint-bol)
107
102
  (define-key ess-transcript-mode-map "\M-\t"    'comint-replace-by-expanded-filename)
108
103
  (define-key ess-transcript-mode-map "\M-?"     'comint-dynamic-list-completions)
109
104
  (define-key ess-transcript-mode-map "\C-c\C-k" 'ess-request-a-process)
127
122
 ess-transcript-mode-menu ess-transcript-mode-map
128
123
 "Menu for use in S transcript mode."
129
124
 '("ESS-trans"
130
 
   ["What is this? (beta)"    ess-mouse-me                      t]
 
125
   ["What is this? (beta)" ess-mouse-me                  t]
131
126
   ["Describe"         describe-mode                     t]
132
127
   ["About"            (ess-goto-info "Transcript Mode") t]
133
128
   ["Send bug report"  ess-submit-bug-report             t]
138
133
   "------"
139
134
   ["Send and move"  ess-transcript-send-command-and-move t]
140
135
   ["Copy command"   ess-transcript-copy-command          t]
141
 
   ["Send command"   ess-transcript-send-command          t]))
 
136
   ["Send command"   ess-transcript-send-command          t]
 
137
   ["Clean Region"   ess-transcript-DO-clean-region       t]))
 
138
 
142
139
 
143
140
 
144
141
(if (not (string-match "XEmacs" emacs-version))
177
174
  (require 'ess-inf)
178
175
  (kill-all-local-variables)
179
176
  (toggle-read-only t) ;; to protect the buffer.
180
 
  (ess-setq-vars-local alist (current-buffer))
 
177
  (ess-setq-vars-local alist); (current-buffer))
181
178
  (setq major-mode 'ess-transcript-mode)
182
179
  (setq mode-name "ESS Transcript")
183
180
  (use-local-map ess-transcript-mode-map)
203
200
  ;; font-lock support
204
201
  (make-local-variable 'font-lock-defaults)
205
202
  (setq font-lock-defaults
206
 
        '(ess-trans-font-lock-keywords nil nil ((?' . "."))))
 
203
        '(inferior-ess-font-lock-keywords nil nil ((?' . "."))))
207
204
 
208
205
  ;;; Keep <tabs> out of the code.
209
206
  (make-local-variable 'indent-tabs-mode)
253
250
      (insert input)))
254
251
  (ess-switch-to-end-of-ESS))
255
252
 
256
 
(defun ess-transcript-clean-region (beg end)
 
253
(defun ess-transcript-clean-region (beg end even-if-read-only)
257
254
  "Strip the transcript in the region, leaving only (R/S/Lsp/..) commands.
258
255
Deletes any lines not beginning with a prompt, and then removes the
259
 
prompt from those lines than remain."
 
256
prompt from those lines that remain.  Prefix argument means to use
 
257
\\[toggle-read-only] to clean even if the buffer is \\[read-only]."
 
258
  (interactive "r\nP")
 
259
  (let ((do-toggle (and buffer-read-only even-if-read-only)))
 
260
    (save-excursion
 
261
      (if do-toggle (toggle-read-only 0))
 
262
      (save-restriction
 
263
        (deactivate-mark)
 
264
        (narrow-to-region beg end)
 
265
        (goto-char (point-min))
 
266
        (delete-non-matching-lines (concat "^" inferior-ess-prompt))
 
267
        (goto-char (point-min))
 
268
        (replace-regexp (concat "^" inferior-ess-prompt) ""))
 
269
      (if do-toggle (toggle-read-only 1)))))
 
270
 
 
271
(defun ess-transcript-DO-clean-region (beg end)
 
272
  "Clean the current via \\[ess-transcript-clean-region] even if the buffer is read-only."
260
273
  (interactive "r")
261
 
  (save-excursion
262
 
    (save-restriction
263
 
      (narrow-to-region beg end)
264
 
      (goto-char (point-min))
265
 
      (delete-non-matching-lines (concat "^" inferior-ess-prompt))
266
 
      (goto-char (point-min))
267
 
      (replace-regexp (concat "^" inferior-ess-prompt) ""))))
 
274
  (ess-transcript-clean-region beg end 'In-ANY-case))
268
275
 
269
276
 ; Local variables section
270
277