Skip to content

Instantly share code, notes, and snippets.

@thomp
Last active May 30, 2024 15:16
Show Gist options
  • Save thomp/0a8ed29b2094fdf43536a151722ebe6a to your computer and use it in GitHub Desktop.
Save thomp/0a8ed29b2094fdf43536a151722ebe6a to your computer and use it in GitHub Desktop.
quickly generate a temporary Emacs buffer
;; quickly generate a temporary Emacs buffer
;; mktmp.el ==> qtb.el
;; ==> change to qtb = quick temporary buffer
;; current location:
;; https://gist.github.com/thomp/0a8ed29b2094fdf43536a151722ebe6a
;; related:
;; https://stackoverflow.com/questions/22289271/in-gnu-emacs-how-to-create-new-empty-buffer-with-one-keystroke
;; aquamacs ~new-tab~
;; https://stackoverflow.com/questions/234963/re-open-scratch-buffer-in-emacs/21071757#21071757
;; https://stackoverflow.com/questions/10363982/how-can-i-open-a-temporary-buffer
;; https://github.com/kostafey/temporary-persistent
;; default mode for qtb buffers
(defvar qtb-default-mode 'text-mode ; (fundamental-mode) might also be a good default
)
(defun qtb-make-buffer-name ()
(concat "tmp-" (format-time-string "%m.%dT%H.%M.%S")))
(defun qtb-quick-temp-buffer ()
"Generate a new buffer. Switch to that buffer. Return ??"
(interactive)
;; maybe make things file-based
;; (qtb-make-tmp-file . . .)
(switch-to-buffer (generate-new-buffer (concat "tmp-" (format-time-string "%m.%dT%H.%M.%S"))))
;; maybe set mode
(if qtb-default-mode
(funcall qtb-default-mode))
)
;(global-set-key (kbd "<f7>") 'qtb-quick-temp-buffer)
(provide 'qtb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment