姜戈 + Emacs(作为 TextMate 的替代品)

发布于 2024-08-02 07:23:16 字数 170 浏览 7 评论 0原文

有没有完整的教程如何配置 emacs 以与 Django (1.1)(在 Mac 上)一起使用? 我正在考虑从 TextMate 切换到 Emacs,以便为 django 提供多平台编辑器。我有我的最爱。来自 textmate 的主题,我想将其转换为 emacs(也许是“转换器”?)。从 Textmate 切换是个好主意吗?

There is any complete tutorial how to configure emacs for using with Django (1.1) (on Mac)?
Im thinking about switch from TextMate to Emacs to have multiplatform editor for django. I have my fav. theme from textmate and I want to convert this to emacs (maybe is "converter" for this?). Switching from Textmate is a good idea ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故人爱我别走 2024-08-09 07:23:16

我赞同 @docgnome 对 Django 模式yasnippet,但真正让您再也不想回到 TextMate 的关键是集成 PyFlakes 到您的开发环境中,此时 Emacs 将为您提供有关 Python 代码中错误的即时通知。这些远远超出了仅通过语法突出显示即可免费获得的拼写错误级别的错误检测;您将收到错误通知,例如赋值前的变量、未使用的导入以及错误的缩进等。

在 Emacs 中安装 PyFlakes 相对简单:只需下载并安装 PyFlakes,然后将以下内容添加到您的~/.emacs~/.emacs.d/init.el(视情况而定):

(when (load "flymake" t) 
  (defun flymake-pyflakes-init () 
    (let* ((temp-file (flymake-init-create-temp-buffer-copy 
                       'flymake-create-temp-inplace)) 
           (local-file (file-relative-name 
                        temp-file 
                        (file-name-directory buffer-file-name)))) 
      (list "pyflakes" (list local-file)))) 
  (add-to-list 'flymake-allowed-file-name-masks 
               '("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'python-mode-hook 'flymake-mode)

就是这样。您现在应该注意到,每当您编辑 Python 时,错误都会以红色突出显示。将鼠标悬停在上面即可查看所提供行的问题的完整说明。

至于像 TextMate 这样的主题:主题可能有点烦人的 Emacs;除非你真的想要 TextMate 中的主题,否则我会选择 Emacs 的 Color Theme并找到一款适合您的喜好。您几乎肯定可以找到一款与您当前的 TextMate 非常接近的一款,并且无需手动配置面孔。

I second @docgnome's suggestion of Django mode and yasnippet, but the real kicker that will make you never want to go back to TextMate is to integrate PyFlakes into your development environment, at which point Emacs will provide you on-the-fly notification of errors in your Python code. These go far beyond the typo-level error detection you get for free merely by having syntax highlighting; you'll be notified of errors such as variable before assignment, unused imports, and bad indentation, among other things.

Installing PyFlakes in Emacs is relatively straightforward: just download and install PyFlakes, and then add the following to your ~/.emacs or ~/.emacs.d/init.el, as appropriate:

(when (load "flymake" t) 
  (defun flymake-pyflakes-init () 
    (let* ((temp-file (flymake-init-create-temp-buffer-copy 
                       'flymake-create-temp-inplace)) 
           (local-file (file-relative-name 
                        temp-file 
                        (file-name-directory buffer-file-name)))) 
      (list "pyflakes" (list local-file)))) 
  (add-to-list 'flymake-allowed-file-name-masks 
               '("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'python-mode-hook 'flymake-mode)

That's it. You should now notice that, whenever you're editing Python, errors are highlighted in red. Mouse over to see a full explanation of what's wrong with the provided line.

As far as theming like TextMate: theming can be a bit annoying Emacs; unless you truly want the exact theme you have in TextMate, I'd grab Color Theme for Emacs and find one that suits your fancy. You can almost certainly find one very close to your current TextMate one, and won't have to deal with manually configuring faces.

信愁 2024-08-09 07:23:16

您可以查看 emacs 的 Django 模式。您正在寻找什么具体功能?对于代码片段,我推荐 yasnippet,它的灵感来自于 TextMate 代码片段系统。

You might check out Django mode for emacs. What specific functionality were you looking for? For snippets, I recommend yasnippet which is inspired by the TextMate snippet system.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文