From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Idea: unify *newline(-and-indent) Date: Sun, 31 Aug 2008 05:37:46 -0400 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v926) Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1220175498 5329 80.91.229.12 (31 Aug 2008 09:38:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 31 Aug 2008 09:38:18 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 31 11:39:13 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 1KZjOh-0006Ih-Df for ged-emacs-devel@m.gmane.org; Sun, 31 Aug 2008 11:39:03 +0200 Original-Received: from localhost ([127.0.0.1]:51269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KZjNi-0003tN-Gz for ged-emacs-devel@m.gmane.org; Sun, 31 Aug 2008 05:38:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KZjNa-0003qt-Vx for emacs-devel@gnu.org; Sun, 31 Aug 2008 05:37:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KZjNY-0003pl-St for emacs-devel@gnu.org; Sun, 31 Aug 2008 05:37:54 -0400 Original-Received: from [199.232.76.173] (port=34833 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KZjNY-0003pg-Lj for emacs-devel@gnu.org; Sun, 31 Aug 2008 05:37:52 -0400 Original-Received: from vpn.merrillpress.com ([64.61.107.78]:35879) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KZjNY-0002g7-4P for emacs-devel@gnu.org; Sun, 31 Aug 2008 05:37:52 -0400 Original-Received: from cpe-76-180-38-217.buffalo.res.rr.com ([76.180.38.217] helo=[192.168.1.103]) by mars.merrillpress.net with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1KZjNW-0007ye-D0 for emacs-devel@gnu.org; Sun, 31 Aug 2008 05:37:50 -0400 X-Mailer: Apple Mail (2.926) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) 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:103306 Archived-At: The newline situation has annoyed me for a long time. Before fixing =20 it, I figure I'll float the idea here and see what kind of reception I =20= get. In emacs CVS, I found these functions: ada-indent-newline-indent-conditional align-newline-and-indent c-context-line-break c-newline-and-indent electric-pascal-terminate-line electric-verilog-terminate-and-indent electric-verilog-terminate-line html-paragraph idlwave-newline m2-newline message-newline-and-reformat newline newline-and-indent octave-reindent-then-newline-and-indent reindent-then-newline-and-indent table--cell-newline-and-indent vera-electric-return vhdl-electric-return I'm not even counting all the modes that aren't in CVS, or all the =20 (reindent-)newline(-and-indent) functions grep couldn't find. Why do =20 we need so many functions for essentially the same thing? Recently, I =20= tried seeing whether I could make newline not kill trailing =20 whitespace. I'd have to rewrite the newline function quite a few major =20= modes, and the solution would still be brittle. Why not unify all the newline-and-friends functions? - Cull the above list to three functions interactive-newline (new function) newline-and-indent reindent-then-newline-and-indent - Change the C-m binding in bindings.el to interactive-newline. - Define a new variable, interactive-newline-function, which defaults =20= to #'newline. (The existing #'newline would stay the same for backward =20 compatibility. I see 122 direct calls to (newline) in current CVS, and =20= I bet the callers wouldn't like new behavior.) Change newline-and-indent and reindent-then-newline-and-indent to call =20= interactive-newline instead of newline. Have interactive-newline call =20= interactive-newline-function. (Which is plain old #'newline by =20 default, remember.) Then, take all the functions above and convert them to functions that =20= can be plugged into interactive-newline-function. The situation we end =20= up with something like indent-for-tab-command and indent-line-function. Is it worth writing the patch? Thanks, Dan (Also =96 any objections to making cc-mode and lisp-mode use indent-for-=20= tab-command? The lisp tab command has an indent-whole-sexp feature, but that be handled by passing the =20 prefix argument to indent-line-function. The cc-mode indent function =20 has some tab-or-indent DWIM feature, but isn't it better to put that =20 in indent-for-tab-command by extending tab-always-indent?)