|
From: | Herbert Euler |
Subject: | Re: Fill for // style comments in C |
Date: | Tue, 28 Nov 2006 22:13:10 +0800 |
And if what are critical are `comment-start' and `comment-end', why not making `command-start' and `comment-end' for c-mode the same as c++-mode? The two languages support the same comment styles now. Regards, Guanpeng Xu
From: "Herbert Euler" <address@hidden> To: address@hidden, address@hiddenCC: address@hidden, address@hidden, address@hidden,address@hidden, address@hidden, address@hiddenSubject: Re: Fill for // style comments in C Date: Tue, 28 Nov 2006 20:34:53 +0800 How about this? *** cc-cmds.el.origal Tue Nov 28 20:31:16 2006 --- cc-cmds.el Tue Nov 28 20:30:53 2006 *************** (defun c-mask-paragraph (fill-paragraph *** 3897,3903 **** (prog1 (save-restriction (narrow-to-region beg end) ! (apply fun args)) (if point-rel ;; Restore point if it was outside the region. (if (< point-rel 0) --- 3897,3911 ---- (prog1 (save-restriction (narrow-to-region beg end) ! (let* ((comment-start (save-excursion ! (goto-char (point-min)) ! (if (looking-at "//") ! "//" ! comment-start))) ! (comment-end (if (string= comment-start "//") ! "" ! comment-end))) ! (apply fun args))) (if point-rel ;; Restore point if it was outside the region. (if (< point-rel 0) Regards, Guanpeng XuFrom: "Herbert Euler" <address@hidden> To: address@hidden, address@hiddenCC: address@hidden, address@hidden, address@hidden, address@hidden, address@hidden, address@hiddenSubject: Re: Fill for // style comments in C Date: Tue, 28 Nov 2006 19:35:59 +0800 I added (read-string (format "%s" `(apply ,fun ,args))) before and after invoking `apply': (prog1 (save-restriction (narrow-to-region beg end) (read-string (format "%s" `(apply ,fun ,args))) (apply fun args) (read-string (format "%s" `(apply ,fun ,args)))) And I put the point in between the following comment and pressed M-q: // A real long comment that will cause the fill command in Emacs I saw what is actually called is (apply fill-paragraph (nil)) But the behavior of `fill-paragraph' is not the same as when executing with pressing M-x fill-paragraph RET when the point is at the same point. Strange. Regards, Guanpeng XuFrom: "Herbert Euler" <address@hidden> To: address@hiddenCC: address@hidden, address@hidden, address@hidden,address@hidden, address@hidden, address@hiddenSubject: Re: Fill for // style comments in C Date: Tue, 28 Nov 2006 16:20:01 +0800 In the orignal code, (apply 'fill-paragraph '(nil)) will be called both for c-mode and c++-mode. And if you put point in between// A real long comment that will cause the fill command in Emacs making mistakes.and evaluate (apply 'fill-paragraph '(nil)) by pressing M-:, you will see that the comment is refilled correctly. CC mode seems doing more than just filling, but I don't have time to trace now. Regards, Guanpeng XuFrom: martin rudalics <address@hidden> To: Herbert Euler <address@hidden>CC: address@hidden, address@hidden, address@hidden, address@hidden, address@hidden, address@hiddenSubject: Re: Fill for // style comments in C Date: Mon, 27 Nov 2006 10:47:29 +0100 > And in c-mode, pressing M-q in between comments like this: >> // A real long comment that will cause the fill command in Emacs C mode> making mistakes. > > will get > > // A real long comment that will cause the fill command in Emacs C > mode making mistakes. It's because `c-fill-paragraph' calls `c-mask-paragraph' the latter calls `fill-paragraph' and `fill-paragraph' gets it wrong since it has `comment-end' set to " */" instead of nil. Does the attached workaround remove the problem?*** progmodes/cc-cmds.el Mon Nov 27 10:32:48 2006 --- progmodes/cc-cmds.el Mon Nov 27 10:33:20 2006 *************** *** 3897,3903 **** (prog1 (save-restriction (narrow-to-region beg end) ! (apply fun args)) (if point-rel ;; Restore point if it was outside the region. (if (< point-rel 0) --- 3897,3905 ---- (prog1 (save-restriction (narrow-to-region beg end) ! (if (eq c-lit-type 'c++) ! (apply 'fill-comment-paragraph args) ! (apply fun args))) (if point-rel ;; Restore point if it was outside the region. (if (< point-rel 0)_________________________________________________________________Don't just search. Find. Check out the new MSN Search! http://search.msn.com/_______________________________________________ Emacs-devel mailing list address@hidden http://lists.gnu.org/mailman/listinfo/emacs-devel_________________________________________________________________Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/_________________________________________________________________Don't just search. Find. Check out the new MSN Search! http://search.msn.com/_______________________________________________ Emacs-devel mailing list address@hidden http://lists.gnu.org/mailman/listinfo/emacs-devel
_________________________________________________________________Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
[Prev in Thread] | Current Thread | [Next in Thread] |