⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linuxdoc+emacs+ispell-howto.txt

📁 linux-bible.rar linux-bible.rar
💻 TXT
📖 第 1 页 / 共 2 页
字号:
   您只要将下列文字加入 .emacs 档案内,您就可以使用上述程式库:         (setq sgml-mode-hook      '(lambda () "Defaults for SGML mode."       (load-library "iso-sgml")))4.2 SGML 模式 (SGML mode)   当载入 .sgml 相关文件时, Emacs 通常会自动进入 sgml 模式。 假如没有的话   ,您可以键入 Meta-x sgml-mode 来驱动它进入 sgml 模式。或者将下列指令加   入 .emacs 档案内来设定它自动进入:         (setq auto-mode-alist      (append '(("\.sgml$"  . sgml-mode))                auto-mode-alist))   在 sgml 模式下,您可以选择要如何输出 8-bit 文字。比如,使用 Meta-x   sgml-name-8bit-mode (或是选单项目上的 SGML/Toggle 8-bit insertion),   您可以选择直接输出 8-bit 文字的格式,或是输出 SGML 的格式(即 &...; 格   式)。      在此模式下,您也可以使用 Meta-x sgml-tags-invisible(或是选单项目上的   SGML/Toggle Tag Visibility) 来选择是否要隐藏或显示 SGML 标签。   4.3 PSGML 模式 (PSGML mode)   PSGML 模式对於在使用 Emacs 下编辑 SGML 文件很有助益。      这份文件 [5]psgml-linuxdoc 解释了如何安装这个模式,及如何将之应用在   LinuxDoc。   4.4 其他相关模式  Auto-fill mode     在一般模式下,当您打完一个段落,您通常会键入 Return 以便换到下一行,否   则您文章的段落就会相连,无法分清楚。但当您使用 Return 以便换到下一行时   ,您的段落的右边通常是参差不齐的。      但假如您不换到下一行而继续键入文字,在某些编辑器下,您就无法看到右边边   界外的文字是什麽。      在这情形下,auto-fill 模式可以帮您改正这情况。当您键入超过预设值的第70   列时,在这模式下,您就会自动换到下一行。      下列是执行 auto-fill 模式的指令,并可将一行的宽度调整为80列:          (setq sgml-mode-hook             '(lambda () "Defaults for SGML mode."                 (auto-fill-mode)                 (setq fill-column 80)))5. Ispell   如果您要在使用 Emacs 时作拼字检查,您可以使用 Ispell 套件及其 Emacs 模   式。   5.1 选择您的预设辞典 (default dictionaries)   您可以设定 Emacs,使之在开始载入某一文件时,便自动选择所需的辞典(您可   以选择好几个)。预设辞典 (main dictionary) 即主要辞典,是与 Ispell 一起   发行的辞典。您可以选择您所需要的语言。第二个即是您的个人辞典 (personal   dictionary),您可以设定要 Ispell 将您在主要辞典里所找不到的字放到这里。      假如您要将 Ispell 里的法文辞典设为预设辞典,并想用您主目录 (home   directory) 下的 .ispell-dico-perso 档案作为个人辞典,可以在 .emacs 档案   里加入下列指令:          (setq sgml-mode-hook       '(lambda () "Defauts for SGML mode."       (setq ispell-personal-dictionary "~/.ispell-dico-perso")       (ispell-change-dictionary "francais")       ))5.2 为特定文件设定个别的辞典   如果您没有用同一语言来检查整份文件的拼字,那麽您可能会遇到一些困难。但   当您在翻译文章时,您很有可能经常交换使用不同的语言与辞典。      不管是自动设定的或是手动的,我并不清楚 Lisp 是如何选择所需的主辞典和个   人辞典。(如果您知道的话,请来信告诉我!)      不过呢,在每一个档案的结尾,只要将下列指令加入作为注释,您都可以指定您   现行的档案要使用哪一辞典。 Ispell 开始拼字检查时即可应用所指定的辞典:         <!-- Local IspellDict: english -->      <!-- Local IspellPersDict: ~/emacs/.ispell-english -->   假如您在 .emacs 档案里已经设定了预设辞典为法文,那您可以将上述指令加入   您所写的英文文件的结尾,以便使用英文辞典。   5.3 文件的拼字检查   若要检查整份文件,可在文件内任一处使用 Meta-x ispell-buffer 指令。您也   可以检查文件某些部分的拼字:        * 将要检查拼字的部分之开头用 Ctrl-Spc 标注 (mark) (即所谓的       mark-set-command),     * 然後标注到那部分的结尾,     * 再键入指令 Meta-x ispell-region.          Emacs 就会开始执行 Ispell。当遇到辞典里所没有的字时,程式会显示这个字(   通常以反白显示),并要求您输入下列指令:        * spc accepts the word, this time only,     * i accepts the word and inserts it in your personal dictionary,     * a accepts the word for this session,     * A accepts the word for this file, and inserts it in the local file       dictionary     * r allows you to correct the word by hand     * R allows you to correct all the occurrences of the misspelled       word,     * x stops the checking, and puts the cursor back in place,     * X stops the checking and leaves the cursor where it is, letting       you correct your file; you will be able to continue the       spell-checking later if you type Meta-x ispell-continue,     * ? gives you online help.          如果 Ispell 找到类似的词汇,它会将这些文字显现在一小视窗内,每一个文字   前都有号码标明,只要键入您要的那个字汇的号码, Ispell 就会以您所选的字   取代错字。   5.4 个人辞典与个别档案辞典 (local file dictionary) 的比较   i 键让您可以在您的个人辞典内插入一个新字,而 A 键让您在个别档案辞典内插   入新字。      个别档案辞典其实是一档案结尾所插入一系列的字或评论, Ispell 每次检查此   档案的拼字时都会重新读取这个辞典。如此,您就可以键入一些只在这特定档案   能接受的字,而其他档案则可不受此辞典影响。      在我看来,我认为个人辞典最好是用来储存一些主辞典所没有的字,尤其是那些   属於各国语言的字(像是有连字符号 hyphenated 的字),及一些通用的特定名   词(像是 Linux),但在个人辞典内加入太多像是姓名的单字也不太好,因为这   些字就会被当作一般字使用了(您可以想像如果您把 Tof 加入个人辞典内,   Ispell 可能就会在下列的例子里,忽略这个错字:        `When the going gets tof, the tof get going.' Tof 是法文 Christophe     名字的缩写。        5.5 键入时的拼字检查   当您在键入文字时,只要您在这 ispell-minor-mode 模式下, Ispell 就会自动   帮您检查拼字。要启动或关闭这模式,请键入这指令 Meta-x   ispell-minor-mode。每当有 Ispell 查不到的字时,它就会哔一声来提醒您。      假如您觉得哔一声很烦人,只要键入指令 Meta-x set-variable RET   visible-bell RET t RET ,您就可以改用萤幕的闪烁来提醒您。您也可以在   .emacs 档案里加入下列指令来关掉 Emacs 的声音:          (setq visible-bell t)6. 一些投机的技巧6.1 自动插入页首 (header)   在 Emacs 下,您可以将任何事件外挂 (hook) 任何的动作(像是打开一个档案,   储存,或执行一个新的模式,等等)。      您也可以利用 autoinsert 程式库来执行一些特别的动作:当您在 Emacs 下开新   档案时,这个程式库就会根据档案的属性来插入相符的标准页首。      就我们的情形,这标准页首就是我们说明文件型态 (LinuxDoc),标题,作者,及   日期的地方。      接下来我会描述两个如何插入这种页首的方法。您可以插入一个含有相关资讯的   模板 (template) 档案,或者您也可以跑一跑 elisp 程式。     藉由插入一个档案     当您开启一份档案时,首先您必须告诉 Emacs 执行自动插入,然後再读取   autoinsert 程式库的资料来宣告我们要改变的 auto-insert-alist 表单。这表   单定义了不同档案型态所要插入的页首。它的预设值是要插入的档案必须在   ~/insert/ 目录下,但如果您要重新定义其 auto-insert-directory 也是可行的      每一次您开启一份新的 SGML 档案时,只要在 .emacs 档案内加入下列指示,您   就可以插入 ~/emacs/sgml-insert.sgml 档:         (add-hook 'find-file-hooks 'auto-insert)      (load-library "autoinsert")      (setq auto-insert-directory "~/emacs/")      (setq auto-insert-alist            (append '((sgml-mode .  "sgml-insert.sgml"))                    auto-insert-alist))   那您就可以在 ~/emacs/sgml-insert.sgml 档写入您自订的页首,然後再重新执   行 Emacs 来开启某一 foobar.sgml 档案,之後 Emacs 会询问您确认这自动插入   的指令来插入您要的页首。     藉由执行一个程式     这方法跟上述大同小异,但不同的是您必须设定 auto-insert-alist 表单,告诉   它要插入的是一个执行程式,而非一个档案。只要在 .emacs 档案内加入下列指   示,就可以自动执行,不过当然您得先把这程式写在一个叫做   ~/emacs/sgml-header.el 的档案里才可以。(鉴於这函式可能会过长,您不需要   将它放在 .emacs 档案里):         (add-hook 'find-file-hooks 'auto-insert)      (load-library "autoinsert")      (add-to-list 'load-path "~/emacs")      (load-library "sgml-header")      (setq auto-insert-alist            (append '(((sgml-mode .  "SGML Mode") . insert-sgml-header))                    auto-insert-alist))   您可以参考 [6]附录里有关 Insert-sgml-header 程式的例子。   Appendix7. Insert-sgml-header程式之□例   读者在撰写一份 Linux Documentation Project 文件时,可以使用下列程式来启   动自动插入自订的页首。      透过一 mini-buffer,上述程式会要求读者提供一些或许必要的资讯。      它会先询问要输出的标题是什麽,若您没有提供,则页首就不会显现标题。再来   是日期,作者,作者的电子邮件帐号与 home page (最後两项可随意填入)。      接著它会询问翻译者的名字。若无,请直接键入 Return。若有,程式就会接著询   问译者的电子邮件帐号及 home page (同样也是随意填入)。      再来它会把您的输入存入 current buffer,包括任何您输入的资讯格式,及摘要   和第一章的标签。之後它会将游标导向您要键入摘要的的地方。   (defun insert-sgml-header ()  "Inserts the header for a LinuxDoc document"  (interactive)  (let (title author email home translator email-translator home-translator date              starting-point)    (setq title (read-from-minibuffer "Title: "))    (if (> (length title) 0)        (progn          (setq date (read-from-minibuffer "Date: ")                author (read-from-minibuffer "Author: ")                email (read-from-minibuffer "Author e-mail: ")                home (read-from-minibuffer "Author home page: http://")                translator (read-from-minibuffer "Translator: "))          (insert "<!doctype linuxdoc system>\n<article>\n<title>")          (insert title)          (insert "</title>\n<author>\nAuthor: ") (insert author) (insert "<newline>\n")          (if (> (length email) 0)              (progn                (insert "<htmlurl url=\"mailto:")                (insert email) (insert "\" name=\"") (insert email)                (insert "\"><newline>\n")))          (if (> (length home) 0)              (progn                (insert "<htmlurl url=\"http://")                (insert home) (insert "\" name=\"") (insert home)                (insert "\">\n<newline>")))          (if (> (length translator) 0)              (progn                (setq email-translator (read-from-minibuffer "Translator e-mail: ")                      home-translator (read-from-minibuffer "Translator home page: http://"))                (insert "Translator : ")                (insert translator)                (insert "<newline>\n")                (if (> (length email-translator) 0)                    (progn                      (insert "<htmlurl url=\"mailto:")                      (insert email-translator) (insert "\" name=\"")                      (insert email-translator)                      (insert "\"><newline>\n")))                (if (> (length home-translator) 0)                    (progn                      (insert "<htmlurl url=\"http://")                      (insert home-translator) (insert "\" name=\"")                      (insert home-translator)                      (insert "\"><newline>\n")))))          (insert "</author>\n<date>\n")          (insert date)          (insert "\n</date>\n\n<abstract>\n")          (setq point-beginning (point))          (insert "\n</abstract>\n<toc>\n\n<sect>\n<p>\n\n\n</sect>\n\n</article>\n")          (goto-char point-beginning)          ))))References   1. mailto:feloy@wanadoo.fr   2. mailto:Sebastien.Blondeel@lifl.fr   3. mailto:anshan@hello.com.tw   4. ftp://ftp.lip6.fr/pub/sgml-tools/   5. http://www.linux-france.com/article/psgml-linuxdoc   6. file://localhost/tmp/bg5sgmltools.7100/LinuxDoc+Emacs+Ispell-HOWTO.txt.html#insert-sgml-header

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -