summaryrefslogtreecommitdiff
path: root/lisp/km-buffers.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-01-10 23:43:14 -0500
committerKyle Meyer <kyle@kyleam.com>2016-01-12 22:15:25 -0500
commit8d97d1f2063f19c0c679e54fc082691a495c9303 (patch)
tree77cc0ce12ecceb5739b5d0e35a5bc2eab09a9adc /lisp/km-buffers.el
parent2d395ef1ccedd51e3c11b1eb8ff552f03bae4797 (diff)
downloademacs.d-8d97d1f2063f19c0c679e54fc082691a495c9303.tar.gz
Rewrite configuration with use-package
Diffstat (limited to 'lisp/km-buffers.el')
-rw-r--r--lisp/km-buffers.el60
1 files changed, 60 insertions, 0 deletions
diff --git a/lisp/km-buffers.el b/lisp/km-buffers.el
new file mode 100644
index 0000000..b2138de
--- /dev/null
+++ b/lisp/km-buffers.el
@@ -0,0 +1,60 @@
+;;; km-buffers.el --- Buffer-related extensions
+
+;; Copyright (C) 2012-2016 Kyle Meyer <kyle@kyleam.com>
+
+;; Author: Kyle Meyer <kyle@kyleam.com>
+;; URL: https://github.com/kyleam/emacs.d
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+;;;###autoload
+(defun km/save-and-kill-buffer ()
+ "Save current buffer and then kill it."
+ (interactive)
+ (save-buffer)
+ (kill-this-buffer))
+
+;;;###autoload
+(defun km/kill-buffer (&optional arg)
+ "Kill this buffer.
+With single C-u, prompt for buffer to kill. With double C-u,
+kill this buffer and the window."
+ (interactive "P")
+ (cond
+ ((not arg)
+ (kill-buffer))
+ ((equal arg '(16))
+ (kill-buffer-and-window))
+ (t
+ (call-interactively #'kill-buffer))))
+
+;;;###autoload
+(defun km/save-buffers ()
+ "Run `save-some-buffers', but don't ask to save the current buffer.
+`save-some-buffers' is called interactively."
+ (interactive)
+ (let* ((base-buf (buffer-base-buffer))
+ (buf (or base-buf (current-buffer)))
+ (buf-file (buffer-file-name buf)))
+ (when (and (buffer-live-p buf)
+ (buffer-modified-p buf)
+ buf-file)
+ (with-current-buffer buf
+ (save-buffer))))
+ (call-interactively #'save-some-buffers))
+
+(provide 'km-buffers)
+;;; km-buffers.el ends here