emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Patch to genericize org-yank (6.21b)
@ 2009-05-12  2:18 sand
  2009-05-12 14:30 ` Carsten Dominik
  0 siblings, 1 reply; 3+ messages in thread
From: sand @ 2009-05-12  2:18 UTC (permalink / raw)
  To: emacs-orgmode

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?"

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

* Re: Patch to genericize org-yank (6.21b)
  2009-05-12  2:18 Patch to genericize org-yank (6.21b) sand
@ 2009-05-12 14:30 ` Carsten Dominik
  2009-05-12 21:10   ` Scot Becker
  0 siblings, 1 reply; 3+ messages in thread
From: Carsten Dominik @ 2009-05-12 14:30 UTC (permalink / raw)
  To: sand; +Cc: emacs-orgmode

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

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

* Re: Patch to genericize org-yank (6.21b)
  2009-05-12 14:30 ` Carsten Dominik
@ 2009-05-12 21:10   ` Scot Becker
  0 siblings, 0 replies; 3+ messages in thread
From: Scot Becker @ 2009-05-12 21:10 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, sand


[-- Attachment #1.1: Type: text/plain, Size: 3165 bytes --]

Cool.  I was just looking for something like that the other day.

On Tue, May 12, 2009 at 3:30 PM, Carsten Dominik
<carsten.dominik@gmail.com>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
>

[-- Attachment #1.2: Type: text/html, Size: 4358 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

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

end of thread, other threads:[~2009-05-12 21:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-12  2:18 Patch to genericize org-yank (6.21b) sand
2009-05-12 14:30 ` Carsten Dominik
2009-05-12 21:10   ` Scot Becker

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