From: Phil Jackson <phil@shellarchive.co.uk>
To: Bastien <bzg@altern.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: Easily re-indent the #+OPTIONS lines
Date: Thu, 17 Jan 2008 09:09:07 +0000 [thread overview]
Message-ID: <87prw0akek.fsf@shellarchive.co.uk> (raw)
In-Reply-To: <87ejchqu0l.fsf@bzg.ath.cx> (Bastien's message of "Wed\, 16 Jan 2008 22\:34\:50 +0000")
Hey Bastien,
Bastien <bzg@altern.org> 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
next prev parent reply other threads:[~2008-01-17 9:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-16 22:34 Easily re-indent the #+OPTIONS lines Bastien
2008-01-17 9:09 ` Phil Jackson [this message]
2008-01-17 17:51 ` Adam Spiers
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87prw0akek.fsf@shellarchive.co.uk \
--to=phil@shellarchive.co.uk \
--cc=bzg@altern.org \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.