bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#24982: 24.5; way to let Elisp reader ignore unreadable #(...) constr


From: Lars Ingebrigtsen
Subject: bug#24982: 24.5; way to let Elisp reader ignore unreadable #(...) constructs
Date: Sat, 22 Aug 2020 21:53:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Drew Adams <drew.adams@oracle.com> writes:

>> In Common Lisp, this is the #| ...  |# operator, and it's handy
>> occasionally.  It's really like a nesting comment thing...
>
> Good point.  I was thinking of #(...), but yes,
> the situation is more general.  It's about #
> syntax that's found to be invalid, but for cases
> where # nevertheless can tell where the sexp
> parsing should end (and so can advance point there).

Yup.

I couldn't quite remember whether the Common Lisp #| |# was balanced,
but it is, which is nice.  That is, you can write

#| foo #| bar |# zot |#

and the first |# doesn't end the first #|.

Digression: While Googling, I was reminded that Common Lisp also has

#+condition
(foo:bar)

which (possibly) ignores the next sexp...  which is handy in Common
Lisp, but Emacs doesn't need it.  Common Lisp needs it because reference
to an unloaded package is a read error, instead of an undefined error.
Which is a really bad design choice.  That is, you can't say
(if (fboundp 'foo:bar) ...) if foo is a package that isn't loaded --
it's a read error.

Digression over!

I'm not an expert on the Emacs Lisp reader, but poking at it at bit, it
seems like adding support for #| |# should be trivial: It's just a new
comment syntax, really, so we just have to count #|'s and discard the
input.

A bigger issue would be in emacs-lisp-mode -- having forward-sexp etc do
the right thing.  However, surely that's handled already in the Common
Lisp modes, so we could just crib code from those, I'd have thought...

So I think it's doable, which only leaves us with the question: What's
the use case?

Well, I think it's handy when developing.  If I'm in the middle of a
function

...
(foo)
(bar)
(and-here-i'm-adding-some-new-stuff-that's-not-finished
  ...
  )
(zot)
...

and I'm testing stuff, and I decide to take out the stuff I'm
writing...  Emacs doesn't really handle that well.  I usually end up
deleting the sexp, and hoping that the kill ring is big enough to hold
it until I need it again, or slapping a (when nil ...) around it, which
is unsatisfactory, because that changes the indentation.

Just being able to do:

...
(foo)
(bar)
#|
(and-here-i'm-adding-some-new-stuff-that's-not-finished
  ...
  )
|#
(zot)
...

would be nice.  And then the stuff I'm working on doesn't even have to
be syntactically correct.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

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