[Top][All Lists]

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

[Orgmode] Using orgstruct-mode to structure source code

From: Tassilo Horn
Subject: [Orgmode] Using orgstruct-mode to structure source code
Date: Wed, 03 Sep 2008 10:32:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)


this is a resend of my message from <2008-08-20 Wed>.  So far nobody
answered and since Carsten is back now, I thought I may try again.

I'd like to switch from outline-minor-mode to orgstruct-mode for various
source code files, because the outline keybindings are not really quick
nor easy to remember.

For example in shell scripts (sh-mode) a headline looks like

#* Foobar

and in an elisp file it would be

;;* Foobar

Now I've found out that `org-context-p' returns nil for these lines, and
thus no org-mode command will be executed.  So I've redefined it to this

--8<---------------cut here---------------start------------->8---
(defun org-context-p (&rest contexts)
  "Check if local context is and of CONTEXTS.
Possible values in the list of contexts are `table', `headline', and `item'."
  (let ((pos (point))
        (comment-starter (replace-regexp-in-string "[ ]+$" "" (or comment-start 
    (goto-char (point-at-bol))
    (prog1 (or (and (memq 'table contexts)
                    (looking-at (concat comment-starter "?[ \t]*|")))
               (and (memq 'headline contexts)
                    (looking-at (concat comment-starter "?\\*+")))
               (and (memq 'item contexts)
                    (looking-at (concat comment-starter "?[ \t]*\\([-+*] 
\\|[0-9]+[.)] \\)"))))
      (goto-char pos))))
--8<---------------cut here---------------end--------------->8---

Now it does return t for headlines like above, but still no org-mode
command is issued.

What do I have to do to get that working correctly?


reply via email to

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