emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* problem with orgstruct/outline-minor-mode with indented headlines
@ 2012-01-24 21:47 David Rogoff
  2012-01-29  7:15 ` David Rogoff
  0 siblings, 1 reply; 2+ messages in thread
From: David Rogoff @ 2012-01-24 21:47 UTC (permalink / raw)
  To: emacs-orgmode

Hi all.

I'm still trying to get orgstruct to work right. One thing I found is that I was 
getting confused with outline-magic which set up outline-minor-mode-map but not 
orgstruct-mode-map.  I'm working inside verilog-mode, which uses the same "//" 
comment as c.  So I defined outline-regexp:

(setq outline-regexp "\\s-*// [*]+ ")  ;; any line that starts with "// " 
(possibly preceeded with whitespace) and some number of stars and a space

This works fine. I needed the whitespace in front since verilog-mode indents 
comments along with code.

The problem is when I run org-cycle on a headline.  The following headline ends 
up on the same line (also in outline-minor-mode).

For example, in plain org mode I have this:

* head 1
** head 2
*** head 3
    head 3 text    
    head 3 text
** head 2b
   head 2b text
   head 2b text

I now run org-cycle on headline "head 2" and it looks like this:

* head 1
** head 2...
** head 2b
   head 2b text
   head 2b text

p.s. - is there a way to copy/export exactly what the collapse buffer looks 
like?  I had to manually create this since copy/paste of the text includes the 
hidden parts.

If I change to verlog-mode with orgstruct minor mode and add "// " at the 
beginning of headlines, everything is still good:

// * head 1
// ** head 2
// *** head 3
    head 3 text    
    head 3 text
// ** head 2b
   head 2b text
   head 2b text

and

// * head 1
// ** head 2
// ** head 2b
   head 2b text
   head 2b text

Where it breaks is the case of indented comments:

// * module declaration
module a (
	  // * ports
	  // ** inputs
	  input  b, 
	  input  c,
	  // ** outputs
	  output d,
	  output e
	  );

   // module code
   assign d = b & c;
   assign e = d | e;
   
   // * end module declaration
endmodule // a

If I run org-cycle on headline "ports" I get this:

// * module declaration
module a (
	  // * ports  // * end module declaration
endmodule // a

Instead of this:

// * module declaration
module a (
	  // * ports  
	  // * end module declaration
endmodule // a

Likewise, collapsing "inputs" gives this:

// * module declaration
module a (
	  // * ports
	  // ** inputs // ** outputs
	  output d,
	  output e
	  );

   // module code
   assign d = b & c;
   assign e = d | e;
   
   // * end module declaration
endmodule // a


Not this:

// * module declaration
module a (
	  // * ports
	  // ** inputs ...
	  // ** outputs
	  output d,
	  output e
	  );

   // module code
   assign d = b & c;
   assign e = d | e;
   
   // * end module declaration
endmodule // a


What's going on?  There's some confusion about the headline level being based on 
the indent and the number of stars.

I'm so close, but need help figuring out this last problem.

Thanks,

 David

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: problem with orgstruct/outline-minor-mode with indented headlines
  2012-01-24 21:47 problem with orgstruct/outline-minor-mode with indented headlines David Rogoff
@ 2012-01-29  7:15 ` David Rogoff
  0 siblings, 0 replies; 2+ messages in thread
From: David Rogoff @ 2012-01-29  7:15 UTC (permalink / raw)
  To: emacs-orgmode

David Rogoff <david <at> therogoffs.com> writes:

>
> Hi all.
>
> I'm still trying to get orgstruct to work right. One thing I
> found is that I7 was getting confused with outline-magic which
> set up outline-minor-mode-map but not orgstruct-mode-map.  I'm
> working inside verilog-mode, which uses the same "//" comment
> as c.  So I defined outline-regexp:
>
> (setq outline-regexp "\\s-*// [*]+ ")  ;; any line that starts with "// "
> (possibly preceeded with whitespace) and some number of stars and a space
>
> This works fine. I needed the whitespace in front since
> verilog-mode indents comments along with code.
>
> The problem is when I run org-cycle on a headline.  The
> following headline ends up on the same line (also in
> outline-minor-mode).
>
>    TRIMMED
>
> What's going on?  There's some confusion about the headline
> level being based on the indent and the number of stars.
>
> I'm so close, but need help figuring out this last problem.
>

Anyone?  I've been trying to learn how outline-mode works to modify
the outline level, but I'm not quite there yet. I made my own versions
of the outline-level function to try
and see what's going on:

(defun dhr-outline-level ()
  "Return the depth to which a statement is nested in the outline.
Point must be at the beginning of a header line.
This is actually either the level specified in `outline-heading-alist'
or else the number of characters matched by `outline-regexp'."
  (interactive)
  (or (cdr (assoc (match-string 0) outline-heading-alist))
      (- (match-end 0) (match-beginning 0))))

(defvar dhr-outline-level 'dhr-outline-level
  "*Function of no args to compute a header's nesting level in an
     outline. It can assume point is at the beginning of a header line
     and that the match data reflects the `outline-regexp'.")

(defun dhr-disp-ol ()
  (interactive)
  (message "outline level = %d" (funcall dhr-outline-level))
  )

I'm close but still not quite there and could really use a little help!
Again, I had to add variable whitespace to the beginning of outline-regex
since verilog-mode indents comments.  I want to be able to adjust the
outline-level based on where "//" starts, not from the beginning of
the line.

Thanks in advance for any help on this!   This really makes editing my
code so much easier and if I can get this last bit to work right I can
convince a bunch of other ASIC engineers to use it and emacs!

 David

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-29  7:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 21:47 problem with orgstruct/outline-minor-mode with indented headlines David Rogoff
2012-01-29  7:15 ` David Rogoff

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).