From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: How to change a link? Date: Mon, 20 Oct 2014 15:02:41 +0200 Message-ID: <87d29m28su.fsf@nicolasgoaziou.fr> References: <87a94yjia9.fsf@wmi.amu.edu.pl> <87bnpd4ov7.fsf@nicolasgoaziou.fr> <87h9yzobge.fsf@wmi.amu.edu.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgCbB-0006O4-Oe for emacs-orgmode@gnu.org; Mon, 20 Oct 2014 09:02:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgCb3-0002GE-W2 for emacs-orgmode@gnu.org; Mon, 20 Oct 2014 09:02:09 -0400 Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:50750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgCb3-0002B2-Qh for emacs-orgmode@gnu.org; Mon, 20 Oct 2014 09:02:01 -0400 In-Reply-To: <87h9yzobge.fsf@wmi.amu.edu.pl> (Marcin Borkowski's message of "Mon, 20 Oct 2014 02:02:09 +0200") 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: Marcin Borkowski Cc: org-mode List Marcin Borkowski writes: > OK, it works, but: if the link description is empty, after this change > it's still empty, so that it becomes the result of concatenation. I'd > like the link description to stay the same, no matter whether it's empty > or not. How do I set the /contents/ of a link object (as opposed to a > property)? Two examples: 1. with a full AST (org-with-wide-buffer (dolist (link (nreverse (org-element-map (org-element-parse-buffer) 'link (lambda (l) (member (org-element-property :type l) '("custom-id" "fuzzy")))))) (goto-char (+ (org-element-property :begin link) 2)) (insert "file:path/to/other-file.org::"))) 2. working directly on the buffer (org-with-wide-buffer (goto-char (point-min)) (while (re-search-forward org-bracket-link-regexp nil t) (let ((context (org-element-context))) (when (and (eq (org-element-type context) 'link) (member (org-element-property :type context) '("custom-id" "fuzzy"))) (goto-char (+ (org-element-property :begin context) 2)) (insert "file:path/to/other-file.org::"))))) Regards, -- Nicolas Goaziou