emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] align tags


From: henry atting
Subject: [Orgmode] align tags
Date: Fri, 03 Oct 2008 10:22:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

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 via email to

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