From: Alex Kost <alezost@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 4/5] emacs: Improve REPL procedures.
Date: Tue, 21 Oct 2014 22:12:26 +0400 [thread overview]
Message-ID: <87oat547hx.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 24 bytes --]
More internal changes.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-emacs-Improve-REPL-procedures.patch --]
[-- Type: text/x-diff, Size: 4482 bytes --]
From 6dd7a04f6021892b79b88579297cdf3358e3c2dc Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Mon, 20 Oct 2014 23:23:32 +0400
Subject: [PATCH 4/5] emacs: Improve REPL procedures.
* emacs/guix-backend.el (guix-start-process-maybe): Add 'start-msg' and
'end-msg' optional arguments.
(guix-start-repl-maybe): Likewise. Do not kill buffer with a dead process.
(guix-repl-exit): New procedure.
(guix-eval-in-repl): Use 'geiser-repl--send'.
---
emacs/guix-backend.el | 46 ++++++++++++++++++++++++++++++++--------------
1 file changed, 32 insertions(+), 14 deletions(-)
diff --git a/emacs/guix-backend.el b/emacs/guix-backend.el
index ddc106f..e6f0944 100644
--- a/emacs/guix-backend.el
+++ b/emacs/guix-backend.el
@@ -152,24 +152,31 @@ from operations performed in Guix REPL by a user.")
(list (concat "--listen="
(number-to-string guix-default-port))))))
-(defun guix-start-process-maybe ()
- "Start Geiser REPL configured for Guix if needed."
- (guix-start-repl-maybe)
+(defun guix-start-process-maybe (&optional start-msg end-msg)
+ "Start Geiser REPL configured for Guix if needed.
+START-MSG and END-MSG are strings displayed in the minibuffer in
+the beginning and in the end of the starting process. If nil,
+display default messages."
+ (guix-start-repl-maybe nil
+ (or start-msg "Starting Guix REPL ...")
+ (or end-msg "Guix REPL has been started."))
(if guix-use-guile-server
(guix-start-repl-maybe 'internal)
(setq guix-internal-repl-buffer guix-repl-buffer)))
-(defun guix-start-repl-maybe (&optional internal)
+(defun guix-start-repl-maybe (&optional internal start-msg end-msg)
"Start Guix REPL if needed.
-If INTERNAL is non-nil, start an internal REPL."
+If INTERNAL is non-nil, start an internal REPL.
+
+START-MSG and END-MSG are strings displayed in the minibuffer in
+the beginning and in the end of the process. If nil, do not
+display messages."
(let* ((repl-var (guix-get-repl-buffer-variable internal))
(repl (symbol-value repl-var)))
(unless (and (buffer-live-p repl)
(get-buffer-process repl))
- ;; Kill REPL buffer with a dead process
- (and (buffer-live-p repl) (kill-buffer repl))
- (or internal
- (message "Starting Geiser REPL for Guix ..."))
+ (and start-msg (message start-msg))
+ (setq guix-repl-operation-p nil)
(let ((geiser-guile-binary (guix-get-guile-program internal))
(geiser-guile-init-file (or internal guix-helper-file))
(repl (get-buffer-create
@@ -184,8 +191,8 @@ If INTERNAL is non-nil, start an internal REPL."
"See buffer '%s' for details")
guix-default-port (buffer-name repl))))
(set repl-var repl)
+ (and end-msg (message end-msg))
(unless internal
- (message "Guix REPL has been started.")
(run-hooks 'guix-after-start-repl-hook))))))
(defun guix-start-repl (buffer &optional address)
@@ -251,6 +258,20 @@ This is a replacement for `geiser-repl--output-filter'."
(match-beginning 0))
(geiser-autodoc--disinhibit-autodoc))))
+(defun guix-repl-exit (&optional internal no-wait)
+ "Exit the current Guix REPL.
+If INTERNAL is non-nil, exit the internal REPL.
+If NO-WAIT is non-nil, do not wait for the REPL process to exit:
+send a kill signal to it and return immediately."
+ (let ((repl (symbol-value (guix-get-repl-buffer-variable internal))))
+ (when (get-buffer-process repl)
+ (with-current-buffer repl
+ (geiser-con--connection-deactivate geiser-repl--connection t)
+ (comint-kill-subjob)
+ (unless no-wait
+ (while (get-buffer-process repl)
+ (sleep-for 0.1)))))))
+
(defun guix-get-repl-buffer (&optional internal)
"Return Guix REPL buffer; start REPL if needed.
If INTERNAL is non-nil, return an additional internal REPL."
@@ -343,10 +364,7 @@ successful executing of the current operation,
guix-operation-buffer operation-buffer)
(let ((repl (guix-get-repl-buffer)))
(with-current-buffer repl
- (delete-region (geiser-repl--last-prompt-end) (point-max))
- (goto-char (point-max))
- (insert str)
- (geiser-repl--send-input))
+ (geiser-repl--send str))
(geiser-repl--switch-to-buffer repl)))
(provide 'guix-backend)
--
2.1.2
next reply other threads:[~2014-10-21 18:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 18:12 Alex Kost [this message]
2014-10-26 18:38 ` [PATCH 4/5] emacs: Improve REPL procedures Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oat547hx.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.