Fork me on GitHub
#emacs
<
2022-08-26
>
Drew Verlee02:08:48

What about instead of "toggle-word-wrap" we had "toggle-s-expression-wrap" where it moved expressions that bumped up agains the window all to the next line and applied the formatting rules.

clojure-spin 1
💡 3
ag19:08:11

You probably wouldn't want a "destructive operation" like that. Just like vertically aligning things (M-x clojure-align) is not universally liked, wrapping expressions too narrow, I think would not be welcomed in every team. What would be nice though is to have a mode where you can make things visually more appealing (maybe using overlays); if you like vertical alignment - it will show things aligned; if window is too narrow - it will display things as you described. But all that without actually affecting the code itself.

ag19:08:58

What I love about Lisp dialects in general, is that no matter how narrow the window gets, the code wraps around but retains its readability. You can comfortably read Lisp code on your phone. That doesn't work with most other PLs. Indent-based languages are the worst for that. That's why whenever I see comments like: "Lisp is not very readable", I roll my eyes as if someone said: "Sun revolves around the Earth"

😅 2
❤️ 2
ag19:08:54

Since the "visually-pretty-clojure" mode doesn't exists, and my team doesn't like when I vertically align things with clojure-align, I often still use it (because the table form is much more readable), but I quickly undo things and try not to commit the code with alignments. Here's a little helper I use all the time:

(defun clojure-unalign (beg end)
  "Un-align (remove extra spaces) in vertically aligned sexp around the point."
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end))
                 (save-excursion
                   (let ((end (progn (end-of-defun)
                                     (point))))
                     (clojure-backward-logical-sexp)
                     (list (point) end)))))

  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (while (re-search-forward "\\s-+" nil t)
        (replace-match " "))
      (let ((clojure-align-forms-automatically nil))
        (indent-region beg end)))))

👀 1
Drew Verlee05:08:21

What i was suggesting was just changing the view and not the text itself as written to the disc.

Drew Verlee05:08:38

The real culprit is the lack of structural diffs. I need to check difftastic again. If that works then i see no reason why everyone couldn't use whatever formatting rules they want. It's a bit silly that we have to fight over viewing preference just because of git. Though of course, there are some rather hard to encode elements of code structure...