From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleh Subject: Re: mark parent element? Date: Fri, 14 Mar 2014 18:57:07 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOWM1-0003oz-PD for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 13:57:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOWM0-00030P-SW for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 13:57:09 -0400 Received: from mail-we0-x231.google.com ([2a00:1450:400c:c03::231]:33985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOWM0-00030H-Lx for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 13:57:08 -0400 Received: by mail-we0-f177.google.com with SMTP id u57so2341321wes.8 for ; Fri, 14 Mar 2014 10:57:07 -0700 (PDT) In-Reply-To: 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 Hi Matt, > 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))) > (let ((parent-props (car (cdr parent)))) > ;; (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)) > (set-mark (point)) > (goto-char (plist-get parent-props :end)) > (exchange-point-and-mark) > ))) > ) > ) The probelm here is that `(org-element-at-point)` doesn't always have a parent. I'm using plain outline functions for this purpose. See `worf-mark-left' at https://github.com/abo-abo/worf/blob/master/worf.el. regards, Oleh