unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Idea: unify *newline(-and-indent)
@ 2008-08-31  9:28 Daniel Colascione
  2008-08-31 13:59 ` Daniel Colascione
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Colascione @ 2008-08-31  9:28 UTC (permalink / raw)
  To: emacs-devel

The newline situation has annoyed me for a long time. Before fixing  
it, I figure I'll float the idea here and see what kind of reception I  
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  
(reindent-)newline(-and-indent) functions grep couldn't find. Why do  
we need so many functions for essentially the same thing? Recently, I  
tried seeing whether I could make newline not kill trailing  
whitespace. I'd have to rewrite the newline function quite a few major  
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  
to #'newline.

(The existing #'newline would stay the same for backward  
compatibility. I see 122 direct calls to (newline) in current CVS, and  
I bet the callers wouldn't like new behavior.)

Change newline-and-indent and reindent-then-newline-and-indent to call  
interactive-newline instead of newline. Have interactive-newline call  
interactive-newline-function. (Which is plain old #'newline by  
default, remember.)

Then, take all the functions above and convert them to functions that  
can be plugged into interactive-newline-function. The situation we end  
up with something like indent-for-tab-command and indent-line-function.

Is it worth writing the patch?

Thanks,
Dan

(Also – any objections to making cc-mode and lisp-mode use indent-for- 
tab-command? The lisp tab command
has an indent-whole-sexp feature, but that be handled by passing the  
prefix argument to indent-line-function. The cc-mode indent function  
has some tab-or-indent DWIM feature, but isn't it better to put that  
in indent-for-tab-command by extending tab-always-indent?)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Idea: unify *newline(-and-indent)
@ 2008-08-31  9:37 Daniel Colascione
  2008-08-31 11:59 ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Colascione @ 2008-08-31  9:37 UTC (permalink / raw)
  To: emacs-devel

The newline situation has annoyed me for a long time. Before fixing  
it, I figure I'll float the idea here and see what kind of reception I  
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  
(reindent-)newline(-and-indent) functions grep couldn't find. Why do  
we need so many functions for essentially the same thing? Recently, I  
tried seeing whether I could make newline not kill trailing  
whitespace. I'd have to rewrite the newline function quite a few major  
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  
to #'newline.

(The existing #'newline would stay the same for backward  
compatibility. I see 122 direct calls to (newline) in current CVS, and  
I bet the callers wouldn't like new behavior.)

Change newline-and-indent and reindent-then-newline-and-indent to call  
interactive-newline instead of newline. Have interactive-newline call  
interactive-newline-function. (Which is plain old #'newline by  
default, remember.)

Then, take all the functions above and convert them to functions that  
can be plugged into interactive-newline-function. The situation we end  
up with something like indent-for-tab-command and indent-line-function.

Is it worth writing the patch?

Thanks,
Dan

(Also – any objections to making cc-mode and lisp-mode use indent-for- 
tab-command? The lisp tab command
has an indent-whole-sexp feature, but that be handled by passing the  
prefix argument to indent-line-function. The cc-mode indent function  
has some tab-or-indent DWIM feature, but isn't it better to put that  
in indent-for-tab-command by extending tab-always-indent?)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Idea: unify *newline(-and-indent)
  2008-08-31  9:37 Daniel Colascione
@ 2008-08-31 11:59 ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-08-31 11:59 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: emacs-devel

Daniel Colascione wrote:
> Then, take all the functions above and convert them to functions that
> can be plugged into interactive-newline-function. The situation we end
> up with something like indent-for-tab-command and indent-line-function.
> 
> Is it worth writing the patch?
> 
> Thanks,
> Dan

I think this would be very good.

Users that normally use several different major could benefit. This is
of course often the case in web development.

> (Also – any objections to making cc-mode and lisp-mode use
> indent-for-tab-command? The lisp tab command
> has an indent-whole-sexp feature, but that be handled by passing the
> prefix argument to indent-line-function. The cc-mode indent function has
> some tab-or-indent DWIM feature, but isn't it better to put that in
> indent-for-tab-command by extending tab-always-indent?)

In my opinion, yes.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Idea: unify *newline(-and-indent)
  2008-08-31  9:28 Idea: unify *newline(-and-indent) Daniel Colascione
@ 2008-08-31 13:59 ` Daniel Colascione
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Colascione @ 2008-08-31 13:59 UTC (permalink / raw)
  To: emacs-devel

On Aug 31, 2008, at 5:28 AM, Daniel Colascione wrote:
> The newline situation has annoyed me for a long time.

Also, duplicated messages. Sorry about the spam.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-31 13:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-31  9:28 Idea: unify *newline(-and-indent) Daniel Colascione
2008-08-31 13:59 ` Daniel Colascione
  -- strict thread matches above, loose matches on Subject: below --
2008-08-31  9:37 Daniel Colascione
2008-08-31 11:59 ` Lennart Borgman (gmail)

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).