Skip to content

Commit 23d850c

Browse files
committed
Formalize docstrings
Add missing docstrings and fix typos/meanings.
1 parent 72018aa commit 23d850c

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

resize-window.el

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
(require 'cl-lib)
6262

6363
(defgroup resize-window nil
64-
"Quickly resize current window"
64+
"Quickly resize windows."
6565
:group 'convenience
6666
:prefix "rw-")
6767

@@ -74,7 +74,7 @@
7474
:type 'integer)
7575

7676
(defcustom resize-window-allow-backgrounds t
77-
"Allow resize mode to set a background.
77+
"Allow resize mode to set backgrounds.
7878
This is also valuable to see that you are in resize mode."
7979
:type 'boolean)
8080

@@ -128,9 +128,9 @@ should return the fine adjustment (default 1)."
128128
(?k resize-window--kill-other-windows " Kill other windows (save state)" nil)
129129
(?y resize-window--restore-windows " (when state) Restore window configuration" nil)
130130
(?? resize-window--display-menu " Resize - display menu" nil))
131-
"List of actions for `resize-window-dispatch-default.
131+
"List of resize mode bindings.
132132
Main data structure of the dispatcher with the form:
133-
\(char function documentation match-capitals\)")
133+
\(key function documentation allows-capitals\)")
134134

135135
(defvar resize-window-alias-list
136136
'((right ?f)
@@ -141,16 +141,16 @@ Main data structure of the dispatcher with the form:
141141
Rather than have to use n, etc, you can alias keys for others.")
142142

143143
(defun resize-window--notify (&rest info)
144-
"Notify with INFO, a string.
144+
"Notify with INFO, a string or list (format-string object...).
145145
This is just a pass through to message usually. However, it can be
146146
overridden in tests to test the output of message."
147147
(when resize-window-notify-with-messages (apply #'message info)))
148148

149149
(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.
151151
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."
154154
(let ((alias (assoc key resize-window-alias-list)))
155155
(if alias
156156
(car (cdr alias))
@@ -177,7 +177,7 @@ nil."
177177

178178
(defun resize-window--display-choice (choice)
179179
"Formats screen message about CHOICE.
180-
CHOICE is a \(key function description allows-capital\)."
180+
CHOICE is a \(key function documentation allows-capitals\)."
181181
(let ((key (resize-window--choice-keybinding choice)))
182182
(format "%s: %s " (if (resize-window--allows-capitals choice)
183183
(format "%s|%s"
@@ -187,6 +187,7 @@ CHOICE is a \(key function description allows-capital\)."
187187
(resize-window--choice-documentation choice))))
188188

189189
(defun resize-window--get-documentation-strings ()
190+
"Return documented keybindings as a multiline string."
190191
(mapconcat #'identity (mapcar 'resize-window--display-choice
191192
resize-window-dispatch-alist)
192193
"\n"))
@@ -203,8 +204,8 @@ CHOICE is a \(key function description allows-capital\)."
203204

204205
(defun resize-window--execute-action (choice &optional scaled)
205206
"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'."
208209
(let ((action (resize-window--choice-lambda choice))
209210
(description (resize-window--choice-documentation choice)))
210211
(unless (equal (resize-window--choice-keybinding choice) ??)
@@ -250,22 +251,25 @@ to enlarge right."
250251
;;; Function Handlers
251252
(defun resize-window--enlarge-down (&optional size)
252253
"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'."
254255
(let ((size (or size (resize-window-lowercase-argument))))
255256
(enlarge-window size)))
256257

257258
(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'."
259261
(let ((size (or size (resize-window-lowercase-argument))))
260262
(enlarge-window (- size))))
261263

262264
(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'."
264267
(let ((size (or size (resize-window-lowercase-argument))))
265268
(enlarge-window size t)))
266269

267270
(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'."
269273
(let ((size (or size (resize-window-lowercase-argument))))
270274
(enlarge-window (- size) t)))
271275

@@ -274,9 +278,11 @@ If no SIZE is given, extend by `resize-window-default-argument`"
274278
(balance-windows))
275279

276280
(defun resize-window--delete-overlays ()
281+
"Remove overlays."
277282
(delete-overlay resize-window--background-overlay))
278283

279284
(defun resize-window--create-overlay ()
285+
"Add overlay."
280286
(setq resize-window--background-overlay (resize-window--make-background)))
281287

282288
(defun resize-window--cycle-window-positive ()
@@ -296,38 +302,48 @@ If no SIZE is given, extend by `resize-window-default-argument`"
296302
(resize-window--notify "%s" (resize-window--get-documentation-strings)))
297303

298304
(defun resize-window--delete-window ()
305+
"Delete the current window."
299306
(delete-overlay resize-window--background-overlay)
300307
(delete-window)
301308
(setq resize-window--background-overlay (resize-window--make-background)))
302309

303310
(defun resize-window--window-push ()
311+
"Save the current state in the stack."
304312
(push (current-window-configuration) resize-window--window-stack))
305313

306314
(defun resize-window--window-pop ()
315+
"Return the first element and remove it from the stack."
307316
(pop resize-window--window-stack))
308317

309318
(defun resize-window--kill-other-windows ()
319+
"Delete other windows."
310320
(resize-window--delete-overlays)
311321
(resize-window--window-push)
312322
(delete-other-windows)
313323
(resize-window--create-overlay))
314324

315325
(defun resize-window--restore-windows ()
326+
"Restore the previous state."
316327
(let ((config (resize-window--window-pop)))
317328
(when config
318329
(resize-window--delete-overlays)
319330
(set-window-configuration config)
320331
(resize-window--create-overlay))))
321332

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.")
324337

325338
(defun resize-window--key-available? (key)
339+
"Return non-nil if KEY is bound, otherwise return nil."
326340
(let ((keys (mapcar #'resize-window--choice-keybinding resize-window-dispatch-alist)))
327341
(not (member key keys))))
328342

329343
(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+
331347
KEY is the char (eg ?c) that should invoke the FUNC. DOC is a doc
332348
string for the help menu, and optional ALLOWS-CAPITALS should be
333349
t or nil. Functions should be of zero arity if they do not allow

0 commit comments

Comments
 (0)