[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 97cb255: newcomment.el (comment-line): New command
From: |
Artur Malabarba |
Subject: |
[Emacs-diffs] master 97cb255: newcomment.el (comment-line): New command on C-x C-; . |
Date: |
Sun, 08 Feb 2015 19:03:38 +0000 |
branch: master
commit 97cb255360172980e7b79ed6a8cb35abbc58f897
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
newcomment.el (comment-line): New command on C-x C-;.
---
lisp/ChangeLog | 6 ++++++
lisp/bindings.el | 1 +
lisp/newcomment.el | 32 ++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b862d42..64424b7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-08 Artur Malabarba <address@hidden>
+
+ * newcomment.el (comment-line): New command.
+
+ * bindings.el (ctl-x-map): Bind to `C-x C-;'.
+
2015-02-08 Oleh Krehel <address@hidden>
* outline.el (outline-show-entry): Fix one invisible char for the
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 883914e..4cc9f6a 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -1130,6 +1130,7 @@ if `inhibit-field-text-motion' is non-nil."
(define-key esc-map "j" 'indent-new-comment-line)
(define-key esc-map "\C-j" 'indent-new-comment-line)
(define-key ctl-x-map ";" 'comment-set-column)
+(define-key ctl-x-map "C-;" 'comment-line)
(define-key ctl-x-map "f" 'set-fill-column)
(define-key ctl-x-map "$" 'set-selective-display)
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index e307eac..aabafc7 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1451,6 +1451,38 @@ unless optional argument SOFT is non-nil."
(end-of-line 0)
(insert comend))))))))))))
+;;;###autoload
+(defun comment-line (n)
+ "Comment or uncomment current line and leave point after it.
+With positive prefix, apply to N lines including current one.
+With negative prefix, apply to -N lines above. Also, further
+consecutive invocations of this command will inherit the negative
+argument.
+
+If region is active, comment lines in active region instead.
+Unlike `comment-dwim', this always comments whole lines."
+ (interactive "p")
+ (if (use-region-p)
+ (comment-or-uncomment-region
+ (save-excursion
+ (goto-char (region-beginning))
+ (line-beginning-position))
+ (save-excursion
+ (goto-char (region-end))
+ (line-end-position)))
+ (when (and (eq last-command 'comment-line-backward)
+ (natnump n))
+ (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)))
+
(provide 'newcomment)
;;; newcomment.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 97cb255: newcomment.el (comment-line): New command on C-x C-; .,
Artur Malabarba <=