[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/detached 669113092c 2/2: Improve session output functio
From: |
ELPA Syncer |
Subject: |
[elpa] externals/detached 669113092c 2/2: Improve session output function |
Date: |
Tue, 8 Nov 2022 13:57:31 -0500 (EST) |
branch: externals/detached
commit 669113092ce7a927c5988e302215f9f1183f52f4
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Improve session output function
This patch reworks the removal of detached message from output. The
previous implementation could get stack overflow in regexp matcher.
---
detached.el | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/detached.el b/detached.el
index 335c964c54..d6206259a3 100644
--- a/detached.el
+++ b/detached.el
@@ -907,14 +907,15 @@ This function uses the `notifications' library."
"Return content of SESSION's output."
(let* ((filename (detached--session-file session 'log))
(detached-message
- (rx (regexp "\n.*\\[detached-exit-code: .*\\]"))))
+ (rx (regexp "\\[detached-exit-code: .*\\]"))))
(with-temp-buffer
(insert-file-contents filename)
(detached--maybe-watch-session session)
- (goto-char (point-min))
- (let ((beginning (point))
- (end (if (search-forward-regexp detached-message nil t)
- (match-beginning 0)
+ (goto-char (point-max))
+ (forward-line -1)
+ (let ((beginning (point-min))
+ (end (if (string-match detached-message (thing-at-point 'line t))
+ (and (forward-line -1) (point))
(point-max))))
(buffer-substring beginning end)))))