在Emacs中使用Elpy禁用Python代码的自动完成。

huangapple go评论56阅读模式
英文:

Disable auto completion of python code in emacs with elpy

问题

我是新手使用 elpy,这是一个用于处理 Python 的 Emacs 包。我一般不喜欢自动完成,特别是 elpy 使用的 YAsnippet 工具。我该如何禁用它?我在网上找到了解决方法,应该在启用 elpy 之前执行以下操作:(delete 'elpy-module-yasnippet elpy-modules)。但在加载 elpy 之前,这个变量未定义,我遇到了一个循环依赖的问题!以下是我的 init.el 文件,只包含一组最相关的代码行:

(package-initialize)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(require 'use-package)

(custom-set-variables
 '(package-selected-packages (quote (elpy python-mode)))
)

(use-package elpy
  :ensure t
  :defer t
  :init
  (advice-add 'python-mode :before 'elpy-enable)
)

;; 禁用 elpy 中的 YAsnippet 代码补全
;(delete 'elpy-module-yasnippet elpy-modules)
英文:

I am new to using elpy, an emacs package for working with Python. I am not a fan of auto-complete in general, and the YAsnippet tool elpy uses in particular. How can I disable it? I found on the web I should do (delete 'elpy-module-yasnippet elpy-modules) before elpy is enabled. But I have a chicken and egg problem that this var is undefined before I load elpy! Here is my init.el, cut down to a minimal set of relevant lines:

(package-initialize)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(require 'use-package)

(custom-set-variables
 '(package-selected-packages (quote (elpy python-mode)))
)

(use-package elpy
  :ensure t
  :defer t
  :init
  (advice-add 'python-mode :before 'elpy-enable)
)

;; disable YAsnippet code completion in elpy
;(delete 'elpy-module-yasnippet elpy-modules)

答案1

得分: 2

如果您的问题的关键点确实是

我有一个鸡生蛋问题,在我加载elpy之前,这个变量未定义!

那么解决方案是

(with-eval-after-load 'elpy
  (delete 'elpy-module-yasnippet elpy-modules))
英文:

If the crux of your problem is indeed

> I have a chicken and egg problem that this var is undefined before I load elpy!

Then the solution is

(with-eval-after-load 'elpy
  (delete 'elpy-module-yasnippet elpy-modules))

huangapple
  • 本文由 发表于 2023年7月11日 01:15:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76655943.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定