Weekly Post #127

Posted on June 13, 2026
Categories (2): ,

Unlimited untitled buffers

I spawn a shit load of untitled TextEdit windows for floating bits of information that I need through out my day.

In an attempt to centeralize my workflow around(Emacs) and also to reduce the number of open apps I created a small elisp function to spawn these buffers in Emacs.

;; Func for empty buffers
(defun new-empty-buffer ()
  "Create a new empty buffer and switch to it."
  (interactive)
  (let ((buf (generate-new-buffer "untitled")))
    (switch-to-buffer buf)
    (funcall initial-major-mode)))
 
(global-set-key (kbd "C-c n") 'new-empty-buffer)

Closing all the open/floating TextEdit windows in part was what pushed me to create the above code snippet. At the end each day I would have like 20+ windows to close and didn’t want to go through the confirmation window on every single one to close them. Laziness compounds resulting in 100+ windows.

(defun kill-buffers-by-name (&optional regexp)
  "Kill all buffers whose names match REGEXP."
  (interactive "sKill buffers matching name (regexp): ")
  (setq regexp (if (string-empty-p regexp) "untitled" regexp))
  (dolist (buf (buffer-list))
    (when (string-match-p regexp (buffer-name buf))
      (kill-buffer buf))))