gsp*_*spr 11 emacs haskell indentation
我是一名Emacs用户,在配置编辑器方面没有任何技能.从haskell-mode 2.4 升级到2.7之后,我注意到了两个变化:
我看到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)
Run Code Online (Sandbox Code Playgroud)
和它类似,但我要么最终得到标准模式或普通的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
)
Run Code Online (Sandbox Code Playgroud)
nom*_*olo 15
配置此类内容的最佳方法是编写自定义挂钩:
(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.
)
Run Code Online (Sandbox Code Playgroud)
您也可以在其中粘贴匿名函数,但如果您想尝试某些设置,则可以更轻松地使用命名函数.只是重新定义函数(并重新打开Haskell文件)将为您提供新的行为.
| 归档时间: |
|
| 查看次数: |
2274 次 |
| 最近记录: |