clojure-emacs / clojure-emacs/clojure-mode
Adaptive fill mode broken in docstring
- Langage dominant
- Emacs Lisp
- Étoiles
- 1k
- Forks
- 249
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
When filling in a docstring, there is no proper adaptive filling and it always seems to fill to the beginning column of the docstring. This problem has annoyed me for more than 5 years, so I stepped a bit through the debugger, but I don't understand Emacs Lisp well enough to provide a proper fix.
```
An arg - asdfasdfasd sadf as dfas df asdf asdf as df as df asd
fas df asdf asdf asdf as df asd fa sd fa sdf as df asdf as dfa sdf
```
Put the cursor somewhere into the indented section and press M-q. In Clojure mode, it will ruin the indentation. Proper adaptive filling will cut `as dfa sdf` and put in on the next line at col 9.
My best solution so far is to set `adaptive-fill-function` to `ignore` and `fill-paragraph-function` to `nil`. So far, I haven't observed any adverse side effects but sure it breaks something.
In general, there seems to be a bunch of logic implemented around docstrings in Clojure mode, but it is not very well documented and probably not working properly. Probably one could draw inspiration for how docstring indentation is solved in other LISP major modes.
I noticed that in Emacs Lisp for instance, docstrings have no special indentation behavior, and in Clojure there are two spaces prepended to each line. Its a weird convention but it seems to be somehow rooted in Clojure core? Is that what all the logic is about? Maybe getting rid of that is too much to ask for, but it would be nice if you can make adaptive filling work.
```
;;; Workaround, use at your own risk
(add-hook 'clojure-mode-hook
(lambda ()
(interactive)
(setq-local fill-paragraph-function nil)
(setq-local adaptive-fill-function 'ignore)))
```
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Reproduisez le problème dans Clojure mode en plaçant le curseur dans la section de docstring indentée et en appuyant sur M-q. Examinez la logique de remplissage liée à docstring qui implique adaptive-fill-function et fill-paragraph-function, puis comparez-la à celle d’autres modes majeurs Lisp. Le travail est considéré comme terminé lorsque le remplissage adaptatif place le texte renvoyé à la ligne avec la bonne indentation sans nécessiter le workaround signalé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- clojure, emacs-lisp
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100