emacs haskell模式下的默认lambda符号?
有谁知道我如何在emacs中使用haskell打印λ而不是。 我知道可以使用haskell-font-lock-symbols,但是我发现其余的很难阅读 - 箭头太小了!
有没有一种简单的方法可以覆盖其余的键?
你可以这样做:
(defun pretty-lambdas-haskell ()
(font-lock-add-keywords
nil `((,(concat "(" (regexp-quote "") ")")
(0 (progn (compose-region (match-beginning 1) (match-end 1)
,(make-char 'greek-iso8859-7 107))
nil))))))
(add-hook 'haskell-mode-hook 'pretty-lambdas-haskell)
这将lambda作为关键字添加,这意味着它不会出现在字符串中的转义序列中(例如:在更改事物后,情况并非如此)。 ,(make-char 'greek-iso8859-7 107)
当然等于?λ
,但在这种情况下,您必须确保您的Emacs init文件被编码为unicode。
您还可以启用完整符号字体锁定并使用更好的(阅读:更宽的箭头)字体,如Pragmata Pro,Inconsolata或Ubuntu Monospace。 我使用下面的代码来选择一个好的字体:
(defun font-existsp (font)
"Check to see if the named FONT is available."
(if (null (x-list-fonts font))
nil t))
(require 'cl)
(defun font-avail (fonts)
"Finds the available fonts."
(remove-if-not 'font-existsp fonts))
(defvar font-preferences
'("PragmataPro"
"Inconsolata"
"DejaVu Sans Mono"
"Bitstream Vera Sans Mono"
"Anonymous Pro"
"Menlo"
"Consolas"))
(unless (eq window-system nil)
(let ((fonts (font-avail font-preferences)))
(unless (null fonts)
(set-face-attribute
'default nil :font
(car fonts)))))
你也可以用类似的东西解决问题
(eval-after-load 'haskell-font-lock
'(setq haskell-font-lock-symbols-alist
(delq nil
(mapcar (lambda (rewrite)
(if (member (car rewrite) '("->" "<-"))
nil rewrite))
haskell-font-lock-symbols-alist))))
除了将“→”改成“→”和“< - ”改成“←”的映射之外,应该保留所有的映射。
链接地址: http://www.djcxy.com/p/59169.html