emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Unintended behavior? Links without description
@ 2010-12-28 10:29 Christian Moe
  2010-12-31 20:09 ` Thomas S. Dye
  2011-02-12 22:11 ` Bastien
  0 siblings, 2 replies; 7+ messages in thread
From: Christian Moe @ 2010-12-28 10:29 UTC (permalink / raw)
  To: Org Mode; +Cc: Carsten Dominik

(sorry -- hit "send" too early by mistake in the previous mail)

Hi,

In pre-processing for export with org-export-normalize-links, links 
that lack a description part are given one, which consists of the full 
raw path of the link. In other words, link descriptions are never nil. 
This seems to conflict with the expectations of org-bbdb.el and custom 
links based on that example.

The link [[bbdb:Carsten Dominik]], for instance, is exported to html 
and latex as follows:

   <i>bbdb:Carsten Dominik</i>
   \textit{bbdb:Carsten Dominik}.

Org-bbdb.el is clearly prepared to be passed a desc that is nil, in 
which case it would use path instead:

(defun org-bbdb-export (path desc format)
   "Create the export version of a BBDB link specified by PATH or DESC.
If exporting to either HTML or LaTeX FORMAT the link will be
italicized, in all other cases it is left unchanged."
   (cond
    ((eq format 'html) (format "<i>%s</i>" (or desc path)))
    ((eq format 'latex) (format "\\textit{%s}" (or desc path)))
    (t (or desc path))))

However, desc is never nil, because a missing description part is 
replaced in export pre-processing by a string consisting of the link 
type, a colon, and the path. This takes place in the function 
org-export-normalize-links.

This makes for unexpected behavior in custom links that some of us 
have defined. E.g., Thomas S. Dye's `cite' links (the thread 
`org-add-link-type'):

>   (org-add-link-type
>    "citet" 'ebib
>    (lambda (path desc format)
>      (cond
>       ((eq format 'latex)
>        (if (and desc)
>              (format "\\citet[%s]{%s}" desc path)
>              (format "\\citet{%s}" path))))))
>
> [[citet:green84:_settl_patter_studies_ocean]]
>
> yields this:
>
> \citet[citet:green84:_settl\_patter\_studies\_ocean]{green84:_settl_patter_studies_ocean}

Some of my links, more closely modeled on org-bbdb.el, have similar 
problems.

I haven't done the bisection thing, but I suspect this is a fairly 
recent change.

I think I've tracked down the problem, but I don't necessarily 
understand what org-export-normalize-links is supposed to do or what 
other behaviors depend on this, so I'm not going to submit a patch. If 
this is now the intended behavior, it will be no problem to rewrite 
the custom link export definitions to take account of it.

Yours,
Christian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unintended behavior? Links without description
  2010-12-28 10:29 Unintended behavior? Links without description Christian Moe
@ 2010-12-31 20:09 ` Thomas S. Dye
  2011-02-12 22:11 ` Bastien
  1 sibling, 0 replies; 7+ messages in thread
From: Thomas S. Dye @ 2010-12-31 20:09 UTC (permalink / raw)
  To: mail; +Cc: Org Mode, Carsten Dominik

Aloha Christian,

I explored the possibility of bisecting but found two things: 1) with  
my setup I can't run versions of Org-mode earlier than approximately  
7.01h because of requirements for ob.el, and 2) the current behavior  
has been around at least since last summer--Org-mode version 7.01trans  
(release_7.01h.209.g2c33b) yields the same results as the current git  
master.

All the best,
Tom


On Dec 28, 2010, at 12:29 AM, Christian Moe wrote:

> (sorry -- hit "send" too early by mistake in the previous mail)
>
> Hi,
>
> In pre-processing for export with org-export-normalize-links, links  
> that lack a description part are given one, which consists of the  
> full raw path of the link. In other words, link descriptions are  
> never nil. This seems to conflict with the expectations of org- 
> bbdb.el and custom links based on that example.
>
> The link [[bbdb:Carsten Dominik]], for instance, is exported to html  
> and latex as follows:
>
>  <i>bbdb:Carsten Dominik</i>
>  \textit{bbdb:Carsten Dominik}.
>
> Org-bbdb.el is clearly prepared to be passed a desc that is nil, in  
> which case it would use path instead:
>
> (defun org-bbdb-export (path desc format)
>  "Create the export version of a BBDB link specified by PATH or DESC.
> If exporting to either HTML or LaTeX FORMAT the link will be
> italicized, in all other cases it is left unchanged."
>  (cond
>   ((eq format 'html) (format "<i>%s</i>" (or desc path)))
>   ((eq format 'latex) (format "\\textit{%s}" (or desc path)))
>   (t (or desc path))))
>
> However, desc is never nil, because a missing description part is  
> replaced in export pre-processing by a string consisting of the link  
> type, a colon, and the path. This takes place in the function org- 
> export-normalize-links.
>
> This makes for unexpected behavior in custom links that some of us  
> have defined. E.g., Thomas S. Dye's `cite' links (the thread `org- 
> add-link-type'):
>
>>  (org-add-link-type
>>   "citet" 'ebib
>>   (lambda (path desc format)
>>     (cond
>>      ((eq format 'latex)
>>       (if (and desc)
>>             (format "\\citet[%s]{%s}" desc path)
>>             (format "\\citet{%s}" path))))))
>>
>> [[citet:green84:_settl_patter_studies_ocean]]
>>
>> yields this:
>>
>> \citet[citet:green84:_settl\_patter\_studies\_ocean] 
>> {green84:_settl_patter_studies_ocean}
>
> Some of my links, more closely modeled on org-bbdb.el, have similar  
> problems.
>
> I haven't done the bisection thing, but I suspect this is a fairly  
> recent change.
>
> I think I've tracked down the problem, but I don't necessarily  
> understand what org-export-normalize-links is supposed to do or what  
> other behaviors depend on this, so I'm not going to submit a patch.  
> If this is now the intended behavior, it will be no problem to  
> rewrite the custom link export definitions to take account of it.
>
> Yours,
> Christian
>
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unintended behavior? Links without description
  2010-12-28 10:29 Unintended behavior? Links without description Christian Moe
  2010-12-31 20:09 ` Thomas S. Dye
@ 2011-02-12 22:11 ` Bastien
  2011-02-13 12:45   ` [PATCH] " Christian Moe
  2011-02-13 12:49   ` Christian Moe
  1 sibling, 2 replies; 7+ messages in thread
From: Bastien @ 2011-02-12 22:11 UTC (permalink / raw)
  To: mail; +Cc: Org Mode, Carsten Dominik

Hi Christian,

Christian Moe <mail@christianmoe.com> writes:

> I think I've tracked down the problem, but I don't necessarily understand
> what org-export-normalize-links is supposed to do or what other behaviors
> depend on this, so I'm not going to submit a patch. If this is now the
> intended behavior, it will be no problem to rewrite the custom link export
> definitions to take account of it.

Here again*, I think org-export-normalize-links: various backends will
decide what to do about having identical [path] and [desc].

I'd welcome a patch making org-bbdb.el a bit more clever about this.

Thanks!

* see my recent email about org-footnote-normalize

-- 
 Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Re: Unintended behavior? Links without description
  2011-02-12 22:11 ` Bastien
@ 2011-02-13 12:45   ` Christian Moe
  2011-02-15  4:38     ` Bastien
  2011-02-13 12:49   ` Christian Moe
  1 sibling, 1 reply; 7+ messages in thread
From: Christian Moe @ 2011-02-13 12:45 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Carsten Dominik

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

bbdb: Export links with normalized desc part

* org-bbdb.el (org-bbdb-export): When a link description has been
added by org-export-normalize-links, use path instead (remove the
`bbdb:' prefix).

The existing code handled the case where desc is nil. However, this no
longer occurs, since org-export-normalize-links now automatically adds
a desc to links, with a `bbdb:' prefix that would not usually be
wanted in exported text. The patch results in the same output as
originally intended.

TINYCHANGE


diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el
index c04b7ff..1d3252c 100644
--- a/lisp/org-bbdb.el
+++ b/lisp/org-bbdb.el
@@ -208,10 +208,12 @@ date year)."
    "Create the export version of a BBDB link specified by PATH or DESC.
  If exporting to either HTML or LaTeX FORMAT the link will be
  italicized, in all other cases it is left unchanged."
+  (when (string= desc (format "bbdb:%s" path))
+    (setq desc path))
    (cond
-   ((eq format 'html) (format "<i>%s</i>" (or desc path)))
-   ((eq format 'latex) (format "\\textit{%s}" (or desc path)))
-   (t (or desc path))))
+   ((eq format 'html) (format "<i>%s</i>" desc))
+   ((eq format 'latex) (format "\\textit{%s}" desc))
+   (t desc)))

  (defun org-bbdb-open (name)
    "Follow a BBDB link to NAME."


[-- Attachment #2: org-bbdb.el.diff --]
[-- Type: text/plain, Size: 762 bytes --]

diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el
index c04b7ff..1d3252c 100644
--- a/lisp/org-bbdb.el
+++ b/lisp/org-bbdb.el
@@ -208,10 +208,12 @@ date year)."
   "Create the export version of a BBDB link specified by PATH or DESC.
 If exporting to either HTML or LaTeX FORMAT the link will be
 italicized, in all other cases it is left unchanged."
+  (when (string= desc (format "bbdb:%s" path)) 
+    (setq desc path))
   (cond
-   ((eq format 'html) (format "<i>%s</i>" (or desc path)))
-   ((eq format 'latex) (format "\\textit{%s}" (or desc path)))
-   (t (or desc path))))
+   ((eq format 'html) (format "<i>%s</i>" desc))
+   ((eq format 'latex) (format "\\textit{%s}" desc))
+   (t desc)))
 
 (defun org-bbdb-open (name)
   "Follow a BBDB link to NAME."

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Unintended behavior? Links without description
  2011-02-12 22:11 ` Bastien
  2011-02-13 12:45   ` [PATCH] " Christian Moe
@ 2011-02-13 12:49   ` Christian Moe
  2011-02-15  4:39     ` Bastien
  1 sibling, 1 reply; 7+ messages in thread
From: Christian Moe @ 2011-02-13 12:49 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, Carsten Dominik

Hi,

I've sent a patch separately. Please take a hard look at it, since 
org-bbdb.el is a suggested model for people to look at when devising 
custom link types.

Yours,
Christian


On 2/12/11 11:11 PM, Bastien wrote:
> Hi Christian,
>
> Christian Moe<mail@christianmoe.com>  writes:
>
>> I think I've tracked down the problem, but I don't necessarily understand
>> what org-export-normalize-links is supposed to do or what other behaviors
>> depend on this, so I'm not going to submit a patch. If this is now the
>> intended behavior, it will be no problem to rewrite the custom link export
>> definitions to take account of it.
>
> Here again*, I think org-export-normalize-links: various backends will
> decide what to do about having identical [path] and [desc].
>
> I'd welcome a patch making org-bbdb.el a bit more clever about this.
>
> Thanks!
>
> * see my recent email about org-footnote-normalize
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Re: Unintended behavior? Links without description
  2011-02-13 12:45   ` [PATCH] " Christian Moe
@ 2011-02-15  4:38     ` Bastien
  0 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2011-02-15  4:38 UTC (permalink / raw)
  To: mail; +Cc: Org Mode, Carsten Dominik

Hi Christian,

Christian Moe <mail@christianmoe.com> writes:

> bbdb: Export links with normalized desc part
>
> * org-bbdb.el (org-bbdb-export): When a link description has been
> added by org-export-normalize-links, use path instead (remove the
> `bbdb:' prefix).
>
> The existing code handled the case where desc is nil. However, this no
> longer occurs, since org-export-normalize-links now automatically adds
> a desc to links, with a `bbdb:' prefix that would not usually be
> wanted in exported text. The patch results in the same output as
> originally intended.
>
> TINYCHANGE

Applied, thanks.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unintended behavior? Links without description
  2011-02-13 12:49   ` Christian Moe
@ 2011-02-15  4:39     ` Bastien
  0 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2011-02-15  4:39 UTC (permalink / raw)
  To: mail; +Cc: Org Mode, Carsten Dominik

Hi Christian,

Christian Moe <mail@christianmoe.com> writes:

> I've sent a patch separately. Please take a hard look at it, since
> org-bbdb.el is a suggested model for people to look at when devising custom
> link types.

Looks good, thanks again.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-15  4:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-28 10:29 Unintended behavior? Links without description Christian Moe
2010-12-31 20:09 ` Thomas S. Dye
2011-02-12 22:11 ` Bastien
2011-02-13 12:45   ` [PATCH] " Christian Moe
2011-02-15  4:38     ` Bastien
2011-02-13 12:49   ` Christian Moe
2011-02-15  4:39     ` Bastien

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).