branch: externals/window-commander
commit 73a241cf383ef7c6a8591cb34b17ac3cdd1c4668
Author: Daniel Semyonov <[email protected]>
Commit: Daniel Semyonov <[email protected]>
Ensure 'swsw-id-chars' is set correctly when customized
* swsw.el (swsw--set-id-chars): New set function for 'swsw-id-chars'
which ensures it contains at least 2 characters and updates
information for all tracked windows.
(swsw-id-chars): Set 'set' function to 'swsw--set-id-chars'.
---
swsw.el | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/swsw.el b/swsw.el
index a41d48d748..65c52f0f52 100644
--- a/swsw.el
+++ b/swsw.el
@@ -64,9 +64,21 @@
:group 'convenience
:prefix "swsw-")
+(defun swsw--set-id-chars (sym chars)
+ "Set the variable ‘swsw-id-chars’.
+Check that the new list has at least two elements, set SYM’s value to
+CHARS, and call ‘swsw-update’."
+ (if (> 2 (length chars))
+ (user-error
+ "‘swsw-id-chars’ should contain at least two characters")
+ (set-default sym chars)
+ (swsw-update)))
+
(defcustom swsw-id-chars '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
- "Base set of characters from which window IDs are constructed."
- :type '(repeat character))
+ "Base set of characters from which window IDs are constructed.
+This list should contain at least two characters."
+ :type '(repeat character)
+ :set #'swsw--set-id-chars)
(defcustom swsw-minibuffer-id ?m
"ID reserved for the minibuffer."