From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phil Jackson Subject: Re: Easily re-indent the #+OPTIONS lines Date: Thu, 17 Jan 2008 09:09:07 +0000 Message-ID: <87prw0akek.fsf@shellarchive.co.uk> References: <87ejchqu0l.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JFQkN-0003KW-Dq for emacs-orgmode@gnu.org; Thu, 17 Jan 2008 04:09:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JFQkL-0003Jy-FL for emacs-orgmode@gnu.org; Thu, 17 Jan 2008 04:09:13 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JFQkK-0003Jn-Sd for emacs-orgmode@gnu.org; Thu, 17 Jan 2008 04:09:12 -0500 Received: from b.painless.aaisp.net.uk ([81.187.81.52]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JFQkL-0000oF-1L for emacs-orgmode@gnu.org; Thu, 17 Jan 2008 04:09:13 -0500 In-Reply-To: <87ejchqu0l.fsf@bzg.ath.cx> (Bastien's message of "Wed\, 16 Jan 2008 22\:34\:50 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: emacs-orgmode@gnu.org Hey Bastien, Bastien 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