Skip to content

current-column wrong in interactive-haskell-mode #9

@unhammer

Description

@unhammer
(add-hook 'haskell-interactive-mode-hook 'yas-minor-mode)
(add-hook 'interactive-haskell-mode-hook
            (defun my-interactive-haskell-use-snippets ()
                (yas-activate-extra-mode 'haskell-mode)))

turns it on in interactive-haskell-mode, but most of the snippets don't expand because they test (current-column) (to check that we're writing "imp" at the start of the line) which gets offset due to the repl prompt. One solution would be to have a helper like doing something like

(defun haskell-snippets-current-column ()
  (let ((prompt-len (if (eq major-mode 'haskell-interactive-mode)
                        (save-excursion
                          (goto-char (line-beginning-position))
                          (cond ((looking-at-p (regexp-quote
                                                haskell-interactive-prompt))
                                 (length haskell-interactive-prompt))
                                ((looking-at-p (regexp-quote
                                                haskell-interactive-prompt2))
                                 (length haskell-interactive-prompt2))
                                (t 0)))
                      0)))
    (- (current-column) prompt-len)))

(and using that instead of current-column in the snippets) but maybe there's a built-in thing like that in emacs? (or one could use haskell-interactive-mode-bol)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions