[Top][All Lists]

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

Re: skeleton.el machinery eats newlines.

From: Luc Teirlinck
Subject: Re: skeleton.el machinery eats newlines.
Date: Sun, 19 Jan 2003 22:25:43 -0600 (CST)

I did not realize that the subject I initiated in another thread
(sh-script.el and magic numbers) had already been discussed before.
It was not my intention to rediscuss issues on which a decision had
already been made.  That decision was that sh-script.el should not
rely on shell scripts starting with any kind of comment, magic or
other.  It seems to me that the very fact that the subject seems
controversial indicates that this decision was correct, since we are
in the business of helping people write in whichever style they
choose, not in the business of prescribing programming styles (except,
of course, for stuff submitted for inclusion in Emacs).

Given that, however, we have at least one problem.  (I now believe
that the other two problems I referred to, but did not elaborate on,
can both be solved, by the user, by giving sh-shell-file a file local
value, so I will not go into these.)

This leaves the "Beginning of buffer" problem.  Trying sh-case
(normally bound to C-c C-c) at the very beginning of the buffer pretty
soon aborts with this error.  Nothing wrong with sh-case or skeletons,
`sh-get-indent-info' is to blame, as I reported earlier in this thread.
(I really should have made a separate thread out of this, it has
nothing to do with skeleton.el.)  I could repost my bug reports from
more than a week ago if this would seem useful.

The problem is, as I explained earlier, that sh-get-indent-info does a
(forward-char -1) at the beginning of the buffer.  I first (naively)
tried (unless (bobp) (forward-char -1)), but this was not good
enough.  For a correct return value (and hence for correct
indentation, in particular of the case form) point really needs to be
at position 0, just before the beginning of the buffer.

One obvious (but probably contorted and inelegant) way in which the
problem can be solved is to add a newline at the beginning of the
buffer at the start of sh-get-indent-info, erase it at the end of that
function and then replace the resulting (t NUMBER) by (t (1- NUMBER)).

A more elegant solution seems to require a good understanding of the
entire sh-script.el indentation mechanism.  At present, I do not have
the time to start studying that mechanism.  I have the impression that
anybody familiar with that mechanism could come up with a much more
elegant solution than the one described above.  However, I could
implement that solution if it would be considered acceptable and
nobody would come up with a better one.  (I believe that the only
problem with that solution is its stylistic inelegance.)



reply via email to

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