From 5aaccd93c416c7e02f02b84da828dbe07f0032c5 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sat, 13 Sep 2008 21:02:01 +0200 Subject: [PATCH] New yank function. --- lisp/ChangeLog | 1 + lisp/org.el | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6dcbf3d5c..e46f9de41 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,7 @@ * org.el (org-indent-line-function): Do not indent in regions that are external source code. + (org-yank-and-fold-if-subtree): New function. * org-agenda.el (org-agenda-todayp): New function. (org-agenda-get-deadlines, org-agenda-get-scheduled): Use diff --git a/lisp/org.el b/lisp/org.el index 5f028b5e3..d2e999911 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -14392,27 +14392,23 @@ beyond the end of the headline." (org-set-tags nil t)) (t (kill-region (point) (point-at-eol))))) + (define-key org-mode-map "\C-k" 'org-kill-line) -(defun org-yank (&optional arg) - (interactive "*P") - (let ((fold (get-text-property 0 :org-folded-kill - (current-kill (cond ((listp arg) 0) - ((eq arg '-) -2) - (t (1- arg)))))) - (fold t) - (yank-excluded-properties - (cons :org-folded-kill yank-excluded-properties)) - (pos (point)) p1) +(defun org-yank-and-fold-if-subtree () + "Yank, and if the yanked text is a single subtree, fold it." + (interactive) + (let ((pos (point)) p1) (call-interactively 'yank) (setq p1 (point)) (goto-char pos) - (when (and (bolp) (looking-at outline-regexp) fold) - (save-restriction - (narrow-to-region pos p1) - (hide-subtree) - (org-cycle-show-empty-lines 'folded)) - (goto-char p1)))) + (when (and (bolp) + (looking-at outline-regexp) + (org-kill-is-subtree-p)) + (hide-subtree) + (org-cycle-show-empty-lines 'folded)) + (goto-char p1) + (skip-chars-forward " \t\n\r"))) (defun org-invisible-p () "Check if point is at a character currently not visible." @@ -14775,3 +14771,4 @@ Still experimental, may disappear in the future." ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd ;;; org.el ends here +