emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] ox-ascii.el: Consistently add brackets around links (was: Re: [RFC][PATCH] Allow to export to ascii custom link types as notes)
Date: Tue, 24 Oct 2023 22:06:05 +0700	[thread overview]
Message-ID: <uh8mgt$lpo$1@ciao.gmane.io> (raw)
In-Reply-To: <87edhk717a.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]

On 24/10/2023 17:40, Ihor Radchenko wrote:
> Max Nikulin writes:
>>>>          [Org mode] (<http://orgmode.org>)
>>>> man
>>>>          man (http://man.he.net/?topic=man&section=all)
[...]
> Should be [man] (<http://man.he.net/?topic=man&section=all>)

Side note: it should be either just "man(1)" or "man(8)" without any URL 
for plain text export, but it is another story.

>>>> internal
>>>>          heading (See section 1)
[...]
> Hmm.. I do see a problem now. To be consistent, it should be
> 
> [heading] (See section 1)

See the attached patch.

After:

--- 8< ---
web
       [Org mode] (<http://orgmode.org>)
man
       [man] (<http://man.he.net/?topic=man&section=all>)
internal
       [heading] (See section 1)


1 Heading
═════════
--- >8 ---

Before:

--- 8< ---
web
       [Org mode] (<http://orgmode.org>)
man
       man (http://man.he.net/?topic=man&section=all)
internal
       heading (See section 1)


1 Heading
═════════
--- >8 ---

I would consider

--- 8< ---
web
       Org mode <http://orgmode.org>
man
       man <http://man.he.net/?topic=man&section=all>
internal
       heading (See section 1)


1 Heading
═════════
--- >8 ---

but inconsistency is worse anyway.

[-- Attachment #2: 0001-ox-ascii.el-Consistently-add-brackets-around-links.patch --]
[-- Type: text/x-patch, Size: 2812 bytes --]

From 3434fdf9b1669304ed2051c89554efc9922c5feb Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Tue, 24 Oct 2023 21:45:36 +0700
Subject: [PATCH] ox-ascii.el: Consistently add brackets around links

* lisp/ox-ascii.el (org-ascii-link): Add square brackets around
description of fuzzy links when they are exported inline.
* lisp/ol-docview.el (org-docview-export):
* lisp/ox-ascii.el (org-ascii-link): Export links with square brackets
around description and angle brackets around path.

This make export of links inline (when `org-ascii-links-to-notes' is
nil) consistent with "http:" links: "[DESC] (<URI>)".

I would drop brackets for "http:" and similar links instead
("DESC (<URI>)" or even "DESC <URI>"), but any case I prefer
consistency.

Ihor Radchenko to emacs-orgmode. Re: [RFC][PATCH] Allow to export to
ascii custom link types as notes. Tue, 24 Oct 2023 10:40:41 +0000.
<https://list.orgmode.org/87edhk717a.fsf@localhost>
---
 lisp/ol-docview.el | 2 +-
 lisp/ol-man.el     | 2 +-
 lisp/ox-ascii.el   | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/ol-docview.el b/lisp/ol-docview.el
index bb9b34a17..bcb26520b 100644
--- a/lisp/ol-docview.el
+++ b/lisp/ol-docview.el
@@ -67,7 +67,7 @@ (defun org-docview-export (link description backend _info)
       (cond
        ((eq backend 'html) (format "<a href=\"%s\">%s</a>" path desc))
        ((eq backend 'latex) (format "\\href{%s}{%s}" path desc))
-       ((eq backend 'ascii) (format "%s (%s)" desc path))
+       ((eq backend 'ascii) (format "[%s] (<%s>)" desc path))
        (t path)))))
 
 (defun org-docview-open (link _)
diff --git a/lisp/ol-man.el b/lisp/ol-man.el
index abe79086a..645a6108e 100644
--- a/lisp/ol-man.el
+++ b/lisp/ol-man.el
@@ -91,7 +91,7 @@ (defun org-man-export (link description backend)
      ((eq backend 'html) (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
      ((eq backend 'latex) (format "\\href{%s}{%s}" path desc))
      ((eq backend 'texinfo) (format "@uref{%s,%s}" path desc))
-     ((eq backend 'ascii) (format "%s (%s)" desc path))
+     ((eq backend 'ascii) (format "[%s] (<%s>)" desc path))
      ((eq backend 'md) (format "[%s](%s)" desc path))
      (t path))))
 
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index 110bb4601..ae4273489 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -1607,9 +1607,9 @@ (defun org-ascii-link (link desc info)
 	  ((guard desc)
 	   (if (plist-get info :ascii-links-to-notes)
 	       (format "[%s]" desc)
-	     (concat desc
-		     (format " (%s)"
-			     (org-ascii--describe-datum destination info)))))
+	     (format "[%s] (%s)"
+                     desc
+		     (org-ascii--describe-datum destination info))))
 	  ;; External file.
 	  (`plain-text destination)
 	  (`headline
-- 
2.39.2


  reply	other threads:[~2023-10-24 15:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20 17:21 [RFC][PATCH] Allow to export to ascii custom link types as notes Max Nikulin
2023-10-22  9:13 ` Ihor Radchenko
2023-10-22 17:05   ` Max Nikulin
2023-10-23  9:17     ` Ihor Radchenko
2023-10-23 11:00       ` Max Nikulin
2023-10-23 12:09         ` Ihor Radchenko
2023-10-24  8:11           ` Max Nikulin
2023-10-24 10:40             ` Ihor Radchenko
2023-10-24 15:06               ` Max Nikulin [this message]
2023-10-25 10:34                 ` [PATCH] ox-ascii.el: Consistently add brackets around links (was: Re: [RFC][PATCH] Allow to export to ascii custom link types as notes) Ihor Radchenko
2023-10-26 16:46                   ` man pages references (Re: [PATCH] ox-ascii.el: Consistently add brackets around links) Max Nikulin
2023-11-05 12:08                     ` Ihor Radchenko
2023-10-27 14:36               ` [RFC][PATCH] Allow to export to ascii custom link types as notes Max Nikulin
2023-10-25 15:16           ` [RFC][PATCH v2] " Max Nikulin
2023-11-07  9:30             ` Ihor Radchenko
2023-11-07 11:48               ` Max Nikulin
2023-11-07 11:58                 ` Ihor Radchenko
2023-11-08 10:23                   ` Max Nikulin
2023-11-08 10:45                     ` Ihor Radchenko
2023-11-08 10:57                       ` Max Nikulin
2023-11-08 11:16                         ` Ihor Radchenko
2023-11-09 11:12                           ` Max Nikulin
2023-11-11 11:17                             ` Ihor Radchenko

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='uh8mgt$lpo$1@ciao.gmane.io' \
    --to=manikulin@gmail.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).