emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Matt Price <moptop99@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: mark parent element?
Date: Fri, 14 Mar 2014 19:11:27 +0100	[thread overview]
Message-ID: <87a9cstzu8.fsf@gmail.com> (raw)
In-Reply-To: <CAN_Dec9jfG_i7mjuUHirvhfAJNuxateiQ2MrthC6t2QYcq5W8g@mail.gmail.com> (Matt Price's message of "Fri, 14 Mar 2014 11:42:06 -0400")

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'
instead.


Regards,

-- 
Nicolas Goaziou

  parent reply	other threads:[~2014-03-14 18:11 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 [this message]
2014-03-15  2:06   ` Matt Price

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=87a9cstzu8.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=moptop99@gmail.com \
    /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).