[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Easily re-indent the #+OPTIONS lines
From: |
Bastien |
Subject: |
[Orgmode] Easily re-indent the #+OPTIONS lines |
Date: |
Wed, 16 Jan 2008 22:34:50 +0000 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.0 (gnu/linux) |
Hi folks,
I often fiddle around #+AUTHOR, #+TITLE, and other such lines. But
having to re-align them so that it looks better is time-consuming.
This function does it automatically:
(defun bzg-org-indent-options ()
"Indent option lines correctly."
(interactive)
(save-excursion
(goto-char (point-min))
(let ((max-length 0))
(while (re-search-forward "^#\\+\\([A-Z_]+\\)" nil t)
(if (> (length (match-string 1)) max-length)
(setq max-length (length (match-string 1)))))
(goto-char (point-min))
(while (re-search-forward "^#\\+\\([A-Z_]+\\):[ \t]*\\(.+\\)$" nil t)
(replace-match
(concat "#+" (match-string 1) ":"
(make-string (1+ (- max-length (length (match-string 1)))) 32)
(match-string 2)) t t)))))
For example, it converts this:
#+TITLE: Test file
#+STARTUP: hidestars
#+AUTHOR: Bastien Guerry
#+EMAIL: bzg AT altern DOT org
#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:t -:t f:t
#+SEQ_TODO: TODO NEXT FEEDBACK VERIFY DONE
#+COLUMNS: %66ITEM %8TODO %10SCHEDULED %3PRIORITY %1TAGS
into this:
#+TITLE: Test file
#+STARTUP: hidestars
#+AUTHOR: Bastien Guerry
#+EMAIL: bzg AT altern DOT org
#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:t -:t f:t
#+SEQ_TODO: TODO NEXT FEEDBACK VERIFY DONE
#+COLUMNS: %66ITEM %8TODO %10SCHEDULED %3PRIORITY %1TAGS
--
Bastien
- [Orgmode] Easily re-indent the #+OPTIONS lines,
Bastien <=