From: Matt Price <moptop99@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: mark parent element?
Date: Fri, 14 Mar 2014 22:06:19 -0400 [thread overview]
Message-ID: <CAN_Dec_iHqvQS0XVxoZ+QC7hcBYrLO7rJC0GxOLOyCZPfLB8Mg@mail.gmail.com> (raw)
In-Reply-To: <87a9cstzu8.fsf@gmail.com>
On Fri, Mar 14, 2014 at 2:11 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Hello,
>
> Matt Price <moptop99@gmail.com> 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
prev parent reply other threads:[~2014-03-15 2:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-14 15:42 mark parent element? Matt Price
2014-03-14 17:11 ` Thorsten Jolitz
2014-03-14 17:57 ` Oleh
2014-03-14 18:11 ` Nicolas Goaziou
2014-03-15 2:06 ` Matt Price [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAN_Dec_iHqvQS0XVxoZ+QC7hcBYrLO7rJC0GxOLOyCZPfLB8Mg@mail.gmail.com \
--to=moptop99@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).