我是一名Emacs用户,在配置编辑器方面没有任何技能。我升级后 哈斯克尔模式 2.4到2.7,我注意到两个变化:
- 缩进是 不同 不知何故,在某种程度上我不太喜欢。我无法完全理解它是什么。
- 更重要的是:如果我启用了cua模式并突出显示一个文本块,则退格/删除会执行 不 删除整个块,只删除标记中的上一个/下一个字符。
我看到haskell-mode 2.7默认使用次模式haskell-indentation-mode,而2.4的行为以haskell-indent-mode的形式保存。如果我先关闭前者,然后关闭后者,我想恢复的行为(即缩进感觉就像之前一样,退格/删除会删除突出显示的块)。
但是,每当我打开带有.hs后缀的文件时,我都无法自动执行此操作。我尝试了各种类似的东西
(remove-hook 'haskell-mode-hook 'turn-on-haskell-indentation-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent-mode)
和它类似,但我最终得到标准模式或普通的haskell模式没有缩进和文档。
有任何想法吗?
解决方案(感谢nominolo):
(remove-hook 'haskell-mode-hook 'turn-on-haskell-indent)
(remove-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
(defun my-haskell-mode-hook ()
(haskell-indentation-mode -1) ;; turn off, just to be sure
(haskell-indent-mode 1) ;; turn on indent-mode
)
配置此类内容的最佳方法是编写自定义钩子:
(add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
(defun my-haskell-mode-hook ()
(haskell-indentation-mode -1) ;; turn off, just to be sure
(haskell-indent-mode 1) ;; turn on indent-mode
;; further customisations go here. For example:
(setq locale-coding-system 'utf-8 )
(flyspell-prog-mode) ;; spell-checking in comments and strings
;; etc.
)
您也可以在其中粘贴匿名函数,但如果您想尝试某些设置,则可以更轻松地使用命名函数。重新定义函数(并重新打开Haskell文件)将为您提供新的行为。
配置此类内容的最佳方法是编写自定义钩子:
(add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
(defun my-haskell-mode-hook ()
(haskell-indentation-mode -1) ;; turn off, just to be sure
(haskell-indent-mode 1) ;; turn on indent-mode
;; further customisations go here. For example:
(setq locale-coding-system 'utf-8 )
(flyspell-prog-mode) ;; spell-checking in comments and strings
;; etc.
)
您也可以在其中粘贴匿名函数,但如果您想尝试某些设置,则可以更轻松地使用命名函数。重新定义函数(并重新打开Haskell文件)将为您提供新的行为。