From b1098a1ab3e5a526f3514fd6178fe676d23849f7 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 11 Jan 2011 12:13:14 +0100 Subject: [PATCH 06/10] Add org-insert-and-inherit-partially * org.el (org-insert-and-inherit-partially): New function Signed-off-by: Julien Danjou --- lisp/org.el | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index b2b08ae..c024916 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -18867,6 +18867,22 @@ work correctly." ;;; Other stuff. +(defun org-insert-and-inherit-partially (&rest args) + "Insert the arguments at point, partially inheriting properties from adjoining text. +The properties are inherited only if they are not set on the argument." + (dolist (arg args) + (let ((start (point)) + (arg-props (loop for i from 0 to (1- (length arg)) + collect (text-properties-at i arg)))) + (insert-and-inherit arg) + (loop for i from 0 to (length arg-props) + for place = (+ start i) + for props = (nth i arg-props) + do (loop for prop in props by 'cddr + for value in (cdr props) by 'cddr + do (put-text-property place (1+ place) + prop value)))))) + (defun org-toggle-fixed-width-section (arg) "Toggle the fixed-width export. If there is no active region, the QUOTE keyword at the current headline is -- 1.7.2.3