[ESS] ESS code-folding?

Karlo Guidoni Martins kgu|don|m@rt|n@ @end|ng |rom gm@||@com
Thu Aug 17 13:28:54 CEST 2023


With that code snippet:
### acts as the first level of the folding, #### as second level and so on.

Check out if the outline-minor-mode is activated after evaluating that code
snippet as well. The TAB key open and close the folding by default, just
like org-mode.

In my case, this works like this:

Without code folding
### test1
test1 = c(1, 2)
#### test2
test2 = c(1, 2)

With code folding
### test1...
#### test2...





On Wed, 16 Aug 2023 at 16:06 Sparapani, Rodney <rsparapa using mcw.edu> wrote:

> Hi Karlo:
>
>
>
> This is very interesting.  But, I must not be doing it right.
>
> Do you have a simple example of how to use this to do case-folding?
>
> Thanks
>
>
>
> --
>
> Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His
>
> Vice President, Wisconsin Chapter of the American Statistical Association
>
> Institute for Health and Equity, Division of Biostatistics
>
> Medical College of Wisconsin, Milwaukee Campus
>
>
>
>
>
> *From: *Karlo Guidoni Martins <kguidonimartins using gmail.com>
> *Date: *Wednesday, August 16, 2023 at 1:02 PM
> *To: *Sparapani, Rodney <rsparapa using mcw.edu>
> *Cc: *ess-help (ess-help using r-project.org) <ess-help using r-project.org>
> *Subject: *Re: [ESS] ESS code-folding?
>
> ATTENTION: This email originated from a sender outside of MCW. Use caution
> when clicking on links or opening attachments.
> ------------------------------
>
> hi!
>
>
>
> this works fine for me:
>
>
>
> ;;; BEG
>
> ;;; outline-(minor)-mode
>
> (setq outline-minor-mode-highlight 'override) ; emacs28
>
> (setq outline-minor-mode-cycle t)
>
>
>
> ;;; outline for ess-mode
>
> (add-hook 'ess-mode-hook
>
>           #'(lambda ()
>
>               (outline-minor-mode)
>
>               (setq-local outline-regexp "\\(^#\\{3,7\\}
> \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function(.*{\\)")
>
>               (setq-local outline-regexp "\\(^#\\{3,7\\} \\)")
>
>               (defun outline-level ()
>
>                 ;; ## continues only as a comment.
>
>                 (cond ((looking-at "^### ") 1) ; first level
>
>                       ((looking-at "^#### ") 2) ; second level
>
>                       ((looking-at "^##### ") 3) ; and so on...
>
>                       ((looking-at "^###### ") 4)
>
>                       ((looking-at "^####### ") 5)
>
>                       ((looking-at "^######## ") 6)
>
>                       ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
>
>                       (t 1000)))
>
>               (outline-hide-body)))
>
>
>
> ;;; force outline height
>
> (custom-set-faces
>
>  '(outline-1 ((t (:height 1.100 :weight bold))))
>
>  '(outline-2 ((t (:height 1.075 :weight bold))))
>
>  '(outline-3 ((t (:height 1.050 :weight bold))))
>
>  '(outline-4 ((t (:height 1.025 :weight bold))))
>
>  '(outline-5 ((t (:height 1.000 :weight bold))))
>
>  '(outline-6 ((t (:height 1.000 :weight bold))))
>
>  '(outline-7 ((t (:height 1.000 :weight bold))))
>
>  '(outline-8 ((t (:height 1.000 :weight bold))))
>
>  )
>
> ;;; END
>
>
>
>
>
> On 16 Aug 2023 14:30:02, "Sparapani, Rodney via ESS-help" <
> ess-help using r-project.org> wrote:
>
> Hi Gang:
>
> One of my student’s asked this question.
>
> Any resources/knowledge on code folding? in RStudio ‘####’ creates a
> collapsible section. Came across hideshow-org<
> https://urldefense.com/v3/__https:/melpa.org/*/hideshow-org__;Iw!!H8mHWRdzp34!5RPr9v2ZhWFZvGqgU1l_SCB3m8RiGAGo3z3tOZJeYnGOEM1PJSipOO32pr70Qd7JRbtycMb_EwhMdNuJ$>
> but I don’t want to only be able to use it in org mode.
>
> Something like
>
> Without code folding
> #### test ####
> test = c(1, 2)
> ####
>
> With code folding
> #### test ####
> ####
>
> Any ideas?
> --
> Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His
> Vice President, Wisconsin Chapter of the American Statistical Association
> Institute for Health and Equity, Division of Biostatistics
> Medical College of Wisconsin, Milwaukee Campus
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> ESS-help using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
> <https://urldefense.com/v3/__https:/stat.ethz.ch/mailman/listinfo/ess-help__;!!H8mHWRdzp34!6_FDWsoQA1JsKpSpQpyv2luWZb9KS5ZN7pEfO-2lbaa_6weoDg9aRoBLZOdVUd_7T1T4OSTpumBRkdnIkSngEUEJbg$>
>
>

	[[alternative HTML version deleted]]



More information about the ESS-help mailing list