emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Using orgstruct-mode to structure source code


From: Carsten Dominik
Subject: Re: [Orgmode] Using orgstruct-mode to structure source code
Date: Fri, 5 Sep 2008 11:07:30 +0200


On Sep 5, 2008, at 10:02 AM, Tassilo Horn wrote:

Carsten Dominik <address@hidden> writes:

Hi Carsten,

I though a little bit about this, and using org-struct-mode in a
commented block of text is going to be bumpy.  No easy path.

Too bad.  I thought that it would be easy (at least for headlines) by
simply allowing `comment-start' before the headline.

What I do in such cases:

I put tow markers into the buffer hat delimit the text I want to edit
in orgstruct-mode.  And then I have custom function that toggles the
comment starters on an off, like so:

;; BEGIN ORGSTRUCT ";; "
;; * heading 1
;;   with text
;; * heading 2
;; ** subheading
;; END ORGSTRUCT

The problem with this is, that "with text" will be commented, too. But
in my case this would be source code, which should not be commented.

So now I think I'll stay with outline-minor-mode.  The thing which is
much better with orgstruct-mode is that TAB has a special meaning
depending on the context point is on. So I'll use that feature to make outline-minor-mode do what I want. IMO this facility could be of use in
may other places, too.  I think it would be nice to rip that out of
org-mode into something more generic, like

 (define-context-key some-keymap (kbd "TAB")
                     'foobar-context-p
                     'do-foo).

I played a bit with the code and tried to elicit how you get the command
that normally would have been invoked if the stealing function wasn't
there, but I failed.  Could you please enlighten me?

I am explaining this in detail near the end of the google tech talk, with a code example. Basically, it works by temporarily turning of the minor mode that defines the command and doing a key lookup.

- Carsten



All the best,
Tassilo





reply via email to

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