From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: How to use c-style to comment a region? Date: Thu, 10 May 2007 10:50:20 +0200 Message-ID: <4642DCCC.2020003@gmx.at> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070308080401020309090008" X-Trace: sea.gmane.org 1178787440 5869 80.91.229.12 (10 May 2007 08:57:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 May 2007 08:57:20 +0000 (UTC) Cc: emacs-devel@gnu.org To: William Xue Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 10 10:57:19 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hm4Sb-0005Kp-Ie for ged-emacs-devel@m.gmane.org; Thu, 10 May 2007 10:57:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hm4Zr-0005x1-SX for ged-emacs-devel@m.gmane.org; Thu, 10 May 2007 05:04:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hm4ZO-0005Sk-8h for emacs-devel@gnu.org; Thu, 10 May 2007 05:04:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hm4ZL-0005SK-Ec for emacs-devel@gnu.org; Thu, 10 May 2007 05:04:16 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hm4ZL-0005SD-0i for emacs-devel@gnu.org; Thu, 10 May 2007 05:04:15 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Hm4S2-00086w-AC for emacs-devel@gnu.org; Thu, 10 May 2007 04:56:42 -0400 Original-Received: (qmail invoked by alias); 10 May 2007 08:56:39 -0000 Original-Received: from N740P022.adsl.highway.telekom.at (EHLO [62.47.36.118]) [62.47.36.118] by mail.gmx.net (mp037) with SMTP; 10 May 2007 10:56:39 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18ytMdBEnQyeKO/ZNI7grpA7zNw+hpfNoupwSGPn3 3pKxaonqT4dB7F User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: X-Y-GMX-Trusted: 0 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:70739 Archived-At: This is a multi-part message in MIME format. --------------070308080401020309090008 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > That's not my request, I only want a command or a keybinding. You could try to bind (defun my-cpp-comment-region (beg end &optional arg) (interactive "*r\nP") (let ((comment-start "/* ") (comment-end " */")) (comment-region beg end arg))) to a key. BTW with comment-styles box / box-multi and newline terminated comment syntax `comment-region' comments out the entire text from the beginning of the region till EOL. The attached patch should cure that. --------------070308080401020309090008 Content-Type: text/plain; name="new-comment.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="new-comment.patch" *** newcomment.el.~1.101.~ Mon Apr 2 07:45:08 2007 --- newcomment.el Thu May 10 10:38:22 2007 *************** *** 926,941 **** the region rather than at left margin." ;;(assert (< beg end)) (let ((no-empty (not (or (eq comment-empty-lines t) ! (and comment-empty-lines (zerop (length ce))))))) ;; Sanitize CE and CCE. (if (and (stringp ce) (string= "" ce)) (setq ce nil)) (if (and (stringp cce) (string= "" cce)) (setq cce nil)) ;; If CE is empty, multiline cannot be used. (unless ce (setq ccs nil cce nil)) ;; Should we mark empty lines as well ? (if (or ccs block lines) (setq no-empty nil)) ;; Make sure we have end-markers for BLOCK mode. ! (when block (unless ce (setq ce (comment-string-reverse cs)))) ;; If BLOCK is not requested, we don't need CCE. (unless block (setq cce nil)) ;; Continuation defaults to the same as CS and CE. --- 926,943 ---- the region rather than at left margin." ;;(assert (< beg end)) (let ((no-empty (not (or (eq comment-empty-lines t) ! (and comment-empty-lines (zerop (length ce)))))) ! ce-sanitized) ;; Sanitize CE and CCE. (if (and (stringp ce) (string= "" ce)) (setq ce nil)) + (setq ce-sanitized ce) (if (and (stringp cce) (string= "" cce)) (setq cce nil)) ;; If CE is empty, multiline cannot be used. (unless ce (setq ccs nil cce nil)) ;; Should we mark empty lines as well ? (if (or ccs block lines) (setq no-empty nil)) ;; Make sure we have end-markers for BLOCK mode. ! (when (and block (not ce)) (setq ce (comment-string-reverse cs))) ;; If BLOCK is not requested, we don't need CCE. (unless block (setq cce nil)) ;; Continuation defaults to the same as CS and CE. *************** *** 945,951 **** (goto-char end) ;; If the end is not at the end of a line and the comment-end ;; is implicit (i.e. a newline), explicitly insert a newline. ! (unless (or ce (eolp)) (insert "\n") (indent-according-to-mode)) (comment-with-narrowing beg end (let ((min-indent (point-max)) (max-indent 0)) --- 947,954 ---- (goto-char end) ;; If the end is not at the end of a line and the comment-end ;; is implicit (i.e. a newline), explicitly insert a newline. ! (unless (or ce-sanitized (eolp)) ! (insert "\n") (indent-according-to-mode)) (comment-with-narrowing beg end (let ((min-indent (point-max)) (max-indent 0)) *************** *** 1163,1169 **** (buffer-substring (point) (progn (move-to-left-margin) (point))))))))))))) ! ;;;###autoload (defun comment-indent-new-line (&optional soft) --- 1166,1172 ---- (buffer-substring (point) (progn (move-to-left-margin) (point))))))))))))) ! ;;;###autoload (defun comment-indent-new-line (&optional soft) --------------070308080401020309090008 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------070308080401020309090008--