unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: bruce.connor.am@gmail.com
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel <emacs-devel@gnu.org>
Subject: RE: [PATCH] newcomment.el (comment-line): New command.
Date: Sun, 1 Feb 2015 13:40:28 -0800 (PST)	[thread overview]
Message-ID: <e554ef37-3ac4-4ae7-a30d-78a96d21a892@default> (raw)
In-Reply-To: <CAAdUY-J-MAF0E3_vQ2xO0yxxq-VR7Z8qnuL49_=y6En0ezZQZA@mail.gmail.com>

> FWIW, the command I suggested is indeed repeatable because it moves
> `forward-line' after commenting the line. So you can just invoke it
> repeatedly to comment several lines (for those who don't use prefix
> arguments).

My bad; I didn't notice that it was repeatable.

Yes, that's useful, and yes, it makes sense to use a repeatable key.
Maybe `C-;'.  (Fits with the repeatable versions of `C-a' and `C-e'
that I use. ;-))

Consider letting a negative prefix arg be carried over to
repetitions, so you can do C-- C-; C-; C-; ... to do it
backwards.  Currently you need to do C-- C-; C-- C-; C-- C-; ...

E.g., something like this:

(defun comment-line (n)
  "Comment or uncomment current line and leave point after it.
With positive prefix arg, apply to N lines including current one.
With negative prefix arg, apply to -N lines above.
When repeated, a negative prefix arg switches direction."
  (interactive "p")
  (when (eq last-command 'comment-line-backward) (setq n (- n)))
  (let ((range (list (line-beginning-position)
                     (goto-char (line-end-position n)))))
    (comment-or-uncomment-region
     (apply #'min range)
     (apply #'max range)))
  (forward-line 1)
  (back-to-indentation)
  (unless (natnump n) (setq this-command 'comment-line-backward)))



  reply	other threads:[~2015-02-01 21:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 19:17 [PATCH] newcomment.el (comment-line): New command Artur Malabarba
2015-01-26 22:41 ` Stefan Monnier
2015-01-27  2:35   ` Artur Malabarba
2015-01-27  2:53     ` Drew Adams
2015-02-01 19:48       ` Artur Malabarba
2015-02-01 21:40         ` Drew Adams [this message]
2015-02-02 12:02           ` Artur Malabarba
2015-02-02  7:01         ` Thierry Volpiatto
2015-02-02 17:17         ` Stefan Monnier

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=e554ef37-3ac4-4ae7-a30d-78a96d21a892@default \
    --to=drew.adams@oracle.com \
    --cc=bruce.connor.am@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).