From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: mark parent element? Date: Fri, 14 Mar 2014 19:11:27 +0100 Message-ID: <87a9cstzu8.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOWZZ-000560-Up for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 14:11:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOWZQ-0008JD-N3 for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 14:11:09 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:58496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOWZQ-0008J7-CL for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 14:11:00 -0400 Received: by mail-wi0-f181.google.com with SMTP id hm4so49845wib.8 for ; Fri, 14 Mar 2014 11:10:59 -0700 (PDT) In-Reply-To: (Matt Price's message of "Fri, 14 Mar 2014 11:42:06 -0400") 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: Matt Price Cc: Org Mode 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' instead. Regards, -- Nicolas Goaziou