[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: narrow-to-here-document

From: David Kastrup
Subject: Re: narrow-to-here-document
Date: 21 Jun 2003 10:01:31 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

"Stephen J. Turnbull" <address@hidden> writes:

> >>>>> "Masatake" == Masatake YAMATO <address@hidden> writes:
>     >> But are there any other modes with here-docs?
>     Masatake> As far as I know ruby lang has "here document".
>     Masatake> ruby-mode doesn't handle here document region now.
> Any language (Python or Emacs-Lisp, for examples) with multi-line
> strings effectively has here-docs.  My version of Emacs doesn't
> support either narrow-to-string or mark-string AFAICT, so maybe this
> would be a good time to add those, too.

TeX is one particular contestant.  There are forms of "Literate
Programming" with a heavy mixture of code and comments, but every
reference manual contains C code passages, shell scripts and similar
stuff.  An excerpt:

That way, several specialized sort routines may be defined with
different names in the same module.  C++ templates the ugly way.

listptr *listsort(listptr *head,   /* pointer to head of list */
                  size_t n,    /* number of elements to sort */
                  size_t linkoffs, /* offset of link in structure */
                  int (*compar)(const void *, const void *)
                                   /* comparison routine */
The body will have to start with a few declarations.

  size_t underpow,n1,n2,bitrev;
  int lev, kmax;


You get the drift.  And inside of those passages, indentation and
editing should reign that is governed by C mode.  In essence, what
would be best is if editing effectively could happen in a virtual
buffer constituted of all the code passages in C, with C indentation
over the continued passages, and keybindings.

Literate programming can even mean TeX immersed into TeX: so-called
dtx documents look like this:

%  This is a nuisance since we have to advise \emph{both} the
%  environment and its end.
%    \begin{macrocode}
   \csname address@hidden@endparse}%
   \csname end#2\endcsname{\endgroup}}
%    \end{macrocode}
%  Ok, this looks complicated, but we have to start a group in order
%  to be able to hook address@hidden into the game only when

Again, indentation and other context (environment open and closing,
something akin to verbose brace matching) should effectually happen in
virtual buffers that contain only a selected subset of the file in

David Kastrup, Kriemhildstr. 15, 44793 Bochum

reply via email to

[Prev in Thread] Current Thread [Next in Thread]