unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* file variables and man pages with preprocessors
@ 2007-11-06  7:50 Werner LEMBERG
  2007-11-07  0:15 ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Werner LEMBERG @ 2007-11-06  7:50 UTC (permalink / raw)
  To: emacs-devel


There is a convention in man pages to mark them whether a preprocessor
has to be used or not.  The first line must resemble

  '\" <string>

where <string> is a combination of letters which identify the used
preprocessor.  For example, `p' and `t' stand for pic and tbl,
respectively:

  '\" tp

However, if a man page starts with such a comment, local file
variables can't be placed into the first line and are no longer
recognized by Emacs.

I thus ask to handle files which start with

  '\"

similar to shell scripts, this is, to take the *second* line for file
variables.

Another reason for this request is the forthcoming release of groff
which contains a preprocessor, preconv, to handle man pages in various
input encodings, and which recognizes Emacs coding tags (within a file
variable at the top of a file).


    Werner

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

* Re: file variables and man pages with preprocessors
  2007-11-06  7:50 file variables and man pages with preprocessors Werner LEMBERG
@ 2007-11-07  0:15 ` Richard Stallman
  2007-11-07  4:01   ` Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2007-11-07  0:15 UTC (permalink / raw)
  To: Werner LEMBERG; +Cc: emacs-devel

    I thus ask to handle files which start with

      '\"

    similar to shell scripts, this is, to take the *second* line for file
    variables.

It sounds ok to me, but does anyone see a likely problem?

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

* Re: file variables and man pages with preprocessors
  2007-11-07  0:15 ` Richard Stallman
@ 2007-11-07  4:01   ` Glenn Morris
  2007-11-07 16:39     ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2007-11-07  4:01 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

Richard Stallman wrote:

> It sounds ok to me, but does anyone see a likely problem?

It seems a little ugly to shoe-horn yet another special case in, when
local variables can just go at the end of the file.

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

* Re: file variables and man pages with preprocessors
  2007-11-07  4:01   ` Glenn Morris
@ 2007-11-07 16:39     ` Richard Stallman
  2007-11-08  0:54       ` Werner LEMBERG
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2007-11-07 16:39 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

    > It sounds ok to me, but does anyone see a likely problem?

    It seems a little ugly to shoe-horn yet another special case in, when
    local variables can just go at the end of the file.

It is a lot more convenient to use -*- -*- for something simple.

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

* Re: file variables and man pages with preprocessors
  2007-11-07 16:39     ` Richard Stallman
@ 2007-11-08  0:54       ` Werner LEMBERG
  2007-11-08 17:39         ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Werner LEMBERG @ 2007-11-08  0:54 UTC (permalink / raw)
  To: rms; +Cc: rgm, emacs-devel


>     It seems a little ugly to shoe-horn yet another special case in,
>     when local variables can just go at the end of the file.
> 
> It is a lot more convenient to use -*- -*- for something simple.

Well, preconv acts as a filter -- as do (almost) all components in
groff -- thus reading something from the `end of a file' (a) needs a
temporary buffer since the input data stream is `stdin' in most cases
and (b) isn't implemented in preconv due to (a).

Additionally, I'm not aware of any other special case except this one;
man pages act this way since at least 20 years AFAIK.


    Werner

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

* Re: file variables and man pages with preprocessors
  2007-11-08  0:54       ` Werner LEMBERG
@ 2007-11-08 17:39         ` Richard Stallman
  2007-11-09  7:27           ` Werner LEMBERG
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2007-11-08 17:39 UTC (permalink / raw)
  To: Werner LEMBERG; +Cc: rgm, emacs-devel

    Well, preconv acts as a filter -- as do (almost) all components in
    groff -- thus reading something from the `end of a file' (a) needs a
    temporary buffer since the input data stream is `stdin' in most cases
    and (b) isn't implemented in preconv due to (a).

I don't understand this.  What is preconv, and what does it have to do
with visiting these files in Emacs?

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

* Re: file variables and man pages with preprocessors
  2007-11-08 17:39         ` Richard Stallman
@ 2007-11-09  7:27           ` Werner LEMBERG
  2007-11-09 20:16             ` Glenn Morris
  2007-11-10 17:54             ` Richard Stallman
  0 siblings, 2 replies; 14+ messages in thread
From: Werner LEMBERG @ 2007-11-09  7:27 UTC (permalink / raw)
  To: rms; +Cc: rgm, emacs-devel

>     Well, preconv acts as a filter -- as do (almost) all components
>     in groff -- thus reading something from the `end of a file' (a)
>     needs a temporary buffer since the input data stream is `stdin'
>     in most cases and (b) isn't implemented in preconv due to (a).
> 
> I don't understand this.  What is preconv, and what does it have to
> do with visiting these files in Emacs?

`preconv' is a new preprocessor (currently in the CVS of groff only)
which converts man pages in any input encoding to something groff can
digest.  It supports the GNU Emacs convention for coding tags at the
beginning of a file but not at the end of a file for the reasons given
above.

Consider this example of troff.man (omitting some lines for brevity):

  '\" t
  .ig
    troff.man
    Copyright (C) ...
  ..
  .
  .TH TROFF 1 "2000-10-20" "Groff Version 1.2.3"
  .SH NAME
  troff \- the troff processor of the groff text formatting system

Here, the first line indicates that the `tbl' preprocessor is needed;
and the `man' program will call it due to this line.

Now assume that I want to have this man page in, say, German.  It how
has to start with

  '\" t
  .\" -*- coding: latin-1 -*-
  .ig
    troff.man
    Copyright (C) ...
  ..
  .
  .TH TROFF 1 "2000-10-20" "Groff Version 1.2.3"
  .SH NAME
  troff \- Der troff-Prozessor des groff-Textformatierungssystems

to use latin-1 (or another suitable encoding like utf-8).

Opening such a file currently in Emacs doesn't select the proper file
encoding.


    Werner

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

* Re: file variables and man pages with preprocessors
  2007-11-09  7:27           ` Werner LEMBERG
@ 2007-11-09 20:16             ` Glenn Morris
  2007-11-10 17:54             ` Richard Stallman
  1 sibling, 0 replies; 14+ messages in thread
From: Glenn Morris @ 2007-11-09 20:16 UTC (permalink / raw)
  To: Werner LEMBERG; +Cc: rms, emacs-devel

Werner LEMBERG wrote:

> `preconv' is a new preprocessor (currently in the CVS of groff only)
> which converts man pages in any input encoding to something groff can
> digest.  It supports the GNU Emacs convention for coding tags at the
> beginning of a file but not at the end of a file for the reasons given
> above.

You said this in your very first post and I totally missed it, sorry.
I think this makes the decision a no-brainer.

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

* Re: file variables and man pages with preprocessors
  2007-11-09  7:27           ` Werner LEMBERG
  2007-11-09 20:16             ` Glenn Morris
@ 2007-11-10 17:54             ` Richard Stallman
  2007-11-12  6:45               ` Werner LEMBERG
  1 sibling, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2007-11-10 17:54 UTC (permalink / raw)
  To: Werner LEMBERG; +Cc: rgm, emacs-devel

Thanks.  I think that explains enough.

Would someone please install this change?

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

* Re: file variables and man pages with preprocessors
  2007-11-10 17:54             ` Richard Stallman
@ 2007-11-12  6:45               ` Werner LEMBERG
  2007-11-12  8:50                 ` Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: Werner LEMBERG @ 2007-11-12  6:45 UTC (permalink / raw)
  To: rms; +Cc: rgm, emacs-devel


> Would someone please install this change?

If someone shows me where this should be handled, I'll fix it by
myself and apply the changes to the CVS.  I wasn't able to find the
location in the sources where the shebang is handled
w.r.t. recognizing the encoding tag.


    Werner

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

* Re: file variables and man pages with preprocessors
  2007-11-12  6:45               ` Werner LEMBERG
@ 2007-11-12  8:50                 ` Glenn Morris
  2007-11-12 11:20                   ` Werner LEMBERG
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2007-11-12  8:50 UTC (permalink / raw)
  To: Werner LEMBERG; +Cc: rms, emacs-devel

Werner LEMBERG wrote:

> If someone shows me where this should be handled, I'll fix it by
> myself and apply the changes to the CVS.  I wasn't able to find the
> location in the sources where the shebang is handled
> w.r.t. recognizing the encoding tag.

set-auto-mode-1 in files.el

If the #! special case is documented in the manuals, the \" one
probably should be too.

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

* Re: file variables and man pages with preprocessors
  2007-11-12  8:50                 ` Glenn Morris
@ 2007-11-12 11:20                   ` Werner LEMBERG
  2007-11-12 20:13                     ` Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: Werner LEMBERG @ 2007-11-12 11:20 UTC (permalink / raw)
  To: rgm; +Cc: rms, emacs-devel


> > If someone shows me where this should be handled, I'll fix it by
> > myself and apply the changes to the CVS.  I wasn't able to find
> > the location in the sources where the shebang is handled
> > w.r.t. recognizing the encoding tag.
> 
> set-auto-mode-1 in files.el

Thanks.  Here's what I'm planning to commit:


--- files.el.old	2007-11-11 14:20:14.000000000 +0100
+++ files.el	2007-11-12 12:19:03.000000000 +0100
@@ -2428,7 +2428,12 @@
                             ;; put them in the first line of
                             ;; such a file without screwing up
                             ;; the interpreter invocation.
-                            (and (looking-at "^#!") 2)) t)
+                            ;; The same holds for
+                            ;;   '\"
+                            ;; in man pages (preprocessor
+                            ;; magic for the `man' program).
+                            (and (or (looking-at "^#!")
+                                     (looking-at "^'\\\\\"")) 2)) t)
      (progn
        (skip-chars-forward " \t")
        (setq beg (point))


> If the #! special case is documented in the manuals, the \" one
> probably should be too.

Yes, will do.


    Werner

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

* Re: file variables and man pages with preprocessors
  2007-11-12 11:20                   ` Werner LEMBERG
@ 2007-11-12 20:13                     ` Glenn Morris
  2007-11-13 11:32                       ` Werner LEMBERG
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2007-11-12 20:13 UTC (permalink / raw)
  To: Werner LEMBERG; +Cc: rms, emacs-devel

Werner LEMBERG wrote:

> +                            (and (or (looking-at "^#!")
> +                                     (looking-at "^'\\\\\"")) 2)) t)

Why not (looking-at "^\\(#!\\|'\\\\\"\\)") ?

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

* Re: file variables and man pages with preprocessors
  2007-11-12 20:13                     ` Glenn Morris
@ 2007-11-13 11:32                       ` Werner LEMBERG
  0 siblings, 0 replies; 14+ messages in thread
From: Werner LEMBERG @ 2007-11-13 11:32 UTC (permalink / raw)
  To: rgm; +Cc: rms, emacs-devel


> Why not (looking-at "^\\(#!\\|'\\\\\"\\)") ?

OK.


    Werner

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

end of thread, other threads:[~2007-11-13 11:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-06  7:50 file variables and man pages with preprocessors Werner LEMBERG
2007-11-07  0:15 ` Richard Stallman
2007-11-07  4:01   ` Glenn Morris
2007-11-07 16:39     ` Richard Stallman
2007-11-08  0:54       ` Werner LEMBERG
2007-11-08 17:39         ` Richard Stallman
2007-11-09  7:27           ` Werner LEMBERG
2007-11-09 20:16             ` Glenn Morris
2007-11-10 17:54             ` Richard Stallman
2007-11-12  6:45               ` Werner LEMBERG
2007-11-12  8:50                 ` Glenn Morris
2007-11-12 11:20                   ` Werner LEMBERG
2007-11-12 20:13                     ` Glenn Morris
2007-11-13 11:32                       ` Werner LEMBERG

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