From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: lgfang Newsgroups: gmane.emacs.bugs Subject: Re: comment-kill can't deal with following situation Date: Fri, 29 Feb 2008 19:02:16 +0800 Message-ID: <86tzjsqb47.fsf@163.com> References: <198A33EB1E9E344EBC566802C7761D6B4ACE3C@CNSHGSMBS04.ad4.ad.alcatel.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1204297081 9631 80.91.229.12 (29 Feb 2008 14:58:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 Feb 2008 14:58:01 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 29 15:58:26 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 1JV6gQ-0005Yc-K9 for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Feb 2008 15:57:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JV6fu-0003UE-84 for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Feb 2008 09:57:26 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JV3l8-0001K0-Cj for bug-gnu-emacs@gnu.org; Fri, 29 Feb 2008 06:50:38 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JV3l6-0001HJ-JX for bug-gnu-emacs@gnu.org; Fri, 29 Feb 2008 06:50:38 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JV3l6-0001H6-BD for bug-gnu-emacs@gnu.org; Fri, 29 Feb 2008 06:50:36 -0500 Original-Received: from m12-12.163.com ([220.181.12.12]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1JV3l5-0006V2-4T for bug-gnu-emacs@gnu.org; Fri, 29 Feb 2008 06:50:36 -0500 Original-Received: from fbbox (unknown [122.4.109.23]) by smtp8 (Coremail) with SMTP id DMCowLCLLBLV5sdH5Bm6HQ==.18773S2; Fri, 29 Feb 2008 19:04:59 +0800 (CST) In-Reply-To: <198A33EB1E9E344EBC566802C7761D6B4ACE3C@CNSHGSMBS04.ad4.ad.alcatel.com> (FANG Ark's message of "Fri\, 29 Feb 2008 10\:37\:25 +0800") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (berkeley-unix) X-Coremail-Antispam: 1Uf129KBjvJXoW7Cr47AF17ury7KrWfKr1kuFg_yoW8Xw1kpF 4fArWfArWDXw17JFyktr17Zryjqwn5Jr4UJry5Kr97AF1qy348tr4UtrWrAr9xXrWDGF4U tF4ftrn8WF4UJF7anT9S1TB71UUUUUUv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjlCc7 Ca8VAvwVA2a4k0FcxrMxkFs20EY4vE77kJMc02F40EFcxC0VAKzVAqx4xG6I80ewAFF20E 14v26r1j6r4UM7C26xCjj4IEI4klw4CSwwAFxVCaYxvI4VCIwcAKzIAtM7CIcVAFz4kK6r 1j6r18McIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwCjxxvEw4Wl c2IjII80xcxEwVAKI48JMxCjnVAqn7xvrwC2zVAF1VAY17CE14v26r1j6r15M7k0a2IF6r 1UM7kC6x804xJvcSsGvfC2KfnxnUUI43ZEXa7IU1Lih7UUUUU== X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-Greylist: delayed 2718 seconds by postgrey-1.27 at monty-python; Fri, 29 Feb 2008 06:50:30 EST X-Mailman-Approved-At: Fri, 29 Feb 2008 09:56:34 -0500 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:17621 Archived-At: Hi, comment-kill is defined in newcomment.el. It is supposed to kill comments (refer to its document). But it can't deal with the cases in which there are more than one comment in a line. An example is: --------8<----------------8<-------- void f(){ int i; /* this will be killed */ int j; /* oops, this one won't be killed */ } --------8<----------------8<-------- I check the code and think it is due to lack of loop. It seems that following fix works. But maybe there are better fixes. --------8<------Fixed comment-kill ----------8<-------- (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") (comment-normalize-vars) (dotimes (_ (prefix-numeric-value arg)) (save-excursion (beginning-of-line) (let ((line-num (line-number-at-pos)) (cs (comment-search-forward (line-end-position) t))) (while cs (goto-char cs) (skip-syntax-backward " ") (setq cs (point)) (comment-forward) (kill-region cs (if (bolp) (1- (point)) (point))) (indent-according-to-mode) (when (= line-num (line-number-at-pos)) ; still in the line (setq cs (comment-search-forward (line-end-position) t)))))) (if arg (forward-line 1)))) --------8<----------------8<-------- In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600) of 2007-06-02 on RELEASE Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include' Regards, Fang, lungang