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: Indentation and visual-line-mode Date: Fri, 25 Nov 2011 09:52:19 -0500 Message-ID: References: <878vn44kbi.fsf@tsdh.uni-koblenz.de> <83k46o8lmi.fsf@gnu.org> <87bos0l6ml.fsf@escher.home> <87sjlc2tpw.fsf@tsdh.uni-koblenz.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1322232753 32364 80.91.229.12 (25 Nov 2011 14:52:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 25 Nov 2011 14:52:33 +0000 (UTC) Cc: Eli Zaretskii , Stephen Berman , emacs-devel@gnu.org To: Tassilo Horn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 25 15:52:28 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RTx8e-0008Sb-0Q for ged-emacs-devel@m.gmane.org; Fri, 25 Nov 2011 15:52:28 +0100 Original-Received: from localhost ([::1]:55781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTx8d-0003gn-L2 for ged-emacs-devel@m.gmane.org; Fri, 25 Nov 2011 09:52:27 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTx8b-0003gi-2e for emacs-devel@gnu.org; Fri, 25 Nov 2011 09:52:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RTx8Z-0006yy-QB for emacs-devel@gnu.org; Fri, 25 Nov 2011 09:52:25 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:53838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RTx8Z-0006yr-M9; Fri, 25 Nov 2011 09:52:23 -0500 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id pAPEqJQM015960; Fri, 25 Nov 2011 09:52:19 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 64AF958D75; Fri, 25 Nov 2011 09:52:19 -0500 (EST) In-Reply-To: <87sjlc2tpw.fsf@tsdh.uni-koblenz.de> (Tassilo Horn's message of "Fri, 25 Nov 2011 14:54:19 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4052=0 X-NAI-Spam-Version: 2.2.0.9286 : core <4052> : streams <704703> : uri <1015404> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:146230 Archived-At: >>> (assuming you never want to change the indentation during editing). >> A while ago there was a thread about implementing a minor mode to get >> visual indentation with wrap-prefix using fill-context-prefix, in >> which I proposed an adaptation of the above; see >> . AFAIK there >> was no followup to my proposal. Indeed I didn't find the time to look at it and it ended up on my long list of "things to do when hell finally freezes over". > I've just tried that code, and it's exactly what I've been looking for. I've just looked at it and it looks really nice and simple. It can even be simplified further (see below). Sadly, this can't be generalized to programming languages, in the sense that you can't use foo-indent-calculate to set a wrap-prefix property since the wrap-prefix to use depends on the place where the line is wrapped. > I'd appreciate if that feature would ship with Emacs. It's too late for 24.1, but I've added it (under name "awp-mode.el" which provides adaptive-wrap-prefix-mode) to ELPA. Stefan (defun srb-adaptive-indent (beg end) "Indent the region between BEG and END with adaptive filling." (goto-char beg) (while (< (point) end) (let ((blp (line-beginning-position))) (put-text-property (point) (progn (search-forward "\n" end 'move) (point)) 'wrap-prefix (fill-context-prefix blp (point)))))) (define-minor-mode srb-adaptive-wrap-mode "Wrap the buffer text with adaptive filling." :lighter "" (if srb-adaptive-wrap-mode (jit-lock-register #'srb-adaptive-indent) (jit-lock-unregister #'srb-adaptive-indent) (with-silent-modifications (save-restriction (widen) (remove-text-properties (point-min) (point-max) '(wrap-prefix nil))))))