From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?iso-8859-1?q?R=F6hler?= Newsgroups: gmane.emacs.bugs Subject: Re: comment-kill can't deal with following situation Date: Sun, 2 Mar 2008 17:12:04 +0100 Message-ID: <200803021712.05386.andreas.roehler@online.de> References: <198A33EB1E9E344EBC566802C7761D6B4ACE3C@CNSHGSMBS04.ad4.ad.alcatel.com> <86hcfps0c2.fsf@163.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_VHtyHnW+J/lIDRc" X-Trace: ger.gmane.org 1204474260 5333 80.91.229.12 (2 Mar 2008 16:11:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Mar 2008 16:11:00 +0000 (UTC) Cc: lgfang To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 02 17:11:25 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JVqmQ-0003Dr-DN for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Mar 2008 17:11:14 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVqlt-0000ZS-Dy for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Mar 2008 11:10:41 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JVqln-0000Yt-LT for bug-gnu-emacs@gnu.org; Sun, 02 Mar 2008 11:10:35 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JVqlm-0000YP-3z for bug-gnu-emacs@gnu.org; Sun, 02 Mar 2008 11:10:35 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVqll-0000YK-Ue for bug-gnu-emacs@gnu.org; Sun, 02 Mar 2008 11:10:33 -0500 Original-Received: from moutng.kundenserver.de ([212.227.126.187]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JVqll-0007Su-Dk for bug-gnu-emacs@gnu.org; Sun, 02 Mar 2008 11:10:33 -0500 Original-Received: from noname (p54BE9B61.dip0.t-ipconnect.de [84.190.155.97]) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis) id 0MKwtQ-1JVqlj0FQo-0005fR; Sun, 02 Mar 2008 17:10:31 +0100 User-Agent: KMail/1.9.5 In-Reply-To: <86hcfps0c2.fsf@163.com> X-Provags-ID: V01U2FsdGVkX18YGaxW0w/kVUk0wtGXAZprER9FrfTeKSr5NNC mAYtATKX1O6F723N/zo4QoKKQOw2AyEKLU7ExsARvMRgEzSWAl NwLFG7YtotX4qMwc2UHsQ== X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:17638 Archived-At: --Boundary-00=_VHtyHnW+J/lIDRc Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Am Sonntag, 2. M=E4rz 2008 14:49 schrieb lgfang: > int j; /* comment 1 */ int k; /* comment 2*/ Herewith a patch. It relies at the fact, that if a comment was removed, variable `cs' was set before with `(cs (comment-search-forward`. Performs a recursive call as long that's true on a given line. As the argument only make sense as a numeric one, I used interactive lesser p. That prevents another bug, which would occur with this fix otherwise. HTH Andreas R=F6hler =20 --Boundary-00=_VHtyHnW+J/lIDRc Content-Type: text/x-diff; charset="iso-8859-1"; name="comment-kill.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="comment-kill.diff" --- old/newcomment.el 2008-01-08 21:44:45.000000000 +0100 +++ new/newcomment.el 2008-03-02 16:45:34.000000000 +0100 @@ -679,9 +679,9 @@ (defun comment-kill (arg) "Kill the comment on this line, if any. With prefix ARG, kill comments on that many lines starting with this one." - (interactive "P") + (interactive "p") (comment-normalize-vars) - (dotimes (_ (prefix-numeric-value arg)) + (dotimes (_ arg) (save-excursion (beginning-of-line) (let ((cs (comment-search-forward (line-end-position) t))) @@ -691,8 +691,10 @@ (setq cs (point)) (comment-forward) (kill-region cs (if (bolp) (1- (point)) (point))) - (indent-according-to-mode)))) - (if arg (forward-line 1)))) + (indent-according-to-mode) + (comment-kill 1)))) + (setq arg (1- arg)) + (when (< 0 arg) (forward-line 1)))) (defun comment-padright (str &optional n) "Construct a string composed of STR plus `comment-padding'. Diff finished. Sun Mar 2 16:45:53 2008 --Boundary-00=_VHtyHnW+J/lIDRc--