corgi-emacs / corgi

Unbundled Emacs configuration aimed at Clojure developers
181 stars 18 forks source link

Word wrap and adaptive wrapping #4

Closed oxalorg closed 2 years ago

oxalorg commented 3 years ago

I've added this to my user config file to get word-wrap working more beautifully

(use-package adaptive-wrap
  :config
  (when (fboundp 'adaptive-wrap-prefix-mode)
    (defun my-activate-adaptive-wrap-prefix-mode ()
      "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
      (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
    (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode))
  (global-visual-line-mode t))

Without adaptive word wrap: image

With adaptive word wrap: image

Do you think this should be enabled by default? Or maybe again we can create this as a package

plexus commented 3 years ago

Interesting, I tend to not have long lines like that. I hit M-q habitually as soon as lines start getting longer. Works well on comments, strings, and text content like markdown/org-mode.

Judging by your screenshots this is showing whitespace that isn't actually there (the indentation), which seems more magic than I'd like for corgi. I personally have no issue with your first screenshot. It shows me what's in the code, which is a couple of excessively long strings.

plexus commented 3 years ago

Before:

2020-11-25-084424_1926x282_scrot

After hitting M-q

2020-11-25-084447_1527x159_scrot

oxalorg commented 3 years ago

I agree breaking down lines at 80/120 char is the optimal solution, but unfortunately that's not always the case for every code you encounter (this usually is a problem html files).

Also, what happens when M-q line width set is larger than your window split size? We run into the same word wrapping issue. This is why I like the magic indentation to keep things aligned regardless of my window size / line width. This is also the default behavior in VSCode and a lot of other modern editors.

We can keep this open for now, if anyone else needs it :)

plexus commented 3 years ago

The snippet you posted I think is small enough to qualify as "just loading a package + some glue", so it doesn't necessarily need to be its own package. I'm suprised this is what "modern editors" do, it doesn't seem right to me :) but I'm going to drop your snippet into my user config to test drive it for a bit.

plexus commented 3 years ago

Oh boy I can already tell this is going to be hard to get used to... I really don't think I want my editor to wrap lines

2020-11-26-092321_1787x261_scrot

It's impossible to tell now that [parts/title] is nested inside [title-area].

plexus commented 2 years ago

I think the conclusion here is that this is a snippet that people can easily add to their config if they so please. Something we could/should think about if if there's a good place where such snippets could live. I think it would be neat to have a "next steps" somewhere, where after you have the base config going you can browse some of the additional stuff that people install and configure. Will open a separate issue for that.