emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Easily re-indent the #+OPTIONS lines


From: Phil Jackson
Subject: Re: [Orgmode] Easily re-indent the #+OPTIONS lines
Date: Thu, 17 Jan 2008 09:09:07 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

Hey Bastien,

Bastien <address@hidden> writes:

> 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)))))

Thanks, really handy. BTW did you know about align-regexp?

 ,----
 | (align-regexp (point-min) (point-max) "^#\\+[A-Z_]+:\\( +\\)" 1 5)
 `----

Dare I say will have a similar affect.

Cheers,
Phil
-- 
 Phil Jackson
 http://www.shellarchive.co.uk




reply via email to

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