emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Paul Sexton <psexton@xnet.co.nz>
To: emacs-orgmode@gnu.org
Subject: Make M-up and M-down transpose paragraphs in org buffers
Date: Tue, 21 Jun 2011 23:08:46 +0000 (UTC)	[thread overview]
Message-ID: <loom.20110622T010528-283@post.gmane.org> (raw)

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

             reply	other threads:[~2011-06-21 23:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21 23:08 Paul Sexton [this message]
2011-06-28 17:14 ` Bastien
2011-06-28 18:44   ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20110622T010528-283@post.gmane.org \
    --to=psexton@xnet.co.nz \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).