unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 24982@debbugs.gnu.org, Stefan Kangas <stefan@marxist.se>
Subject: bug#24982: 24.5; way to let Elisp reader ignore unreadable #(...) constructs
Date: Sat, 22 Aug 2020 15:44:02 -0700 (PDT)	[thread overview]
Message-ID: <29a39702-e355-4b00-9805-53f098bc1d40@default> (raw)
In-Reply-To: <87pn7ih2y9.fsf@gnus.org>

You bring up a few things.  I'll comment only about
commenting. ;-)

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

Yes, CL block commenting is fully nestable and unnestable.

(IMO, that's really the point/advantage of block commenting.)

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

Possibly; dunno.

[Aside: I think it would be great if Elisp had reader
macros - give Lisp programs control over the Lisp reader.]
 
> So ... 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.

Yes.  Well, we do have such a feature, but we don't have
it by just inserting paired delimiters.

We have it with `comment-region' (and similar).  How so?
Plain `C-u' UNcomments/unnests a given comment level.

One difference, besides the paired-delimiter one (but
which follows from it), is that you can't do it with
the same effect in-line.

Another is that because a single `;' comments to eol,
syntactically there's no essential difference among
`;', `;;', `;;;', etc.  And yet the commenting and
UNcommenting of `comment-region' give you the
additional control of how many `;' to work with.

E.g., you can "uncomment" by N `;', which may uncomment
some code and leave other code commented (which had M>N
`;').  But that's also what makes `comment-region' and
its `C-u' give you block-commenting behavior.

That's how I use `comment-region' - for block commenting
and uncommenting - unnesting a block of commented code.

And it's why I use `M-;' (`comment-dwim') ONLY for a
comment after a line of code.  I don't use it to comment
the region as a block comment.  Its behavior when the
region consists only of comments is different from its
region behavior otherwise.  And I don't want that.
___


Actually, instead of `comment-region' for block commenting
I use this, which is the same except it comments/uncomments
whole lines.

(defun comment-region-lines (beg end &optional arg)
  (interactive "*r\nP")
  (when (> beg end) (setq beg  (prog1 end (setq end  beg))))
  (let ((bol  (save-excursion
                (goto-char beg)
                (line-beginning-position)))
        (eol  (save-excursion
                (goto-char end)
                (if (bolp) (point) (line-end-position)))))
    (comment-region bol eol arg)))





  reply	other threads:[~2020-08-22 22:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21 21:47 bug#24982: 24.5; way to let Elisp reader ignore unreadable #(...) constructs Drew Adams
2018-04-02 19:32 ` Juri Linkov
2018-04-02 20:31   ` Drew Adams
2018-04-02 20:54     ` Juri Linkov
2018-04-02 21:32       ` Drew Adams
2018-04-03 20:06         ` Juri Linkov
2020-08-22 19:13 ` Stefan Kangas
2020-08-22 19:17   ` Lars Ingebrigtsen
2020-08-22 19:28     ` Drew Adams
2020-08-22 19:53       ` Lars Ingebrigtsen
2020-08-22 22:44         ` Drew Adams [this message]
2020-08-22 19:25   ` Drew Adams
2022-02-13  8:46 ` Lars Ingebrigtsen
2022-02-13 17:33   ` bug#24982: [External] : " Drew Adams
2022-02-13 17:53     ` Lars Ingebrigtsen
2022-02-13 18:03       ` Drew Adams
2022-02-14  4:15   ` Richard Stallman
2022-04-30 17:01     ` Lars Ingebrigtsen
2022-04-30 17:26       ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29a39702-e355-4b00-9805-53f098bc1d40@default \
    --to=drew.adams@oracle.com \
    --cc=24982@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).