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: comment-dwim on blank lines Date: Fri, 02 Nov 2007 07:45:49 +0100 Message-ID: <472AC79D.8090804@gmx.at> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060908080108000305040507" X-Trace: ger.gmane.org 1193986141 24334 80.91.229.12 (2 Nov 2007 06:49:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 2 Nov 2007 06:49:01 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 02 07:49:03 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 1InqKz-0007xN-Ip for ged-emacs-devel@m.gmane.org; Fri, 02 Nov 2007 07:49:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1InqKp-0005EB-8S for ged-emacs-devel@m.gmane.org; Fri, 02 Nov 2007 02:48:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1InqKm-0005Ds-50 for emacs-devel@gnu.org; Fri, 02 Nov 2007 02:48:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1InqKl-0005De-GB for emacs-devel@gnu.org; Fri, 02 Nov 2007 02:48:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1InqKl-0005Db-Dn for emacs-devel@gnu.org; Fri, 02 Nov 2007 02:48:47 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1InqKk-0007SJ-Jo for emacs-devel@gnu.org; Fri, 02 Nov 2007 02:48:47 -0400 Original-Received: (qmail invoked by alias); 02 Nov 2007 06:48:44 -0000 Original-Received: from N912P010.adsl.highway.telekom.at (EHLO [62.47.57.234]) [62.47.57.234] by mail.gmx.net (mp028) with SMTP; 02 Nov 2007 07:48:44 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1939GNQm5V3MIe1RIXUGOihHvmK8oQ6Dsos7Rw9V4 BOJNmPhmHIAaQP 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: by monty-python.gnu.org: 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:82342 Archived-At: This is a multi-part message in MIME format. --------------060908080108000305040507 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Glen, if you're going to spend some time on newcomment please have a look at the below. I once asked Stefan but apparently he forgot. With emacs -Q customize `comment-style' to box or box-multi. In *scratch* insert (foo bar baz) set the region around bar and do `comment-region'. Gets you (foo ;; bar ;; baz) instead of (foo ;; bar ;; baz) Responsible is the (when block (unless ce (setq ce (comment-string-reverse cs)))) line in `comment-region-internal' which makes the subsequent (unless (or ce (eolp)) (insert "\n") (indent-according-to-mode)) fail. I proposed the attached patch. --------------060908080108000305040507 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) --------------060908080108000305040507 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 --------------060908080108000305040507--