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: Ergus
Subject: Re: Is Elisp really that slow?
Date: Wed, 15 May 2019 22:09:30 +0200
User-agent: NeoMutt/20180716

On Wed, May 15, 2019 at 12:53:43PM -0700, Drew Adams wrote:
>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.

To no waste bindings we could just modify comment-region to accept
negative prefix to uncomment. So C-- M-; uncoments region, and M-;
comments it.

I don't get your point.  `comment-region' already
uncomments, with plain `C-u'.

But now there will come another user saying that the dwim
version is better... we will never agree in anything this way.

The point was that both `M-;' and `comment-region'
are useful, and that neither substitutes for the other.
It doesn't matter which one someone think is "better".
They're both available.

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

This is the king of features I would really support. Enable line or
region by default. There is a package for that in melpa y find very
useful.

I proposed it long ago to emacs-devel.  Other,
similar commands were also discussed.  Emacs-devel
decided not to go there (by adding such a command
or by giving it - or even `comment-region' - a
binding by default).  Apparently it was thought
that `M-;' is sufficient.  Giving something a DWIM
name makes it universally useful, I guess. ;-)

Well, `comment-region' still does have a "key"
binding in vanilla Emacs (at least in some modes),
but not a _keyboard_ key binding:

But that's the point. The common features in emacs should have the same
base behavior independently of the mode (comment region, hungry deletion
indent region, send to terminal (compile and execute)/ send mail/ commit)

comment-region is on <menu-bar> <emacs-lisp> <comment-region>




reply via email to

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