Created
November 24, 2012 23:52
-
-
Save jorgenschaefer/4141848 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun ngz/copy-buffer (oldbuf new-name) | |
| "Create a new buffer named NEW-NAME as a copy of OLDBUF. | |
| Will copy the contents and all buffer-local variables. | |
| Returns the newly-created buffer" | |
| (let ((newbuf (get-buffer-create new-name))) | |
| (with-current-buffer oldbuf | |
| (copy-to-buffer newbuf (point-min) (point-max))) | |
| (with-current-buffer newbuf | |
| (dolist (varspec (buffer-local-variables oldbuf)) | |
| (set (car varspec) (cdr varspec)))) | |
| newbuf)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment