From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: lee Newsgroups: gmane.emacs.help Subject: Re: M-q on comments in source code Date: Sat, 24 May 2014 20:00:45 +0200 Organization: my virtual residence Message-ID: <87ha4fawfm.fsf@yun.yagibdah.de> References: <87ppj3csrk.fsf@yun.yagibdah.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1400954587 18387 80.91.229.3 (24 May 2014 18:03:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 May 2014 18:03:07 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat May 24 20:03:00 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WoGHb-0005oA-Hx for geh-help-gnu-emacs@m.gmane.org; Sat, 24 May 2014 20:02:59 +0200 Original-Received: from localhost ([::1]:48951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoGHb-0002hK-5s for geh-help-gnu-emacs@m.gmane.org; Sat, 24 May 2014 14:02:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoGH1-0002Fk-I4 for help-gnu-emacs@gnu.org; Sat, 24 May 2014 14:02:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoGGv-0008Vn-B2 for help-gnu-emacs@gnu.org; Sat, 24 May 2014 14:02:23 -0400 Original-Received: from client-194-42-186-216.muenet.net ([194.42.186.216]:37584 helo=yun.yagibdah.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoGGv-0008VW-30 for help-gnu-emacs@gnu.org; Sat, 24 May 2014 14:02:17 -0400 Original-Received: from lee by yun.yagibdah.de with local (Exim 4.80.1) (envelope-from ) id 1WoGGo-00013M-Nt for help-gnu-emacs@gnu.org; Sat, 24 May 2014 20:02:10 +0200 In-Reply-To: (Stefan Monnier's message of "Sat, 24 May 2014 10:21:54 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) Mail-Followup-To: help-gnu-emacs@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.42.186.216 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97823 Archived-At: Stefan Monnier writes: >> This formatting is a bit silly ... What can I do to get the comments >> formatted as in the first example, i. e. the comment indented with the >> source but with each line trimmed to a length of about max 75 >> characters, not counting the indentation? > > I find this to be a waste of space (you'll need windows > larger than 80 columns to comfortably edit/browse such files), The lines in the source can easily get longer than 80 cpl, and my screen is wider than it is high, so it`s the opposite for me: Source with long lines is easier to review than source with short, broken lines. And there`s astyle ... ;; ;; astyle buffer ... ;; (defun astyle-buffer (mcl) "Ask for code length and pipe all buffer contents through astyle and replace with the output from astyle, then do whitespace-cleanup." (interactive "nMax code length: ") (shell-command-on-region (point-min) (point-max) (format "astyle --max-code-length=%d" mcl) nil t 'shell-command-default-error-buffer t) (whitespace-cleanup)) ... which does break long lines but doesn`t put broken lines back together. (I have an .astylerc with some settings I like.) > but if you really want that you can probably get it with something > like: > > (advice-add 'current-file-column :around > (lambda (orig) > (if (derived-mode-p 'c-mode) > (+ fill-column (current-indentation)) > (funcall orig)))) Hmm, yes, this is like Eli suggested, thank you :) I think I can come up with a function that is called instead of c-fill-paragraph, adjusts fill-column when comments are formatted, calls c-fill-paragraph and resets fill-column. That should work ... I`ll post it once I wrote it. -- Knowledge is volatile and fluid. Software is power.