aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my/my-buffer.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-buffer.el')
-rw-r--r--emacs/.emacs.d/lisp/my/my-buffer.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-buffer.el b/emacs/.emacs.d/lisp/my/my-buffer.el
index ef988f8..21401b5 100644
--- a/emacs/.emacs.d/lisp/my/my-buffer.el
+++ b/emacs/.emacs.d/lisp/my/my-buffer.el
@@ -458,5 +458,18 @@ With double prefix arguments, create a new indirect buffer."
(4 (my-switch-indirect-buffer))
(_ (my-cycle-indirect-buffer))))
+(defun my-save-text-and-switch-to-buffer (text file-name)
+ "Save TEXT to FILE-NAME and switch to buffer."
+ (let ((buffer (find-file-noselect file-name))
+ (coding-system-for-write 'utf-8))
+ (with-current-buffer buffer
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (insert text))
+ (goto-char (point-min))
+ (save-buffer)
+ (revert-buffer t t))
+ (switch-to-buffer buffer)))
+
(provide 'my-buffer)
;;; my-buffer.el ends here