[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-clojure 0bb2700 156/313: Introduce inf-clojure-log-act
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-clojure 0bb2700 156/313: Introduce inf-clojure-log-activity |
Date: |
Wed, 11 Aug 2021 10:00:06 -0400 (EDT) |
branch: elpa/inf-clojure
commit 0bb2700a9bd2dce43f740547cb16505860fab0fc
Author: Andrea Richiardi <a.richiardi.work@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Introduce inf-clojure-log-activity
Log commands and responses from/to the inf-clojure process. It can be
enabled
with (setq inf-clojure-log-activity t). Vital for debugging.
---
README.md | 10 ++++++++++
inf-clojure.el | 35 ++++++++++++++++++++++++++++++++---
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index bb60fdc..7fa0384 100644
--- a/README.md
+++ b/README.md
@@ -201,6 +201,16 @@ directory and add this line to that file:
jline.terminal=unsupported
```
+### Log process activity
+
+Standard Emacs debugging turns out to be difficult when an asynchronous
process is involved. In this case try to enable logging:
+
+```el
+(setq inf-clojure-log-activity t)
+```
+
+This creates `.inf-clojure.log` in the process root for you to `tail -f` on.
+
## License
Copyright © 2014-2017 Bozhidar Batsov and [contributors][].
diff --git a/inf-clojure.el b/inf-clojure.el
index f72825f..b38735f 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -946,7 +946,33 @@ prefix argument PROMPT-FOR-SYMBOL, it prompts for a symbol
name."
;;;; Response parsing
;;;; ================
-(defvar inf-clojure--redirect-buffer-name " *Inf-Clojure Redirect Buffer*")
+(defvar inf-clojure--redirect-buffer-name " *Inf-Clojure Redirect Buffer*"
+ "The name of the buffer used for process output redirection.")
+
+(defvar inf-clojure--log-file-name ".inf-clojure.log"
+ "The name of the file used to log process activity.")
+
+(defvar inf-clojure-log-activity nil
+ "Log process activity?.
+Inf-Clojure will create a log file in the project folder named
+`inf-clojure--log-file-name' and dump the process activity in it
+in case this is not nil." )
+
+(defun inf-clojure--log-string (string &optional type)
+ "Log STRING to file, according to `inf-clojure-log-response'.
+The optional TYPE will be converted to string and printed before
+STRING if present."
+ (when inf-clojure-log-activity
+ (write-region (concat "\n"
+ (when type
+ (concat (prin1-to-string type) " | "))
+ (let ((print-escape-newlines t))
+ (prin1-to-string string)))
+ nil
+ (expand-file-name inf-clojure--log-file-name
+ (inf-clojure-project-root))
+ 'append
+ 'no-annoying-write-file-in-minibuffer)))
;; Originally from:
;; https://github.com/glycerine/lush2/blob/master/lush2/etc/lush.el#L287
@@ -958,6 +984,7 @@ string will start from (point) in the results buffer. If
END-STRING is nil, the result string will end at (point-max) in
the results buffer. It cuts out the output from and including
the `inf-clojure-prompt`."
+ (inf-clojure--log-string command :cmd)
(let ((work-buffer inf-clojure--redirect-buffer-name))
(save-excursion
(set-buffer (get-buffer-create work-buffer))
@@ -978,8 +1005,10 @@ the `inf-clojure-prompt`."
(search-forward end-string nil t))
(point-max)))
(prompt (when (search-forward inf-clojure-prompt nil t)
- (match-beginning 0))))
- (buffer-substring-no-properties beg (or prompt end))))))
+ (match-beginning 0)))
+ (buffer-string (buffer-substring-no-properties beg (or prompt
end))))
+ (inf-clojure--log-string buffer-string :res)
+ buffer-string))))
(defun inf-clojure--nil-string-match-p (string)
"Return true iff STRING is not nil.
- [nongnu] elpa/inf-clojure b87c5fb 215/313: update instructions to setup lumo repl (#147), (continued)
- [nongnu] elpa/inf-clojure b87c5fb 215/313: update instructions to setup lumo repl (#147), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 16455ab 224/313: Fix typo in inf-clojure--joker-repl-form (#163), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 975e580 222/313: Fix CircleCI badge in README, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 173d0e7 228/313: Bump the development version, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 80cefbb 244/313: API to update repl-features, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 3e7ca33 248/313: Add lein and boot to the startup-forms, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 1c8429a 247/313: Bump the development version, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 5abac0b 262/313: Tweak the REPL type documentation, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 6f4e792 065/313: Add a note about mixing cider & inf-clojure, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure c797a5a 143/313: Release inf-clojure 2.0, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 0bb2700 156/313: Introduce inf-clojure-log-activity,
ELPA Syncer <=
- [nongnu] elpa/inf-clojure 86d0b60 158/313: Adopt find-ns for detecting the repl type, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure b04f05d 174/313: Fix the default value for inf-clojure-arglists-form-planck (#112), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure ca96cfc 180/313: Add README note about ClojureScript REPL support, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 715bd82 188/313: Add macroexpand forms for Lumo, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure ec99211 189/313: Support loading directory locals in our buffers, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 803a419 193/313: Add test harness (finally?), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 903dd73 196/313: Set explicitly inf-clojure-repl-type for REPL and source buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure de59fce 206/313: Merge pull request #142 from austinhaas/master, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 9deb198 202/313: Use comint-send-string, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure b2224bc 211/313: Merge pull request #145 from austinhaas/master, ELPA Syncer, 2021/08/11