about summary refs log tree commit diff
path: root/exwm-manage.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2019-08-11T00·00+0000
committerChris Feng <chris.w.feng@gmail.com>2019-08-11T00·00+0000
commitd78c562f9a90055b595cb783928af43597b5ca6c (patch)
treeabd96ed76934ba94daa1dd3a881db07f7cb9a9c2 /exwm-manage.el
parenta1cf0d9b85e1d1d4f3b50a9d51980688b7b816df (diff)
Make `exwm-manage-configurations' more user friendly
* exwm-manage.el (exwm-manage-configurations): Specify type for each
configuration option.
Diffstat (limited to 'exwm-manage.el')
-rw-r--r--exwm-manage.el78
1 files changed, 57 insertions, 21 deletions
diff --git a/exwm-manage.el b/exwm-manage.el
index 6f89fff4f048..797fc15cc678 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -74,28 +74,64 @@ criterion would be applied."
   :type '(alist :key-type (sexp :tag "Matching criterion" nil)
                 :value-type
                 (plist :tag "Configurations"
-                       :key-type
-                       (choice
-                        (const :tag "Floating" floating)
-                        (const :tag "X" x)
-                        (const :tag "Y" y)
-                        (const :tag "Width" width)
-                        (const :tag "Height" height)
-                        (const :tag "Border width" border-width)
-                        (const :tag "Fullscreen" fullscreen)
-                        (const :tag "Floating mode-line" floating-mode-line)
-                        (const :tag "Tiling mode-line" tiling-mode-line)
-                        (const :tag "Floating header-line"
-                               floating-header-line)
-                        (const :tag "Tiling header-line" tiling-header-line)
-                        (const :tag "Char-mode" char-mode)
-                        (const :tag "Prefix keys" prefix-keys)
-                        (const :tag "Simulation keys" simulation-keys)
-                        (const :tag "Workspace" workspace)
-                        (const :tag "Managed" managed)
+                       :options
+                       (((const :tag "Floating" floating) boolean)
+                        ((const :tag "X" x) number)
+                        ((const :tag "Y" y) number)
+                        ((const :tag "Width" width) number)
+                        ((const :tag "Height" height) number)
+                        ((const :tag "Border width" border-width) integer)
+                        ((const :tag "Fullscreen" fullscreen) boolean)
+                        ((const :tag "Floating mode-line" floating-mode-line)
+                         sexp)
+                        ((const :tag "Tiling mode-line" tiling-mode-line) sexp)
+                        ((const :tag "Floating header-line"
+                                floating-header-line)
+                         sexp)
+                        ((const :tag "Tiling header-line" tiling-header-line)
+                         sexp)
+                        ((const :tag "Char-mode" char-mode) boolean)
+                        ((const :tag "Prefix keys" prefix-keys)
+                         (repeat key-sequence))
+                        ((const :tag "Simulation keys" simulation-keys)
+                         (alist :key-type (key-sequence :tag "From")
+                                :value-type (key-sequence :tag "To")))
+                        ((const :tag "Workspace" workspace) integer)
+                        ((const :tag "Managed" managed) boolean)
                         ;; For forward compatibility.
-                        (other))
-                       :value-type (sexp :tag "Value" nil))))
+                        ((other) sexp))))
+  ;; TODO: This is admittedly ugly.  We'd be better off with an event type.
+  :get (lambda (symbol)
+         (mapcar (lambda (pair)
+                   (let* ((match (car pair))
+                          (config (cdr pair))
+                          (prefix-keys (plist-get config 'prefix-keys)))
+                     (when prefix-keys
+                       (setq config (copy-tree config)
+                             config (plist-put config 'prefix-keys
+                                               (mapcar (lambda (i)
+                                                         (if (sequencep i)
+                                                             i
+                                                           (vector i)))
+                                                       prefix-keys))))
+                     (cons match config)))
+                 (default-value symbol)))
+  :set (lambda (symbol value)
+         (set symbol
+              (mapcar (lambda (pair)
+                        (let* ((match (car pair))
+                               (config (cdr pair))
+                               (prefix-keys (plist-get config 'prefix-keys)))
+                          (when prefix-keys
+                            (setq config (copy-tree config)
+                                  config (plist-put config 'prefix-keys
+                                                    (mapcar (lambda (i)
+                                                              (if (sequencep i)
+                                                                  (aref i 0)
+                                                                i))
+                                                            prefix-keys))))
+                          (cons match config)))
+                      value))))
 
 ;; FIXME: Make the following values as small as possible.
 (defconst exwm-manage--height-delta-min 5)