emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* align tags
@ 2008-10-03  8:22 henry atting
  2008-10-03 10:58 ` John Rakestraw
  0 siblings, 1 reply; 6+ messages in thread
From: henry atting @ 2008-10-03  8:22 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-10-04  4:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-03  8:22 align tags henry atting
2008-10-03 10:58 ` 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

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).