emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: henry atting <nspm_01@literaturlatenight.de>
To: emacs-orgmode@gnu.org
Subject: align tags
Date: Fri, 03 Oct 2008 10:22:48 +0200	[thread overview]
Message-ID: <87bpy2gk9z.fsf@literaturlatenight.de> (raw)

Is there a function which aligns tags in an org document?

As I could not find on, I tried it with a slightly changed function from
ledger.el:

--8<---------------cut here---------------start------------->8---

(defun org-align (&optional column)
  (interactive "p")
  (if (= column 1)
      (setq column 95))
  (while (search-forward ":" nil t)
    (backward-char)
    (let ((col (current-column))
	  (beg (point))
	  target-col len)
      (skip-chars-forward "-:a-zA-z")
      (setq len (- (point) beg))
      (setq target-col (- column len))
      (if (< col target-col)
	  (progn
	    (goto-char beg)
	    (insert (make-string (- target-col col) ? )))
	(move-to-column target-col)
	(if (looking-back "  ")
	    (delete-char (- col target-col))
	  (skip-chars-forward "^ \t")
	  (delete-horizontal-space)
	  (insert "  ")))
      (forward-line))))

--8<---------------cut here---------------end--------------->8---

It only works half because numbers are also skipped forward.

henry

             reply	other threads:[~2008-10-03  8:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-03  8:22 henry atting [this message]
2008-10-03 10:58 ` align tags John Rakestraw
2008-10-03 15:08   ` henry atting
2008-10-03 16:00     ` Nick Dokos
2008-10-03 17:00       ` henry atting
2008-10-04  4:20         ` henry atting

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bpy2gk9z.fsf@literaturlatenight.de \
    --to=nspm_01@literaturlatenight.de \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).