[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] Make M-up and M-down transpose paragraphs in org buffers
From: |
Paul Sexton |
Subject: |
[O] Make M-up and M-down transpose paragraphs in org buffers |
Date: |
Tue, 21 Jun 2011 23:08:46 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
By default, if used within ordinary paragraphs in org mode, M-up and M-down
transpose *lines* (not sentences). This was not useful to me. The following
code makes these keys transpose paragraphs, keeping the point at the start
of the moved paragraph. Behaviour in tables and headings is unaffected. It
would be easy to modify this to transpose sentences.
(defun org-transpose-paragraphs (arg)
(interactive)
(when (and (not (or (org-at-table-p) (org-on-heading-p) (org-at-item-p)))
(thing-at-point 'sentence))
(transpose-paragraphs arg)
(backward-paragraph)
(re-search-forward "[[:graph:]]")
(goto-char (match-beginning 0))
t))
(add-to-list 'org-metaup-hook
(lambda () (interactive) (org-transpose-paragraphs -1)))
(add-to-list 'org-metadown-hook
(lambda () (interactive) (org-transpose-paragraphs 1)))
- [O] Make M-up and M-down transpose paragraphs in org buffers,
Paul Sexton <=