Skip to content

Conversation

@christophe-gouel
Copy link

Add support for various outline styles.

Replace ess-r-outline-regexp with a new user option
ess-r-outline-style (RStudio or stars). Add
ess-r-outline-style-alist, regex and level helpers, a dispatcher for
outline-level, and ess-r-set-outline-style to apply the chosen style
buffer-locally (hack-local-variables aware). Update ess-r-mode
initialization, docs, and ChangeLog.
@bastistician
Copy link
Contributor

Shouldn't the "stars" style rather be called "Org-like"? It is Org syntax with an R comment prefix ### .

@christophe-gouel
Copy link
Author

I have no opinion on this. If you prefer that, I will do the change tomorrow.

@bastistician
Copy link
Contributor

For RStudio-style sections # Setup ----, it could be recommended to (setq ess-indent-with-fancy-comments nil), unless (setq ess-style 'RStudio) is used anyway. Otherwise single-hash comments are treated as right-margin comments with comment-column 40.

@bastistician
Copy link
Contributor

It might be worth asking @kurthornik if he has a preferred name for this outline style:

### * File utilities.

### ** file_ext

"stars" or "Org-like"?

@christophe-gouel
Copy link
Author

christophe-gouel commented Dec 23, 2025

For RStudio-style sections # Setup ----, it could be recommended to (setq ess-indent-with-fancy-comments nil), unless (setq ess-style 'RStudio) is used anyway. Otherwise single-hash comments are treated as right-margin comments with comment-column 40.

Good point, I will update the info file and the docstrings to add this precision.

Explain handling of single-hash comments and recommend setting
ess-indent-with-fancy-comments to nil or ess-style to 'RStudio.
Update manual and ess-r-outline-style docstring to describe behavior
and examples.
@christophe-gouel
Copy link
Author

I have adjusted the info and docstrings to warn about the interaction with the indentation style.

Regarding the naming of the stars/Org-like style, I will wait for the end of the Christmas break. In the absence of other comments, I will move it to "Org-like".

@christophe-gouel
Copy link
Author

I have changed the name of the style from stars to Org-like.

Let me know if you want other changes.

@mmaechler
Copy link
Member

Thank you, Christophe (@christophe-gouel). I have not yet tried your proposal, but browsed a bit the changes. It's good you've added more documentation. As mentioned, I'm not often actively using outline style in R scripts, but I think the current proposal relatively strongly not back compatible, as it uses

  1. RStudio style by default
  2. for that style, it (correctly and honestly) documents here) that when using the RStudio outline style, it is recommended to use (setq ess-indent-with-fancy-comments nil) or (setq ess-style 'RStudio).
    Otherwise, single-hash comments are treated as right-margin comments with `comment-column' 40.

Neither of the two is desirable for me (nor @kurthornik I think).
Could you provide an option to only set these "locally" when inside RStudio style outline mode? ... or do we have something better (somehow / somewhere)?

@christophe-gouel
Copy link
Author

Wouldn't the best option be to add a third outline style, which would be no outline?

This would be the default option, which is what we had up to now. Then there is no backward compatibility issue.

Remains the compatibility issue between the RStudio outlining and the indent styling. For this one, either we let users manage the issue, or I can add to the function ess-r-set-outline-style a call to (setq-local ess-indent-with-fancy-comments nil) in case the RStudio style is chosen.

@mmaechler
Copy link
Member

Wouldn't the best option be to add a third outline style, which would be no outline?

This would be the default option, which is what we had up to now. Then there is no backward compatibility issue.

Yes, I think this should be the way to go.

Remains the compatibility issue between the RStudio outlining and the indent styling. For this one, either we let users manage the issue, or I can add to the function ess-r-set-outline-style a call to (setq-local ess-indent-with-fancy-comments nil) in case the RStudio style is chosen.

I also agree with the idea. However, it should possibly happen "smartly":
Once something like the above (both proposals) is implemented, and user switches to RStudio style .. and after a while dislikes it (e.g. because they want the fancy comment indentation back) and thus "goes back" to the default style, the above ess-indent-with-fancy-comments should be reset, too.... or is that unnecessary because the (setq-local ..) setting would only apply "inside" RStudio outline style ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants