From: Jay Kamat <jaygkamat@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Export of irc links in ox-html
Date: Sun, 24 Sep 2017 12:28:16 -0400 [thread overview]
Message-ID: <871smwqcwv.fsf@gmail.com> (raw)
In-Reply-To: <87tvzs8sva.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Sun, 24 Sep 2017 09:20:57 +0200")
[-- Attachment #1: Type: text/plain, Size: 704 bytes --]
Hi Nicolas,
> The proper fix would be to patch "org-irc.el" and add an export function
> there. "irc" links are not default links in Org, so there is no reason
> to hard-code them in "ox-html.el".
Thanks for pointing that out! I didn't even realize up until now org had
support for custom link types.
I've attached a second patch which adds a new function to org-irc.el,
which seems to handle export of irc links in ox-md and ox-html
properly. I'm very new to this system, so please make sure it's correct,
and I'll be happy to follow up with corrections if it isn't!
Because I added support for md links in org-irc.el, I also removed the
workaround I added a while back for that in ox-md.el.
-Jay
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-irc.el-Add-proper-export-functions-for-irc.patch --]
[-- Type: text/x-diff, Size: 2199 bytes --]
From e6c824f363bf6959f0eb35e4b8208a14d2cbffcb Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygkamat@gmail.com>
Date: Sun, 24 Sep 2017 12:11:52 -0400
Subject: [PATCH] org-irc.el: Add proper export functions for irc
* lisp/org-irc.el (org-irc-export): Add a new function,
org-irc-export, which properly exports irc links to html and markdown
* lisp/ox-md.el (org-md-link): Remove workaround to get irc links
working properly in ox-md, and use org-irc's export functions instead
---
lisp/org-irc.el | 20 +++++++++++++++++++-
lisp/ox-md.el | 2 +-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/lisp/org-irc.el b/lisp/org-irc.el
index 5889f6d2fe..eee71aef52 100644
--- a/lisp/org-irc.el
+++ b/lisp/org-irc.el
@@ -71,7 +71,10 @@
;; Generic functions/config (extend these for other clients)
-(org-link-set-parameters "irc" :follow #'org-irc-visit :store #'org-irc-store-link)
+(org-link-set-parameters "irc"
+ :follow #'org-irc-visit
+ :store #'org-irc-store-link
+ :export #'org-irc-export)
(defun org-irc-visit (link)
"Parse LINK and dispatch to the correct function based on the client found."
@@ -245,6 +248,21 @@ default."
;; no server match, make new connection
(erc-select :server server :port port))))
+(defun org-irc-export (link description format)
+ "Export an info link.
+See `org-link-parameters' for details about LINK, DESCRIPTION and FORMAT."
+ (let* ((desc (or description link)))
+ (pcase format
+ (`html
+ (format "<a href=\"irc:%s\">%s</a>"
+ link
+ desc))
+ (`md
+ (format "[%s](irc:%s)"
+ desc
+ link))
+ (_ nil))))
+
(provide 'org-irc)
;; Local variables:
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 5ba52e7faf..146956eedf 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -449,7 +449,7 @@ a communication channel."
(t (let* ((raw-path (org-element-property :path link))
(path
(cond
- ((member type '("http" "https" "ftp" "mailto" "irc"))
+ ((member type '("http" "https" "ftp" "mailto"))
(concat type ":" raw-path))
((string= type "file")
(org-export-file-uri (funcall link-org-files-as-md raw-path)))
--
2.11.0
next prev parent reply other threads:[~2017-09-24 16:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-24 5:18 [PATCH] Export of irc links in ox-html Jay Kamat
2017-09-24 7:20 ` Nicolas Goaziou
2017-09-24 16:28 ` Jay Kamat [this message]
2017-09-24 16:35 ` Nicolas Goaziou
2017-09-25 1:34 ` Jay Kamat
2017-09-25 13:52 ` Nicolas Goaziou
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=871smwqcwv.fsf@gmail.com \
--to=jaygkamat@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=mail@nicolasgoaziou.fr \
/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).