emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Minor org mode for achieve code folding effects


From: David Rogoff
Subject: Re: [O] Minor org mode for achieve code folding effects
Date: Tue, 10 Jan 2012 17:21:40 -0800
User-agent: Postbox 3.0.2 (Macintosh/20111203)



January 10, 2012 4:34 PM
Carlos Russo <mestre.adamastor <at> gmail.com> writes:
I have used both Carsten's and Eric's solution, as well as
hideshow-org (https://github.com/secelis/hideshow-org), which works
rather well and deserves a mention.

Expanding a bit on Carsten's post: Tassilo Horn wrote some convenience
functions to set the outline minor mode regexps to correspond to the
current comment syntax.  Thus, if I'm (for instance) in shell-script
mode, # * and # ** become the outline level 1 and 2 markers.

This is great info! I was just looking for this in the last couple of days and appreciate everyone's code since it's way beyond my elisp abilities.
I like this a lot more than the folding.el I had been using since I already use orgmode.  However, I've got a question:

I'm using this with verilog-mode which uses "// " to start comments.  The problem is that when I indent my file, the comments indent too and it seems that output-minor-mode (and, I assume, orgmode) only recognize headings that start in column 0.  How/where can I change this so it will recognize any line that is whitepace followed by the comment-start?

This works, but is probably not the best way to do it:

(defun th-outline-regexp ()
  "Calculate the outline regexp for the current mode."
  (let ((comment-starter (replace-regexp-in-string
                          "[[:space:]]+" "" comment-start)))
    (when (string= comment-starter ";")
      (setq comment-starter ";;"))
    (when (string= comment-starter "#")
      (setq comment-starter "##"))
    (when (eq major-mode 'verilog-mode)
      (setq comment-starter "\\s-*//"))     ;; for verilog-mode, define comment-starter as any amount of whitespace followed by "//". This allows indented comments as outline levels
    (concat comment-starter " [*]+ ")))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]