From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 2/5] emacs: Introduce REPL operation type. Date: Tue, 21 Oct 2014 22:12:13 +0400 Message-ID: <87r3y147ia.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgdux-0008Pb-JS for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xgduo-0004DP-Fa for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:23 -0400 Received: from mail-la0-x233.google.com ([2a00:1450:4010:c03::233]:49427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgduo-0004DC-7B for guix-devel@gnu.org; Tue, 21 Oct 2014 14:12:14 -0400 Received: by mail-la0-f51.google.com with SMTP id ge10so1566008lab.38 for ; Tue, 21 Oct 2014 11:12:13 -0700 (PDT) Received: from leviafan (128-74-164-65.broadband.corbina.ru. [128.74.164.65]) by mx.google.com with ESMTPSA id rb2sm2941155lbb.17.2014.10.21.11.12.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2014 11:12:12 -0700 (PDT) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This is an auxiliary commit for a =E2=80=9Cpull=E2=80=9D operation added in= a later patch. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-emacs-Introduce-REPL-operation-type.patch >From ef04333314fbe738d18d33b23a67dc47c8e75dbb Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Mon, 20 Oct 2014 23:18:13 +0400 Subject: [PATCH 2/5] emacs: Introduce REPL operation type. * emacs/guix-backend.el (guix-repl-operation-type): New variable. (guix-repl-output-filter): Run type hooks after performing an operation. (guix-eval-read): Add 'operation-type' argument. --- emacs/guix-backend.el | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/emacs/guix-backend.el b/emacs/guix-backend.el index d37d9d4..ddc106f 100644 --- a/emacs/guix-backend.el +++ b/emacs/guix-backend.el @@ -133,6 +133,9 @@ This REPL is used for receiving information only if This internal variable is used to distinguish Guix operations from operations performed in Guix REPL by a user.") +(defvar guix-repl-operation-type nil + "Type of the current operation performed by `guix-eval-in-repl'.") + (defun guix-repl-operation-success-message () "Message telling about successful Guix operation." (message "Guix operation has been performed.")) @@ -232,7 +235,16 @@ This is a replacement for `geiser-repl--output-filter'." (geiser-autodoc--disinhibit-autodoc) (when guix-repl-operation-p (setq guix-repl-operation-p nil) - (run-hooks 'guix-after-repl-operation-hook))) + (run-hooks 'guix-after-repl-operation-hook) + ;; Run hooks specific to the current operation type. + (when guix-repl-operation-type + (let ((type-hook (intern + (concat "guix-after-" + (symbol-name guix-repl-operation-type) + "-hook")))) + (setq guix-repl-operation-type nil) + (and (boundp type-hook) + (run-hooks type-hook)))))) ((string-match geiser-guile--debugger-prompt-regexp str) (setq guix-repl-operation-p nil) (geiser-con--connection-set-debugging geiser-repl--connection @@ -317,12 +329,17 @@ Return elisp expression of the first result value of evaluation." (replace-regexp-in-string "#t" "t" (car (guix-eval str wrap)))))) -(defun guix-eval-in-repl (str &optional operation-buffer) +(defun guix-eval-in-repl (str &optional operation-buffer operation-type) "Switch to Guix REPL and evaluate STR with guile expression there. If OPERATION-BUFFER is non-nil, it should be a buffer from which -the current operation was performed." +the current operation was performed. + +If OPERATION-TYPE is non-nil, it should be a symbol. After +successful executing of the current operation, +`guix-after-OPERATION-TYPE-hook' is called." (run-hooks 'guix-before-repl-operation-hook) (setq guix-repl-operation-p t + guix-repl-operation-type operation-type guix-operation-buffer operation-buffer) (let ((repl (guix-get-repl-buffer))) (with-current-buffer repl -- 2.1.2 --=-=-=--