unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* RE: [External] : Re: Indentation conventions for Info manuals; recognizing code
  2021-03-07  6:33 ` Eli Zaretskii
@ 2021-03-08  3:47   ` Drew Adams
  2021-03-08  5:49     ` Yuri Khan
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2021-03-08  3:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel@gnu.org

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

> > Given only an Info buffer, i.e., not Texinfo source code but its output
> that's used by Emacs users, is there a convention wrt indentation of, say
> code blocks?  Or is there some other way (e.g. a text property) to recognize
> code or similar text that really deserves a fixed-pitch font?
> 
> No, I don't think so.  Not from examining the indentation, anyway.
> You could try some heuristics to detect code from the contents,
> perhaps.

I don't see any possible heuristics.  It could be
any kind of code.  And not just code.  Shell input
and output, ASCII art,...  Really anything that it
makes sense to put in a fixed-pitch font.  The kind
of thing that usually gets something like an HTML
<code> tag.

> I think it's hopeless to rely on indentation for such a feature.  As
> you discovered, the indentation can vary if the code block is inside
> some other "environment", like a table (this is what causes
> multi-level indentation in CC Mode manual).  Moreover, there's a
> (rarely used) Texinfo directive that changes the default indentation
> of a code block, even if it is not nested inside some other indented
> text.  If, for example, such a directive is used in the ELisp manual,
> it will immediately ruin the results for your feature.

Yeah, I've discovered as much.

> > I know that the use of Texinfo output (what ends up as Info buffer text) is
> wider than just Emacs Info.  But is there, at the Texinfo level at least,
> some semantic markup that distinguishes something like code?
> 
> Yes, the @example, @smallexample, @lisp, and @smallisp are such
> markup in Texinfo.

Is what `makeinfo' produces for them for Info
hard-coded, or can it be modified in some ways?

Or even if hard-coded, is it possible for the
resulting Info text to be somehow distinguished
as such - e.g., as we get '...' in the Info text,
resulting from some Texinfo @ construct?  (I
don't have a Texinfo or `makeinfo' manual.)

I don't see any way to recognize this in the Info
output we currently get, but is there perhaps
some way to get some indication there, e.g., to
define what Info output `makeinfo' produces for
something like @example or @lisp?

> > If there is, could that info be maintained - transferred to Info buffers in
> some way, or does the translation just have to be lossy in this way?
> 
> The conversion to Info is performed by 'makeinfo', a program that is
> part of the Texinfo package.  Its output must be mostly plain text,
> and the format of that file must be understood by the various Info
> readers out there.  So if some kind of "code" marker would be retained
> in the Info output, it would need to be implemented in the 2 or 3
> other Info readers out there, not just in Emacs.  The chances of such
> a change in the Info output format, just for the sake of some fancy
> display in a single Emacs-related package sound small -- but you need
> to talk about this with the Texinfo developers, not with us.

Too bad the translation has to be lossy.  The
effect of showing <code>-like stuff is helpful
(and is common in technical doc).

And something will be needed if we ever hope to
allow for variable-pitch text for most regular
text while using fixed-pitch for places it makes
sense (e.g. code).

With the `...' quoting there's no problem
recognizing (most) code (and key) bits embedded
in ordinary text, and using a fixed-pitch font
on the former.

I don't suppose it's feasible to have another
such construct to indicate the equivalent of
<code>...</code>?  We already have some Texinfo
markup or whatever that gets converted to '...'.
Is there some existing Texinfo construct that
could be leveraged for @lisp etc.?

See attached screenshots, for an idea of the
usefulness.  They're the same node - the only
difference is toggling minor mode
`Info-variable-pitch-text-mode'.

[-- Attachment #2: throw-emacs-Info-code-block.png --]
[-- Type: image/png, Size: 95468 bytes --]

[-- Attachment #3: throw-emacs-Info-var-pitch+code-block.png --]
[-- Type: image/png, Size: 95836 bytes --]

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

* Re: [External] : Re: Indentation conventions for Info manuals; recognizing code
  2021-03-08  3:47   ` [External] : " Drew Adams
@ 2021-03-08  5:49     ` Yuri Khan
  2021-03-08 14:07       ` Eli Zaretskii
  2021-03-08 15:33       ` Drew Adams
  0 siblings, 2 replies; 8+ messages in thread
From: Yuri Khan @ 2021-03-08  5:49 UTC (permalink / raw)
  To: Drew Adams; +Cc: Eli Zaretskii, emacs-devel@gnu.org

On Mon, 8 Mar 2021 at 10:49, Drew Adams <drew.adams@oracle.com> wrote:

> Too bad the translation has to be lossy.  The
> effect of showing <code>-like stuff is helpful
> (and is common in technical doc).
>
> And something will be needed if we ever hope to
> allow for variable-pitch text for most regular
> text while using fixed-pitch for places it makes
> sense (e.g. code).

You *want* nice variable-pitch text in Info, so you *ask for* a way to
distinguish code from body text in the Info output format, but what
you really *need* is the HTML output and a convenient browser for
that.



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

* Re: Indentation conventions for Info manuals; recognizing code
@ 2021-03-08  9:51 tydrdn
  2021-03-08 15:33 ` [External] : " Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: tydrdn @ 2021-03-08  9:51 UTC (permalink / raw)
  To: emacs-devel@gnu.org

> So if some kind of "code" marker would be retained
> in the Info output, it would need to be implemented in the 2 or 3
> other Info readers out there, not just in Emacs.

makeinfo could have a new option to add separators for the generated
code examples, something like:

--- example begin

....

--- example end


This is just text, so others info readers could display it as is,
while emacs could use the separators to recognize code sections.



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

* Re: [External] : Re: Indentation conventions for Info manuals; recognizing code
  2021-03-08  5:49     ` Yuri Khan
@ 2021-03-08 14:07       ` Eli Zaretskii
  2021-03-08 15:33       ` Drew Adams
  1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2021-03-08 14:07 UTC (permalink / raw)
  To: Yuri Khan; +Cc: drew.adams, emacs-devel

> From: Yuri Khan <yuri.v.khan@gmail.com>
> Date: Mon, 8 Mar 2021 12:49:32 +0700
> Cc: Eli Zaretskii <eliz@gnu.org>, "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> 
> You *want* nice variable-pitch text in Info, so you *ask for* a way to
> distinguish code from body text in the Info output format, but what
> you really *need* is the HTML output and a convenient browser for
> that.

Yes, I believe the right direction to having a better styled display
of manuals is to begin with the HTML output.  The Texinfo developers
are actually moving in that direction: to make the HTML output more
functional, so that it doesn't miss the important advantages of Info.



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

* RE: [External] : Re: Indentation conventions for Info manuals; recognizing code
  2021-03-08  5:37 ` Richard Stallman
@ 2021-03-08 15:33   ` Drew Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2021-03-08 15:33 UTC (permalink / raw)
  To: rms@gnu.org; +Cc: emacs-devel@gnu.org

>   > But other manuals don't seem to use the same indentation.  Several
>   > (org, eintr, ccmode, efaq(-w32),...) indent code (including Elisp)
>   > 5 spaces - which is the same amount that other, non-code text is
>   > indented.
> 
> Aside from eintr, I don't know anything specific about those manuals.
> 
> The eintr manual was written by Bob Chassell; I presume it is still
> generated from Texinfo, right?  So I find it puzzling that it produces
> a different format in the Info file.
> 
> Why does it do that?  Is the source formatted in an unusual way?  Does
> it somehow specify different parameters for generating the Info file?

Sorry, this was my misunderstanding, from a too-cursory
look at the Elisp manual.

All manuals (including Elisp) have varying indentation,
for different things.  It's not possible, in any general
way, to rely on indentation level to determine whether
some content is code-like, i.e., deserves a fixed-pitch font.

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

* RE: [External] : Re: Indentation conventions for Info manuals; recognizing code
  2021-03-08  5:49     ` Yuri Khan
  2021-03-08 14:07       ` Eli Zaretskii
@ 2021-03-08 15:33       ` Drew Adams
  1 sibling, 0 replies; 8+ messages in thread
From: Drew Adams @ 2021-03-08 15:33 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Eli Zaretskii, emacs-devel@gnu.org

> > Too bad the translation has to be lossy.  The
> > effect of showing <code>-like stuff is helpful
> > (and is common in technical doc).
> >
> > And something will be needed if we ever hope to
> > allow for variable-pitch text for most regular
> > text while using fixed-pitch for places it makes
> > sense (e.g. code).
> 
> You *want* nice variable-pitch text in Info, so you *ask for* a way to
> distinguish code from body text in the Info output format, but what
> you really *need* is the HTML output and a convenient browser for
> that.

Actually, I do *want* (in addition to Info in Emacs)
HTML manuals - and we already have that.

We *need*, I think, an ability to (optionally) use
variable-pitch for most text in Info (in Emacs) and
fixed-pitch for some text, such as code, examples
of user input/output, shell use, ASCII art etc.

All that I find (so far) missing for this is an
ability to recognize the latter, apart from `...',
<...>, function/macro/etc. header lines, etc.

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

* RE: [External] : Re: Indentation conventions for Info manuals; recognizing code
  2021-03-08  9:51 Indentation conventions for Info manuals; recognizing code tydrdn
@ 2021-03-08 15:33 ` Drew Adams
  2021-03-26  5:12   ` scame
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2021-03-08 15:33 UTC (permalink / raw)
  To: tydrdn, emacs-devel@gnu.org

> > So if some kind of "code" marker would be retained
> > in the Info output, it would need to be implemented in the 2 or 3
> > other Info readers out there, not just in Emacs.
> 
> makeinfo could have a new option to add separators for the generated
> code examples, something like:
> 
> --- example begin
> ....
> --- example end
> 
> This is just text, so others info readers could display it as is,
> while emacs could use the separators to recognize code sections.

Yes, just the kind of thing I was suggesting
(hoping for).

Emacs handling of that can hide that "markup" and
DTRT wrt the font type.

There are likely several kinds of text "elements"
that might be candidates for this.  Eli mentioned
Texinfo @example, @smallexample, @lisp, and
@smallisp.

Given that (different purposes/semantics) ideally
we would have more than just one resulting kind of
"markup" as well, i.e., not only -- example begin/end.


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

* RE: [External] : Re: Indentation conventions for Info manuals; recognizing code
  2021-03-08 15:33 ` [External] : " Drew Adams
@ 2021-03-26  5:12   ` scame
  0 siblings, 0 replies; 8+ messages in thread
From: scame @ 2021-03-26  5:12 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel@gnu.org

On Monday, March 8, 2021 4:33 PM, Drew Adams <drew.adams@oracle.com> wrote:

> > > So if some kind of "code" marker would be retained
> > > in the Info output, it would need to be implemented in the 2 or 3
> > > other Info readers out there, not just in Emacs.
> >
> > makeinfo could have a new option to add separators for the generated
> > code examples, something like:
> > --- example begin
> > ....
> > --- example end
> > This is just text, so others info readers could display it as is,
> > while emacs could use the separators to recognize code sections.
>
> Yes, just the kind of thing I was suggesting
> (hoping for).
>


It occurred to me makeinfo doesn't need a new option at all if
a preprocessing step is added to info generation.

For example this text from the current info:

@smallexample
;; Avoid this pattern.
(let ((beg ...) (end ...) (my-completions (my-make-completions)))
  (list beg end my-completions))
;; Use this instead.
(let ((beg ...) (end ...))
  (list beg
        end
        (completion-table-dynamic
          (lambda (_)
            (my-make-completions)))))
@end smallexample


could be converted automatically by an emacs build script before
info generation to:


--- example begin -----------------------

@smallexample
;; Avoid this pattern.
(let ((beg ...) (end ...) (my-completions (my-make-completions)))
  (list beg end my-completions))
;; Use this instead.
(let ((beg ...) (end ...))
  (list beg
        end
        (completion-table-dynamic
          (lambda (_)
            (my-make-completions)))))
@end smallexample

--- example end -----------------------


so that makeinfo converts the example as usual and leave the
added section markers in place for the final output, so that
emacs can use it to detect example sections to font lock them
and hide the markers.

And other info readers can simply display the text as is, showing
the added section separators around the example.



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

end of thread, other threads:[~2021-03-26  5:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08  9:51 Indentation conventions for Info manuals; recognizing code tydrdn
2021-03-08 15:33 ` [External] : " Drew Adams
2021-03-26  5:12   ` scame
  -- strict thread matches above, loose matches on Subject: below --
2021-03-07  1:58 Drew Adams
2021-03-07  6:33 ` Eli Zaretskii
2021-03-08  3:47   ` [External] : " Drew Adams
2021-03-08  5:49     ` Yuri Khan
2021-03-08 14:07       ` Eli Zaretskii
2021-03-08 15:33       ` Drew Adams
2021-03-08  5:37 ` Richard Stallman
2021-03-08 15:33   ` [External] : " Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).