emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Exporter] Why fall-back to :title if :alt-title is nil?
@ 2013-11-16 10:24 Thorsten Jolitz
  2013-11-16 11:01 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Jolitz @ 2013-11-16 10:24 UTC (permalink / raw)
  To: emacs-orgmode


Hi List, 

in ox.el I find this function for getting the (optional) alternative title of
a headline:

#+begin_src emacs-lisp
(defun org-export-get-alt-title (headline info)
  "Return alternative title for HEADLINE, as a secondary string.
INFO is a plist used as a communication channel.  If no optional
title is defined, fall-back to the regular title."
  (or (org-element-property :alt-title headline)
      (org-element-property :title headline)))
#+end_src

I'm not so sure that it is a good idea to fallback to the regular title in
case :alt-title is nil, because when extracting both, title and alt-title,
from a headline, there is a almost always a duplication (the regular title
string is received two times, via the get-title and get-alt-title functions)
because :alt-title isn't really set very often.

Wouldn't it make more sense to just return nil when :alt-title is nil? If the
application code needs a title string anyway, it can always fall-back to a
call to the get-title function.

-- 
cheers,
Thorsten

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

* Re: [Exporter] Why fall-back to :title if :alt-title is nil?
  2013-11-16 10:24 [Exporter] Why fall-back to :title if :alt-title is nil? Thorsten Jolitz
@ 2013-11-16 11:01 ` Nicolas Goaziou
  2013-11-16 12:38   ` Thorsten Jolitz
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2013-11-16 11:01 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

Hello,

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Hi List, 
>
> in ox.el I find this function for getting the (optional) alternative title of
> a headline:
>
> #+begin_src emacs-lisp
> (defun org-export-get-alt-title (headline info)
>   "Return alternative title for HEADLINE, as a secondary string.
> INFO is a plist used as a communication channel.  If no optional
> title is defined, fall-back to the regular title."
>   (or (org-element-property :alt-title headline)
>       (org-element-property :title headline)))
> #+end_src
>
> I'm not so sure that it is a good idea to fallback to the regular title in
> case :alt-title is nil, because when extracting both, title and alt-title,
> from a headline, there is a almost always a duplication (the regular title
> string is received two times, via the get-title and get-alt-title functions)
> because :alt-title isn't really set very often.
>
> Wouldn't it make more sense to just return nil when :alt-title is nil? If the
> application code needs a title string anyway, it can always fall-back to a
> call to the get-title function.

There is no "get-title" function.

When building a TOC, you are required to get a title for the current
entry. This function prevent checking both sources.

Anyway, I think this is nitpicking, because you can always check if its
return value equals (org-element-property :title headline).


Regards,

-- 
Nicolas Goaziou

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

* Re: [Exporter] Why fall-back to :title if :alt-title is nil?
  2013-11-16 11:01 ` Nicolas Goaziou
@ 2013-11-16 12:38   ` Thorsten Jolitz
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Jolitz @ 2013-11-16 12:38 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <n.goaziou@gmail.com> writes:

Hello,

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> Hi List, 
>>
>> in ox.el I find this function for getting the (optional) alternative
>> title of a headline:
>>
>> #+begin_src emacs-lisp
>> (defun org-export-get-alt-title (headline info)
>>   "Return alternative title for HEADLINE, as a secondary string.
>> INFO is a plist used as a communication channel.  If no optional
>> title is defined, fall-back to the regular title."
>>   (or (org-element-property :alt-title headline)
>>       (org-element-property :title headline)))
>> #+end_src
>>
>> I'm not so sure that it is a good idea to fallback to the regular
>> title in case :alt-title is nil, because when extracting both, title
>> and alt-title, from a headline, there is a almost always a
>> duplication (the regular title string is received two times, via the
>> get-title and get-alt-title functions) because :alt-title isn't
>> really set very often.
>>
>> Wouldn't it make more sense to just return nil when :alt-title is
>> nil? If the application code needs a title string anyway, it can
>> always fall-back to a call to the get-title function.
>
> There is no "get-title" function.
>
> When building a TOC, you are required to get a title for the current
> entry. This function prevent checking both sources.
>
> Anyway, I think this is nitpicking, because you can always check if its
> return value equals (org-element-property :title headline).

it is nitpicking and not really important, but a function name like

,------------------------------------------------
| (defun org-export-get-toc-title (headline info)
`------------------------------------------------

would probably better describe what the function really does. 

-- 
cheers,
Thorsten

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

end of thread, other threads:[~2013-11-16 12:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-16 10:24 [Exporter] Why fall-back to :title if :alt-title is nil? Thorsten Jolitz
2013-11-16 11:01 ` Nicolas Goaziou
2013-11-16 12:38   ` Thorsten Jolitz

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