From 8de42129ac9127967e1c9b82bca1abef85bf5e62 Mon Sep 17 00:00:00 2001 From: pi-bot-01 Date: Thu, 26 Mar 2026 01:01:07 -0700 Subject: [PATCH] Initial commit --- buffer-keys.el | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 buffer-keys.el diff --git a/buffer-keys.el b/buffer-keys.el new file mode 100644 index 0000000..05c7cd3 --- /dev/null +++ b/buffer-keys.el @@ -0,0 +1,64 @@ +;;; buffer-keys.el --- buffer key binder. -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Robert Rose + +;; Author: Robert Rose +;; Keywords: lisp bind-key +;; Version: 0.0.1 +;; Package-Requires ((emacs "24")) + +;; 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 . + +;;; Commentary: + +;; Provides a global minor mode for setting buffer keys. This makes +;; switching to specific buffers almost thoughtless. It essentially +;; binds a key that binds a key to switch to the current buffer. Maybe +;; a better name would be key-ception. It works well and thats all that +;; matters. You can enable or disable the key binds by toggling +;; buffer-keys-mode. + +;;; Code: + +(defgroup buffer-keys nil + "Settings group for buffer-keys.") + +(defcustom buffer-keys-mode nil + "Enable or disable buffer-keys mode." + :group 'buffer-keys) + +(defvar buffer-keys-map (make-sparse-keymap) + "Key binds for buffer-keys-mode.") + +(define-minor-mode buffer-keys-mode + "A global minor mode for accessing buffer keys." + :lighter nil + :global t + :keymap buffer-keys-map) + +(defun buffer-keys (keys) + "Set key to bind a buffer key for each (KEY . KEY) in alist keys." + (unless (eq keys ()) + (define-key buffer-keys-map + (car (car keys)) + `(lambda () (interactive) + (define-key buffer-keys-map + (cdr (car ',keys)) + `(lambda () (interactive) + (switch-to-buffer ,(current-buffer)))))) + (buffer-keys (cdr keys)))) + +(provide 'buffer-keys) + +;;; buffer-keys.el ends here