* org-add-link-type @ 2010-12-27 0:29 Thomas S. Dye 2010-12-27 6:10 ` org-add-link-type Christian Moe 0 siblings, 1 reply; 9+ messages in thread From: Thomas S. Dye @ 2010-12-27 0:29 UTC (permalink / raw) To: emacs-orgmode ml Aloha all, Sorry in advance for coming to the list with a beginner type question, but I'm stumped. I'm trying to use the extended link syntax to export citations to LaTeX. If the link lacks a description, then I don't want the \citep command to have an optional argument. As I understand the documentation, if the description is absent, then the variable desc is nil, so the following looks good to my untrained eye. But, it doesn't add the optional argument when the description is present. (org-add-link-type "citep" 'ebib (lambda (path desc format) (cond ((eq format 'latex) (when (and desc) (format "\\citep[%s]{%s}" desc path) (format "\\citep{%s}" path)))))) All the best, Tom ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-add-link-type 2010-12-27 0:29 org-add-link-type Thomas S. Dye @ 2010-12-27 6:10 ` Christian Moe 2010-12-27 7:06 ` org-add-link-type Thomas S. Dye 0 siblings, 1 reply; 9+ messages in thread From: Christian Moe @ 2010-12-27 6:10 UTC (permalink / raw) To: Org Mode Hi, Thomas, Try it with "if" rather than "when". Yours, Christian On 12/27/10 1:29 AM, Thomas S. Dye wrote: > Aloha all, > > Sorry in advance for coming to the list with a beginner type question, > but I'm stumped. > > I'm trying to use the extended link syntax to export citations to > LaTeX. If the link lacks a description, then I don't want the \citep > command to have an optional argument. As I understand the > documentation, if the description is absent, then the variable desc is > nil, so the following looks good to my untrained eye. But, it doesn't > add the optional argument when the description is present. > > (org-add-link-type > "citep" 'ebib > (lambda (path desc format) > (cond > ((eq format 'latex) > (when (and desc) > (format "\\citep[%s]{%s}" desc path) > (format "\\citep{%s}" path)))))) > > All the best, > Tom > > _______________________________________________ > 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 [flat|nested] 9+ messages in thread
* Re: org-add-link-type 2010-12-27 6:10 ` org-add-link-type Christian Moe @ 2010-12-27 7:06 ` Thomas S. Dye 2010-12-27 10:58 ` org-add-link-type Christian Moe 2011-01-17 18:35 ` org-add-link-type Bastien 0 siblings, 2 replies; 9+ messages in thread From: Thomas S. Dye @ 2010-12-27 7:06 UTC (permalink / raw) To: mail; +Cc: Org Mode Hi Christian, Thanks, I've put away my copy of ANSI Common Lisp. The results surprise me. (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} All the best, Tom On Dec 26, 2010, at 8:10 PM, Christian Moe wrote: > Hi, Thomas, > > Try it with "if" rather than "when". > > Yours, > Christian > > > On 12/27/10 1:29 AM, Thomas S. Dye wrote: >> Aloha all, >> >> Sorry in advance for coming to the list with a beginner type >> question, >> but I'm stumped. >> >> I'm trying to use the extended link syntax to export citations to >> LaTeX. If the link lacks a description, then I don't want the \citep >> command to have an optional argument. As I understand the >> documentation, if the description is absent, then the variable desc >> is >> nil, so the following looks good to my untrained eye. But, it doesn't >> add the optional argument when the description is present. >> >> (org-add-link-type >> "citep" 'ebib >> (lambda (path desc format) >> (cond >> ((eq format 'latex) >> (when (and desc) >> (format "\\citep[%s]{%s}" desc path) >> (format "\\citep{%s}" path)))))) >> >> All the best, >> Tom >> >> _______________________________________________ >> 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 >> > > > _______________________________________________ > 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 [flat|nested] 9+ messages in thread
* Re: org-add-link-type 2010-12-27 7:06 ` org-add-link-type Thomas S. Dye @ 2010-12-27 10:58 ` Christian Moe 2011-01-17 18:35 ` org-add-link-type Bastien 1 sibling, 0 replies; 9+ messages in thread From: Christian Moe @ 2010-12-27 10:58 UTC (permalink / raw) To: Thomas S. Dye; +Cc: Org Mode Hi again, That is indeed surprising. It looks as if an empty desc is never passed, instead it is replaced with the full raw path. I don't think that's the right behavior, and I don't really see how it could result from org-export-latex-links. Hadn't noticed this before because my own "cite" links all have a desc part, e.g. [[cite:green84][Green, 1984]], and then the problem doesn't come up. Yours, Christian On 12/27/10 8:06 AM, Thomas S. Dye wrote: > Hi Christian, > > Thanks, I've put away my copy of ANSI Common Lisp. > > The results surprise me. > > (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} > > > All the best, > Tom > > On Dec 26, 2010, at 8:10 PM, Christian Moe wrote: > >> Hi, Thomas, >> >> Try it with "if" rather than "when". >> >> Yours, >> Christian >> >> >> On 12/27/10 1:29 AM, Thomas S. Dye wrote: >>> Aloha all, >>> >>> Sorry in advance for coming to the list with a beginner type question, >>> but I'm stumped. >>> >>> I'm trying to use the extended link syntax to export citations to >>> LaTeX. If the link lacks a description, then I don't want the \citep >>> command to have an optional argument. As I understand the >>> documentation, if the description is absent, then the variable desc is >>> nil, so the following looks good to my untrained eye. But, it doesn't >>> add the optional argument when the description is present. >>> >>> (org-add-link-type >>> "citep" 'ebib >>> (lambda (path desc format) >>> (cond >>> ((eq format 'latex) >>> (when (and desc) >>> (format "\\citep[%s]{%s}" desc path) >>> (format "\\citep{%s}" path)))))) >>> >>> All the best, >>> Tom >>> >>> _______________________________________________ >>> 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 >>> >> >> >> _______________________________________________ >> 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 [flat|nested] 9+ messages in thread
* Re: org-add-link-type 2010-12-27 7:06 ` org-add-link-type Thomas S. Dye 2010-12-27 10:58 ` org-add-link-type Christian Moe @ 2011-01-17 18:35 ` Bastien 2011-01-18 17:45 ` org-add-link-type Thomas S. Dye 1 sibling, 1 reply; 9+ messages in thread From: Bastien @ 2011-01-17 18:35 UTC (permalink / raw) To: Thomas S. Dye; +Cc: Org Mode, mail Hi Thomas, "Thomas S. Dye" <tsd@tsdye.com> writes: > (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} This is because "_" chars are usually protected from conversion in links, but the LaTeX exporter might be confused by links it doesn't know. What about this : (org-add-link-type "citet" 'ebib (lambda (path desc format) (cond ((eq format 'latex) (if (and desc) (org-export-latex-protect-string (format "\\citet[%s]{%s}" desc path)) (org-export-latex-protect-string (format "\\citet{%s}" path))))))) Check for other uses of `org-export-latex-protect-string' in org-latex.el to better understand in what contexts this function is useful. HTH, -- Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-add-link-type 2011-01-17 18:35 ` org-add-link-type Bastien @ 2011-01-18 17:45 ` Thomas S. Dye 2011-02-12 22:39 ` org-add-link-type Bastien 0 siblings, 1 reply; 9+ messages in thread From: Thomas S. Dye @ 2011-01-18 17:45 UTC (permalink / raw) To: Bastien; +Cc: Org Mode, mail Aloha Bastien, Thanks for looking at this. The problem isn't that the description is being protected from conversion, it is that it is there at all. The link in the example lacks a description and the documentation says that in this case desc will be nil, so it was a surprise to find a value being passed instead. In the example code (and desc) is supposed to evaluate false if the link lacks a description. However, it never evaluates to false. I'm using the following code now, which tests for both the documented and actual behavior when a description is absent from the link. #+source: define-citet-link #+begin_src emacs-lisp :results silent (org-add-link-type "citet" 'ebib (lambda (path desc format) (cond ((eq format 'latex) (if (or (not desc) (equal 0 (search "citet:" desc))) (format "\\citet{%s}" path) (format "\\citet[%s]{%s}" desc path) ))))) #+end_src All the best, Tom On Jan 17, 2011, at 8:35 AM, Bastien wrote: > Hi Thomas, > > "Thomas S. Dye" <tsd@tsdye.com> writes: > >> (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} > > This is because "_" chars are usually protected from conversion in > links, but the LaTeX exporter might be confused by links it doesn't > know. > > What about this : > > (org-add-link-type > "citet" 'ebib > (lambda (path desc format) > (cond > ((eq format 'latex) > (if (and desc) > (org-export-latex-protect-string > (format "\\citet[%s]{%s}" desc path)) > (org-export-latex-protect-string > (format "\\citet{%s}" path))))))) > > Check for other uses of `org-export-latex-protect-string' in > org-latex.el to better understand in what contexts this function > is useful. > > HTH, > > -- > Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-add-link-type 2011-01-18 17:45 ` org-add-link-type Thomas S. Dye @ 2011-02-12 22:39 ` Bastien 2011-02-12 23:16 ` org-add-link-type Thomas S. Dye 0 siblings, 1 reply; 9+ messages in thread From: Bastien @ 2011-02-12 22:39 UTC (permalink / raw) To: Thomas S. Dye; +Cc: Org Mode, mail Hi Thomas, "Thomas S. Dye" <tsd@tsdye.com> writes: > Thanks for looking at this. The problem isn't that the description is > being protected from conversion, it is that it is there at all. The > link in the example lacks a description and the documentation says > that in this case desc will be nil, so it was a surprise to find a > value being passed instead. Yes -- that's because org-export-normalize-links add a description when there is none. Can you tell me where the documentation is wrong about this? I cannot find it right now. Thanks! -- Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-add-link-type 2011-02-12 22:39 ` org-add-link-type Bastien @ 2011-02-12 23:16 ` Thomas S. Dye 2011-02-12 23:32 ` org-add-link-type Bastien 0 siblings, 1 reply; 9+ messages in thread From: Thomas S. Dye @ 2011-02-12 23:16 UTC (permalink / raw) To: Bastien; +Cc: Org Mode, mail [-- Attachment #1: Type: text/plain, Size: 16 bytes --] Aloha Bastien, [-- Attachment #2: 0001-lisp-org.el-Documentation-change-for-org-add-link-ty.patch --] [-- Type: application/octet-stream, Size: 1022 bytes --] From 7f8d2f1ccab79b9e0978ebfe730fb3f5bb82b6ca Mon Sep 17 00:00:00 2001 From: Tom Dye <tsd@tsdye.com> Date: Sat, 12 Feb 2011 13:14:55 -1000 Subject: [PATCH] * lisp/org.el: Documentation change for org-add-link-type --- lisp/org.el | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index e56ce4f..8168a28 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8268,7 +8268,8 @@ EXPORT should format the link path for export to one of the export formats. It should be a function accepting three arguments: path the path of the link, the text after the prefix (like \"http:\") - desc the description of the link, if any, nil if there was no description + desc the description of the link, if any, or a description added by + org-export-normalize-links if there is none format the export format, a symbol like `html' or `latex' or `ascii'.. The function may use the FORMAT information to return different values -- 1.7.1 [-- Attachment #3: Type: text/plain, Size: 673 bytes --] All the best, Tom On Feb 12, 2011, at 12:39 PM, Bastien wrote: > Hi Thomas, > > "Thomas S. Dye" <tsd@tsdye.com> writes: > >> Thanks for looking at this. The problem isn't that the description >> is >> being protected from conversion, it is that it is there at all. The >> link in the example lacks a description and the documentation says >> that in this case desc will be nil, so it was a surprise to find a >> value being passed instead. > > Yes -- that's because org-export-normalize-links add a description > when > there is none. > > Can you tell me where the documentation is wrong about this? I cannot > find it right now. > > Thanks! > > -- > Bastien [-- Attachment #4: 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] 9+ messages in thread
* Re: org-add-link-type 2011-02-12 23:16 ` org-add-link-type Thomas S. Dye @ 2011-02-12 23:32 ` Bastien 0 siblings, 0 replies; 9+ messages in thread From: Bastien @ 2011-02-12 23:32 UTC (permalink / raw) To: Thomas S. Dye; +Cc: Org Mode, mail Great, applied, thanks! -- Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-02-12 23:46 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-12-27 0:29 org-add-link-type Thomas S. Dye 2010-12-27 6:10 ` org-add-link-type Christian Moe 2010-12-27 7:06 ` org-add-link-type Thomas S. Dye 2010-12-27 10:58 ` org-add-link-type Christian Moe 2011-01-17 18:35 ` org-add-link-type Bastien 2011-01-18 17:45 ` org-add-link-type Thomas S. Dye 2011-02-12 22:39 ` org-add-link-type Bastien 2011-02-12 23:16 ` org-add-link-type Thomas S. Dye 2011-02-12 23:32 ` org-add-link-type 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).