Better way to maintain custom indentation
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia esaminando gli esempi di indentazione nell’issue, la configurazione .dir-locals.el referenziata e le discussioni collegate nelle issue 398 e 309. Il lavoro non è ancora circoscritto a uno specifico punto di ingresso o test; sarebbe prima necessario concordare un meccanismo e criteri di accettazione chiari per l’indentazione personalizzata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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!
- Lingua principale
- Emacs Lisp
- Stelle
- 1k
- Fork
- 249
- Merge medio
- 1g 6h
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di clojure-emacs/clojure-mode
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
clojure-emacs/clojure-mode#699 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
clojure-emacs/clojure-mode#660 · 5 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
clojure-emacs/clojure-mode#647 · 1 commento ·
-
bug help wanted indentation
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
clojure-emacs/clojure-mode#620 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
clojure-emacs/clojure-mode#613 · 1 reazione ·
Tutte le issue di clojure-emacs/clojure-mode
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
py-econometrics/pyfixest#2114 ·
I maintainer di solito rispondono entro 1 giorno
-
Verify the Linux Python quick start from a fresh Ubuntu checkoutForse già presa @romanv9 l’ha presa oggi. Apertadocumentation good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
R0Y00/Xbox2Windows#652 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Haseeb-MernStack/commune#138 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
clojure-emacs/cider#4235 ·
I maintainer di solito rispondono entro 1 giorno