emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Levin Du <zsdjw@21cn.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Let tab do org-cycle only at special place.
Date: Wed, 23 May 2007 17:56:52 +0800	[thread overview]
Message-ID: <200705231756.53173.zsdjw@21cn.com> (raw)

I've my busy tab key set to a super expand/indent function:

   (global-set-key "\t" 'ext-super-tab)

Currently in org-mode, tab is only doing indent in none headline/special 
place. I'd like to use tab only at the beginning of headline or buffer. So I 
put something like this in my org-conf.el :

(defun org-tab (&optional arg)
  "Do org-cycle only at the beginning of a headline, otherwise do
the job defined in global keymap."
  (interactive "P")
  (let* ((outline-regexp
	  (if (and (org-mode-p) org-cycle-include-plain-lists)
	      "\\(?:\\*+\\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) \\)"
	    outline-regexp))
	 (bob-special (and org-cycle-global-at-bob (bobp)
			   (not (looking-at outline-regexp)))))
    (if (or bob-special
	    (eq arg t)
	    (integerp arg)
	    (org-at-table-p 'any)
	    (looking-at outline-regexp))
	(org-cycle arg)
      (call-interactively (global-key-binding "\t")))))

(define-key org-mode-map [(tab)] 'org-tab)

Hope this is useful for someone else.

Levin

             reply	other threads:[~2007-05-23  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-23  9:56 Levin Du [this message]
2007-05-23 14:20 ` Let tab do org-cycle only at special place Carsten Dominik
  -- strict thread matches above, loose matches on Subject: below --
2007-05-22  6:12 levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200705231756.53173.zsdjw@21cn.com \
    --to=zsdjw@21cn.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).