emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
623 stars 162 forks source link

(fill-paragraph) missing it wonderful behavior #1284

Open walmes opened 8 months ago

walmes commented 8 months ago

Hi everyone,

I like very much the behavior of (fill-paragraph) because it helps me keep one argument per line saving me lots of time breaking lines. I just must call (fill-paragraph) with the point before a comma to the magic happens. It cycles among these 3 states.

# State 1. Long line with code after fill-column.
c("one" = 1, "two" = 2, "three" = 3, "four" = 4, "five" = 5, "six" = 6, "seven" = 7, "eight" = 8, "nine" = 9, "ten" = 10)

# State 2. Break lines to keep the code inside fill-column.
c("one" = 1, "two" = 2, "three" = 3, "four" = 4, "five" = 5, "six" = 6,
  "seven" = 7, "eight" = 8, "nine" = 9, "ten" = 10)

# State 3. Break lines to have one line with comma at the end.
c(
    "one" = 1,
    "two" = 2,
    "three" = 3,
    "four" = 4,
    "five" = 5,
    "six" = 6,
    "seven" = 7,
    "eight" = 8,
    "nine" = 9,
    "ten" = 10
)

But this behavior is missing now. It still cycles among states. But the 2 state is returned without no proper indentation. The 3 state has only a break line after the first comma. I suspect that is something related to some regular expression applied.

# Wrong result of 3 state.
c("one" = 1,
 "two" = 2, "three" = 3, "four" = 4, "five" = 5, "six" = 6, "seven" = 7, "eight" = 8, "nine" = 9, "ten" = 10)

I'am using Doom-Emacs with ESS (https://github.com/walmes/doom-emacs/blob/master/config.el#L601). My version is

Archive: melpa
Version: 20240229.2054
Commit: cf237253049583a547bafc16edb9eb9a52e1ebf6

I inspect the code and I saw that (ess-r--fill-paragraph) is an advice to (fill-paragraph). #288 reports and infinite loop, but was before the advice. I think that this behavior was affected by 126d3441 because new line indentation and (fill-paragraph) broke together.

I appreciate any direction or providence. My LISP programming is still in a basic level but any direction would be of great value.