Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Dump the current region (if any) into the scratch buffer, ELPAnize.

  • Loading branch information...
commit 54e31e81cd239e1fd1b3c6a20ff426029bf9aaf5 1 parent ca45180
@ieure authored
Showing with 15 additions and 7 deletions.
  1. +15 −7 scratch.el
View
22 scratch.el
@@ -1,10 +1,10 @@
;;; scratch.el --- Mode-specific scratch buffers
;; Author: Ian Eure <ian.eure@gmail.com>
-
+;; Version: 1.1
;; Keywords: editing
-;; Copyright (c) 2009-1020, 2010 Ian Eure <ian.eure@gmail.com>
+;; Copyright (c) 2009-1020, 2010, 2012 Ian Eure <ian.eure@gmail.com>
;; All rights reserved.
;; Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,9 @@
;; 2010-08-16 Ian Eure
;; Broke out into its own file.
+;; 2012-08-30 Ian Eure
+;; Dump current region into new scratch buffer
+
;;; Code:
(defgroup scratch nil
@@ -107,10 +110,15 @@ for those buffers."
(cond ((bufferp buf)
(pop-to-buffer buf))
(t
- (setq buf (get-buffer-create name))
- (pop-to-buffer buf)
- (let ((scratch-buffer t))
- (funcall mode))
- (setq scratch-buffer t)))))
+ (let ((contents (when (region-active-p)
+ (buffer-substring (region-beginning)
+ (region-end)))))
+ (setq buf (get-buffer-create name))
+ (pop-to-buffer buf)
+ (let ((scratch-buffer t))
+ (funcall mode))
+ (when contents (save-excursion (insert contents)))
+ (setq scratch-buffer t))))))
(provide 'scratch)
+;;; scratch.el ends here
Please sign in to comment.
Something went wrong with that request. Please try again.