diff options
| author | F. Jason Park | 2023-11-18 23:44:20 -0800 |
|---|---|---|
| committer | F. Jason Park | 2023-11-24 13:38:52 -0800 |
| commit | 0d6c8d41ab7172a496c6db951c270821807dce99 (patch) | |
| tree | cec32be0beef207b55923480bf983abfb152d94d /test | |
| parent | 3c9cba9df3d392a89314e06a6396c4157065f3b0 (diff) | |
| download | emacs-0d6c8d41ab7172a496c6db951c270821807dce99.tar.gz emacs-0d6c8d41ab7172a496c6db951c270821807dce99.zip | |
Use overlay instead of text prop to hide ERC's prompt
* lisp/erc/erc-backend.el (erc--hidden-prompt-overlay):
New variable, a buffer-local handle for the prompt overlay.
(erc--reveal-prompt): Delete overlay instead of text prop.
(erc--conceal-prompt): Add overlay instead of text prop.
(erc--unhide-prompt): Run `erc--refresh-prompt-hook' after revealing.
(erc--hide-prompt): Run `erc--refresh-prompt-hook' after hiding.
* lisp/erc/erc-stamp.el (erc-stamp--adjust-margin): Attempt a more
accurate estimate of the prompt's width in columns when initially
setting left-margin.
(erc-stamp--skip-left-margin-prompt-p): New variable to inhibit normal
behavior of displaying prompt in left margin.
(erc-stamp--display-margin-mode): Allow opting out of
prompt-in-left-margin behavior.
(erc--reveal-prompt): Delete unneeded method implementation.
(erc--conceal-prompt): Put overlay in margin.
* test/lisp/erc/erc-tests.el (erc-hide-prompt): Use
`get-char-property' instead of `get-text-property' in order to
accommodate overlay-based prompt hiding. (Bug#51082)
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 8c85f37dfe5..980928aceac 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -187,101 +187,101 @@ | |||
| 187 | (with-current-buffer "ServNet" | 187 | (with-current-buffer "ServNet" |
| 188 | (should (= (point) erc-insert-marker)) | 188 | (should (= (point) erc-insert-marker)) |
| 189 | (erc--hide-prompt erc-server-process) | 189 | (erc--hide-prompt erc-server-process) |
| 190 | (should (string= ">" (get-text-property (point) 'display)))) | 190 | (should (string= ">" (get-char-property (point) 'display)))) |
| 191 | 191 | ||
| 192 | (with-current-buffer "#chan" | 192 | (with-current-buffer "#chan" |
| 193 | (goto-char erc-insert-marker) | 193 | (goto-char erc-insert-marker) |
| 194 | (should (string= ">" (get-text-property (point) 'display))) | 194 | (should (string= ">" (get-char-property (point) 'display))) |
| 195 | (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) | 195 | (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) |
| 196 | (goto-char erc-input-marker) | 196 | (goto-char erc-input-marker) |
| 197 | (ert-simulate-command '(self-insert-command 1 ?/)) | 197 | (ert-simulate-command '(self-insert-command 1 ?/)) |
| 198 | (goto-char erc-insert-marker) | 198 | (goto-char erc-insert-marker) |
| 199 | (should-not (get-text-property (point) 'display)) | 199 | (should-not (get-char-property (point) 'display)) |
| 200 | (should-not (memq #'erc--unhide-prompt-on-self-insert | 200 | (should-not (memq #'erc--unhide-prompt-on-self-insert |
| 201 | pre-command-hook))) | 201 | pre-command-hook))) |
| 202 | 202 | ||
| 203 | (with-current-buffer "bob" | 203 | (with-current-buffer "bob" |
| 204 | (goto-char erc-insert-marker) | 204 | (goto-char erc-insert-marker) |
| 205 | (should (string= ">" (get-text-property (point) 'display))) | 205 | (should (string= ">" (get-char-property (point) 'display))) |
| 206 | (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) | 206 | (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) |
| 207 | (goto-char erc-input-marker) | 207 | (goto-char erc-input-marker) |
| 208 | (ert-simulate-command '(self-insert-command 1 ?/)) | 208 | (ert-simulate-command '(self-insert-command 1 ?/)) |
| 209 | (goto-char erc-insert-marker) | 209 | (goto-char erc-insert-marker) |
| 210 | (should-not (get-text-property (point) 'display)) | 210 | (should-not (get-char-property (point) 'display)) |
| 211 | (should-not (memq #'erc--unhide-prompt-on-self-insert | 211 | (should-not (memq #'erc--unhide-prompt-on-self-insert |
| 212 | pre-command-hook))) | 212 | pre-command-hook))) |
| 213 | 213 | ||
| 214 | (with-current-buffer "ServNet" | 214 | (with-current-buffer "ServNet" |
| 215 | (should (get-text-property erc-insert-marker 'display)) | 215 | (should (get-char-property erc-insert-marker 'display)) |
| 216 | (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) | 216 | (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) |
| 217 | (erc--unhide-prompt) | 217 | (erc--unhide-prompt) |
| 218 | (should-not (memq #'erc--unhide-prompt-on-self-insert | 218 | (should-not (memq #'erc--unhide-prompt-on-self-insert |
| 219 | pre-command-hook)) | 219 | pre-command-hook)) |
| 220 | (should-not (get-text-property erc-insert-marker 'display)))) | 220 | (should-not (get-char-property erc-insert-marker 'display)))) |
| 221 | 221 | ||
| 222 | (ert-info ("Value: server") | 222 | (ert-info ("Value: server") |
| 223 | (setq erc-hide-prompt '(server)) | 223 | (setq erc-hide-prompt '(server)) |
| 224 | (with-current-buffer "ServNet" | 224 | (with-current-buffer "ServNet" |
| 225 | (erc--hide-prompt erc-server-process) | 225 | (erc--hide-prompt erc-server-process) |
| 226 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) 'hidden)) | 226 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) 'hidden)) |
| 227 | (should (string= ">" (get-text-property erc-insert-marker 'display)))) | 227 | (should (string= ">" (get-char-property erc-insert-marker 'display)))) |
| 228 | 228 | ||
| 229 | (with-current-buffer "#chan" | 229 | (with-current-buffer "#chan" |
| 230 | (should-not (get-text-property erc-insert-marker 'display))) | 230 | (should-not (get-char-property erc-insert-marker 'display))) |
| 231 | 231 | ||
| 232 | (with-current-buffer "bob" | 232 | (with-current-buffer "bob" |
| 233 | (should-not (get-text-property erc-insert-marker 'display))) | 233 | (should-not (get-char-property erc-insert-marker 'display))) |
| 234 | 234 | ||
| 235 | (with-current-buffer "ServNet" | 235 | (with-current-buffer "ServNet" |
| 236 | (erc--unhide-prompt) | 236 | (erc--unhide-prompt) |
| 237 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) t)) | 237 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) t)) |
| 238 | (should-not (get-text-property erc-insert-marker 'display)))) | 238 | (should-not (get-char-property erc-insert-marker 'display)))) |
| 239 | 239 | ||
| 240 | (ert-info ("Value: channel") | 240 | (ert-info ("Value: channel") |
| 241 | (setq erc-hide-prompt '(channel)) | 241 | (setq erc-hide-prompt '(channel)) |
| 242 | (with-current-buffer "ServNet" | 242 | (with-current-buffer "ServNet" |
| 243 | (erc--hide-prompt erc-server-process) | 243 | (erc--hide-prompt erc-server-process) |
| 244 | (should-not (get-text-property erc-insert-marker 'display))) | 244 | (should-not (get-char-property erc-insert-marker 'display))) |
| 245 | 245 | ||
| 246 | (with-current-buffer "bob" | 246 | (with-current-buffer "bob" |
| 247 | (should-not (get-text-property erc-insert-marker 'display))) | 247 | (should-not (get-char-property erc-insert-marker 'display))) |
| 248 | 248 | ||
| 249 | (with-current-buffer "#chan" | 249 | (with-current-buffer "#chan" |
| 250 | (should (string= ">" (get-text-property erc-insert-marker 'display))) | 250 | (should (string= ">" (get-char-property erc-insert-marker 'display))) |
| 251 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) 'hidden)) | 251 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) 'hidden)) |
| 252 | (erc--unhide-prompt) | 252 | (erc--unhide-prompt) |
| 253 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) t)) | 253 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) t)) |
| 254 | (should-not (get-text-property erc-insert-marker 'display)))) | 254 | (should-not (get-char-property erc-insert-marker 'display)))) |
| 255 | 255 | ||
| 256 | (ert-info ("Value: query") | 256 | (ert-info ("Value: query") |
| 257 | (setq erc-hide-prompt '(query)) | 257 | (setq erc-hide-prompt '(query)) |
| 258 | (with-current-buffer "ServNet" | 258 | (with-current-buffer "ServNet" |
| 259 | (erc--hide-prompt erc-server-process) | 259 | (erc--hide-prompt erc-server-process) |
| 260 | (should-not (get-text-property erc-insert-marker 'display))) | 260 | (should-not (get-char-property erc-insert-marker 'display))) |
| 261 | 261 | ||
| 262 | (with-current-buffer "bob" | 262 | (with-current-buffer "bob" |
| 263 | (should (string= ">" (get-text-property erc-insert-marker 'display))) | 263 | (should (string= ">" (get-char-property erc-insert-marker 'display))) |
| 264 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) 'hidden)) | 264 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) 'hidden)) |
| 265 | (erc--unhide-prompt) | 265 | (erc--unhide-prompt) |
| 266 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) t)) | 266 | (should (eq (get-text-property erc-insert-marker 'erc-prompt) t)) |
| 267 | (should-not (get-text-property erc-insert-marker 'display))) | 267 | (should-not (get-char-property erc-insert-marker 'display))) |
| 268 | 268 | ||
| 269 | (with-current-buffer "#chan" | 269 | (with-current-buffer "#chan" |
| 270 | (should-not (get-text-property erc-insert-marker 'display)))) | 270 | (should-not (get-char-property erc-insert-marker 'display)))) |
| 271 | 271 | ||
| 272 | (ert-info ("Value: nil") | 272 | (ert-info ("Value: nil") |
| 273 | (setq erc-hide-prompt nil) | 273 | (setq erc-hide-prompt nil) |
| 274 | (with-current-buffer "ServNet" | 274 | (with-current-buffer "ServNet" |
| 275 | (erc--hide-prompt erc-server-process) | 275 | (erc--hide-prompt erc-server-process) |
| 276 | (should-not (get-text-property erc-insert-marker 'display))) | 276 | (should-not (get-char-property erc-insert-marker 'display))) |
| 277 | 277 | ||
| 278 | (with-current-buffer "bob" | 278 | (with-current-buffer "bob" |
| 279 | (should-not (get-text-property erc-insert-marker 'display))) | 279 | (should-not (get-char-property erc-insert-marker 'display))) |
| 280 | 280 | ||
| 281 | (with-current-buffer "#chan" | 281 | (with-current-buffer "#chan" |
| 282 | (should-not (get-text-property erc-insert-marker 'display)) | 282 | (should-not (get-char-property erc-insert-marker 'display)) |
| 283 | (erc--unhide-prompt) ; won't blow up when prompt already showing | 283 | (erc--unhide-prompt) ; won't blow up when prompt already showing |
| 284 | (should-not (get-text-property erc-insert-marker 'display)))) | 284 | (should-not (get-char-property erc-insert-marker 'display)))) |
| 285 | 285 | ||
| 286 | (when noninteractive | 286 | (when noninteractive |
| 287 | (kill-buffer "#chan") | 287 | (kill-buffer "#chan") |