From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scot Becker Subject: Re: Patch to genericize org-yank (6.21b) Date: Tue, 12 May 2009 22:10:42 +0100 Message-ID: References: <18952.56447.183195.891996@priss.frightenedpiglet.com> <295BBE0C-EB9C-4235-9DB8-E84C4BD0BD88@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1980647731==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M3zFT-0006Kw-JW for emacs-orgmode@gnu.org; Tue, 12 May 2009 17:10:51 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M3zFO-0006K2-KY for emacs-orgmode@gnu.org; Tue, 12 May 2009 17:10:51 -0400 Received: from [199.232.76.173] (port=59487 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3zFO-0006Jt-Ex for emacs-orgmode@gnu.org; Tue, 12 May 2009 17:10:46 -0400 Received: from mx20.gnu.org ([199.232.41.8]:44120) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M3zFN-0008Ne-WE for emacs-orgmode@gnu.org; Tue, 12 May 2009 17:10:46 -0400 Received: from mail-ew0-f162.google.com ([209.85.219.162]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M3zFM-0004mu-Rs for emacs-orgmode@gnu.org; Tue, 12 May 2009 17:10:45 -0400 Received: by ewy6 with SMTP id 6so337827ewy.42 for ; Tue, 12 May 2009 14:10:42 -0700 (PDT) In-Reply-To: <295BBE0C-EB9C-4235-9DB8-E84C4BD0BD88@gmail.com> 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: Carsten Dominik Cc: emacs-orgmode@gnu.org, sand@blarg.net --===============1980647731== Content-Type: multipart/alternative; boundary=0015174bde841249e30469bd879a --0015174bde841249e30469bd879a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cool. I was just looking for something like that the other day. On Tue, May 12, 2009 at 3:30 PM, Carsten Dominik wrote: > Applied, thanks. > > - Carsten > > > On May 12, 2009, at 4:18 AM, sand@blarg.net wrote: > > 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?" >> >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Remember: use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >> > > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > --0015174bde841249e30469bd879a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cool.=A0 I was just looking for something like that the other day.

<= div class=3D"gmail_quote">On Tue, May 12, 2009 at 3:30 PM, Carsten Dominik = <carsten.= dominik@gmail.com> wrote:
Applied, thanks.<= br>
- Carsten


On May 12, 2009, at 4:18 AM, sand@blarg.net wrote:

The org-yank function has special support for outline structures. =A0But if you want the same behavior for something other than yank, you're
out of luck. =A0This patch (against 6.21b) moves the main functionality
into org-yank-generic, with yanking being just one particular entry
point. =A0(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 =A0 =A0 =A02009-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 =A0 =A0and if there are no other headings with fewer stars."
=A0(interactive "P")
- =A0(setq this-command 'yank)
+ =A0(org-yank-generic 'yank arg))
+
+(defun org-yank-generic (command arg)
+ =A0"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."
+ =A0(setq this-command command)
=A0(if arg
- =A0 =A0 =A0(call-interactively 'yank)
+ =A0 =A0 =A0(call-interactively command)
=A0 =A0(let ((subtreep ; is kill a subtree, and the yank position appropri= ate?
=A0 =A0 =A0 =A0 =A0(and (org-kill-is-subtree-p)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 (or (bolp)
@@ -14826,7 +14834,7 @@
=A0 =A0 =A0 =A0 =A0 =A0 end)
=A0 =A0 =A0 =A0 (if (and subtreep org-yank-adjusted-subtrees)
=A0 =A0 =A0 =A0 =A0 =A0 (org-paste-subtree nil nil 'for-yank)
- =A0 =A0 =A0 =A0 =A0 (call-interactively 'yank))
+ =A0 =A0 =A0 =A0 =A0 (call-interactively command))
=A0 =A0 =A0 =A0 (setq end (point))
=A0 =A0 =A0 =A0 (goto-char beg)
=A0 =A0 =A0 =A0 (when (and (bolp) subtreep
@@ -14842,7 +14850,7 @@
=A0 =A0 =A0 =A0 =A0 =A0 =A0 (error (goto-char end)))))
=A0 =A0 =A0 =A0 (when swallowp
=A0 =A0 =A0 =A0 =A0 (message
- =A0 =A0 =A0 =A0 =A0 =A0"Yanked text not folded because that would sw= allow text"))
+ =A0 =A0 =A0 =A0 =A0 =A0"Inserted text not folded because that would = swallow text"))
=A0 =A0 =A0 =A0 (goto-char end)
=A0 =A0 =A0 =A0 (skip-chars-forward " \t\n\r")
=A0 =A0 =A0 =A0 (beginning-of-line 1)
@@ -14852,7 +14860,7 @@
=A0 =A0 =A0 =A0 (org-paste-subtree nil nil 'for-yank)
=A0 =A0 =A0 =A0 (push-mark beg 'nomsg)))
=A0 =A0 =A0 (t
- =A0 =A0 =A0 (call-interactively 'yank))))))
+ =A0 =A0 =A0 (call-interactively command))))))

(defun org-yank-folding-would-swallow-text (beg end)
=A0"Would hide-subtree at BEG swallow any text after END?"


_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gn= u.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode



_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gn= u.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

--0015174bde841249e30469bd879a-- --===============1980647731== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1980647731==--