emacs-devel
[Top][All Lists]
Advanced

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

Re: comment-dwim has no behavior to comment out the current line without


From: Will Farrington
Subject: Re: comment-dwim has no behavior to comment out the current line without a region
Date: Wed, 10 Dec 2008 07:22:58 -0500

On second inspection, C-M-; is not bound by default.

How would you feel about binding the following function to that keybinding?

(defun comment-dwim-line (&optional arg)
  ""
  (interactive "*P")
  (comment-normalize-vars)
  (if (not (region-active-p))
      (comment-or-uncomment-region (line-beginning-position) (line-end-position))
    (comment-dwim arg)))

Obviously a better description than "" is needed, but the behavior of this has changed a bit since it can now afford to (being a different function and keybinding). Rather than relying on the position of (point), it has a clear established behavior of commenting out the current line unless the region is active.

On Dec 9, 2008, at 2:48 PM, Stefan Monnier wrote:

Generally speaking, what makes BOL a "common starting point" to perform
comment-indent more-so than any other part of the line?

I'm not sure it's much more so, but it's at least as common as
current-indentation, end of line, etc...

Additionally, is not BOL semantically the clearest place to run comment-dwim
and expect it to comment out a given line rather than having it run
comment-indent?

Could be.  I'm not saying your idea isn't good.  I'm just saying that it
is not compatible with the current behavior and that the current
behavior makes sense as well.  You may find some other way to combine
comment-indent, comment-kill, and comment-region onto a single key.
E.g. M-; M-; is currently unused.


       Stefan


reply via email to

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