Better way to maintain custom indentation
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Beginne damit, die Einrückungsbeispiele im Issue, die referenzierte .dir-locals.el-Konfiguration und die verlinkten Diskussionen in den Issues 398 und 309 zu prüfen. Die Arbeit ist noch nicht auf einen bestimmten Einstiegspunkt oder Test eingegrenzt; zunächst müssten ein abgestimmter Mechanismus und klare Akzeptanzkriterien für benutzerdefinierte Einrückung festgelegt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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!
- Vorherrschende Sprache
- Emacs Lisp
- Sterne
- 1k
- Forks
- 249
- Ø Merge
- 1 T. 6 Std.
- Gemergte PRs (30 T.)
- 6
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus clojure-emacs/clojure-mode
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
clojure-emacs/clojure-mode#699 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
clojure-emacs/clojure-mode#660 · 5 Kommentare ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
clojure-emacs/clojure-mode#647 · 1 Kommentar ·
-
bug help wanted indentation
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 42/100
clojure-emacs/clojure-mode#620 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
clojure-emacs/clojure-mode#613 · 1 Reaktion ·
Alle Issues in clojure-emacs/clojure-mode
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
py-econometrics/pyfixest#2114 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Verify the Linux Python quick start from a fresh Ubuntu checkoutEvtl. vergeben @romanv9 hat das heute übernommen. Offendocumentation good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
R0Y00/Xbox2Windows#652 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Haseeb-MernStack/commune#138 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
clojure-emacs/cider#4235 ·
Maintainer antworten meist innerhalb von 1 Tag