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



_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to