emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Make M-up and M-down transpose paragraphs in org buffers
@ 2011-06-21 23:08 Paul Sexton
  2011-06-28 17:14 ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Sexton @ 2011-06-21 23:08 UTC (permalink / raw)
  To: emacs-orgmode

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)
  (when (and (not (or (org-at-table-p) (org-on-heading-p) (org-at-item-p)))
             (thing-at-point 'sentence))
    (transpose-paragraphs arg)
    (re-search-forward "[[:graph:]]")
    (goto-char (match-beginning 0))

(add-to-list 'org-metaup-hook 
  (lambda () (interactive) (org-transpose-paragraphs -1)))
(add-to-list 'org-metadown-hook 
  (lambda () (interactive) (org-transpose-paragraphs 1)))

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

end of thread, other threads:[~2011-06-28 18:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-21 23:08 Make M-up and M-down transpose paragraphs in org buffers Paul Sexton
2011-06-28 17:14 ` Bastien
2011-06-28 18:44   ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox


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