unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] newcomment.el (comment-line): New command.
@ 2015-01-26 19:17 Artur Malabarba
  2015-01-26 22:41 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Artur Malabarba @ 2015-01-26 19:17 UTC (permalink / raw)
  To: emacs-devel; +Cc: Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 1276 bytes --]

Is there any particular reason why there's no `comment-line' command in Emacs?
If not, I'd like to propose the following patch to newcomment.el


---
 lisp/ChangeLog     |  4 ++++
 lisp/newcomment.el | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ff352a2..9e6d18f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2015-01-26  Artur Malabarba  <bruce.connor.am@gmail.com>
+
+    * newcomment.el (comment-line): New command.
+
 2015-01-26  Stefan Monnier  <monnier@iro.umontreal.ca>


diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index e307eac..8f6ac5a 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1451,6 +1451,18 @@ 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."
+  (interactive "p")
+  (comment-or-uncomment-region
+   (line-beginning-position)
+   (goto-char (line-end-position n)))
+  (forward-line 1)
+  (back-to-indentation))
+
 (provide 'newcomment)

 ;;; newcomment.el ends here
-- 
2.2.2

[-- Attachment #2: 0001-newcomment.el-comment-line-New-command.patch --]
[-- Type: text/x-patch, Size: 1340 bytes --]

From 5e30c5c5b4120123a98021f49062ec5e39c083dc Mon Sep 17 00:00:00 2001
From: Artur Malabarba <bruce.connor.am@gmail.com>
Date: Mon, 26 Jan 2015 17:11:24 -0200
Subject: [PATCH] newcomment.el (comment-line): New command.

---
 lisp/ChangeLog     |  4 ++++
 lisp/newcomment.el | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ff352a2..9e6d18f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2015-01-26  Artur Malabarba  <bruce.connor.am@gmail.com>
+
+	* newcomment.el (comment-line): New command.
+
 2015-01-26  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index e307eac..8f6ac5a 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1451,6 +1451,18 @@ 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."
+  (interactive "p")
+  (comment-or-uncomment-region
+   (line-beginning-position)
+   (goto-char (line-end-position n)))
+  (forward-line 1)
+  (back-to-indentation))
+
 (provide 'newcomment)
 
 ;;; newcomment.el ends here
-- 
2.2.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-02-02 17:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2015-02-02 12:02           ` Artur Malabarba
2015-02-02  7:01         ` Thierry Volpiatto
2015-02-02 17:17         ` Stefan Monnier

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