我准备了一个最小的工作示例来检查其他依赖项是否没有干扰这一点。测试函数为:
(defun test-haskell-problems ()
(interactive)
(insert (s-lower-camel-case "other_string")))
问题的完整再现(通过软件包安装)如下:
(setq package-list '(
s
haskell-mode
))
(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
)
; activate all the packages (in particular autoloads)
(package-initialize)
; fetch the list of packages available
(when (not package-archive-contents)
(package-refresh-contents))
; install the missing packages
(dolist (package package-list)
(when (not (package-installed-p package))
(package-install package)))
(require 's)
(defun test-haskell-problems ()
(interactive)
(insert (s-lower-camel-case "other_string")))
通过激活此功能test-haskell-problems
在 haskell 缓冲区中我们得到字符串结果other_string
预期结果和结果*scratch*
缓冲区是otherString
我不明白这里发生了什么?
有人有什么想法吗?
这是由于定义“单词”是什么的语法条目造成的。在 Haskell 中,asdf_asdf 是一个单词,而 s.el 通过按单词拆分字符串来进行驼峰式命名。
一个简单的解决方案是在临时缓冲区中执行骆驼套管。
(insert (with-temp-buffer (s-lower-camel-case "asdf_asdf")))
更正确的解决方案是暂时重新定义单词边界。
编辑:在这里
(insert (with-syntax-table (make-syntax-table) (s-lower-camel-case "asdf_asdf")))
这也快得多:
(benchmark 10000 '(with-temp-buffer (s-lower-camel-case "asdf_asdf")))
"Elapsed time: 1.188508s (0.204679s in 2 GCs)"
(benchmark 10000 '(with-syntax-table (make-syntax-table) (s-lower-camel-case "asdf_asdf")))
"Elapsed time: 0.368366s (0.191607s in 2 GCs)"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)