From 2ef49bf609839c30b6659b43c1d0a10e2cf53339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Fayzrakhmanov=20=28=D0=90=D1=80=D1=82=D1=83=D1=80?= =?UTF-8?q?=20=D0=A4=D0=B0=D0=B9=D0=B7=D1=80=D0=B0=D1=85=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=29?= Date: Fri, 5 Jun 2015 01:19:46 +0500 Subject: [PATCH 1/4] Follow Emacs namespace convention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename + haskell-present-buffer-name → haskell-presentation-buffer-name + haskell-present-hint-message → haskell-presentation-hint-message + haskell-present-clear → haskell-presentation-clear + haskell-present → haskell-presentation-present --- haskell-commands.el | 2 +- haskell-interactive-mode.el | 5 +++-- haskell-presentation-mode.el | 18 +++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/haskell-commands.el b/haskell-commands.el index a597840f3..bae02ae21 100644 --- a/haskell-commands.el +++ b/haskell-commands.el @@ -966,7 +966,7 @@ If variable `haskell-process-use-presentation-mode' is NIL it will output modified message MSG to echo area." (if haskell-process-use-presentation-mode (let ((session (haskell-process-session (haskell-interactive-process)))) - (haskell-present session msg)) + (haskell-presentation-present session msg)) (let ((m (haskell-utils-reduce-string msg))) (message m)))) diff --git a/haskell-interactive-mode.el b/haskell-interactive-mode.el index 67a76d699..87d2cfc82 100644 --- a/haskell-interactive-mode.el +++ b/haskell-interactive-mode.el @@ -1096,7 +1096,8 @@ don't care when the thing completes as long as it's soonish." (defun haskell-process-show-repl-response (line) "Send LINE to the GHCi process and echo the result in some fashion. Result will be printed in the minibuffer or presented using -haskell-present, depending on variable `haskell-process-use-presentation-mode'." +function `haskell-presentation-present', depending on variable +`haskell-process-use-presentation-mode'." (let ((process (haskell-interactive-process))) (haskell-process-queue-command process @@ -1106,7 +1107,7 @@ haskell-present, depending on variable `haskell-process-use-presentation-mode'." (haskell-process-send-string (car state) (cdr state))) :complete (lambda (state response) (if haskell-process-use-presentation-mode - (haskell-present + (haskell-presentation-present (haskell-process-session (car state)) response) (haskell-mode-message-line response))))))) diff --git a/haskell-presentation-mode.el b/haskell-presentation-mode.el index 30621542f..911df3083 100644 --- a/haskell-presentation-mode.el +++ b/haskell-presentation-mode.el @@ -34,44 +34,44 @@ \\{hypertext-mode-map}" (setq case-fold-search nil)) -(defconst haskell-present-buffer-name +(defconst haskell-presentation-buffer-name "*Haskell Presentation*" "Haskell Presentation buffer name.") -(defconst haskell-present-hint-message +(defconst haskell-presentation-hint-message "-- Hit `q' to close this window; `c' to clear.\n\n" "Hint message appered in Haskell Presentation buffer.") (easy-mmode-defmap haskell-presentation-mode-map `(("q" . #'quit-window) - ("c" . #'haskell-present-clear)) + ("c" . #'haskell-presentation-clear)) "The base key map for `haskell-presentation-mode'.") -(defun haskell-present-clear () +(defun haskell-presentation-clear () "Clear Haskell Presentation buffer." (interactive) - (let ((hp-buf (get-buffer haskell-present-buffer-name))) + (let ((hp-buf (get-buffer haskell-presentation-buffer-name))) (when hp-buf (with-current-buffer hp-buf (let ((buffer-read-only nil)) (erase-buffer) - (insert haskell-present-hint-message)))))) + (insert haskell-presentation-hint-message)))))) -(defun haskell-present (session code &optional clear) +(defun haskell-presentation-present (session code &optional clear) "Present given code in a popup buffer. Creates temporal Haskell Presentation buffer and assigns it to given haskell SESSION; presented CODE will be fontified as haskell code. Give an optional non-nil CLEAR arg to clear the buffer before presenting message." - (let ((buffer (get-buffer-create haskell-present-buffer-name))) + (let ((buffer (get-buffer-create haskell-presentation-buffer-name))) (with-current-buffer buffer (haskell-presentation-mode) (when (boundp 'shm-display-quarantine) (set (make-local-variable 'shm-display-quarantine) nil)) - (when clear (haskell-present-clear)) + (when clear (haskell-presentation-clear)) (haskell-session-assign session) (save-excursion (let ((buffer-read-only nil)) From 1e1f4778d459f72eff422eaa9e573f38aedd6f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Fayzrakhmanov=20=28=D0=90=D1=80=D1=82=D1=83=D1=80?= =?UTF-8?q?=20=D0=A4=D0=B0=D0=B9=D0=B7=D1=80=D0=B0=D1=85=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=29?= Date: Fri, 5 Jun 2015 01:21:08 +0500 Subject: [PATCH 2/4] Fix presentation mode mappings Sharp-quotes are evaluated to list (e.g. `(function quit-window)`) breaking interactive calls, in order to use them it should be interpolated, e.g. `("q" . ,#'quit-window)`, so it's easier just omit them. --- haskell-presentation-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haskell-presentation-mode.el b/haskell-presentation-mode.el index 911df3083..8e654eb76 100644 --- a/haskell-presentation-mode.el +++ b/haskell-presentation-mode.el @@ -44,8 +44,8 @@ (easy-mmode-defmap haskell-presentation-mode-map - `(("q" . #'quit-window) - ("c" . #'haskell-presentation-clear)) + `(("q" . quit-window) + ("c" . haskell-presentation-clear)) "The base key map for `haskell-presentation-mode'.") (defun haskell-presentation-clear () From 4762fca578e8e32b55e7612e53b2e2c2e162f87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Fayzrakhmanov=20=28=D0=90=D1=80=D1=82=D1=83=D1=80?= =?UTF-8?q?=20=D0=A4=D0=B0=D0=B9=D0=B7=D1=80=D0=B0=D1=85=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=29?= Date: Fri, 5 Jun 2015 01:25:53 +0500 Subject: [PATCH 3/4] Define a function which returns presentation buffer This function returns existing presentation buffer, or properly creates new one if it absent: + create new buffer named according to `haskell-presentation-buffer-name` + enable `presentation-mode` + insert `haskell-presentaion-hint-message` + make buffer read only --- haskell-presentation-mode.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/haskell-presentation-mode.el b/haskell-presentation-mode.el index 8e654eb76..9a857a0ac 100644 --- a/haskell-presentation-mode.el +++ b/haskell-presentation-mode.el @@ -48,6 +48,22 @@ ("c" . haskell-presentation-clear)) "The base key map for `haskell-presentation-mode'.") +(defun haskell-presentation-buffer () + "Return Haskell Presentaion buffer. +Return current presenation buffer or create new one if absent. +Never returns nil." + ;; TODO Provide interactive calling options: when called interactively make + ;; the presentation buffer current. + (let ((may-buffer (get-buffer haskell-presentation-buffer-name))) + (if may-buffer + may-buffer + (let ((buffer (generate-new-buffer haskell-presentation-buffer-name))) + (with-current-buffer buffer + (insert haskell-presentation-hint-message) + (haskell-presentation-mode) + (setq buffer-read-only t)) + buffer)))) + (defun haskell-presentation-clear () "Clear Haskell Presentation buffer." (interactive) From d4892b2bff0cd22f4e4cefb60b2703438ba32e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Fayzrakhmanov=20=28=D0=90=D1=80=D1=82=D1=83=D1=80?= =?UTF-8?q?=20=D0=A4=D0=B0=D0=B9=D0=B7=D1=80=D0=B0=D1=85=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=29?= Date: Fri, 5 Jun 2015 01:31:04 +0500 Subject: [PATCH 4/4] Proper presentation buffer retrieval --- haskell-presentation-mode.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/haskell-presentation-mode.el b/haskell-presentation-mode.el index 9a857a0ac..375d1ddd7 100644 --- a/haskell-presentation-mode.el +++ b/haskell-presentation-mode.el @@ -80,9 +80,8 @@ Creates temporal Haskell Presentation buffer and assigns it to given haskell SESSION; presented CODE will be fontified as haskell code. Give an optional non-nil CLEAR arg to clear the buffer before presenting message." - (let ((buffer (get-buffer-create haskell-presentation-buffer-name))) + (let ((buffer (haskell-presentation-buffer))) (with-current-buffer buffer - (haskell-presentation-mode) (when (boundp 'shm-display-quarantine) (set (make-local-variable 'shm-display-quarantine) nil))