在 Emacs 中使用 haskell-mode 自动完成 Haskell [英] Haskell autocompletion in Emacs using haskell-mode

查看:20
本文介绍了在 Emacs 中使用 haskell-mode 自动完成 Haskell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 emacs 中安装了 haskel-mode.然后我在我的 .emacs 中写:

I installed haskel-mode in emacs. Then I write in my .emacs:

(load "~/.emacs.d/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'haskell-font-lock-symbols t)
(put 'downcase-region 'disabled nil)

我必须在我的 conf 文件中添加什么才能让 emacs 为 Haskell 自动完成?还是 Haskell 模式没有这种可能?

What must I add in my conf file that emacs could autocomplete for Haskell? Or Haskell mode there is no such possibility?

推荐答案

当没有特定语言的支持时,您可以使用标签.这是一个通用的完成机制.

When there is no language-specific support, you can use tags. This is a generic completion mechanism.

  1. 生成一个 TAGS 文件,其中包含标识符列表及其定义位置.Emacs 带有 etags 程序,可以在许多语言中执行此操作,但不是 Haskell;ghc 带有 hasktags.

  1. Generate a TAGS file, which contains a list of identifiers and where they are defined. Emacs comes with the etags program to do this in many languages, but not Haskell; ghc comes with hasktags.

使用 M-x visit-tags-table 加载 TAGS 文件.

Load the TAGS file with M-x visit-tags-table.

标签不依赖于上下文,因此它们会在任何地方不加区别地建议类型、值、构造函数等.它们也不会提供高级功能,例如轻松显示值的类型.最重要的标签命令是:

Tags are not context-dependent, so they'll indiscriminately suggest types, values, constructors, etc everywhere. They also won't provide advanced features such as easily showing the type of a value. The most important tags commands are:

  • M-TAB (complete-symbol) 根据加载的标签列表完成一个标识符.

  • M-TAB (complete-symbol) completes an identifier according to the loaded list of tags.

M-. (find-tag) 转到定义标识符的位置,如有必要,打开包含文件.

M-. (find-tag) goes to the place where the identifier at point is defined, opening the containing file if necessary.

M-* (pop-tag-mark) 回到 M-. 之前的位置.

M-* (pop-tag-mark) goes back where you were before M-..

M-x tags-apropos 显示匹配正则表达式的标识符列表.

M-x tags-apropos shows a list of identifiers matching a regexp.

有关更多信息,请查看 Emacs 手册中的标签"部分.

For more information, look under "Tags" in the Emacs manual.

对于更粗糙但全自动的机制,有动态缩写功能.C-M-/ (dabbrev-completion) 在大多数打开的缓冲区中查找完成;这是完全独立于语言的,因此它甚至可以在字符串、注释等中找到单词.M-/ (dabbrev-expand) 类似,但直接补全到点之前最近的匹配.

For an even cruder, but fully automatic mechanism, there is the dynamic abbrev feature. C-M-/ (dabbrev-completion) looks in most open buffers for a completion; this is completely language-independent, so it'll even find words in strings, comments, whatever. M-/ (dabbrev-expand) is similar, but directly completes to the nearest match before point.

这篇关于在 Emacs 中使用 haskell-mode 自动完成 Haskell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆