[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-clojure ec99211 189/313: Support loading directory loc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-clojure ec99211 189/313: Support loading directory locals in our buffers |
Date: |
Wed, 11 Aug 2021 10:00:14 -0400 (EDT) |
branch: elpa/inf-clojure
commit ec99211bbe9bef6d579a313ab6422694ef63b181
Author: Andrea Richiardi <a.richiardi.work@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Support loading directory locals in our buffers
A couple of changes to the way the redirect buffer and the main REPL buffer
are
created was needed in order to have actual loading of .dir-locals.el.
Additionally, code in inf-clojure--process-response has been simplified and
corrected.
---
CHANGELOG.md | 1 +
inf-clojure.el | 60 ++++++++++++++++++++++++++++++++++------------------------
2 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e455d27..4864593 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
* [#122](https://github.com/clojure-emacs/inf-clojure/pull/122): Introduce
`inf-clojure-completions-fn` defcustom.
* [#128](https://github.com/clojure-emacs/inf-clojure/pull/128): Expose
`inf-clojure-apropos` as `C-c C-S-a` in `inf-clojure-mode` (the REPL).
* [#125](https://github.com/clojure-emacs/inf-clojure/pull/125): Avoid
throwing an error for frequent operations like completion.
+* [#130](https://github.com/clojure-emacs/inf-clojure/pull/130): Support
loading directory locals in our buffers.
### Bugs Fixed
diff --git a/inf-clojure.el b/inf-clojure.el
index b09b34c..b1956e8 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -575,9 +575,10 @@ run).
(list cmd)
(split-string cmd))))
(message "Starting Clojure REPL via `%s'..." cmd)
- (set-buffer (apply #'make-comint
- "inf-clojure" (car cmdlist) nil (cdr cmdlist)))
- (inf-clojure-mode)))
+ (with-current-buffer (apply #'make-comint
+ "inf-clojure" (car cmdlist) nil (cdr
cmdlist))
+ (inf-clojure-mode)
+ (hack-dir-local-variables-non-file-buffer))))
(setq inf-clojure-buffer "*inf-clojure*")
(if inf-clojure-repl-use-same-window
(pop-to-buffer-same-window "*inf-clojure*")
@@ -1124,6 +1125,17 @@ are going to match those."
(length string))
(or (string-match prompt string) (length string))))
+(defun inf-clojure--get-redirect-buffer ()
+ "Get the redirection buffer, creating it if necessary.
+
+It is the buffer used for processing REPL responses, see variable
+\\[inf-clojure--redirect-buffer-name]."
+ (or (get-buffer inf-clojure--redirect-buffer-name)
+ (let ((buffer (generate-new-buffer inf-clojure--redirect-buffer-name)))
+ (with-current-buffer buffer
+ (hack-dir-local-variables-non-file-buffer)
+ buffer))))
+
;; Originally from:
;; https://github.com/glycerine/lush2/blob/master/lush2/etc/lush.el#L287
(defun inf-clojure--process-response (command process &optional beg-regexp
end-regexp)
@@ -1134,31 +1146,29 @@ If BEG-REGEXP is nil, the result string will start from
(point)
in the results buffer. If END-REGEXP 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`."
- (let ((work-buffer inf-clojure--redirect-buffer-name)
+ (let ((redirect-buffer-name inf-clojure--redirect-buffer-name)
(sanitized-command (inf-clojure--sanitize-command command)))
(when (not (string-empty-p sanitized-command))
(inf-clojure--log-string command "----CMD->")
- (with-current-buffer (get-buffer-create work-buffer)
- (erase-buffer)
- (comint-redirect-send-command-to-process sanitized-command work-buffer
process nil t)
- ;; Wait for the process to complete
- (set-buffer (process-buffer process))
- (while (and (null comint-redirect-completed)
- (accept-process-output process 1 0 t))
- (sleep-for 0.01))
- ;; Collect the output
- (set-buffer work-buffer)
- (goto-char (point-min))
- (let* ((buffer-string (buffer-substring-no-properties (point-min)
(point-max)))
- (boundaries (inf-clojure--string-boundaries buffer-string
inf-clojure-prompt beg-regexp end-regexp))
- (beg-pos (car boundaries))
- (end-pos (car (cdr boundaries)))
- (prompt-pos (car (cdr (cdr boundaries))))
- (response-string (substring buffer-string beg-pos (min end-pos
prompt-pos))))
- (inf-clojure--log-string buffer-string "<-BUF----")
- (inf-clojure--log-string boundaries "<-BND----")
- (inf-clojure--log-string response-string "<-RES----")
- response-string)))))
+ (set-buffer (inf-clojure--get-redirect-buffer))
+ (erase-buffer)
+ (comint-redirect-send-command-to-process sanitized-command
redirect-buffer-name process nil t)
+ ;; Wait for the process to complete
+ (set-buffer (process-buffer process))
+ (while (and (null comint-redirect-completed)
+ (accept-process-output process 1 0 t))
+ (sleep-for 0.01))
+ ;; Collect the output
+ (set-buffer redirect-buffer-name)
+ (goto-char (point-min))
+ (let* ((buffer-string (buffer-substring-no-properties (point-min)
(point-max)))
+ (boundaries (inf-clojure--string-boundaries buffer-string
inf-clojure-prompt beg-regexp end-regexp))
+ (beg-pos (car boundaries))
+ (end-pos (car (cdr boundaries)))
+ (prompt-pos (car (cdr (cdr boundaries))))
+ (response-string (substring buffer-string beg-pos (min end-pos
prompt-pos))))
+ (inf-clojure--log-string buffer-string "<-RES----")
+ response-string))))
(defun inf-clojure--nil-string-match-p (string)
"Return true iff STRING is not nil.
- [nongnu] elpa/inf-clojure 3e7ca33 248/313: Add lein and boot to the startup-forms, (continued)
- [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, 2021/08/11
- [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 <=
- [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
- [nongnu] elpa/inf-clojure cf53284 220/313: Fix for https://github.com/clojure-emacs/inf-clojure/issues/154 (#158), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 1e93db8 237/313: Bump the development version, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure c590c65 240/313: Remove projects from inf-clojure except to serve as project root, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 8fb1929 254/313: Set REPL type from startup form, prompt, or defcustom at startup, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure f298612 259/313: [Fix #173] Use clojure-mode project detection (#176), ELPA Syncer, 2021/08/11