From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: line/wrap-prefix patch Date: Sat, 05 Jul 2008 21:05:08 -0400 Message-ID: References: <61zlp3k2xx.fsf@fencepost.gnu.org> <87abh1i6xm.fsf@escher.local.home> <8763rlpe4u.fsf@escher.local.home> <87d4lt5f0e.fsf@catnip.gol.com> <87bq1cggs5.fsf@escher.local.home> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1215306350 5712 80.91.229.12 (6 Jul 2008 01:05:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Jul 2008 01:05:50 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stephen Berman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 06 03:06:36 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KFIi3-0006bD-UR for ged-emacs-devel@m.gmane.org; Sun, 06 Jul 2008 03:06:36 +0200 Original-Received: from localhost ([127.0.0.1]:42485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFIhB-0003IZ-SF for ged-emacs-devel@m.gmane.org; Sat, 05 Jul 2008 21:05:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KFIh7-0003IK-2n for emacs-devel@gnu.org; Sat, 05 Jul 2008 21:05:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KFIh4-0003I8-U9 for emacs-devel@gnu.org; Sat, 05 Jul 2008 21:05:35 -0400 Original-Received: from [199.232.76.173] (port=39812 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFIh4-0003I5-O1 for emacs-devel@gnu.org; Sat, 05 Jul 2008 21:05:34 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:65125 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KFIh4-0007UP-4h for emacs-devel@gnu.org; Sat, 05 Jul 2008 21:05:34 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai8GAJG3b0hFxIdG/2dsb2JhbACBXKpDggM X-IronPort-AV: E=Sophos;i="4.30,308,1212379200"; d="scan'208";a="24006040" Original-Received: from 69-196-135-70.dsl.teksavvy.com (HELO pastel.home) ([69.196.135.70]) by ironport2-out.teksavvy.com with ESMTP; 05 Jul 2008 21:05:09 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 410A8806F; Sat, 5 Jul 2008 21:05:08 -0400 (EDT) In-Reply-To: <87bq1cggs5.fsf@escher.local.home> (Stephen Berman's message of "Sat, 05 Jul 2008 23:30:50 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100377 Archived-At: > (defun srb-adaptive-indent (beg end) > "Indent the region between BEG and END with adaptive filling." > (goto-char beg) > (let ((lbp (line-beginning-position)) > (lep (line-end-position))) > (put-text-property lbp lep 'wrap-prefix (fill-context-prefix lbp lep))) > (while (re-search-forward "\n" (point-max) t) > (forward-char) > (let ((lbp (line-beginning-position)) > (lep (line-end-position))) > (put-text-property lbp lep 'wrap-prefix (fill-context-prefix lbp lep))))) Toi avoid code-duplication: (defun srb-adaptive-indent (beg end) "Indent the region between BEG and END with adaptive filling." (goto-char beg) (while (let ((lbp (line-beginning-position)) (lep (line-end-position))) (put-text-property lbp lep 'wrap-prefix (fill-context-prefix lbp lep)) (search-forward "\n" end t)))) Actually this also fixes a "point-max vs end" confusion, and removes a `forward-char' which didn't seem necessary. > (setq word-wrap nil)) Actually, this minor-mode seems independent from word-wrap, so it had better not touch word-wrap at all. Similarly, I'm not sure that fringe-indicator-alist should be touched here. > (set-buffer-modified-p mod))))) You should use restore-buffer-modified-p instead. Stefan