4 "Copy lines in the kill ring"
6 (kill-ring-save (line-beginning-position)
7 (line-beginning-position (+ 1 arg)))
8 (message "%d line%s copied" arg (if (= 1 arg) "" "s")))
10 (add-to-list 'delete-frame-functions #'kill-buffers-if-deleting-last-frame)
12 (defun frame-list-ignoring-initial-frame ()
15 (not (equal "initial_terminal" (terminal-name frame))))))
17 (defun kill-buffers-if-deleting-last-frame (frame)
18 (when (equal (list frame) (frame-list-ignoring-initial-frame))
19 (dolist (buffer (buffer-list))
20 (kill-buffer-if-not-modified buffer) buffer)))
22 (defun kill-buffers-not-in-frame ()
23 "Kill buffers which are not loaded into some a frame"
26 (dolist (buffer (buffer-list))
27 (if (not (get-buffer-window buffer t))
28 (if (kill-buffer-if-not-modified buffer)
29 (cl-incf kill-count))))
30 (message "Killed %d buffers" kill-count)))
32 (defun open-line-above ()
33 "Open a new line above point with indentation"
38 (indent-for-tab-command))
40 (defun open-line-below ()
41 "Open a new line below point with indentation"
45 (indent-for-tab-command))
47 (defun scratch-buffer ()
48 "Create a new scratch buffer to work in. (could be *scratch* - *scratchX*)"
53 (setq bufname (concat "*scratch"
54 (if (= n 0) "" (int-to-string n))
57 (get-buffer bufname)))
58 (switch-to-buffer (get-buffer-create bufname))
62 (defun toggle-comment-on-line ()
63 "Toggles the comment on for the active region if present or the current line otherwise."
65 (if (and mark-active transient-mark-mode)
66 (comment-or-uncomment-region (region-beginning) (region-end))
67 (comment-or-uncomment-region (line-beginning-position) (line-end-position)))