From 1616b8f00f859ecfacb972e3c491cd3e363c9e71 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: Sun, 7 Jun 2015 03:50:43 +0500 Subject: [PATCH 1/2] Preserve point position in `haskell-utils-compose-type-at-command` Related to issue #700 --- haskell-commands.el | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/haskell-commands.el b/haskell-commands.el index a597840f3..9b1fcf1aa 100644 --- a/haskell-commands.el +++ b/haskell-commands.el @@ -930,19 +930,32 @@ to point." "Prepare :type-at command to be send to haskell process. POS is a cons cell containing min and max positions, i.e. target expression bounds." - (replace-regexp-in-string - "\n$" - "" - (format ":type-at %s %d %d %d %d %s" - (buffer-file-name) - (progn (goto-char (car pos)) - (line-number-at-pos)) - (1+ (current-column)) - (progn (goto-char (cdr pos)) - (line-number-at-pos)) - (1+ (current-column)) - (buffer-substring-no-properties (car pos) - (cdr pos))))) + (save-excursion + (let ((start-p (car pos)) + (end-p (cdr pos)) + start-l + start-c + end-l + end-c + value) + (goto-char start-p) + (setq start-l (line-number-at-pos)) + (setq start-c (1+ (current-column))) + (goto-char end-p) + (setq end-l (line-number-at-pos)) + (setq end-c (1+ (current-column))) + (setq value (buffer-substring-no-properties start-p end-p)) + (replace-regexp-in-string + "\n$" + "" + (format ":type-at %s %d %d %d %d %s" + (buffer-file-name) + start-l + start-c + end-l + end-c + value))))) + (defun haskell-utils-insert-type-signature (signature) "Insert type signature. From 8a08b83bd46a8aae75c7cef29c5ce82c1a5d940f 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: Sun, 7 Jun 2015 04:25:43 +0500 Subject: [PATCH 2/2] Supress multiline expressions Related to issue #701 --- haskell-commands.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/haskell-commands.el b/haskell-commands.el index 9b1fcf1aa..fe6ebbc8c 100644 --- a/haskell-commands.el +++ b/haskell-commands.el @@ -945,6 +945,11 @@ expression bounds." (setq end-l (line-number-at-pos)) (setq end-c (1+ (current-column))) (setq value (buffer-substring-no-properties start-p end-p)) + ;; supress multiline expressions + (let ((lines (split-string value "\n" t))) + (when (and (cdr lines) + (stringp (car lines))) + (setq value (format "[ %s … ]" (car lines))))) (replace-regexp-in-string "\n$" ""