OSX - 配置Emacs使用NSSpellChecker [英] OSX -- configuring Emacs to use NSSpellChecker

查看:120
本文介绍了OSX - 配置Emacs使用NSSpellChecker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法逆向工程Aquamacs来提取NSSpellChecker的使用/功能。我想将这种使用/功能纳入源自Emacs的裸机构建中。我找到了看似相关的文件 - ns-win.el ; flyspell.el ;和 ispell.el - 然而,只需将这些文件从Aquamacs替换为Emacs,则不会启用弹出菜单来运行OSX本机的拼写检查器。我错过了一个或多个拼图 - 我打开了所有的Aquamacs * .gz文件,并搜索了所有这些文件中的几个关键字,但我还没有发现任何其他文件,看起来像他们有与此功能有关。该功能是由Aquamacs 之前启用的,其site-start.el已启动。



我已经学会了如何使用tarball从源代码构建Emacs,还可以使用bzr。如果有人知道如何在构建过程中配置NSSpellChecker,那将是非常好的。



在互联网上没有找到任何远程描述如何做到这一点。 / p>

Aspell的拼写检查功能让我想起了80年代后期的生活。我喜欢使用按钮选择拼写检查选项的弹出菜单。



以下是构建Aquamacs的解释链接,并查看我的待办事项列表中的下一个构建脚本:



http://www.emacswiki.org/cgi-bin/wiki/BuildingAquamacs



编辑1:构建脚本有一点要说NSSpellChecker,因此需要查看的附加文件包括: nsterm.m nsfns.m 。我不认为 aquamacs-menu.el osxkeys.el 是必要的,因为在网站启动后加载.el。越来越多的NSSpellChecker在构建过程中被硬编码到应用程序可执行文件中,与上述文件相结合。



编辑2:是的,那是失落的一块拼图。应用程序包中的Aquamacs的可执行文件(即 ... Aquamacs.app/Contents/MacOS/Aquamacs )包含NSSpellChecker与Aquamacs结合使用的硬编码魔术修改版本 ns-win.el ; flyspell.el ;和 ispell.el



编辑3:此时,一个选项是修改构建脚本在构建过程中使用的Aquamacs和相关文件,以构建自定义应用程序。或者,创建混合也是可能的,但是自带问题,因为Aquamacs可执行文件使用诸如 one-frame-one-buffer-mode 等专业进行硬编码从Finder.app打开一个文件;从Finder.app打开文件时,切换到缓冲区选项卡 ns-application-activated 需要设置为忽略;包括init.el文件中的版本id,以正确安静错误消息;面向Aquamacs的简单菜单选项可用于保存选项;还有一些很明显的问题。简而言之,混合动物是可行的,但在颈部疼痛。我确实有一个混合工作,但我确定我必须做更多的调整,因为我发现更多的Aquamacs定制(由可执行文件创建)需要处理。现在提供任何类型的答案为时尚早。构建脚本修改似乎是最好的解决方案,但是需要很多时间才能正确地进行修改,以创建隔离NSSpellChecker功能的自定义构建。



编辑4:我有一个NSSpellChecker的工作版本,它是Aquamacs24的自定义构建的可执行文件(省略几乎所有的Aquamacs除了拼写检查器)和Emacs-trunk最新的Emacs24(夜间构建)的构建。我正在等待接收一些技术支持,使用终端下载最新的Aquamacs24分支与git,因为我有一些问题与终端的ZIP版本重复。这是非常详细的,我想在发布答案之前简化过程,我想预先彻底测试。



NSSpellChecker http://lawlist.com/images/spellchecker.png

解决方案

补丁(以下简称)是由Aquamacs的select部分的@lawlist创建的:



https://github.com/davidswelt/aquamacs- emacs



要在Emacs的通用版本中启用OSX上的本机拼写检查,需要先修补C源代码,然后再修复还需要修改几个lisp文件。补丁太大了,无法在stackexchange.com上回答。



以下过程假定OSX已安装必要的工具来构建和修补等。 - 例如git,最近版本的 automake autoconf ,xcode等。






EMACS-25 BRANCH - 2016年11月1日



以下补丁和最小化测试是在 emacs-25分支内建 - with-ns 作为2016年11月1日的承诺: 5043e0a7e06dbf6507a59736e55bdde69d9a2a4e



从终端,键入: git clone -b emacs-25 git://git.sv.gnu.org/emacs.git



访问: https://gist.github.com/lawlist/dfc75240cc06c66f19f48eaa3e570d7c



点击下载ZIP 按钮,然后保存他将补丁文件压缩到您计算机上的某个位置。



提取您刚下载的 ZIP 存档,并保存 nsspellchecker_emacs25.diff ... / emacs 根源代码目录,克隆在上面的第一步。



从终端,$ code> cd 到根 ... / emacs 源代码目录。



;;补丁可能会变得过时了,所以这个例子包括一个很难重新设置,可以追溯到2016年11月1日。[开发团队仍然对Emacs 25进行了一些错误修复,这可能会导致补丁过时。] p>

从终端,键入: git reset --hard 5043e0a7e06dbf6507a59736e55bdde69d9a2a4e



;;在成功执行硬复位后,终端中的消息将会说: HEAD现在为5043e0a修复'eudc-options-file'的文档



从终端,键入: git apply nsspellchecker_emacs25.diff



从终端,键入: code> ./ autogen.sh



从终端输入: ./ configure --with -ns



从终端,键入: make



从终端,键入: make install



;;使用Finder.app,浏览到 ... / emacs / nextstep 并尝试您的新Emacs.app



;;打开你的新Emacs.app并输入 M-x eval-expression RET(require'flyspell)RET



;;在 * scratch * 缓冲区中,输入拼写错误的拼写错误。



;;键入: Mx ns-start-spellchecker Mx ispell-buffer



;;使用弹出式拼写检查器播放一下,玩得开心。



;;自定义单词保存到:〜/ Library / Spelling / LocalDictionary






适用于 master 分支的上一个答案截至2016年5月29日



以下修补程序和最小化测试在主分支中执行,建立 - with-ns 2016年5月29日: 76fb19b359dec8556dc66dbac3ad3d333feea3c3



从终端,键入: git clone -b master git://git.sv.gnu.org/emacs.git



访问: https://gist.github.com/lawlist/6a9b281870fcc114ad3c6c1dca121f95



点击下载ZIP 按钮,并将压缩的补丁文件保存在计算机上某处。



提取 ZIP 存档您刚刚下载并将 nsspellchecker.diff 保存到 ... / emacs 在上面第一步克隆的根源代码目录。



从终端, cd 到根 ... / emacs 源代码目录。



;;补丁很快就会变得过时了,所以这个例子包括一个很难重置的方法,可以追溯到2016年5月29日。[Emacs master branch 每天更改次数不会更新/维护补丁。 ]



从终端输入: git reset --hard 76fb19b359dec8556dc66dbac3ad3d333feea3c3



;;在成功执行硬复位后,终端中的消息将会说: HEAD现在为76fb19b * lisp / wid-edit.el(link):删除:follow-link属性(bug#22434)



从终端输入: git apply nsspellchecker.diff


I'm having trouble reverse-engineering Aquamacs to extract the usage / functionality of NSSpellChecker. I would like to incorporate that use / functionality into a bare-bones build of Emacs from source. I've located the seemingly relevant files -- ns-win.el; flyspell.el; and ispell.el -- however, simply replacing those files from Aquamacs to Emacs does not enable the pop-up menu for running the spell-checker that is native to OSX. I'm missing one or more pieces to the puzzle -- I've opened all the Aquamacs *.gz files and searched for a few keywords within all of those files, but I haven't found any other files that look like they have something to do with this functionality. The functionality is enabled by Aquamacs before its site-start.el is initiated.

I've learned how to build Emacs from source using the tarball, and also by using bzr. If anyone knows how to configure NSSpellChecker during the build process, that would be great.

There is nothing I have found on the internet that remotely describes how to do this.

The spell check function of Aspell reminds me of what life was like back in the late-80's. I've grown fond of the pop-up menu with buttons to select the spell-checking options.

Here is the link to an explanation for building Aquamacs, and looking into the build script is next on my to-do list:

http://www.emacswiki.org/cgi-bin/wiki/BuildingAquamacs

Edit 1: The build scripts have a little more to say about NSSpellChecker, so additional files that need to be looked at include: nsterm.m and nsfns.m. I don't think aquamacs-menu.el or osxkeys.el are necessary, because those load after site-start.el. It's looking more and more like NSSpellChecker is hard-coded into the application executable during the build process, in conjunction with the files mentioned above.

Edit 2: Yep, that was the missing piece of the puzzle. The executable of Aquamacs within the application package (i.e., ... Aquamacs.app/Contents/MacOS/Aquamacs) contains the hard-coded magic for NSSpellChecker in conjunction with the Aquamacs modified versions of ns-win.el; flyspell.el; and ispell.el.

Edit 3: At this point, one option would be to modify the build script for Aquamacs and related files used in the build process in order to build a custom application. Alternatively, creating a hybrid is also possible, but comes with its own problems because the Aquamacs executable is hard-coded with specialties such as one-frame-one-buffer-mode when opening a file from Finder.app; switch-to-buffer-in-tab when opening a file from Finder.app; ns-application-activated that needs to be set to ignore; including the version id inside the init.el file to properly quiet the error message; easy-menu options that are geared towards Aquamacs for saving options; and a few other issues that are readily apparent. In short, a hybrid is doable, but a pain in the neck. I do have a hybrid working, but I'm sure I'll have to do more tweaking as I find more Aquamacs customizations (created by the executable) that need to be dealt with. It is too early for me to post any type of an answer. The build script modification appears to be the best solution, but would require a lot of time to modify it properly in order to create a custom build that isolates the NSSpellChecker feature.

Edit 4: I have a working version with NSSpellChecker that is the executable of a custom build of Aquamacs24 (omitting almost everything Aquamacs except for the spellchecker), and the emacs-trunk most recent build of Emacs24 (nightly build). I'm waiting on receiving some technical support to use the terminal for downloading the latest branch of Aquamacs24 with git because I'm having some issues duplicating the ZIP version with the terminal. This is pretty detailed and I'd like to simplify the process before posting an answer, and I want to test it out thoroughly beforehand.

NSSpellChecker http://lawlist.com/images/spellchecker.png

解决方案

The patches (referred to below) were created by @lawlist from select portions of the Aquamacs:

https://github.com/davidswelt/aquamacs-emacs

To enable native spellchecking on OSX in the vanilla/generic version of Emacs, it is necessary to patch the C-source-code prior building, and a few lisp files also need to be modified. The patch is too big to post in an answer on stackexchange.com.

The following procedure assumes the necessary tools have already been installed on OSX to build and patch, etc. -- e.g., git, recent versions of automake and autoconf, xcode, etc.


EMACS-25 BRANCH -- NOVEMBER 1, 2016:

The following patch and minimal testing was performed on the emacs-25 branch built --with-ns as of commit dated November 1, 2016: 5043e0a7e06dbf6507a59736e55bdde69d9a2a4e

From a terminal, type: git clone -b emacs-25 git://git.sv.gnu.org/emacs.git

Visit: https://gist.github.com/lawlist/dfc75240cc06c66f19f48eaa3e570d7c

Click the "Download ZIP" button, and save the zipped patch file somewhere on your computer.

Extract the ZIP archive you just downloaded and save nsspellchecker_emacs25.diff to the .../emacs root source-code directory that was cloned in the first step above.

From a terminal, cd over to the root .../emacs source-code directory.

;; The patch may become outdated, so this example includes a hard reset to go back to November 1, 2016. [Certain bug fixes are still being made to Emacs 25 by the development team, which may cause the patch to become outdated.]

From a terminal, type: git reset --hard 5043e0a7e06dbf6507a59736e55bdde69d9a2a4e

;; After performing a hard reset successfully, the message in the terminal will say: "HEAD is now at 5043e0a Fix documentation for 'eudc-options-file'"

From a terminal, type: git apply nsspellchecker_emacs25.diff

From a terminal, type: ./autogen.sh

From a terminal, type: ./configure --with-ns

From a terminal, type: make

From a terminal, type: make install

;; With Finder.app, navigate over to .../emacs/nextstep and try out your new Emacs.app

;; Open your new Emacs.app and type M-x eval-expression RET (require 'flyspell) RET

;; In a *scratch* buffer, type something spelled correctly and something spelled wrong.

;; Type: M-x ns-start-spellchecker or M-x ispell-buffer

;; Play a little with the pop-up spellchecker and have fun.

;; Custom words are saved to: ~/Library/Spelling/LocalDictionary


Previous answer that applies to the master branch as of May 29, 2016:

The following patch and minimal testing was performed on master branch built --with-ns as of commit dated May 29, 2016: 76fb19b359dec8556dc66dbac3ad3d333feea3c3

From a terminal, type: git clone -b master git://git.sv.gnu.org/emacs.git

Visit: https://gist.github.com/lawlist/6a9b281870fcc114ad3c6c1dca121f95

Click the "Download ZIP" button, and save the zipped patch file somewhere on your computer.

Extract the ZIP archive you just downloaded and save nsspellchecker.diff to the .../emacs root source-code directory that was cloned in the first step above.

From a terminal, cd over to the root .../emacs source-code directory.

;; The patch will soon become outdated, so this example includes a hard reset to go back to May 29, 2016. [I will not be updating/maintaining the patch as Emacs master branch changes several times each day.]

From a terminal, type: git reset --hard 76fb19b359dec8556dc66dbac3ad3d333feea3c3

;; After performing a hard reset successfully, the message in the terminal will say: "HEAD is now at 76fb19b * lisp/wid-edit.el (link): Remove :follow-link property (bug#22434)"

From a terminal, type: git apply nsspellchecker.diff

这篇关于OSX - 配置Emacs使用NSSpellChecker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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