can't use "S" in normal mode with haskell-mode
Hello all, I use emacs-evil with haskell-mode. Whenever I enter the "S" hotkey a new buffer (haskell-mode's "Help" file) is opened on a split window and it gets stuck in <M> state. I can use the "S" hotkey fine when haskell-mode is not active, though. Any pointers? Thanks, -L
Possibly related to: https://bitbucket.org/lyro/evil/issue/241/evil-execute-in-emacs-state-misbeh... On Mon, Mar 18, 2013 at 2:34 PM, Linus Arver <[email protected]> wrote:
Hello all,
I use emacs-evil with haskell-mode. Whenever I enter the "S" hotkey a new buffer (haskell-mode's "Help" file) is opened on a split window and it gets stuck in <M> state. I can use the "S" hotkey fine when haskell-mode is not active, though.
Any pointers?
Thanks, -L
_______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
On Mon, Mar 18 2013 (19:34), Linus Arver <[email protected]> wrote:
Hello all,
I use emacs-evil with haskell-mode. Whenever I enter the "S" hotkey a new buffer (haskell-mode's "Help" file) is opened on a split window and it gets stuck in <M> state. I can use the "S" hotkey fine when haskell-mode is not active, though.
Any pointers?
As emacs has no haskell-mode: Which are you using? This one[1] (or from marmalade)? And more important what does C-h k S RET in normal-state tell you? Michael [1] https://github.com/haskell/haskell-mode
On Mon, Mar 18, 2013 at 08:25:32PM +0100, Michael Markert wrote:
On Mon, Mar 18 2013 (19:34), Linus Arver <[email protected]> wrote:
Hello all,
I use emacs-evil with haskell-mode. Whenever I enter the "S" hotkey a new buffer (haskell-mode's "Help" file) is opened on a split window and it gets stuck in <M> state. I can use the "S" hotkey fine when haskell-mode is not active, though.
Any pointers?
As emacs has no haskell-mode: Which are you using? This one[1] (or from marmalade)?
I am using https://github.com/haskell/haskell-mode.
And more important what does
C-h k S RET
in normal-state tell you?
Well, I only need to do C-h k S because by the time I press 'S' in that key chord it already gives me a new *Help* buffer in a new split window. Anyway, the *Help* buffer says: S runs the command evil-change-whole-line, which is an interactive compiled Lisp function in `evil-commands.el'. It is bound to S. (evil-change-whole-line BEG END &optional TYPE REGISTER YANK-HANDLER) Change whole line. [back] I just noticed that the command 'S' does indeed work in the haskell-mode buffer (it delete the whole line and goes into <I> Insert mode) --- the only problem is that I get a new split window with a haskell-mode *Help* buffer, which gets stuck in <M> state. Here is some of the leading contents of this new buffer: haskell-mode-hook is a variable defined in `haskell-mode.el'. Its value is shown below. This variable is potentially risky when used as a file local variable. Documentation: Hook run after entering Haskell mode. -------------------------------------------------------------------------------- CONFIGURING INDENTATION Using this you can configure the Haskell indentation mode. There are three major Haskell indentation modes: `haskell-indentation', Kristof Bastiaensen Intelligent semi-automatic indentation, mark two. How to enable: ... So I guess haskell-mode-hook is responsible for this. I've looked at haskell-mode.el and it appears that this function is responsible: (defun haskell-mode-suggest-indent-choice () "Ran when the user tries to indent in the buffer but no indentation mode has been selected. Brings up the documentation for haskell-mode-hook." (describe-variable 'haskell-mode-hook)) Maybe evil-change-whole-line for "S" (and also "cc", as this triggers the same behavior) has some indenting code in it, which ends up triggering haskell-mode-suggest-indent-choice? I have in my ~/.emacs the following: (load-library "haskell-site-file") (add-to-list 'auto-mode-alist '("\\.hs\\'" . haskell-mode)) Thanks, -L
On Tue, Mar 19 2013 (18:13), Linus Arver <[email protected]> wrote:
So I guess haskell-mode-hook is responsible for this. I've looked at haskell-mode.el and it appears that this function is responsible:
(defun haskell-mode-suggest-indent-choice () "Ran when the user tries to indent in the buffer but no indentation mode has been selected. Brings up the documentation for haskell-mode-hook." (describe-variable 'haskell-mode-hook))
Yes, well the easy way is: Configure your haskell mode correctly and turn on an indentation mode.
Maybe evil-change-whole-line for "S" (and also "cc", as this triggers the same behavior) has some indenting code in it, which ends up triggering haskell-mode-suggest-indent-choice?
Actually not direct, but when it does when entering insert-state, this (add-hook haskell-mode-hook (lambda () (setq evil-auto-indent nil))) should work around it. Michael
On Tue, Mar 19, 2013 at 06:32:24PM +0100, Michael Markert wrote:
On Tue, Mar 19 2013 (18:13), Linus Arver <[email protected]> wrote:
So I guess haskell-mode-hook is responsible for this. I've looked at haskell-mode.el and it appears that this function is responsible:
(defun haskell-mode-suggest-indent-choice () "Ran when the user tries to indent in the buffer but no indentation mode has been selected. Brings up the documentation for haskell-mode-hook." (describe-variable 'haskell-mode-hook))
Yes, well the easy way is: Configure your haskell mode correctly and turn on an indentation mode.
I've tried all of haskell-mode's indentation modes, and I despise them all. =( I like to use my own, very simple indentation style that's *not* obsessed with exactly lining up the current line within the context of whatever is on the previous line. And plus, I like to use tabs, unlike all other Haskellers out there... Actually, the *only* reason why I use haskell-mode is for syntax highlighting support.
Maybe evil-change-whole-line for "S" (and also "cc", as this triggers the same behavior) has some indenting code in it, which ends up triggering haskell-mode-suggest-indent-choice?
Actually not direct, but when it does when entering insert-state, this
(add-hook haskell-mode-hook (lambda () (setq evil-auto-indent nil)))
should work around it.
This works wonderfully! Thank you very much. For what it's worth, here is my current Haskell-specific code for dead-simple indentation in my ~/.emacs: ; custom indentation function: copy the indentation of the previous line ; adopted from http://sequence.complete.org/node/365 (defun newline-and-indent-relative () (interactive) (newline) (indent-to-column (save-excursion (forward-line -1) (back-to-indentation) (current-column))) ) ; Haskell {{{ ; adopted from http://sequence.complete.org/node/365 (load-library "haskell-site-file") (add-to-list 'auto-mode-alist '("\\.hs\\'" . haskell-mode)) (remove-hook 'haskell-mode-hook 'turn-on-haskell-indent) ; 4-space tabs (add-hook 'haskell-mode-hook (lambda () (turn-on-haskell-doc-mode) (setq evil-auto-indent nil) (setq tab-width 4) (setq indent-tabs-mode t) ) ) ; make indentation saner when inserting new lines, whether from insert mode or normal mode (evil-declare-key 'insert haskell-mode-map (kbd "RET") 'newline-and-indent-relative) (evil-declare-key 'normal haskell-mode-map "o" (lambda () (interactive) (evil-append-line 1) (newline-and-indent-relative) ) ) (evil-declare-key 'normal haskell-mode-map "O" (lambda () (interactive) (previous-line) (evil-append-line 1) (newline-and-indent-relative) ) ) ;}}} -L
On Wed, Mar 20 2013 (01:52), Linus Arver <[email protected]> wrote:
On Tue, Mar 19, 2013 at 06:32:24PM +0100, Michael Markert wrote:
Actually not direct, but when it does when entering insert-state, this
(add-hook haskell-mode-hook (lambda () (setq evil-auto-indent nil)))
should work around it.
This works wonderfully! Thank you very much.
For what it's worth, here is my current Haskell-specific code for dead-simple indentation in my ~/.emacs:
; custom indentation function: copy the indentation of the previous line ; adopted from http://sequence.complete.org/node/365 (defun newline-and-indent-relative () (interactive) (newline) (indent-to-column (save-excursion (forward-line -1) (back-to-indentation) (current-column))) )
Well if you don't want to use the indent modes this one is even simpler: (add-hook 'haskell-mode (lambda () (setq indent-line-function #'indent-relative))) This could make your custom function superfluous and you don't have to disable the auto-indent. Michael
On Wed, Mar 20, 2013 at 09:25:03AM +0100, Michael Markert wrote:
On Wed, Mar 20 2013 (01:52), Linus Arver <[email protected]> wrote:
On Tue, Mar 19, 2013 at 06:32:24PM +0100, Michael Markert wrote:
Actually not direct, but when it does when entering insert-state, this
(add-hook haskell-mode-hook (lambda () (setq evil-auto-indent nil)))
should work around it.
This works wonderfully! Thank you very much.
For what it's worth, here is my current Haskell-specific code for dead-simple indentation in my ~/.emacs:
; custom indentation function: copy the indentation of the previous line ; adopted from http://sequence.complete.org/node/365 (defun newline-and-indent-relative () (interactive) (newline) (indent-to-column (save-excursion (forward-line -1) (back-to-indentation) (current-column))) )
Well if you don't want to use the indent modes this one is even simpler:
(add-hook 'haskell-mode (lambda () (setq indent-line-function #'indent-relative)))
This could make your custom function superfluous and you don't have to disable the auto-indent.
Indeed, it did make my custom indent function unnecessary; I've removed the bindings to "RET", "o", and "O" and they all work by default as expected with my preferred relative indentation style. "S" and "cc" work just fine, also. Thanks again.
participants (3)
-
Barry OReilly -
Linus Arver -
Michael Markert