TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Python Mode in Emacs

27 点作者 tomwans超过 14 年前

1 comment

cgrubb超过 14 年前
If you highlight the following code with python.el:<p><pre><code> a = 1 b = 2 </code></pre> a and b will be highlighted in orange. However, in this code they will not:<p><pre><code> a, b = 1, 2 </code></pre> I tried to modify python.el so that variables defined by parallel assignment would get highlighted. I made the following imperfect change to python.el:<p><pre><code> &#60; ;; If parallel assignment is used, up to four variable names are highlighted. &#60; (,(rx line-start &#60; (zero-or-one (group (1+ (or word ?_))) (0+ space) "," (0+ space)) &#60; (zero-or-one (group (1+ (or word ?_))) (0+ space) "," (0+ space)) &#60; (zero-or-one (group (1+ (or word ?_))) (0+ space) "," (0+ space)) &#60; (group (1+ (or word ?_))) (0+ space) "=") &#60; (1 font-lock-variable-name-face) (2 font-lock-variable-name-face) &#60; (3 font-lock-variable-name-face) (4 font-lock-variable-name-face)) --- &#62; (,(rx line-start (group (1+ (or word ?_))) (0+ space) "=") &#62; (1 font-lock-variable-name-face)) </code></pre> The change is imperfect because it only highlights up to 4 variables created by parallel assignment. It does not work for this code:<p><pre><code> a, b, c, d, e = 1, 2, 3, 4, 5 </code></pre> If anybody is good enough with Emacs Lisp to handle the general case I would be interested to see it.
评论 #1961462 未加载