emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] mark parent element?


From: Matt Price
Subject: Re: [O] mark parent element?
Date: Fri, 14 Mar 2014 22:06:19 -0400

On Fri, Mar 14, 2014 at 2:11 PM, Nicolas Goaziou <address@hidden> wrote:
> Hello,
>
> Matt Price <address@hidden> writes:
>
>> I'm trying to write a function that will mark the parent of the
>> current element.  I think I understand how to do it but for some
>> reason I can get the mark to persist after the funciton is called.  I
>> think it's really an elisp problem, not an org problem, but am hoping
>> someone can ehelp me.  Here's what I have:
>>
>> (defun er/mark-org-parent-element ()
>>   "Marks an org parent element"
>>   (interactive)
>>   (let ((parent (plist-get (car (cdr (org-element-at-point))) :parent)))
>
> It is better to use (org-element-property :parent (org-element-at-point))
>
>>     (let ((parent-props (car (cdr parent))))
>
> You shouldn't extract properties this way. See below.
>
>>       ;; (print parent-props)
>>       ;; (print (plist-get parent-props :begin))
>>       ;; (print (plist-get parent-props :end))
>>       (if (plist-get parent-props :begin)
>>           (progn
>>             (goto-char (plist-get parent-props :begin))
>
> It is better to use (org-element-property :begin parent)
>
>>             (set-mark (point))
>>             (goto-char (plist-get parent-props :end))
>
> It is better to use (org-element-property :end parent)
>
> Anyway, I suggest to use `org-up-element' and `org-mark-element'

I am a little stunned by how awesome this is. it was worth not
noticing org-up-element in the docs to learn the proper way to address
org-element properties.  Thank you Nicolas!  And everyone else too of
course.

Matt



> instead.
>
>
> Regards,
>
> --
> Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]