From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: mark parent element? Date: Fri, 14 Mar 2014 22:06:19 -0400 Message-ID: References: <87a9cstzu8.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOdzR-0001Tx-N3 for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 22:06:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOdzQ-0002U8-Rc for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 22:06:21 -0400 Received: from mail-qa0-x232.google.com ([2607:f8b0:400d:c00::232]:44845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOdzQ-0002Tx-MF for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 22:06:20 -0400 Received: by mail-qa0-f50.google.com with SMTP id o15so3353754qap.9 for ; Fri, 14 Mar 2014 19:06:20 -0700 (PDT) In-Reply-To: <87a9cstzu8.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode On Fri, Mar 14, 2014 at 2:11 PM, Nicolas Goaziou wrote: > Hello, > > Matt Price 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