From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Easily re-indent the #+OPTIONS lines Date: Wed, 16 Jan 2008 22:34:50 +0000 Message-ID: <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 1JFGqX-0005kJ-2v for emacs-orgmode@gnu.org; Wed, 16 Jan 2008 17:34:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JFGqU-0005jZ-WB for emacs-orgmode@gnu.org; Wed, 16 Jan 2008 17:34:56 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JFGqU-0005jT-O1 for emacs-orgmode@gnu.org; Wed, 16 Jan 2008 17:34:54 -0500 Received: from hu-out-0506.google.com ([72.14.214.227]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JFGqU-000552-Dn for emacs-orgmode@gnu.org; Wed, 16 Jan 2008 17:34:54 -0500 Received: by hu-out-0506.google.com with SMTP id 23so1205058huc.1 for ; Wed, 16 Jan 2008 14:34:54 -0800 (PST) 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: emacs-orgmode@gnu.org 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