Better way to maintain custom indentation
还没有人认领这个 Issue。
评估
调研方向
首先查看 issue 中的缩进示例、所引用的 .dir-locals.el 配置,以及 issue 398 和 309 中链接的讨论。目前工作尚未限定到某个具体的入口点或测试;首先需要就自定义缩进达成一致的机制,并明确验收标准。
由索引模型根据 Issue 内容生成。
描述
Problem
Sometimes, it is desirable to indent specific forms in a non-standard(?) way. Below is a couple of use-case exhibit to better illustrate the issue.
;;;; om
;; default
(dom/div #js{:className "container"}
(dom/ul #js{:className "list"}
(dom/li #js{:className "item"} "Hello")))
;; better
(dom/div #js{:className "container"}
(dom/ul #js{:className "list"}
(dom/li #js{:className "item"} "Hello")))
;; this is ok too?
(dom/div #js{:className "container"}
(dom/ul #js{:className "list"}
(dom/li #js{:className "item"} "Hello")))
;;;; re-frame
;; default
(reg-cofx :now
(fn [cofx _]
(assoc cofx :now (js/Date.))))
;; better
(reg-cofx :now
(fn [cofx _]
(assoc cofx :now (js/Date.))))
;;;; Fulcro
;; default
(defmutation something
"docstring"
[args]
(action [{:keys [state]}]
(do-something-to state))
(remote [env]
(some-logic env)))
;; better
(defmutation something
"docstring"
[args]
(action [{:keys [state]}]
(do-something-to state))
(remote [env]
(some-logic env)))
Current Solutions
Currently, the most practical solution is to maintain individual/per-project list of symbol-indentation lookup table. A relatively small example is shown below, but imagine that for om, one would need to list every single dom element in the file.
https://github.com/metabase/metabase/blob/master/.dir-locals.el
Other Solutions
This issue has been reported a couple times in the past and some suggestions have been voiced and/or implemented, but I feel that we have not really solved this problem.
https://github.com/clojure-emacs/clojure-mode/issues/398
The idea here is to infer indentation based on arg list. The concern was that it is unreliable.
https://github.com/clojure-emacs/clojure-mode/issues/309
Metadata based indentation is technically a good solution. This requires buy-in from library maintainer and at least in one case was shot down as seen here https://github.com/omcljs/om/issues/728 . These are Cognitect staff, so I feel it will be very unlikely we will be getting any metadata support in core libraries. I speculate that quite a number of library authors and Cognitect staffs are using Cursive and simply don't have this problem.
Proposed Solutions
Maybe we can brainstorm for a better way to handle this?
- Maybe an option that allow user to override indentation and trigger auto-indent of current form with a keystroke?
- Shorten the symbol lookup table by allowing regex pattern matching?
- Infer indentation based on other uses in the project/file? User will only have to fix indentation once and emacs will try to conform to the file's current indentation rule. Not sure what to do if there is only one use in a project/file.
- I'm sure clojure-mode users will have other ideas?
Thank you for contributing!
- 主要语言
- Emacs Lisp
- 星标
- 1k
- 派生
- 249
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
clojure-emacs/clojure-mode 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
clojure-emacs/clojure-mode#699 ·
-
难度 4/5 3-5 天 新手友好度 35/100
clojure-emacs/clojure-mode#660 · 5 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 35/100
clojure-emacs/clojure-mode#647 · 1 条评论 ·
-
bug help wanted indentation
难度 3/5 1-2 天 新手友好度 42/100
clojure-emacs/clojure-mode#620 ·
-
难度 3/5 1-2 天 新手友好度 45/100
clojure-emacs/clojure-mode#613 · 1 个 reaction ·
查看 clojure-emacs/clojure-mode 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
py-econometrics/pyfixest#2114 ·
维护者通常 1 天内回复
-
Verify the Linux Python quick start from a fresh Ubuntu checkout可能已有人在做 @romanv9 今天认领。 未关闭documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 62/100
R0Y00/Xbox2Windows#652 · 1 条评论 ·
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 72/100
Haseeb-MernStack/commune#138 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 70/100
clojure-emacs/cider#4235 ·
维护者通常 1 天内回复