From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas S. Dye Subject: (org-element-context) :end property Date: Fri, 02 Oct 2015 11:37:27 -1000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi81U-0006Xe-6C for emacs-orgmode@gnu.org; Fri, 02 Oct 2015 17:37:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi81R-0003kz-0V for emacs-orgmode@gnu.org; Fri, 02 Oct 2015 17:37:48 -0400 Received: from gproxy5-pub.mail.unifiedlayer.com ([67.222.38.55]:43752) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Zi81Q-0003hD-Pc for emacs-orgmode@gnu.org; Fri, 02 Oct 2015 17:37:44 -0400 Received: from [168.105.155.89] (port=60829 helo=manifi) by box472.bluehost.com with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.84) (envelope-from ) id 1Zi81C-00008z-MV for emacs-orgmode@gnu.org; Fri, 02 Oct 2015 15:37:30 -0600 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: emacs-org list Aloha all, I've started to use John Kitchin's unlinkify function, which he posted to the list last year. (defun jk/unlinkify () "Replace an org-link with the description, or if this absent, the path." (interactive) (let ((eop (org-element-context))) (when (eq 'link (car eop)) (message "%s" eop) (let* ((start (org-element-property :begin eop)) (end (org-element-property :end eop)) (contents-begin (org-element-property :contents-begin eop)) (contents-end (org-element-property :contents-end eop)) (path (org-element-property :path eop)) (desc (and contents-begin contents-end (buffer-substring contents-begin contents-end)))) (setf (buffer-substring start end) (or desc path)))))) However, I get different results depending on whether the link ends with a space or a character, e.g. Foo [[http:www.tsdye.com][desc]] bar. Foo [[http:www.tsdye.com][desc]], bar. Foo descbar. Foo desc, bar. How can I fix this? I'm guessing that org-element-context sets :end differently depending on the character following the link? All the best, Tom -- Thomas S. Dye http://www.tsdye.com