61
61
(require 'cl-lib )
62
62
63
63
(defgroup resize-window nil
64
- " Quickly resize current window "
64
+ " Quickly resize windows. "
65
65
:group 'convenience
66
66
:prefix " rw-" )
67
67
74
74
:type 'integer )
75
75
76
76
(defcustom resize-window-allow-backgrounds t
77
- " Allow resize mode to set a background .
77
+ " Allow resize mode to set backgrounds .
78
78
This is also valuable to see that you are in resize mode."
79
79
:type 'boolean )
80
80
@@ -128,9 +128,9 @@ should return the fine adjustment (default 1)."
128
128
(?k resize-window--kill-other-windows " Kill other windows (save state)" nil )
129
129
(?y resize-window--restore-windows " (when state) Restore window configuration" nil )
130
130
(?? resize-window--display-menu " Resize - display menu" nil ))
131
- " List of actions for `resize-window-dispatch-default .
131
+ " List of resize mode bindings .
132
132
Main data structure of the dispatcher with the form:
133
- \( char function documentation match -capitals\) " )
133
+ \( key function documentation allows -capitals\) " )
134
134
135
135
(defvar resize-window-alias-list
136
136
'((right ?f )
@@ -141,16 +141,16 @@ Main data structure of the dispatcher with the form:
141
141
Rather than have to use n, etc, you can alias keys for others." )
142
142
143
143
(defun resize-window--notify (&rest info )
144
- " Notify with INFO, a string.
144
+ " Notify with INFO, a string or list (format-string object...) .
145
145
This is just a pass through to message usually. However, it can be
146
146
overridden in tests to test the output of message."
147
147
(when resize-window-notify-with-messages (apply #'message info)))
148
148
149
149
(defun resize-window--match-alias (key )
150
- " Taken the KEY or keyboard selection from `read-key` check for alias.
150
+ " Taken the KEY or keyboard selection from `read-key' check for alias.
151
151
Match the KEY against the alias table. If found, return the value that it
152
- points to, which should be a key in the ‘ resize-window-dispatch-alist’ .
153
- Otherwise, return the key ."
152
+ points to, which should be a key in the ` resize-window-dispatch-alist' .
153
+ Otherwise, return the KEY ."
154
154
(let ((alias (assoc key resize-window-alias-list)))
155
155
(if alias
156
156
(car (cdr alias))
@@ -177,7 +177,7 @@ nil."
177
177
178
178
(defun resize-window--display-choice (choice )
179
179
" Formats screen message about CHOICE.
180
- CHOICE is a \( key function description allows-capital \) ."
180
+ CHOICE is a \( key function documentation allows-capitals \) ."
181
181
(let ((key (resize-window--choice-keybinding choice)))
182
182
(format " %s : %s " (if (resize-window--allows-capitals choice)
183
183
(format " %s |%s "
@@ -187,6 +187,7 @@ CHOICE is a \(key function description allows-capital\)."
187
187
(resize-window--choice-documentation choice))))
188
188
189
189
(defun resize-window--get-documentation-strings ()
190
+ " Return documented keybindings as a multiline string."
190
191
(mapconcat #'identity (mapcar 'resize-window--display-choice
191
192
resize-window-dispatch-alist)
192
193
" \n " ))
@@ -203,8 +204,8 @@ CHOICE is a \(key function description allows-capital\)."
203
204
204
205
(defun resize-window--execute-action (choice &optional scaled )
205
206
" Given a CHOICE, grab values out of the alist.
206
- If SCALED, then call action with the resize-window-capital-argument. "
207
- ; ; (char function description)
207
+ CHOICE is a \( key function documentation allows-capitals \) .
208
+ If SCALED, then call action with the `resize-window-uppercase-argument' . "
208
209
(let ((action (resize-window--choice-lambda choice))
209
210
(description (resize-window--choice-documentation choice)))
210
211
(unless (equal (resize-window--choice-keybinding choice) ?? )
@@ -250,22 +251,25 @@ to enlarge right."
250
251
; ;; Function Handlers
251
252
(defun resize-window--enlarge-down (&optional size )
252
253
" Extend the current window downwards by optional SIZE.
253
- If no SIZE is given, extend by `resize-window-default -argument` "
254
+ If no SIZE is given, extend by `resize-window-lowercase -argument' . "
254
255
(let ((size (or size (resize-window-lowercase-argument))))
255
256
(enlarge-window size)))
256
257
257
258
(defun resize-window--enlarge-up (&optional size )
258
- " Bring bottom edge back up by one or optional SIZE."
259
+ " Bring bottom edge back up by one or optional SIZE.
260
+ If no SIZE is given, extend by `resize-window-lowercase-argument' ."
259
261
(let ((size (or size (resize-window-lowercase-argument))))
260
262
(enlarge-window (- size))))
261
263
262
264
(defun resize-window--enlarge-horizontally (&optional size )
263
- " Enlarge the window horizontally by one or optional SIZE."
265
+ " Enlarge the window horizontally by one or optional SIZE.
266
+ If no SIZE is given, extend by `resize-window-lowercase-argument' ."
264
267
(let ((size (or size (resize-window-lowercase-argument))))
265
268
(enlarge-window size t )))
266
269
267
270
(defun resize-window--shrink-horizontally (&optional size )
268
- " Shrink the window horizontally by one or optional SIZE."
271
+ " Shrink the window horizontally by one or optional SIZE.
272
+ If no SIZE is given, extend by `resize-window-lowercase-argument' ."
269
273
(let ((size (or size (resize-window-lowercase-argument))))
270
274
(enlarge-window (- size) t )))
271
275
@@ -274,9 +278,11 @@ If no SIZE is given, extend by `resize-window-default-argument`"
274
278
(balance-windows ))
275
279
276
280
(defun resize-window--delete-overlays ()
281
+ " Remove overlays."
277
282
(delete-overlay resize-window--background-overlay))
278
283
279
284
(defun resize-window--create-overlay ()
285
+ " Add overlay."
280
286
(setq resize-window--background-overlay (resize-window--make-background)))
281
287
282
288
(defun resize-window--cycle-window-positive ()
@@ -296,38 +302,48 @@ If no SIZE is given, extend by `resize-window-default-argument`"
296
302
(resize-window--notify " %s" (resize-window--get-documentation-strings)))
297
303
298
304
(defun resize-window--delete-window ()
305
+ " Delete the current window."
299
306
(delete-overlay resize-window--background-overlay)
300
307
(delete-window )
301
308
(setq resize-window--background-overlay (resize-window--make-background)))
302
309
303
310
(defun resize-window--window-push ()
311
+ " Save the current state in the stack."
304
312
(push (current-window-configuration ) resize-window--window-stack))
305
313
306
314
(defun resize-window--window-pop ()
315
+ " Return the first element and remove it from the stack."
307
316
(pop resize-window--window-stack))
308
317
309
318
(defun resize-window--kill-other-windows ()
319
+ " Delete other windows."
310
320
(resize-window--delete-overlays)
311
321
(resize-window--window-push)
312
322
(delete-other-windows )
313
323
(resize-window--create-overlay))
314
324
315
325
(defun resize-window--restore-windows ()
326
+ " Restore the previous state."
316
327
(let ((config (resize-window--window-pop)))
317
328
(when config
318
329
(resize-window--delete-overlays)
319
330
(set-window-configuration config)
320
331
(resize-window--create-overlay))))
321
332
322
- (defvar resize-window--capital-letters (number-sequence ?A ?Z ))
323
- (defvar resize-window--lower-letters (number-sequence ?a ?z ))
333
+ (defvar resize-window--capital-letters (number-sequence ?A ?Z )
334
+ " List of uppercase letters as characters." )
335
+ (defvar resize-window--lower-letters (number-sequence ?a ?z )
336
+ " List of lowercase letters as characters." )
324
337
325
338
(defun resize-window--key-available? (key )
339
+ " Return non-nil if KEY is bound, otherwise return nil."
326
340
(let ((keys (mapcar #'resize-window--choice-keybinding resize-window-dispatch-alist)))
327
341
(not (member key keys))))
328
342
329
343
(defun resize-window-add-choice (key func doc &optional allows-capitals )
330
- " Register a function for resize-window.
344
+ " Register a new binding for `resize-window' .
345
+ Refuses to replace an already taken key.
346
+
331
347
KEY is the char (eg ?c) that should invoke the FUNC. DOC is a doc
332
348
string for the help menu, and optional ALLOWS-CAPITALS should be
333
349
t or nil. Functions should be of zero arity if they do not allow
0 commit comments