From: philip@warpmail.net (Philip K.)
To: Juri Linkov <juri@linkov.net>
Cc: 41438@debbugs.gnu.org, emacs-devel@gnu.org
Subject: bug#41438: [PATCH] Allow windmove keys to be bound without prefix or modifiers
Date: Fri, 22 May 2020 20:26:07 +0200 [thread overview]
Message-ID: <87v9kn7rnk.fsf__13454.8490563006$1590172036$gmane$org@bulbul> (raw)
In-Reply-To: <874ks9rkyd.fsf@mail.linkov.net> (message from Juri Linkov on Fri, 22 May 2020 01:18:18 +0300)
[-- Attachment #1: Type: text/plain, Size: 863 bytes --]
Juri Linkov <juri@linkov.net> writes:
>> Another question I'd like to ask before trying it out: Would there be
>> any interest in adding user options for the "default" modifiers that
>> windmove should use? If yes, one could add a :set function that
>> automatically calls the apropriate bindings function, when it's value
>> is non-nil. I have a very customize-centric configuration, where something
>> this would fit in very well.
>
> I think that adding defcustoms (including a new const `none')
> would be the most natural way to customize windmove modifiers
> (provided that the existing functions should remain).
I made a first concept, but it doesn't work unless windmove is explicity
required (see below). As far as I know, autoloading variables isn't good
style, so is there any other way to invoke the :set property of a user
option?
--
Philip K.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Implement-user-options-for-windmove-modifiers-and-pr.patch --]
[-- Type: text/x-diff, Size: 8273 bytes --]
From b35173936e681e170172eb3d4548a2f91f70dad3 Mon Sep 17 00:00:00 2001
From: Philip K <philip@warpmail.net>
Date: Fri, 22 May 2020 20:21:59 +0200
Subject: [PATCH] Implement user options for windmove modifiers and prefixes
---
lisp/windmove.el | 103 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 95 insertions(+), 8 deletions(-)
diff --git a/lisp/windmove.el b/lisp/windmove.el
index 3d7f86b9af..95f74bfb81 100644
--- a/lisp/windmove.el
+++ b/lisp/windmove.el
@@ -162,6 +162,19 @@ windmove-window-distance-delta
(make-obsolete-variable 'windmove-window-distance-delta
"no longer used." "27.1")
+(defconst windmove-modifier-type
+ '(choice (set :tag "Modifier Symbols"
+ :greedy t
+ ;; See `(elisp) Keyboard Events'
+ (const :tag "Meta" meta)
+ (const :tag "Control" control)
+ (const :tag "Shift" shift)
+ (const :tag "Hyper" hyper)
+ (const :tag "Super" super)
+ (const :tag "Alt" alt))
+ (const :tag "No modifier" none))
+ "Customisation type for windmove modifiers")
+
\f
;; Note:
;;
@@ -419,6 +432,7 @@ windmove-down
(interactive "P")
(windmove-do-window-select 'down (and arg (prefix-numeric-value arg))))
+(defvar windmove-modifiers)
;;; set up keybindings
;; Idea for this function is from iswitchb.el, by Stephen Eglen
@@ -433,9 +447,10 @@ windmove-default-keybindings
where MODIFIERS is either a list of modifiers or a single modifier.
If MODIFIERS is `none', the keybindings will be directly bound to
the arrow keys.
-Default value of MODIFIERS is `shift'."
+Default value of MODIFIERS is stored in `windmove-modifiers'."
(interactive)
- (unless modifiers (setq modifiers 'shift))
+ (unless modifiers
+ (setq modifiers windmove-modifiers))
(when (eq modifiers 'none) (setq modifiers nil))
(unless (listp modifiers) (setq modifiers (list modifiers)))
(global-set-key (vector (append modifiers '(left))) 'windmove-left)
@@ -443,6 +458,25 @@ windmove-default-keybindings
(global-set-key (vector (append modifiers '(up))) 'windmove-up)
(global-set-key (vector (append modifiers '(down))) 'windmove-down))
+;; has to be declared AFTER windmove-default-keybindings, or else
+;; windmove is recursivly loaded
+;;;###autoload
+(defcustom windmove-modifiers '(shift super)
+ "Modifiers for `windmove-default-keybindings'.
+Can either be a symbol or list of modifier symbols,
+i.e. `meta',`control', `shift', `hyper', `super', or `alt'
+representing modifier keys to use with the arrow keys.
+
+If the value is just `none', the arrow keys will be directly
+bound to the windmove functions."
+ :type windmove-modifier-type
+ :require 'windmove
+ :initialize #'custom-initialize-changed
+ :set (lambda (sym val)
+ (when val
+ (windmove-swap-states-default-keybindings val))
+ (set-default sym val)))
+
\f
;;; Directional window display and selection
@@ -565,6 +599,8 @@ windmove-display-new-tab
(interactive "P")
(windmove-display-in-direction 'new-tab arg))
+(defvar windmove-display-modifiers)
+
;;;###autoload
(defun windmove-display-default-keybindings (&optional modifiers)
"Set up keybindings for directional buffer display.
@@ -573,7 +609,7 @@ windmove-display-default-keybindings
where MODIFIERS is either a list of modifiers or a single modifier.
If MODIFIERS is `none', the keybindings will be directly bound to
the arrow keys.
-Default value of MODIFIERS is `shift-meta'."
+Default value of MODIFIERS is stored in `windmove-display-modifiers'."
(interactive)
(unless modifiers (setq modifiers '(shift meta)))
(when (eq modifiers 'none) (setq modifiers nil))
@@ -586,6 +622,17 @@ windmove-display-default-keybindings
(global-set-key (vector (append modifiers '(?f))) 'windmove-display-new-frame)
(global-set-key (vector (append modifiers '(?t))) 'windmove-display-new-tab))
+(defcustom windmove-display-modifiers '(shift meta)
+ "Modifiers for `windmove-display-default-keybindings'.
+Analogous to `windmove-modifiers'."
+ :type windmove-modifier-type
+ :require 'windmove
+ :initialize #'custom-initialize-changed
+ :set (lambda (sym val)
+ (when val
+ (windmove-display-default-keybindings val))
+ (set-default sym val)))
+
\f
;;; Directional window deletion
@@ -640,6 +687,9 @@ windmove-delete-down
(interactive "P")
(windmove-delete-in-direction 'down arg))
+(defvar windmove-delete-prefix)
+(defvar windmove-delete-modifiers)
+
;;;###autoload
(defun windmove-delete-default-keybindings (&optional prefix modifiers)
"Set up keybindings for directional window deletion.
@@ -649,12 +699,13 @@ windmove-delete-default-keybindings
a single modifier.
If PREFIX is `none', no prefix is used. If MODIFIERS is `none', the keybindings
are directly bound to the arrow keys.
-Default value of PREFIX is `C-x' and MODIFIERS is `shift'."
+The default values for PREFIX and MODIFIERS are stored in `windmove-delete-prefix'
+and `windmove-delete-modifiers' respectively."
(interactive)
- (unless prefix (setq prefix '(?\C-x)))
+ (unless prefix (setq prefix (list windmove-delete-prefix)))
(when (eq prefix 'none) (setq prefix nil))
(unless (listp prefix) (setq prefix (list prefix)))
- (unless modifiers (setq modifiers '(shift)))
+ (unless modifiers (setq modifiers windmove-delete-modifiers))
(when (eq modifiers 'none) (setq modifiers nil))
(unless (listp modifiers) (setq modifiers (list modifiers)))
(global-set-key (vector prefix (append modifiers '(left))) 'windmove-delete-left)
@@ -662,6 +713,28 @@ windmove-delete-default-keybindings
(global-set-key (vector prefix (append modifiers '(up))) 'windmove-delete-up)
(global-set-key (vector prefix (append modifiers '(down))) 'windmove-delete-down))
+(defcustom windmove-delete-prefix (kbd "C-x")
+ "Prefix for `windmove-delete-default-keybindings'."
+ :type 'key-sequence
+ :require 'windmove
+ :initialize #'custom-initialize-changed
+ :set (lambda (sym val)
+ (windmove-delete-default-keybindings
+ val windmove-delete-modifiers)
+ (set-default sym val)))
+
+(defcustom windmove-delete-modifiers '(shift)
+ "Modifiers for `windmove-delete-default-keybindings'.
+See `windmove-modifiers' for more details"
+ :type windmove-modifier-type
+ :require 'windmove
+ :initialize #'custom-initialize-changed
+ :set (lambda (sym val)
+ (when val
+ (windmove-delete-default-keybindings
+ windmove-delete-prefix val))
+ (set-default sym val)))
+
\f
;;; Directional window swap states
@@ -700,6 +773,8 @@ windmove-swap-states-right
(interactive)
(windmove-swap-states-in-direction 'right))
+(defvar windmove-swap-states-modifiers)
+
;;;###autoload
(defun windmove-swap-states-default-keybindings (&optional modifiers)
"Set up keybindings for directional window swap states.
@@ -709,9 +784,10 @@ windmove-swap-states-default-keybindings
or a single modifier.
If MODIFIERS is `none', the keybindings will be directly bound to the
arrow keys.
-Default value of MODIFIERS is `shift-super'."
+Default value of MODIFIERS is stored in `windmove-swap-states-modifiers'."
(interactive)
- (unless modifiers (setq modifiers '(shift super)))
+ (unless modifiers
+ (setq modifiers windmove-swap-states-modifiers))
(when (eq modifiers 'none) (setq modifiers nil))
(unless (listp modifiers) (setq modifiers (list modifiers)))
(global-set-key (vector (append modifiers '(left))) 'windmove-swap-states-left)
@@ -719,6 +795,17 @@ windmove-swap-states-default-keybindings
(global-set-key (vector (append modifiers '(up))) 'windmove-swap-states-up)
(global-set-key (vector (append modifiers '(down))) 'windmove-swap-states-down))
+(defcustom windmove-swap-states-modifiers
+ '(shift super)
+ "Modifiers for `windmove-swap-states-default-keybindings'.
+Analogous to `windmove-modifiers'."
+ :type windmove-modifier-type
+ :require 'windmove
+ :initialize #'custom-initialize-changed
+ :set (lambda (sym val)
+ (windmove-swap-states-default-keybindings val)
+ (set-default sym val)))
+
\f
(provide 'windmove)
--
2.20.1
next prev parent reply other threads:[~2020-05-22 18:26 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-21 16:56 bug#41438: [PATCH] Allow windmove keys to be bound without prefix or modifiers Philip K.
2020-05-21 22:18 ` Juri Linkov
2020-05-22 18:26 ` Philip K. [this message]
[not found] ` <(message>
[not found] ` <from>
[not found] ` <Juri>
[not found] ` <Linkov>
[not found] ` <on>
[not found] ` <Fri>
[not found] ` <22>
[not found] ` <May>
[not found] ` <2020>
[not found] ` <04:01:05>
[not found] ` <01:18:18>
[not found] ` <+0300)>
[not found] ` <87v9kn7rnk.fsf@bulbul>
2020-05-22 19:15 ` Drew Adams
2020-05-23 22:12 ` Juri Linkov
2020-06-26 19:46 ` Philip K.
2020-06-27 23:53 ` Juri Linkov
2020-06-28 8:30 ` Philip K.
2020-06-28 23:37 ` Juri Linkov
2020-08-05 18:05 ` Lars Ingebrigtsen
2020-08-05 23:40 ` Juri Linkov
2020-08-06 9:28 ` Philip K.
2020-08-06 23:43 ` Juri Linkov
2020-08-07 10:53 ` Philip K.
2020-08-08 23:54 ` Juri Linkov
2021-05-12 20:38 ` Lars Ingebrigtsen
2021-05-12 21:27 ` Philip Kaludercic
2021-05-22 20:29 ` Philip Kaludercic
2021-05-22 21:09 ` Philip Kaludercic
2021-05-23 6:49 ` Eli Zaretskii
2021-05-23 12:36 ` Philip Kaludercic
2021-05-25 5:12 ` Lars Ingebrigtsen
2021-05-25 7:25 ` Philip Kaludercic
2021-05-25 9:53 ` Philip Kaludercic
2021-05-25 11:16 ` Arthur Miller
2021-05-25 11:42 ` Philip Kaludercic
2021-05-25 13:31 ` Arthur Miller
2021-05-25 14:39 ` Philip Kaludercic
2021-05-25 11:36 ` Arthur Miller
2021-05-25 11:46 ` Philip Kaludercic
2021-05-25 13:58 ` Arthur Miller
2021-05-25 19:13 ` Lars Ingebrigtsen
2021-05-25 19:16 ` Lars Ingebrigtsen
2021-05-25 19:25 ` Philip Kaludercic
2021-05-25 20:18 ` Juri Linkov
2021-05-25 21:45 ` Philip Kaludercic
2021-05-26 21:35 ` Juri Linkov
2021-05-27 11:09 ` Philip Kaludercic
2021-05-30 22:11 ` Juri Linkov
2021-05-31 8:50 ` Philip Kaludercic
2021-05-31 20:15 ` Juri Linkov
2021-05-31 21:27 ` Philip Kaludercic
2021-06-03 20:36 ` Juri Linkov
-- strict thread matches above, loose matches on Subject: below --
2020-07-30 4:01 bug#42611: 26.3; edit-abbrevs lets me type and commit, but doesn't store anywhere and abbrevs don't work Brett Randall
[not found] ` <handler.42611.B.159608273314264.ack@debbugs.gnu.org>
[not found] ` <(Brett>
2020-10-17 8:41 ` Lars Ingebrigtsen
2020-10-27 10:36 ` brett.randall
[not found] ` <(brett>
[not found] ` <randall's>
[not found] ` <"Tue,>
[not found] ` <27>
[not found] ` <Oct>
2020-10-27 10:43 ` Lars Ingebrigtsen
2020-10-27 10:49 ` Brett Randall
2020-10-27 11:08 ` Lars Ingebrigtsen
[not found] ` <(Lars>
[not found] ` <Ingebrigtsen's>
[not found] ` <12:08:50>
2020-10-27 11:19 ` bug#42611: (no subject) Lars Ingebrigtsen
[not found] ` <877drbhq6c.fsf@gnus.org>
[not found] ` <handler.42611.C.160379757411378.notifdonectrl.0@debbugs.gnu.org>
2020-10-27 22:22 ` bug#42611: 26.3; edit-abbrevs lets me type and commit, but doesn't store anywhere and abbrevs don't work Brett Randall
2019-04-21 19:30 bug#35367: 26.2; `dired-copy-how-to-fn' and HOW-TO arg of `dired-create-files' Drew Adams
2019-07-09 14:21 ` Lars Ingebrigtsen
2019-07-11 5:51 ` Mike Kupfer
2019-07-11 14:04 ` Lars Ingebrigtsen
2019-07-11 14:18 ` Drew Adams
2019-07-12 3:20 ` Mike Kupfer
2019-07-12 3:33 ` Drew Adams
2022-01-22 14:43 ` Lars Ingebrigtsen
[not found] <Your>
[not found] ` <message>
[not found] ` <of>
[not found] ` <"Thu>
[not found] ` <"Thu,>
[not found] ` <"Tue>
[not found] ` <09>
[not found] ` <Jul>
[not found] ` <2019>
[not found] ` <07:18:26>
[not found] ` <16:21:24>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='87v9kn7rnk.fsf__13454.8490563006$1590172036$gmane$org@bulbul' \
--to=philip@warpmail.net \
--cc=41438@debbugs.gnu.org \
--cc=emacs-devel@gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).