Initial commit

This commit is contained in:
2026-03-26 01:01:07 -07:00
commit 8de42129ac

64
buffer-keys.el Normal file
View File

@@ -0,0 +1,64 @@
;;; buffer-keys.el --- buffer key binder. -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Robert Rose
;; Author: Robert Rose <overclucker@gmail.com>
;; 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 <http://www.gnu.org/licenses/>.
;;; 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