~ubuntu-branches/ubuntu/saucy/ess/saucy-proposed

« back to all changes in this revision

Viewing changes to lisp/ess-trns.el

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2010-11-08 16:52:27 UTC
  • mfrom: (1.2.18 upstream)
  • Revision ID: james.westby@ubuntu.com-20101108165227-u844l0tlegcdn89k
Tags: 5.12-1
* New upstream version released today

* debian/emacen-startup: Follow suggestion by Kevin Ryde in #594750 and
  use debian-pkg-add-load-path-item as well; also improved emacsen-install
  script by using soft links instead of copies  (Closes: #594750)

Show diffs side-by-side

added added

removed removed

Lines of Context:
269
269
prompt from those lines that remain.  Prefix argument means to use
270
270
\\[toggle-read-only] to clean even if the buffer is \\[read-only]."
271
271
  (interactive "r\nP")
272
 
  (let ((do-toggle (and buffer-read-only even-if-read-only)))
 
272
  (unless inferior-ess-prompt
 
273
    (error "Cannot clean ESS transcript region in this mode!
 
274
 That only works in ess-transcript-mode or inferior-ess-mode ('*R*' etc)."
 
275
           ;; Maybe call ess-clean-region-in-new-transcript ?"))
 
276
           ))
 
277
  (let ((do-toggle (and buffer-read-only even-if-read-only))
 
278
        (ess-prompt-rx (concat "^" inferior-ess-prompt)))
273
279
    (save-excursion
274
280
      (if do-toggle (toggle-read-only 0))
275
281
      (save-restriction
277
283
          (deactivate-mark))
278
284
        (narrow-to-region beg end)
279
285
        (goto-char (point-min))
280
 
        (delete-non-matching-lines (concat "^" inferior-ess-prompt))
 
286
        (delete-non-matching-lines ess-prompt-rx)
281
287
        (goto-char (point-min))
282
288
        ;; (replace-regexp  *  * ) :
283
 
        (while (re-search-forward (concat "^" inferior-ess-prompt) nil t)
 
289
        (while (re-search-forward ess-prompt-rx nil t)
284
290
          (replace-match "" nil nil)))
285
291
 
286
292
      (if do-toggle (toggle-read-only 1)))))
287
293
 
 
294
 
 
295
;; unfinished idea :-----------------------
 
296
 
 
297
;; (defun ess-clean-region-in-new-transcript (beg end)
 
298
;;   "Copy the region into a new ess-transcript buffer, and clean it there,
 
299
;;  using \\[ess-transcript-clean-region]."
 
300
;;   (interactive "r")
 
301
 
 
302
;;   (let ((bname (buffer-file-name)))
 
303
;;     (setq bname (if bname .. ..))
 
304
;;     (let
 
305
;;       (fbase (if fname (file-name-sans-extension (file-name-nondirectory fname))
 
306
;;                (buffer-name)))
 
307
;;
 
308
;;       ;; the buffer name should be like a file name
 
309
;;       (buf-nam ....)
 
310
;;       (trns-buf (get-buffer-create fbase))
 
311
;;     (pop-to-buffer trns-buf)
 
312
;;     (ess-transcript-mode .....)
 
313
;; )))
 
314
 
 
315
 
 
316
 
 
317
 
288
318
(defun ess-transcript-DO-clean-region (beg end)
289
319
  "Clean the current via \\[ess-transcript-clean-region] even if the buffer is read-only."
290
320
  (interactive "r")