[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] mark parent element?
From: |
Nicolas Goaziou |
Subject: |
Re: [O] mark parent element? |
Date: |
Fri, 14 Mar 2014 19:11:27 +0100 |
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'
instead.
Regards,
--
Nicolas Goaziou