Skip to content

Commit d4aa9e6

Browse files
author
dan sutton
committed
make internal methods have resize-window-- prefix
1 parent ad2573d commit d4aa9e6

File tree

2 files changed

+49
-51
lines changed

2 files changed

+49
-51
lines changed

resize-window.el

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ This is also valuable to see that you are in resize mode."
6969
"Show notifications in message bar."
7070
:type 'boolean)
7171

72-
(defvar resize-window-background-overlay ()
72+
(defvar resize-window--background-overlay ()
7373
"Holder for background overlay.")
7474

7575
(defface resize-window-background
@@ -95,14 +95,14 @@ should return the fine adjustment (default 1)."
9595
resize-window-coarse-argument))
9696

9797
(defvar resize-window-dispatch-alist
98-
'((?n resize-window-enlarge-down " Resize - Expand down" t)
99-
(?p resize-window-enlarge-up " Resize - Expand up" t)
100-
(?f resize-window-enlarge-horizontally " Resize - horizontally" t)
101-
(?b resize-window-shrink-horizontally " Resize - shrink horizontally" t)
102-
(?r resize-window-reset-windows " Resize - reset window layour" nil)
103-
(?w resize-window-cycle-window-positive " Resize - cycle window" nil)
104-
(?W resize-window-cycle-window-negative " Resize - cycle window" nil)
105-
(?? resize-window-display-menu " Resize - display menu" nil))
98+
'((?n resize-window--enlarge-down " Resize - Expand down" t)
99+
(?p resize-window--enlarge-up " Resize - Expand up" t)
100+
(?f resize-window--enlarge-horizontally " Resize - horizontally" t)
101+
(?b resize-window--shrink-horizontally " Resize - shrink horizontally" t)
102+
(?r resize-window--reset-windows " Resize - reset window layour" nil)
103+
(?w resize-window--cycle-window-positive " Resize - cycle window" nil)
104+
(?W resize-window--cycle-window-negative " Resize - cycle window" nil)
105+
(?? resize-window--display-menu " Resize - display menu" nil))
106106
"List of actions for `resize-window-dispatch-default.
107107
Main data structure of the dispatcher with the form:
108108
\(char function documentation match-capitals\)")
@@ -115,13 +115,13 @@ Main data structure of the dispatcher with the form:
115115
"List of aliases for commands.
116116
Rather than have to use n, etc, you can alias keys for others.")
117117

118-
(defun resize-window-notify (&rest info)
118+
(defun resize-window--notify (&rest info)
119119
"Notify with INFO, a string.
120120
This is just a pass through to message usually. However, it can be
121121
overridden in tests to test the output of message."
122122
(when resize-window-notify-with-messages (apply #'message info)))
123123

124-
(defun resize-window-match-alias (key)
124+
(defun resize-window--match-alias (key)
125125
"Taken the KEY or keyboard selection from `read-key` check for alias.
126126
Match the KEY against the alias table. If found, return the value that it
127127
points to, which should be a key in the resize-window-dispatch-alist.
@@ -131,25 +131,25 @@ Otherwise, return the key."
131131
(car (cdr alias))
132132
key)))
133133

134-
(defun resize-window-display-choice (choice)
134+
(defun resize-window--display-choice (choice)
135135
"Formats screen message about CHOICE.
136136
CHOICE is a \(key function description allows-capital\)."
137-
(format "%s: %s " (if (resize-window-allows-capitals choice)
137+
(format "%s: %s " (if (resize-window--allows-capitals choice)
138138
(format "%s|%s"
139139
(string (car choice))
140140
(string (- (car choice) 32)))
141141
(string (car choice)))
142142
(car (cdr (cdr choice)))))
143143

144-
(defun resize-window-get-documentation-strings ()
144+
(defun resize-window--get-documentation-strings ()
145145
"Get all documentation strings for display."
146146
(let ((documentation ""))
147147
(dolist (choice resize-window-dispatch-alist)
148148
(setq documentation
149-
(concat (resize-window-display-choice choice) "\n" documentation)))
149+
(concat (resize-window--display-choice choice) "\n" documentation)))
150150
documentation))
151151

152-
(defun resize-window-make-background ()
152+
(defun resize-window--make-background ()
153153
"Place a background over the current window."
154154
(when resize-window-allow-backgrounds
155155
(let ((ol (make-overlay
@@ -159,7 +159,7 @@ CHOICE is a \(key function description allows-capital\)."
159159
(overlay-put ol 'face 'resize-window-background)
160160
ol)))
161161

162-
(defun resize-window-execute-action (choice &optional scaled)
162+
(defun resize-window--execute-action (choice &optional scaled)
163163
"Given a CHOICE, grab values out of the alist.
164164
If SCALED, then call action with the resize-window-capital-argument."
165165
;; (char function description)
@@ -169,9 +169,9 @@ If SCALED, then call action with the resize-window-capital-argument."
169169
(funcall action (resize-window-uppercase-argument))
170170
(funcall action))
171171
(unless (equal (car choice) ??)
172-
(resize-window-notify "%s" description))))
172+
(resize-window--notify "%s" description))))
173173

174-
(defun resize-window-allows-capitals (choice)
174+
(defun resize-window--allows-capitals (choice)
175175
"To save time typing, we will tell whether we allow capitals for scaling.
176176
To do so, we check to see whether CHOICE allows for capitals by
177177
checking its last spot in the list for whether it is true or
@@ -184,66 +184,66 @@ nil."
184184
Press n to enlarge down, p to enlarge up, b to enlarge left and f
185185
to enlarge right."
186186
(interactive)
187-
(setq resize-window-background-overlay (resize-window-make-background))
188-
(resize-window-notify "Resize mode: enter character, ? for help")
187+
(setq resize-window--background-overlay (resize-window--make-background))
188+
(resize-window--notify "Resize mode: enter character, ? for help")
189189
(let ((reading-characters t)
190190
;; allow mini-buffer to collapse after displaying menu
191191
(resize-mini-windows t))
192192
(while reading-characters
193-
(let* ((char (resize-window-match-alias (read-key)))
193+
(let* ((char (resize-window--match-alias (read-key)))
194194
(choice (assoc char resize-window-dispatch-alist))
195195
(capital (assoc (+ char 32) resize-window-dispatch-alist)))
196196
(cond
197-
(choice (resize-window-execute-action choice))
198-
((and capital (resize-window-allows-capitals capital))
197+
(choice (resize-window--execute-action choice))
198+
((and capital (resize-window--allows-capitals capital))
199199
;; rather than pass an argument, we tell it to "scale" it
200200
;; with t and that method can worry about how to get that
201201
;; action
202-
(resize-window-execute-action capital t))
202+
(resize-window--execute-action capital t))
203203
(t (setq reading-characters nil)
204-
(delete-overlay resize-window-background-overlay)))))))
204+
(delete-overlay resize-window--background-overlay)))))))
205205

206206
;;; Function Handlers
207-
(defun resize-window-enlarge-down (&optional size)
207+
(defun resize-window--enlarge-down (&optional size)
208208
"Extend the current window downwards by optional SIZE.
209209
If no SIZE is given, extend by `resize-window-default-argument`"
210210
(let ((size (or size (resize-window-lowercase-argument))))
211211
(enlarge-window size)))
212212

213-
(defun resize-window-enlarge-up (&optional size)
213+
(defun resize-window--enlarge-up (&optional size)
214214
"Bring bottom edge back up by one or optional SIZE."
215215
(let ((size (or size (resize-window-lowercase-argument))))
216216
(enlarge-window (- size))))
217217

218-
(defun resize-window-enlarge-horizontally (&optional size)
218+
(defun resize-window--enlarge-horizontally (&optional size)
219219
"Enlarge the window horizontally by one or optional SIZE."
220220
(let ((size (or size (resize-window-lowercase-argument))))
221221
(enlarge-window size t)))
222222

223-
(defun resize-window-shrink-horizontally (&optional size)
223+
(defun resize-window--shrink-horizontally (&optional size)
224224
"Shrink the window horizontally by one or optional SIZE."
225225
(let ((size (or size (resize-window-lowercase-argument))))
226226
(enlarge-window (- size) t)))
227227

228-
(defun resize-window-reset-windows ()
228+
(defun resize-window--reset-windows ()
229229
"Reset window layout to even spread."
230230
(balance-windows))
231231

232-
(defun resize-window-cycle-window-positive ()
232+
(defun resize-window--cycle-window-positive ()
233233
"Cycle windows."
234-
(delete-overlay resize-window-background-overlay)
234+
(delete-overlay resize-window--background-overlay)
235235
(other-window 1)
236-
(setq resize-window-background-overlay (resize-window-make-background)))
236+
(setq resize-window--background-overlay (resize-window--make-background)))
237237

238-
(defun resize-window-cycle-window-negative ()
238+
(defun resize-window--cycle-window-negative ()
239239
"Cycle windows negative."
240-
(delete-overlay resize-window-background-overlay)
240+
(delete-overlay resize-window--background-overlay)
241241
(other-window -1)
242-
(setq resize-window-background-overlay (resize-window-make-background)))
242+
(setq resize-window--background-overlay (resize-window--make-background)))
243243

244-
(defun resize-window-display-menu ()
244+
(defun resize-window--display-menu ()
245245
"Display menu in minibuffer."
246-
(resize-window-notify "%s" (resize-window-get-documentation-strings)))
246+
(resize-window--notify "%s" (resize-window--get-documentation-strings)))
247247

248248
(provide 'resize-window)
249249
;;; resize-window.el ends here

test/resize-window-test.el

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,30 @@
99
(defvar choice-capital '(?n 'function "documentation" t))
1010

1111
(ert-deftest should-match-aliases ()
12-
(should (equal ?f (resize-window-match-alias 'right)))
13-
(should (equal ?b (resize-window-match-alias 'left)))
14-
(should (equal ?n (resize-window-match-alias 'up)))
15-
(should (equal ?p (resize-window-match-alias 'down))))
12+
(should (equal ?f (resize-window--match-alias 'right)))
13+
(should (equal ?b (resize-window--match-alias 'left)))
14+
(should (equal ?n (resize-window--match-alias 'up)))
15+
(should (equal ?p (resize-window--match-alias 'down))))
1616

1717
(ert-deftest should-return-original-if-no-alias ()
18-
(should (equal ?d (resize-window-match-alias ?d))))
18+
(should (equal ?d (resize-window--match-alias ?d))))
1919

2020
(ert-deftest should-create-documentation-from-alist ()
2121
(should (equal "n: documentation "
22-
(resize-window-display-choice choice-no-capital)))
22+
(resize-window--display-choice choice-no-capital)))
2323
(should (equal "n|N: documentation "
24-
(resize-window-display-choice choice-capital))))
24+
(resize-window--display-choice choice-capital))))
2525

2626
(ert-deftest should-execute-and-display-message ()
2727
(let ((choice '(?n (lambda () (setq executed t)) "doc" nil))
2828
resize-window-notify-with-messages ;suppress messages
29-
(resize-window-notify)
30-
(message-written)
3129
(executed))
32-
(resize-window-execute-action choice)
30+
(resize-window--execute-action choice)
3331
(should (equal executed t))))
3432

3533
(ert-deftest should-identify-which-allow-capital-matching ()
36-
(should (resize-window-allows-capitals choice-capital))
37-
(should-not (resize-window-allows-capitals choice-no-capital)))
34+
(should (resize-window--allows-capitals choice-capital))
35+
(should-not (resize-window--allows-capitals choice-no-capital)))
3836

3937
;;; tests for swapping uppercase and lowercase behavior
4038
(ert-deftest resize-window-swap-capital-and-lowercase-behavior-swaps ()

0 commit comments

Comments
 (0)