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

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

RE: Is Elisp really that slow?


From: Drew Adams
Subject: RE: Is Elisp really that slow?
Date: Wed, 15 May 2019 10:29:42 -0700 (PDT)

> > And, as already mentioned, comment-dwim is not an
> > alternative to comment-region. They do different
> > things.
> 
> I beg to differ.

And your begged difference, which presumably shows
that they do NOT do different things, is what? ;-)

I have nothing special to say here about `C-c C-c'
or `cc-mode'.  But I will say I agree with Oscar
that `comment-dwim' and `comment-region' have
different behaviors - so neither is a substitute
for the other.

In particular, `comment-region' lets you also
uncomment, including unnest, comments.

I use both, and I bind each to a short key sequence.

More precisely, I leave `comment-dwim' on `M-;'
and I bind `C-x C-;' to a command similar to
`comment-region' but that I find more useful:
`comment-region-lines'.  It comments/uncomments
whole lines.

(So it too differs from `comment-region' - so it
too is not an exact "replacement".)

As for key bindings:

Although I haven't bothered to change the binding of
`M-;', I think it's a shame and a waste to sacrifice
such a nice, short, _repeatable_ key sequence for a
command that does _nothing_ when you repeat it.

Far better to use `M-;' for some command that keeps
doing something when repeated (just hold down `M-;').
That's what Emacs should do eventually, IMHO.  No
urgency, but someday, when we find a really useful
repeatable command...

As for `comment-dwim': Since I use `C-x C-;'
(`comment-region-lines') for block commenting and
uncommenting, I never really use `M-;' for anything
other than an end-of-line comment.

`M-;' used to be bound to a command that did only
that: `indent-for-comment'.  And since that's all
I really use `M-;' for, the rest of `comment-dwim'
is, yes, wasted and replaceable by `comment-region'
or my `comment-region-line'.  `M-;' for eol comment,
`C-x C-;' for commenting/uncommenting lines.

(defun comment-region-lines (beg end &optional arg)
  "Like `comment-region', but comment/uncomment whole lines."
  (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 via email to

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