Re: [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx

2022-01-23 Thread Jonas Bernoulli
Nicolas Goaziou  writes:

> I suggest to require a special attribute before doing so, e.g.,
>
>   #+attr_texinfo: :compact t
>   - key: a ::
>   - key: b ::
>
>   - key: c ::
>   - key: d ::

I have noticed that I accidentally called it ":combine" in the
documentation and have fixed that.  (Do you think we should stick
to ":compact"?)

I would actually prefer to be able to set this once per file, not
least because this looks a bit weird.

   #+attr_texinfo: :compact t
   - key: a ::
   not "compact"

   - key: c ::
   - key: d ::
   "compact"

> Another option would be to merge consecutive lists with such an
> attribute, for the same result:
>
>   #+attr_texinfo: :compact t
>   - key: a ::
>   - key: b ::
>
>   #+attr_texinfo: :compact t
>   - key: c ::
>   - key: d ::

That would seem like a fix for that issue, but as I mentioned before
that doesn't work because it results in two lists, each with one @item
and one @itemx.

You actually suggested that in your first reply:

>>#+TEXINFO_DEFFN: t
> The chosen UI is rather odd however. I cannot think of another use of
> controlling export thhough "#+keyword: boolean" syntax. Usually, we
> extend the "options" keyword. It could become, for example:
>
>   #+options: texinfo+:t
>
> Could it be possible to use that syntax instead?

You later indicated that you would prefer to specify this per-list.  I
implemented the approach that uses "+" to indicate @itemx items, because
that seemed even nicer to me (because more explicit) but you didn't like
that and so I went with the alternative that you suggested in response
to that attempt.

But I would like to take a step back and ask if

>   #+options: texinfo+:t

still seems like a good idea to you.  (If so, should that be used
instead of the per-list approach or as an alternative?)

 Jonas



Re: [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx

2022-01-05 Thread Jonas Bernoulli
Nicolas Goaziou  writes:

>> For example:
>>
>> - Key: C-c C-w (forge-browse-TYPE) ::
>> + Key: C-c C-w (forge-browse-dwim) ::
>> + Key: N b I (forge-browse-issues) ::
>> + Key: N b P (forge-browse-pullreqs) ::
>> + Key: N b t (forge-browse-topic) ::
>> + Key: N b i (forge-browse-issue) ::
>> + Key: N b p (forge-browse-pullreq) ::
>>
>>   These commands visit the topic, issue(s), pull-request(s), post,
>>   branch, commit, or remote at point in a browser. ...
>>
>> vs.
>>
>> - Key: C-c C-w (forge-browse-TYPE), C-c C-w (forge-browse-dwim), N b I 
>> (forge-browse-issues), N b P (forge-browse-pullreqs), N b t 
>> (forge-browse-topic), N b i (forge-browse-issue), N b p 
>> (forge-browse-pullreq) ::
>>
>>   These commands visit the topic, issue(s), pull-request(s), post,
>>   branch, commit, or remote at point in a browser. ...
>>
>> I am sure I am gonna make mistakes when using the latter approach.
>
> True, but OTOH, the first option is not really possible. However, there
> are still alternatives. For example, you could check blank lines between
> items:
>
>   - key: a ::
>   - key: b ::
>
>   - key: c ::
>   - key: d ::
>
> I suggest to require a special attribute before doing so, e.g.,
>
>   #+attr_texinfo: :compact t
>   - key: a ::
>   - key: b ::
>
>   - key: c ::
>   - key: d ::

I went with that approach.

> Another option would be to merge consecutive lists with such an
> attribute, for the same result:
>
>   #+attr_texinfo: :compact t
>   - key: a ::
>   - key: b ::
>
>   #+attr_texinfo: :compact t
>   - key: c ::
>   - key: d ::
>
>
>   - This is a regular list since it does not have :compact attribute.

Ordered lists are transcoded to @itemize, while description lists are
transcoded to @table or some other table command.  So they cannot be
combined into one list-like thing in Texinfo.

The first two lists could be combined, but IMO it is better to only
require the :compact t once and avoid splitting the list and then
recombining the lists back into one.

 Jonas

Ps: Slightly sad about loosing the +.
It looks very much like the x at the end of @itemx.



Re: [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx

2021-12-30 Thread Nicolas Goaziou
Hello,

Jonas Bernoulli  writes:

> I vaguely remember having run into this feature before when using Org to
> record a pros and cons list.  As a maintainer I don't like this question
> but; could this feature be made optional?  (Of course one could use tags
> to indicate whether an item is a pro or cons, but for such a simple use-
> case that seems more work than necessary and less immediately
> obvious.)

You can also make two lists. I don't think we should provide "pros ans
cons list", because it has implications outside export.

> This bothered me a bit too when writing it but at the same time
> it seemed like overkill to replicate the docstrings of the called
> functions.  How do you feel about using a hook instead?
>
> (defvar org-texinfo--filter-parse-tree-functions
>   '(org-texinfo--normalize-headlines
> org-texinfo--normalize-items)
>   "List of functions the `texinfo' back-end applies to the parsed tree.
> Each filter is called with three arguments: the parse tree, as
> returned by `org-element-parse-buffer', the back-end, as
> a symbol, and the communication channel, as a plist.  It must
> return the modified parse tree to transcode.")

Sure.

> Do you prefer to add the hook functions as done above or should each one
> be added individually using add-hook?

`add-hook' is more for users, I think.

> Done.  Is this okay?:
>
>   (when (and next-item
>  (string-prefix-p
>   "+"
>   (org-element-property :bullet next-item)))
>
> Or should the line-breaks go elsewhere?

The line breaks do not matter much but it may fail if
(org-element-property :bullet next-item) returns nil.

>> Anyhow, relying on mixed bullets is not great…
>
> The alternative isn't great either.
>
> For example:
>
> - Key: C-c C-w (forge-browse-TYPE) ::
> + Key: C-c C-w (forge-browse-dwim) ::
> + Key: N b I (forge-browse-issues) ::
> + Key: N b P (forge-browse-pullreqs) ::
> + Key: N b t (forge-browse-topic) ::
> + Key: N b i (forge-browse-issue) ::
> + Key: N b p (forge-browse-pullreq) ::
>
>   These commands visit the topic, issue(s), pull-request(s), post,
>   branch, commit, or remote at point in a browser. ...
>
> vs.
>
> - Key: C-c C-w (forge-browse-TYPE), C-c C-w (forge-browse-dwim), N b I 
> (forge-browse-issues), N b P (forge-browse-pullreqs), N b t 
> (forge-browse-topic), N b i (forge-browse-issue), N b p 
> (forge-browse-pullreq) ::
>
>   These commands visit the topic, issue(s), pull-request(s), post,
>   branch, commit, or remote at point in a browser. ...
>
> I am sure I am gonna make mistakes when using the latter approach.

True, but OTOH, the first option is not really possible. However, there
are still alternatives. For example, you could check blank lines between
items:

  - key: a ::
  - key: b ::

  - key: c ::
  - key: d ::

I suggest to require a special attribute before doing so, e.g.,

  #+attr_texinfo: :compact t
  - key: a ::
  - key: b ::

  - key: c ::
  - key: d ::

Another option would be to merge consecutive lists with such an
attribute, for the same result:

  #+attr_texinfo: :compact t
  - key: a ::
  - key: b ::

  #+attr_texinfo: :compact t
  - key: c ::
  - key: d ::


  - This is a regular list since it does not have :compact attribute.

IIRC, I did an experiment like this one when introducing matrices in
LaTeX export.

Regards,
-- 
Nicolas Goaziou



Re: [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx

2021-12-27 Thread Jonas Bernoulli
Nicolas Goaziou  writes:

> Hello,
>
> Thanks. Some comments follow.

Thanks for the review!

> Jonas Bernoulli  writes:
>
>> +In description lists the used bullet is significant when exporting to
>> +Texinfo; when in doubt, then use =-=.  An item that uses =+= instead
>> +becomes a new entry in the first column of the table.  The above
>> +output can also be produced with:
>>  
>>  #+begin_example
>> -#+ATTR_TEXINFO: :enum A
>> -1. Alpha
>> -2. Bravo
>> -3. Charlie
>> +,#+attr_texinfo: :table-type vtable :indic asis
>> +- foo ::
>> ++ bar ::
>> +  This is the common text for foo and bar.
>>  #+end_example
>
> The above is fragile, because pressing  on an item will
> "repair" the bullets. Therefore, you cannot support mixed bullets in the
> same list.

The alternative also isn't great (see below).

I vaguely remember having run into this feature before when using Org to
record a pros and cons list.  As a maintainer I don't like this question
but; could this feature be made optional?  (Of course one could use tags
to indicate whether an item is a pro or cons, but for such a simple use-
case that seems more work than necessary and less immediately obvious.)

>>  *** Tables in Texinfo export
>> diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
>> index b0125894a..35862357d 100644
>> --- a/lisp/ox-texinfo.el
>> +++ b/lisp/ox-texinfo.el
>> @@ -418,6 +418,11 @@ (defun org-texinfo--filter-section-blank-lines 
>> (headline _backend _info)
>>"Filter controlling number of blank lines after a section."
>>(replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" "\n\n" headline))
>>  
>> +(defun org-texinfo--filter-parse-tree (tree backend info)
>> +  "Normalize headlines and items."
>> +  (org-texinfo--normalize-headlines tree backend info)
>> +  (org-texinfo--normalize-items tree info))
>
> Could you expound the docstring? Arguments are missing, and "normalize"
> is vague.

This bothered me a bit too when writing it but at the same time
it seemed like overkill to replicate the docstrings of the called
functions.  How do you feel about using a hook instead?

(defvar org-texinfo--filter-parse-tree-functions
  '(org-texinfo--normalize-headlines
org-texinfo--normalize-items)
  "List of functions the `texinfo' back-end applies to the parsed tree.
Each filter is called with three arguments: the parse tree, as
returned by `org-element-parse-buffer', the back-end, as
a symbol, and the communication channel, as a plist.  It must
return the modified parse tree to transcode.")

Do you prefer to add the hook functions as done above or should each one
be added individually using add-hook?

>> +  (org-element-map tree 'plain-list
>> +(lambda (plain-list)
>> +  (when (eq (org-element-property :type plain-list) 'descriptive)
>> +(let ((contents (org-element-contents plain-list)))
>> +  (while (setq item (pop contents))
>> +(let ((next-item (car contents)))
>> +  (when (and next-item
>> + (equal (org-element-property :bullet next-item) "+ 
>> "))
>
> The above will fail if `org-list-two-spaces-after-bullet-regexp' is
> non-nil. You should compare the trimmed bullet with "+".

Done.  Is this okay?:

  (when (and next-item
 (string-prefix-p
  "+"
  (org-element-property :bullet next-item)))

Or should the line-breaks go elsewhere?

> Anyhow, relying on mixed bullets is not great…

The alternative isn't great either.

For example:

- Key: C-c C-w (forge-browse-TYPE) ::
+ Key: C-c C-w (forge-browse-dwim) ::
+ Key: N b I (forge-browse-issues) ::
+ Key: N b P (forge-browse-pullreqs) ::
+ Key: N b t (forge-browse-topic) ::
+ Key: N b i (forge-browse-issue) ::
+ Key: N b p (forge-browse-pullreq) ::

  These commands visit the topic, issue(s), pull-request(s), post,
  branch, commit, or remote at point in a browser. ...

vs.

- Key: C-c C-w (forge-browse-TYPE), C-c C-w (forge-browse-dwim), N b I 
(forge-browse-issues), N b P (forge-browse-pullreqs), N b t 
(forge-browse-topic), N b i (forge-browse-issue), N b p (forge-browse-pullreq) 
::

  These commands visit the topic, issue(s), pull-request(s), post,
  branch, commit, or remote at point in a browser. ...

I am sure I am gonna make mistakes when using the latter approach.

 Cheers,
 Jonas



Re: [PATCH 1/2] ox-texinfo: Turn a description list item with "+" bullet into @itemx

2021-12-26 Thread Nicolas Goaziou
Hello,

Thanks. Some comments follow.

Jonas Bernoulli  writes:

> +In description lists the used bullet is significant when exporting to
> +Texinfo; when in doubt, then use =-=.  An item that uses =+= instead
> +becomes a new entry in the first column of the table.  The above
> +output can also be produced with:
>  
>  #+begin_example
> -#+ATTR_TEXINFO: :enum A
> -1. Alpha
> -2. Bravo
> -3. Charlie
> +,#+attr_texinfo: :table-type vtable :indic asis
> +- foo ::
> ++ bar ::
> +  This is the common text for foo and bar.
>  #+end_example

The above is fragile, because pressing  on an item will
"repair" the bullets. Therefore, you cannot support mixed bullets in the
same list.

>  *** Tables in Texinfo export
> diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
> index b0125894a..35862357d 100644
> --- a/lisp/ox-texinfo.el
> +++ b/lisp/ox-texinfo.el
> @@ -418,6 +418,11 @@ (defun org-texinfo--filter-section-blank-lines (headline 
> _backend _info)
>"Filter controlling number of blank lines after a section."
>(replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" "\n\n" headline))
>  
> +(defun org-texinfo--filter-parse-tree (tree backend info)
> +  "Normalize headlines and items."
> +  (org-texinfo--normalize-headlines tree backend info)
> +  (org-texinfo--normalize-items tree info))

Could you expound the docstring? Arguments are missing, and "normalize"
is vague.

> +  (org-element-map tree 'plain-list
> +(lambda (plain-list)
> +  (when (eq (org-element-property :type plain-list) 'descriptive)
> +(let ((contents (org-element-contents plain-list)))
> +  (while (setq item (pop contents))
> +(let ((next-item (car contents)))
> +  (when (and next-item
> + (equal (org-element-property :bullet next-item) "+ 
> "))

The above will fail if `org-list-two-spaces-after-bullet-regexp' is
non-nil. You should compare the trimmed bullet with "+".

Anyhow, relying on mixed bullets is not great…

Regards,
-- 
Nicolas Goaziou