mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 18:40:39 -08:00
Add :set attribute to winner-dont-bind-my-keys
* lisp/winner.el (winner--set-dont-bind-my-keys): New function. (winner-dont-bind-my-keys): Allow setting with setopt. (winner-mode-map): Use defvar-keymap. * test/lisp/winner-tests.el: New file.
This commit is contained in:
parent
6b295347a9
commit
33cc5427cb
2 changed files with 54 additions and 14 deletions
|
|
@ -24,11 +24,11 @@
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;; Winner mode is a global minor mode that records the changes in the
|
;; Winner mode is a global minor mode that records the changes in the
|
||||||
;; window configuration (i.e. how the frames are partitioned into
|
;; window configuration (in other words, how the frames are partitioned
|
||||||
;; windows) so that the changes can be "undone" using the command
|
;; into windows), so that the changes can be "undone" using the command
|
||||||
;; `winner-undo'. By default this one is bound to the key sequence
|
;; `winner-undo'. By default, it is bound to the key sequence `C-c
|
||||||
;; ctrl-c left. If you change your mind (while undoing), you can
|
;; <left>'. If you change your mind (while undoing), you can press
|
||||||
;; press ctrl-c right (calling `winner-redo').
|
;; `C-c <right>' (`winner-redo').
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
|
@ -44,9 +44,21 @@
|
||||||
"Restoring window configurations."
|
"Restoring window configurations."
|
||||||
:group 'windows)
|
:group 'windows)
|
||||||
|
|
||||||
|
(defun winner--set-dont-bind-my-keys (symbol value)
|
||||||
|
(defvar winner-mode-map)
|
||||||
|
(when (boundp 'winner-mode-map)
|
||||||
|
(if value
|
||||||
|
(progn (keymap-unset winner-mode-map "C-c <left>")
|
||||||
|
(keymap-unset winner-mode-map "C-c <left>"))
|
||||||
|
;; Default bindings.
|
||||||
|
(keymap-set winner-mode-map "C-c <left>" #'winner-undo)
|
||||||
|
(keymap-set winner-mode-map "C-c <right>" #'winner-redo)))
|
||||||
|
(set-default symbol value))
|
||||||
|
|
||||||
(defcustom winner-dont-bind-my-keys nil
|
(defcustom winner-dont-bind-my-keys nil
|
||||||
"Non-nil means do not bind keys in Winner mode."
|
"Non-nil means do not bind default keys in Winner mode."
|
||||||
:type 'boolean)
|
:type 'boolean
|
||||||
|
:set #'winner--set-dont-bind-my-keys)
|
||||||
|
|
||||||
(defcustom winner-ring-size 200
|
(defcustom winner-ring-size 200
|
||||||
"Maximum number of stored window configurations per frame."
|
"Maximum number of stored window configurations per frame."
|
||||||
|
|
@ -321,13 +333,9 @@ You may want to include buffer names such as *Help*, *Apropos*,
|
||||||
"Functions to run whenever Winner mode is turned off."
|
"Functions to run whenever Winner mode is turned off."
|
||||||
:type 'hook)
|
:type 'hook)
|
||||||
|
|
||||||
(defvar winner-mode-map
|
(defvar-keymap winner-mode-map
|
||||||
(let ((map (make-sparse-keymap)))
|
:doc "Keymap for Winner mode.")
|
||||||
(unless winner-dont-bind-my-keys
|
(setopt winner-dont-bind-my-keys winner-dont-bind-my-keys)
|
||||||
(define-key map [(control c) left] #'winner-undo)
|
|
||||||
(define-key map [(control c) right] #'winner-redo))
|
|
||||||
map)
|
|
||||||
"Keymap for Winner mode.")
|
|
||||||
|
|
||||||
(defvar-keymap winner-repeat-map
|
(defvar-keymap winner-repeat-map
|
||||||
:doc "Keymap to repeat winner key sequences. Used in `repeat-mode'."
|
:doc "Keymap to repeat winner key sequences. Used in `repeat-mode'."
|
||||||
|
|
|
||||||
32
test/lisp/winner-tests.el
Normal file
32
test/lisp/winner-tests.el
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
;;; winner-tests.el --- Tests for winner.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Copyright (C) 2025 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
;; This file is part of GNU Emacs.
|
||||||
|
|
||||||
|
;; GNU Emacs 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.
|
||||||
|
|
||||||
|
;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'winner)
|
||||||
|
|
||||||
|
(ert-deftest winner-dont-bind-my-keys ()
|
||||||
|
(should (keymap-lookup winner-mode-map "C-c <left>"))
|
||||||
|
(setopt winner-dont-bind-my-keys t)
|
||||||
|
(should-not (keymap-lookup winner-mode-map "C-c <left>"))
|
||||||
|
(setopt winner-dont-bind-my-keys nil)
|
||||||
|
(should (keymap-lookup winner-mode-map "C-c <left>")))
|
||||||
|
|
||||||
|
(provide 'winner-tests)
|
||||||
|
;;; winner-tests.el ends here
|
||||||
Loading…
Add table
Add a link
Reference in a new issue