unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Will Farrington <wcfarrington@gmail.com>
To: emacs-devel@gnu.org, Will Farrington <wcfarrington@gmail.com>
Subject: Re: comment-dwim has no behavior to comment out the current line without a region
Date: Tue, 9 Dec 2008 04:22:38 -0500	[thread overview]
Message-ID: <747769BF-A786-42C9-B35B-CA29F599FFA8@gmail.com> (raw)
In-Reply-To: <492E5CDD-4C3A-4995-97DD-C2A65133F8D5@gmail.com>

It seems that for whatever reason the .patch got treated as binary  
data. Here's the patch in-line:

 From b3a783075ad4eafe9e2303442d68f6bec41cfaa6 Mon Sep 17 00:00:00 2001
From: Will Farrington <wcfarrington@gmail.com>
Date: Tue, 9 Dec 2008 01:00:18 -0500
Subject: [PATCH] Change comment-dwim behavior to comment out the  
current line when region is inactive and point is at the line- 
beginning-position.


diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 91ece5a..acac17b 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1159,6 +1159,9 @@ is passed on to the respective function."
  If the region is active and `transient-mark-mode' is on, call
    `comment-region' (unless it only consists of comments, in which
    case it calls `uncomment-region').
+Else, if the point is at `line-beginning-position', call `comment- 
region'
+  on the whole line (unless the line consists of comments, in which
+  case it calls `uncomment-region').
  Else, if the current line is empty, call `comment-insert-comment- 
function'
  if it is defined, otherwise insert a comment and indent it.
  Else if a prefix ARG is specified, call `comment-kill'.
@@ -1168,23 +1171,25 @@ You can configure `comment-style' to change  
the way regions are commented."
    (comment-normalize-vars)
    (if (and mark-active transient-mark-mode)
        (comment-or-uncomment-region (region-beginning) (region-end)  
arg)
-    (if (save-excursion (beginning-of-line) (not (looking-at "\\s-* 
$")))
-	;; FIXME: If there's no comment to kill on this line and ARG is
-	;; specified, calling comment-kill is not very clever.
-	(if arg (comment-kill (and (integerp arg) arg)) (comment-indent))
-      ;; Inserting a comment on a blank line. comment-indent calls
-      ;; c-i-c-f if needed in the non-blank case.
-      (if comment-insert-comment-function
-          (funcall comment-insert-comment-function)
-        (let ((add (comment-add arg)))
-          ;; Some modes insist on keeping column 0 comment in column 0
-          ;; so we need to move away from it before inserting the  
comment.
-          (indent-according-to-mode)
-          (insert (comment-padright comment-start add))
-          (save-excursion
-            (unless (string= "" comment-end)
-              (insert (comment-padleft comment-end add)))
-            (indent-according-to-mode)))))))
+    (if (eq (point) (line-beginning-position))
+        (comment-or-uncomment-region (line-beginning-position) (line- 
end-position))
+      (if (save-excursion (beginning-of-line) (not (looking-at "\\s-* 
$")))
+          ;; FIXME: If there's no comment to kill on this line and  
ARG is
+          ;; specified, calling comment-kill is not very clever.
+          (if arg (comment-kill (and (integerp arg) arg)) (comment- 
indent))
+        ;; Inserting a comment on a blank line. comment-indent calls
+        ;; c-i-c-f if needed in the non-blank case.
+        (if comment-insert-comment-function
+            (funcall comment-insert-comment-function)
+          (let ((add (comment-add arg)))
+            ;; Some modes insist on keeping column 0 comment in  
column 0
+            ;; so we need to move away from it before inserting the  
comment.
+            (indent-according-to-mode)
+            (insert (comment-padright comment-start add))
+            (save-excursion
+              (unless (string= "" comment-end)
+                (insert (comment-padleft comment-end add)))
+              (indent-according-to-mode))))))))

  ;;;###autoload
  (defcustom comment-auto-fill-only-comments nil
-- 
1.6.0.4


On Dec 9, 2008, at 3:28 AM, Will Farrington wrote:

> Resending this because it seems to have gotten lost along the way  
> (at least from what I could tell):
> --------------
>
> The subject states my specific objection to the current behavior.
>
> Yes, for many languages, it takes the same number of keystrokes to  
> insert a comment character; however, there are languages/modes where  
> this is *not* true (for example, C89 or anything based on XML).  
> Additionally, it makes sense to have comment-dwim handle all cases  
> of managing commented material and comments.
>
> The proposed diff adds the following additional behavior:
>
> If the point is at `line-beginning-position' (and the region is  
> inactive), call `comment-region'
> on the whole line (unless the line consists of comments, in which
> case it calls `uncomment-region').
>
> The patch is attached below:
> <0001-Change-comment-dwim-behavior-to-comment-out-the-curr.patch>





  reply	other threads:[~2008-12-09  9:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-09  6:06 comment-dwim has no behavior to comment out the current line without a region Will Farrington
2008-12-09  8:28 ` Will Farrington
2008-12-09  9:22   ` Will Farrington [this message]
2008-12-09 12:40   ` Eli Zaretskii
2008-12-09 18:27     ` Stefan Monnier
2008-12-09 22:54       ` Eli Zaretskii
2008-12-09 18:40 ` Stefan Monnier
2008-12-09 18:50   ` Will Farrington
2008-12-09 19:48     ` Stefan Monnier
2008-12-09 20:03       ` Will Farrington
2008-12-10 12:22       ` Will Farrington
2008-12-11 15:27         ` Stefan Monnier
2008-12-11 18:26           ` Ted Zlatanov

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=747769BF-A786-42C9-B35B-CA29F599FFA8@gmail.com \
    --to=wcfarrington@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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).