unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* hungry-delete in other modes
@ 2011-02-23  1:21 Christoph
  2011-02-23  1:48 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph @ 2011-02-23  1:21 UTC (permalink / raw)
  To: emacs-devel

I really like the hungry-delete minor mode that cc-mode provides, so I
would like to have it in other modes, specifically Python mode.

Right now, this does not seem to possible easily, because python-mode
does not inherit from cc-mode, correct?

I can do 

(require 'cc-mode)
(global-set-key (kbd "C-<delete>") 'c-hungry-delete-forward)
(global-set-key (kbd "C-<backspace>") 'c-hungry-delete-backwards)

which enables the hungry-delete globally, but I would like to have some
more finer control over the behavior and set it up in a mode-hook, like
python-mode-hook.

Is there any reason why hungry-delete mode (or subword mode or
auto-newline mode for that matter) is so tightly coupled with cc-mode?
Would it be possible to decouple them and make the functionality
available to other modes as a minor mode instead of them being just
"minor-mode-like features" in cc-mode?

Christoph



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

* Re: hungry-delete in other modes
  2011-02-23  1:21 hungry-delete in other modes Christoph
@ 2011-02-23  1:48 ` Stefan Monnier
  2011-02-23  2:23   ` Nathaniel Flath
  2011-02-24  5:58   ` Christoph
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Monnier @ 2011-02-23  1:48 UTC (permalink / raw)
  To: Christoph; +Cc: emacs-devel

> I really like the hungry-delete minor mode that cc-mode provides, so I
> would like to have it in other modes, specifically Python mode.

For DEL at least, you can

  (global-set-key [?\^?] 'backward-delete-char-untabify)

and even control it via buffer-local settings of
backward-delete-char-untabify-method.

> Is there any reason why hungry-delete mode (or subword mode or
> auto-newline mode for that matter) is so tightly coupled with cc-mode?

Because the CC-mode author wanted to provide the feature to all CC-mode
users and/or did not make the effort to try and submit this feature for
separate inclusion in Emacs.

> Would it be possible to decouple them and make the functionality
> available to other modes as a minor mode instead of them being just
> "minor-mode-like features" in cc-mode?

Of course it's possible.  As a matter of fact we do have subword-mode,
as well as electric-layout-mode.


        Stefan



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

* Re: hungry-delete in other modes
  2011-02-23  1:48 ` Stefan Monnier
@ 2011-02-23  2:23   ` Nathaniel Flath
  2011-02-24  6:00     ` Christoph
  2011-02-24  5:58   ` Christoph
  1 sibling, 1 reply; 5+ messages in thread
From: Nathaniel Flath @ 2011-02-23  2:23 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Christoph, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]

I actually ran into this before, and ended up moving the necessary machinery
out of cc-mode into it's own mode.  You can take a look at
https://github.com/nflath/hungry-delete

Thanks,
Nathaniel Flath
On Tue, Feb 22, 2011 at 8:48 PM, Stefan Monnier <monnier@iro.umontreal.ca>wrote:

> > I really like the hungry-delete minor mode that cc-mode provides, so I
> > would like to have it in other modes, specifically Python mode.
>
> For DEL at least, you can
>
>  (global-set-key [?\^?] 'backward-delete-char-untabify)
>
> and even control it via buffer-local settings of
> backward-delete-char-untabify-method.
>
> > Is there any reason why hungry-delete mode (or subword mode or
> > auto-newline mode for that matter) is so tightly coupled with cc-mode?
>
> Because the CC-mode author wanted to provide the feature to all CC-mode
> users and/or did not make the effort to try and submit this feature for
> separate inclusion in Emacs.
>
> > Would it be possible to decouple them and make the functionality
> > available to other modes as a minor mode instead of them being just
> > "minor-mode-like features" in cc-mode?
>
> Of course it's possible.  As a matter of fact we do have subword-mode,
> as well as electric-layout-mode.
>
>
>        Stefan
>
>

[-- Attachment #2: Type: text/html, Size: 1805 bytes --]

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

* Re: hungry-delete in other modes
  2011-02-23  1:48 ` Stefan Monnier
  2011-02-23  2:23   ` Nathaniel Flath
@ 2011-02-24  5:58   ` Christoph
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph @ 2011-02-24  5:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> For DEL at least, you can
>
>   (global-set-key [?\^?] 'backward-delete-char-untabify)
>
> and even control it via buffer-local settings of
> backward-delete-char-untabify-method.

I didnt know about backward-delete-char-untabify-method. I will have a
look at that.

> Because the CC-mode author wanted to provide the feature to all CC-mode
> users and/or did not make the effort to try and submit this feature for
> separate inclusion in Emacs.

So no technical or historical reason.

> Of course it's possible.  As a matter of fact we do have subword-mode,
> as well as electric-layout-mode.

It looks like subword-mode was created from cc-subword.el.It looks like
the hungry delete functions are pretty self contained and could be
factored out into a separate mode pretty easily. Maybe something to look
into for a future project.

Thanks,
Christoph



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

* Re: hungry-delete in other modes
  2011-02-23  2:23   ` Nathaniel Flath
@ 2011-02-24  6:00     ` Christoph
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph @ 2011-02-24  6:00 UTC (permalink / raw)
  To: Nathaniel Flath; +Cc: emacs-devel

Nathaniel Flath <flat0103@gmail.com> writes:

> I actually ran into this before, and ended up moving the necessary
> machinery out of cc-mode into it's own mode.
> You can take a look athttps://github.com/nflath/hungry-delete

Interesting. I will give that a try. Thanks!

Christoph



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

end of thread, other threads:[~2011-02-24  6:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-23  1:21 hungry-delete in other modes Christoph
2011-02-23  1:48 ` Stefan Monnier
2011-02-23  2:23   ` Nathaniel Flath
2011-02-24  6:00     ` Christoph
2011-02-24  5:58   ` Christoph

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).