From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: lee Newsgroups: gmane.emacs.help Subject: solved: M-q on comments in source code Date: Sun, 25 May 2014 01:01:45 +0200 Organization: my virtual residence Message-ID: <87bnumwzl2.fsf_-_@yun.yagibdah.de> References: <87ppj3csrk.fsf@yun.yagibdah.de> <87ha4fawfm.fsf@yun.yagibdah.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1400973880 14365 80.91.229.3 (24 May 2014 23:24:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 May 2014 23:24:40 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 25 01:24:34 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 1WoLIk-0004dA-7i for geh-help-gnu-emacs@m.gmane.org; Sun, 25 May 2014 01:24:30 +0200 Original-Received: from localhost ([::1]:49641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoLIj-0002HR-Pe for geh-help-gnu-emacs@m.gmane.org; Sat, 24 May 2014 19:24:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoLIP-0002H5-U1 for help-gnu-emacs@gnu.org; Sat, 24 May 2014 19:24:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoLIL-0000zQ-23 for help-gnu-emacs@gnu.org; Sat, 24 May 2014 19:24:09 -0400 Original-Received: from client-194-42-186-216.muenet.net ([194.42.186.216]:37731 helo=yun.yagibdah.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoLIK-0000zE-QF for help-gnu-emacs@gnu.org; Sat, 24 May 2014 19:24:04 -0400 Original-Received: from lee by yun.yagibdah.de with local (Exim 4.80.1) (envelope-from ) id 1WoLIG-0001rX-0d for help-gnu-emacs@gnu.org; Sun, 25 May 2014 01:24:00 +0200 In-Reply-To: (Stefan Monnier's message of "Sat, 24 May 2014 14:50:04 -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:97836 Archived-At: Stefan Monnier writes: >> and my screen is wider than it is high, so it`s the opposite for me: > > I rarely look at a single file at a time, so wider windows means > fewer windows. Usually, I can fit two side by side and can split vertically when I need to. >> Source with long lines is easier to review than source with short, >> broken lines. > > We don't want them too short, indeed, which means not too > indented, mostly. I`m finding things easier to read with what you might call excessive indentation :) > This typically goes hand-in-hand with keeping functions/methods > reasonably short. Mostly, I`m writing things in LSL --- which is a scripting language somewhat similar to C. Such scripts are limited to 64kB each, and functions are big memory eaters, so you have to avoid them as much as you can :( It`s pretty horrible and makes for "lengthy" code like no sane programmer wants to write. I`m running the source through cpp and use #defines somewhat heavily, which helps a lot ... Anyway, here`s what I came up with: (defun my-fill-comment () (interactive) (save-excursion (beginning-of-line) (if (search-forward comment-start (line-end-position) t) (let ((orig-fill-column fill-column)) (setq fill-column (+ orig-fill-column (current-indentation))) (c-fill-paragraph) (setq fill-column orig-fill-column)) (c-fill-paragraph)))) I haven`t tested it much yet, but it seems to do what I want :) I`ll make a key binding for it and see how it turns out. Perhaps (re-search-forward (concat "^[:space:]*" comment-start) (line-end-position) t) is better, but I don`t plan on using the function on anything else than comments (starting with "//") anyway. -- Knowledge is volatile and fluid. Software is power.