diff options
| author | F. Jason Park | 2023-12-19 22:33:48 -0800 |
|---|---|---|
| committer | F. Jason Park | 2023-12-23 06:46:33 -0800 |
| commit | 9cd47017c705fe0efe8f42c143807a489ed69016 (patch) | |
| tree | 8a315109220748e52adac0537df2a397087614fa /test | |
| parent | 34fe0b5c87ca991436d999d451276838529c96c2 (diff) | |
| download | emacs-9cd47017c705fe0efe8f42c143807a489ed69016.tar.gz emacs-9cd47017c705fe0efe8f42c143807a489ed69016.zip | |
Fix overlapping logs from erc-truncate-buffer-on-save
* lisp/erc/erc-button.el (erc-button--display-error-notice-with-keys):
Currently, internal "error notices" do not have timestamps. However,
this causes alignment issues for non-`fill-wrap' users of left-sided
stamps. The heuristic used by this change for detecting such stamps
is weak and prone to false negatives.
* lisp/erc/erc-log.el (erc-log-mode, erc-log-enable): Set explicit
depth for `erc--pre-clear-functions' to 50.
(erc-save-buffer-in-logs): Fix partial regression in which redundant
text would appear in logs that have undergone truncation via an
interactive call to this command when the deprecated option
`erc-truncate-on-save' is non-nil.
* lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-enable): Set
depth for `erc--pre-clear-functions' to 40.
(erc-stamp--reset-on-clear): Only add `erc-stamp--insert-date-hook'
when `erc-stamp--date-mode' is active.
* lisp/erc/erc.el (erc-cmd-CLEAR): Rework to honor but improve upon
the old behavior when called from lisp. Do this by attempting to find
the beginning of the current message and excluding it from the
truncated portion of the buffer. A NEWS entry describing this
behavior already exists for 5.6.
* test/lisp/erc/erc-scenarios-log.el
(erc-scenarios-log--save-buffer-in-logs/truncate-on-save): New test.
These changes originate from bug#60936.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-scenarios-log.el | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-scenarios-log.el b/test/lisp/erc/erc-scenarios-log.el index cd28ea54b2e..cff88d59c85 100644 --- a/test/lisp/erc/erc-scenarios-log.el +++ b/test/lisp/erc/erc-scenarios-log.el | |||
| @@ -206,4 +206,59 @@ | |||
| 206 | (erc-truncate-mode -1) | 206 | (erc-truncate-mode -1) |
| 207 | (when noninteractive (delete-directory tempdir :recursive)))) | 207 | (when noninteractive (delete-directory tempdir :recursive)))) |
| 208 | 208 | ||
| 209 | (defvar erc-insert-timestamp-function) | ||
| 210 | (declare-function erc-insert-timestamp-left "erc-stamp" (string)) | ||
| 211 | |||
| 212 | (ert-deftest erc-scenarios-log--save-buffer-in-logs/truncate-on-save () | ||
| 213 | :tags '(:expensive-test) | ||
| 214 | (erc-scenarios-common-with-cleanup | ||
| 215 | ((erc-scenarios-common-dialog "base/assoc/bouncer-history") | ||
| 216 | (dumb-server (erc-d-run "localhost" t 'foonet)) | ||
| 217 | (tempdir (make-temp-file "erc-tests-log." t nil nil)) | ||
| 218 | (erc-log-channels-directory tempdir) | ||
| 219 | (erc-modules (cons 'log erc-modules)) | ||
| 220 | (port (process-contact dumb-server :service)) | ||
| 221 | (erc-truncate-buffer-on-save t) | ||
| 222 | (logchan (expand-file-name (format "#chan!tester@127.0.0.1:%d.txt" port) | ||
| 223 | tempdir)) | ||
| 224 | (erc-server-flood-penalty 0.1) | ||
| 225 | (erc-insert-timestamp-function #'erc-insert-timestamp-left) | ||
| 226 | (expect (erc-d-t-make-expecter))) | ||
| 227 | |||
| 228 | (unless noninteractive | ||
| 229 | (add-hook 'kill-emacs-hook | ||
| 230 | (lambda () (delete-directory tempdir :recursive)))) | ||
| 231 | |||
| 232 | (ert-info ("Connect to foonet") | ||
| 233 | (with-current-buffer (erc :server "127.0.0.1" | ||
| 234 | :port port | ||
| 235 | :nick "tester" | ||
| 236 | :password "foonet:changeme" | ||
| 237 | :full-name "tester") | ||
| 238 | (should (string= (buffer-name) (format "127.0.0.1:%d" port))))) | ||
| 239 | |||
| 240 | (with-current-buffer (erc-d-t-wait-for 5 (get-buffer "#chan")) | ||
| 241 | (funcall expect 10 "<someone> [07:04:10] hi everyone") | ||
| 242 | (should-not (file-exists-p logchan)) | ||
| 243 | ;; Simulate an M-x erc-save-buffer-in-logs RET | ||
| 244 | (cl-letf (((symbol-function 'called-interactively-p) #'always)) | ||
| 245 | (call-interactively #'erc-save-buffer-in-logs)) | ||
| 246 | (should (file-exists-p logchan)) | ||
| 247 | (funcall expect 10 "<alice> bob: As't please your lordship") | ||
| 248 | (erc-save-buffer-in-logs) | ||
| 249 | ;; Not truncated when called by lisp code. | ||
| 250 | (should (> (buffer-size) 400))) | ||
| 251 | |||
| 252 | (ert-info ("No double entries") | ||
| 253 | (with-temp-buffer | ||
| 254 | (insert-file-contents logchan) | ||
| 255 | (funcall expect 0.1 "hi everyone") | ||
| 256 | (funcall expect -0.1 "hi everyone") | ||
| 257 | (funcall expect 0.1 "Playback Complete") | ||
| 258 | (funcall expect -0.1 "Playback Complete") | ||
| 259 | (funcall expect 10 "<alice> bob: As't"))) | ||
| 260 | |||
| 261 | (erc-log-mode -1) | ||
| 262 | (when noninteractive (delete-directory tempdir :recursive)))) | ||
| 263 | |||
| 209 | ;;; erc-scenarios-log.el ends here | 264 | ;;; erc-scenarios-log.el ends here |