Skip to content

Instantly share code, notes, and snippets.

@prozacchiwawa
Created May 20, 2025 18:19
Show Gist options
  • Save prozacchiwawa/f836472cbfe7fbe4b95b9f6d80af65f5 to your computer and use it in GitHub Desktop.
Save prozacchiwawa/f836472cbfe7fbe4b95b9f6d80af65f5 to your computer and use it in GitHub Desktop.
elisp save selection to file
;; Given a target buffer, copy the range from point to
;; mark in the current buffer to that other buffer.
(defun save-selection-to-file (target-buffer)
(interactive "B")
(copy-region-as-kill (point) (mark))
(with-current-buffer target-buffer
(save-excursion
(erase-buffer)
(yank)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment