【问题标题】:How do I change ispell private dictionary如何更改 ispell 私人词典
【发布时间】:2015-02-17 03:20:40
【问题描述】:

我想对一个大型项目/存储库中的多个文件进行拼写检查,并使用与我自己不同的私人字典。这样我就可以使用项目字典,以后可以将其上传给其他用户使用。

【问题讨论】:

    标签: emacs ispell


    【解决方案1】:

    克里斯的回答是正确的。这只是我用来在aspell 个人词典和aspell 语言之间切换的示例。我同时使用flyspellispell。个人字典的路径需要根据用户规范进行调整。

    (defface ispell-alpha-num-choice-face
      '((t (:background "black" :foreground "red")))
      "Face for `ispell-alpha-num-choice-face`."
      :group 'ispell)
    
    (defface ispell-text-choice-face
      '((t (:background "black" :foreground "forestgreen")))
      "Face for `ispell-text-choice-face`."
      :group 'ispell)
    
    (defun my-ispell-change-dictionaries ()
    "Switch between language dictionaries."
    (interactive)
      (let ((choice (read-char-exclusive (concat
              "["
              (propertize "E" 'face 'ispell-alpha-num-choice-face)
              "]"
              (propertize "nglish" 'face 'ispell-text-choice-face)
              " | ["
              (propertize "S" 'face 'ispell-alpha-num-choice-face)
              "]"
              (propertize "panish" 'face 'ispell-text-choice-face)))))
        (cond
          ((eq choice ?E)
            (setq flyspell-default-dictionary "english")
            (setq ispell-dictionary "english")
            (setq ispell-personal-dictionary "/Users/HOME/.0.data/.0.emacs/.aspell.en.pws")
            (ispell-kill-ispell)
            (message "English"))
          ((eq choice ?S)
            (setq flyspell-default-dictionary "spanish")
            (setq ispell-dictionary "spanish")
            (setq ispell-personal-dictionary "/Users/HOME/.0.data/.0.emacs/.aspell.es.pws")
            (ispell-kill-ispell)
            (message "Español"))
          (t (message "No changes have been made."))) ))
    

    【讨论】:

      【解决方案2】:

      在 Emacs 中,变量 ispell-personal-dictionary 可用于选择您的个人字典文件:

      您的个人拼写词典的文件名,或无。如果为零,则 默认个人字典,("~/.ispell_DICTNAME" for ispell 或 "~/.aspell.LANG.pws" for aspell) 被使用,其中 DICTNAME 是名称 您的默认字典和 LANG 两个字母的语言代码。

      在现代系统上,Emacs 的ispell- 函数一般使用GNU aspell,一个

      旨在最终取代 Ispell 的免费和开源拼写检查器

      从您的问题中不清楚是否每个人都会通过 Emacs 进行拼写检查。幸运的是,aspell 支持一个类似的命令行选项:

      --personal=<file>, -p <file>
          Personal word list file name.
      

      【讨论】:

      • 在将ispell-personal-dictionary 更改为已打开且flyspell 处于活动状态的缓冲区后,我使用ispell-kill-ispell 启动新的ispell 会话。在缓冲区加载前设置ispell-personal-dictionary时,无需调用ispell-kill-ispell
      【解决方案3】:

      我的 init.el 文件中有这个,对我来说非常有用 (位于http://www.emacswiki.org/emacs/FlySpell

      (setq ispell-program-name "aspell")
      (setq ispell-list-command "list")
      
      
      (let ((langs '("spanish" "british" "french")))
        (setq lang-ring (make-ring (length langs)))
        (dolist (elem langs) (ring-insert lang-ring elem)))
      (defun cycle-ispell-languages ()
        (interactive)
        (let ((lang (ring-ref lang-ring -1)))
          (ring-insert lang-ring lang)
          (ispell-change-dictionary lang)))
      

      我已经设置了一个组合键来从一个字典循环到另一个字典

      (global-set-key [M-f6] 'cycle-ispell-languages)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-29
        • 2013-06-04
        • 2018-02-13
        • 2010-11-20
        • 1970-01-01
        相关资源
        最近更新 更多