From: Thomas S. Dye <tsd@tsdye.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: (org-element-context) :end property
Date: Fri, 02 Oct 2015 11:37:27 -1000 [thread overview]
Message-ID: <m2lhblt0iw.fsf@tsdye.com> (raw)
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
next reply other threads:[~2015-10-02 21:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 21:37 Thomas S. Dye [this message]
2015-10-02 21:50 ` (org-element-context) :end property Nicolas Goaziou
2015-10-02 22:26 ` Thomas S. Dye
2015-10-03 4:09 ` Thomas S. Dye
2015-10-04 14:12 ` John Kitchin
2015-10-04 14:48 ` Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2lhblt0iw.fsf@tsdye.com \
--to=tsd@tsdye.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).