From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Rogoff Subject: Re: Minor org mode for achieve code folding effects Date: Tue, 10 Jan 2012 17:21:40 -0800 Message-ID: <4F0CE424.7020409@therogoffs.com> References: CADzxs1nkW_KO_n7RsTtO_W2nAvyUvoKGy+FgztaRFiFyuh44ug@mail.gmail.com <4F0CD92F.9030004@therogoffs.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------040300050103060402070305" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:42069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rkmss-00073Y-5q for emacs-orgmode@gnu.org; Tue, 10 Jan 2012 20:21:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rkmsq-0001JL-MF for emacs-orgmode@gnu.org; Tue, 10 Jan 2012 20:21:46 -0500 Received: from oproxy5-pub.bluehost.com ([67.222.38.55]:60800) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rkmsq-0001J3-BY for emacs-orgmode@gnu.org; Tue, 10 Jan 2012 20:21:44 -0500 Received: from ip68-228-84-160.oc.oc.cox.net ([68.228.84.160] helo=therogoffs.local) by box775.bluehost.com with esmtpa (Exim 4.76) (envelope-from ) id 1Rkmso-0001A7-9X for emacs-orgmode@gnu.org; Tue, 10 Jan 2012 18:21:42 -0700 In-Reply-To: <4F0CD92F.9030004@therogoffs.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------040300050103060402070305 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > David Rogoff > January 10, 2012 4:34 PM > Carlos Russo 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 " [*]+ "))) --------------040300050103060402070305 Content-Type: multipart/related; boundary="------------070104040000090305030507" --------------070104040000090305030507 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit

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 " [*]+ ")))
--------------070104040000090305030507 Content-Type: image/jpeg; x-apple-mail-type=stationery; name="postbox-contact.jpg" Content-Transfer-Encoding: base64 Content-ID: Content-Disposition: inline; filename="postbox-contact.jpg" /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgK CgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkL EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAAR CAAZABkDAREAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl 5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYk NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk 5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDzL41eMPGGsaH4WstFvbRta8YXxOoX1zZQ zSyx/YkllYu6E4BJOBxjCjAAFeK3GDlOa2PSoRdSSgilpvhX4E6hFZ+EJPB2mXGo+Witf21p bCQs3Adh5O3JNehQwlWcfb1ZKMf0PRcMO/3ahf0OcuvDdt8IfjP4Vvvh7eQPbxavBYagtzY2 qPtkmWJmSSKBCoBYDIbcDgjGK2xWFj9VVWLv10PPrUlSqWjf5nsv/DTv7Xf/AEUTwr/3w3+N eP7Zd5fh/kc2nkc/ZeH4teHgPW5JZwdIkOYp15ZZrFI2BPfHBB9KmunaUVbW35no5ZDnrXfR M9f0/wAGaTZxNq81pCDaxFYABgFugf8ADNdnLL6q6aPYUbVE2eHfGG3g0TTNR1R0R5dN1j7W h9WjkSUDPoSq16lbDThho0pabnn46UKjnNHx/wD8NA/ED/n7t/8Avz/9euD6lA8HnR9reB72 7Tw5psUtjcLJYYW5jMRVoWjVFdWXAwQVYEdcgjrXlVOepPZ7nrYCfsqifkd9d/EKLVbF9Lgh t5o5kMTo0uMg8EYxXvULqCV7P+up6cqsakrHhfxllKeGdb0Eh7fz3NwigGVkU7dxwBnHyn6V 7GYOboLq1Y8fESUOaKejPlD/AIU14/8A+ie+Nf8AwQT/APxNeRzM8qx9r/tM/wDJwfjf/r9/ 9pR1cvhNaPxng+rf8f1z/v8A9KeF6HTW+Jlj4d/8lN8L/wDYYsf/AEoSvWq9Dglsz9p68sD/ 2Q== --------------070104040000090305030507-- --------------040300050103060402070305--