From mboxrd@z Thu Jan 1 00:00:00 1970 From: sand@blarg.net Subject: Patch to genericize org-yank (6.21b) Date: Mon, 11 May 2009 19:18:39 -0700 Message-ID: <18952.56447.183195.891996@priss.frightenedpiglet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M3hzq-0005dd-Og for emacs-orgmode@gnu.org; Mon, 11 May 2009 22:45:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M3hzl-0005cg-7Q for emacs-orgmode@gnu.org; Mon, 11 May 2009 22:45:33 -0400 Received: from [199.232.76.173] (port=56960 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3hzl-0005cd-2m for emacs-orgmode@gnu.org; Mon, 11 May 2009 22:45:29 -0400 Received: from v-static-143-234.avvanta.com ([206.124.143.234]:48591 helo=priss.frightenedpiglet.com) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1M3hzi-0000br-TM for emacs-orgmode@gnu.org; Mon, 11 May 2009 22:45:28 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org The org-yank function has special support for outline structures. But if you want the same behavior for something other than yank, you're out of luck. This patch (against 6.21b) moves the main functionality into org-yank-generic, with yanking being just one particular entry point. (I use this to create a new entry point for a personal clipboard-inserting command.) Derek -- Derek Upham sand@blarg.net ------------------------------ cut here ------------------------------ --- org.el.orig 2009-05-11 19:07:08.000000000 -0700 +++ org.el 2009-05-11 19:09:00.000000000 -0700 @@ -14809,9 +14809,17 @@ \[1] Basically, the test checks if the first non-white line is a heading and if there are no other headings with fewer stars." (interactive "P") - (setq this-command 'yank) + (org-yank-generic 'yank arg)) + +(defun org-yank-generic (command arg) + "Perform some yank-like command. + +This function implements the behavior described in the `org-yank' +documentation. However, it has been generalized to work for any +interactive command with similar behavior." + (setq this-command command) (if arg - (call-interactively 'yank) + (call-interactively command) (let ((subtreep ; is kill a subtree, and the yank position appropriate? (and (org-kill-is-subtree-p) (or (bolp) @@ -14826,7 +14834,7 @@ end) (if (and subtreep org-yank-adjusted-subtrees) (org-paste-subtree nil nil 'for-yank) - (call-interactively 'yank)) + (call-interactively command)) (setq end (point)) (goto-char beg) (when (and (bolp) subtreep @@ -14842,7 +14850,7 @@ (error (goto-char end))))) (when swallowp (message - "Yanked text not folded because that would swallow text")) + "Inserted text not folded because that would swallow text")) (goto-char end) (skip-chars-forward " \t\n\r") (beginning-of-line 1) @@ -14852,7 +14860,7 @@ (org-paste-subtree nil nil 'for-yank) (push-mark beg 'nomsg))) (t - (call-interactively 'yank)))))) + (call-interactively command)))))) (defun org-yank-folding-would-swallow-text (beg end) "Would hide-subtree at BEG swallow any text after END?"