emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: [bug, ox-ascii][PATCH] description list and long links
Date: Wed, 28 Jan 2015 01:30:19 +0100	[thread overview]
Message-ID: <87twzbsq5g.fsf@gmx.us> (raw)

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

Hi,

Consider the following example:

--8<---------------cut here---------------start------------->8---
(with-temp-buffer 
  (require 'ox-ascii)
  (insert
   "- [[http://www.npr.org/blogs/monkeysee/2009/03/a_very_long_url_makes_a_very_s.html][A label with a long link]] :: Lorem ipsum dolor sit amet, consectetur adipiscing elit\n")
  (org-ascii-export-as-ascii nil nil nil t))  
--8<---------------cut here---------------end--------------->8---

With output:

--8<---------------cut here---------------start------------->8---
[A label with a long link]: Lorem
                            ipsum
                            dolor
                            sit
                            amet,
                            consectetur
                            adipiscing
                            elit


[A label with a long link]
http://www.npr.org/blogs/monkeysee/2009/03/a_very_long_url_makes_a_very_s.html
--8<---------------cut here---------------end--------------->8---

The reason for the wrong formatting is that org-ascii--current-text-width
takes that there's is like -28 characters left for lorem ipsum...  It does
that because it counts link and label.

The patch fixes this by only counting the length of the label.

I'm not really familiar with the ascii backend, so let me know if there's
any obvious deficits that I have overlooked.

Otherwise I push it.

—Rasmus


-- 
Evidence suggests Snowden used a powerful tool called monospaced fonts

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-ascii.el-Bug-in-description-list-formatting.patch --]
[-- Type: text/x-diff, Size: 1124 bytes --]

From 7b6a8730de6f5ec57f5d45af57c3c9f90f389fef Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Wed, 28 Jan 2015 01:10:56 +0100
Subject: [PATCH] ox-ascii.el: Bug in description-list formatting

* ox-ascii.el (org-ascii--current-text-width): Consider length of
  label for links.
---
 lisp/ox-ascii.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index e294fab..cd239f9 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -624,8 +624,11 @@ INFO is a plist used as a communication channel."
 		      (string-width (or (org-ascii--checkbox parent-item info)
 					""))
 		      (string-width
-		       (or (org-list-get-tag beg-item struct)
-			   (org-list-get-bullet beg-item struct)))))))))))))
+		       (let ((tag (or (org-list-get-tag beg-item struct)
+				      (org-list-get-bullet beg-item struct))))
+			 (if (string-match org-bracket-link-analytic-regexp tag)
+			     (match-string 4 tag)
+			   tag)))))))))))))
 
 (defun org-ascii--current-justification (element)
   "Return expected justification for ELEMENT's contents.
-- 
2.2.2


             reply	other threads:[~2015-01-28  0:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-28  0:30 Rasmus [this message]
2015-01-28 12:58 ` [bug, ox-ascii][PATCH] description list and long links Nicolas Goaziou
2015-01-28 13:48   ` Rasmus

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=87twzbsq5g.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --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).