[ESS] R code folding with hideshow-org.el

Rainer M Krug r.m.krug at gmail.com
Fri Apr 3 15:13:36 CEST 2009


Hi
I have the problem, that TAB works (close to the {), SHIFT-TAB not.
Below the two sections of my .emacs file dealing with hideshow.el and
hiodeshow-org.el

I should say, I don't know nearly nothing about the syntax of the .emacs file.

Thanks

Rainer


;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Load hideshow and enable for ESS
(autoload 'hideshowvis-enable "hideshowvis" "Highlight foldable regions")
(dolist (hook (list 'emacs-lisp-mode-hook
                  'ess-mode-hook))
(add-hook hook 'hideshowvis-enable))
(setq hs-special-modes-alist
    (cons '(ess-mode "{" "}" "#" nil nil) hs-special-modes-alist))

(define-fringe-bitmap 'hs-marker [0 24 24 126 126 24 24 0])

(defcustom hs-fringe-face 'hs-fringe-face
  "*Specify face used to highlight the fringe on hidden regions."
  :type 'face
  :group 'hideshow)

(defface hs-fringe-face
  '((t (:foreground "#888" :box (:line-width 2 :color "grey75" :style
released-button))))
  "Face used to highlight the fringe on folded regions"
  :group 'hideshow)

(defcustom hs-face 'hs-face
  "*Specify the face to to use for the hidden region indicator"
  :type 'face
  :group 'hideshow)

(defface hs-face
  '((t (:background "#ff8" :box t)))
  "Face to hightlight the ... area of hidden regions"
  :group 'hideshow)

(defun display-code-line-counts (ov)
  (when (eq 'code (overlay-get ov 'hs))
    (let* ((marker-string "*fringe-dummy*")
           (marker-length (length marker-string))
           (display-string (format "(%d)..." (count-lines
(overlay-start ov) (overlay-end ov))))
           )
      (overlay-put ov 'help-echo "Hiddent text. C-c,= to show")
      (put-text-property 0 marker-length 'display (list 'left-fringe
'hs-marker 'hs-fringe-face) marker-string)
      (overlay-put ov 'before-string marker-string)
      (put-text-property 0 (length display-string) 'face 'hs-face
display-string)
      (overlay-put ov 'display display-string)
      )))

(setq hs-set-up-overlay 'display-code-line-counts)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Load hideshow-org (http://github.com/secelis/hideshow-org/tree/master)
(require 'hideshow)
(require 'hideshow-org)
(add-to-list 'hs-special-modes-alist
            '(ess-mode "{" "}" "/[*/]" nil
hs-c-like-adjust-block-beginning))
(global-set-key "\C-ch" 'hs-org/minor-mode) ;; toggles hideshow-org
;; (add-hook 'ess-mode-hook 'hs-org/minor-mode) ;; starts for ESS files
(add-hook 'ess-mode-hook '(lambda () (hs-org/minor-mode 1)))
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

On Thu, Apr 2, 2009 at 6:43 PM, Short, Tom <TShort at epri.com> wrote:
>
> > -----Original Message-----
> > From: Stephen Eglen [mailto:S.J.Eglen at damtp.cam.ac.uk]
> > Sent: Thursday, April 02, 2009 11:55 AM
> > To: Short, Tom
> > Cc: ess-help at stat.math.ethz.ch; shane at gnufoo.org
> > Subject: Re: [ESS] R code folding with hideshow-org.el
> >
> ...
> > If I hit TAB, it works only if my cursor is near {, rather than at the
> > start of the line.
>
> I get the same results upon collapse. Luckily unfold works okay
> anywhere on the line. It's a bit easier to initiate the fold on
> the 2nd line of the function.
>
> > Also, in the following, should the comment regexp be a hash, rather
> than
> > C's standard /*  ... */ notation?
> >
> > (add-to-list 'hs-special-modes-alist
> >              '(ess-mode "{" "}" "/[*/]" nil
> >                hs-c-like-adjust-block-beginning))
> >
>
> Probably, but I don't know regex or hideshow well enough to mess
> with it.
>
> - Tom
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



--
Rainer M. Krug, Centre of Excellence for Invasion Biology,
Stellenbosch University, South Africa




More information about the ESS-help mailing list