unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* hungry-delete
@ 2011-04-04 17:19 Andreas Röhler
  2011-04-04 18:20 ` hungry-delete Sam Steingold
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Röhler @ 2011-04-04 17:19 UTC (permalink / raw)
  To: Emacs developers


Hi,

at

https://bugs.launchpad.net/python-mode/+bug/328853

we got the following request:

"I really love the hungry-delete feature of Emacs'
c-mode. It would be great to have hungry-delete for
python-mode as well."

IMO it's neither C nor Python specific.
Should be useful for all edits. What about moving it into simple.el or 
have a hungry-delete.el?

Thanks


Andreas

--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/



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

* Re: hungry-delete
  2011-04-04 17:19 hungry-delete Andreas Röhler
@ 2011-04-04 18:20 ` Sam Steingold
  2011-04-04 18:54   ` hungry-delete Andreas Röhler
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Steingold @ 2011-04-04 18:20 UTC (permalink / raw)
  To: emacs-devel

> * Andreas Röhler <naqernf.ebruyre@bayvar.qr> [2011-04-04 19:19:52 +0200]:
>
> https://bugs.launchpad.net/python-mode/+bug/328853
>
> "I really love the hungry-delete feature of Emacs'
> c-mode. It would be great to have hungry-delete for
> python-mode as well."

DEL (translated from <backspace>) runs the command
backward-delete-char-untabify, which is an interactive compiled Lisp
function in `simple.el'.

It is bound to DEL.

(backward-delete-char-untabify ARG &optional KILLP)

Delete characters backward, changing tabs into spaces.
The exact behavior depends on `backward-delete-char-untabify-method'.
Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil.
Interactively, ARG is the prefix arg (default 1)
and KILLP is t if a prefix arg was specified.

backward-delete-char-untabify-method is a variable defined in `simple.el'.
Its value is all
Original value was untabify

Documentation:
The method for untabifying when deleting backward.
Can be `untabify' -- turn a tab to many spaces, then delete one space;
       `hungry' -- delete all whitespace, both tabs and spaces;
       `all' -- delete all whitespace, including tabs, spaces and newlines;
       nil -- just delete one character.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 20.3 of Emacs.




-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.5 (Final) X
http://ffii.org http://memri.org http://www.PetitionOnline.com/tap12009/
http://palestinefacts.org http://www.memritv.org http://camera.org
I just forgot my whole philosophy of life!!!




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

* Re: hungry-delete
  2011-04-04 18:20 ` hungry-delete Sam Steingold
@ 2011-04-04 18:54   ` Andreas Röhler
  2011-04-04 19:00     ` hungry-delete Sam Steingold
  2011-04-05 16:11     ` hungry-delete Andrew W. Nosenko
  0 siblings, 2 replies; 8+ messages in thread
From: Andreas Röhler @ 2011-04-04 18:54 UTC (permalink / raw)
  To: emacs-devel; +Cc: Sam Steingold

Am 04.04.2011 20:20, schrieb Sam Steingold:
>> * Andreas Röhler<naqernf.ebruyre@bayvar.qr>  [2011-04-04 19:19:52 +0200]:
>>
>> https://bugs.launchpad.net/python-mode/+bug/328853
>>
>> "I really love the hungry-delete feature of Emacs'
>> c-mode. It would be great to have hungry-delete for
>> python-mode as well."
>
> DEL (translated from<backspace>) runs the command
> backward-delete-char-untabify, which is an interactive compiled Lisp
> function in `simple.el'.
>
> It is bound to DEL.
>
> (backward-delete-char-untabify ARG&optional KILLP)
>
> Delete characters backward, changing tabs into spaces.
> The exact behavior depends on `backward-delete-char-untabify-method'.
> Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil.
> Interactively, ARG is the prefix arg (default 1)
> and KILLP is t if a prefix arg was specified.
>
> backward-delete-char-untabify-method is a variable defined in `simple.el'.
> Its value is all
> Original value was untabify
>
> Documentation:
> The method for untabifying when deleting backward.
> Can be `untabify' -- turn a tab to many spaces, then delete one space;
>         `hungry' -- delete all whitespace, both tabs and spaces;
>         `all' -- delete all whitespace, including tabs, spaces and newlines;
>         nil -- just delete one character.
>
> You can customize this variable.
>
> This variable was introduced, or its default value was changed, in
> version 20.3 of Emacs.
>
>
>
>

Hi,

thanks for the hint.
However don't think customizing DEL does it.
In most cases you will use DEL as `untabify'.

"Hungry" eates a lot - that's is fine, but not as taking the common DEL.

Therefore think a seperate key for hungry-delete is needed.

However, seems it must not be copied from the scratch.
What about such a thing:

(defun hunry-delete  (&optional killp)
   "Delete characters backward, changing tabs into spaces.

Kill (save in kill ring) if KILLP is non-nil.
  "
   (interactive "P")
   (let ((backward-delete-char-untabify-method 'all))
     (backward-delete-char-untabify 1 killp)))


;;;;;;;;



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

* Re: hungry-delete
  2011-04-04 18:54   ` hungry-delete Andreas Röhler
@ 2011-04-04 19:00     ` Sam Steingold
  2011-04-04 20:02       ` hungry-delete Andreas Röhler
  2011-04-05 16:11     ` hungry-delete Andrew W. Nosenko
  1 sibling, 1 reply; 8+ messages in thread
From: Sam Steingold @ 2011-04-04 19:00 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: emacs-devel

> * Andreas Röhler <naqernf.ebruyre@bayvar.qr> [2011-04-04 20:54:45 +0200]:
>
> Am 04.04.2011 20:20, schrieb Sam Steingold:
>>> * Andreas Röhler<naqernf.ebruyre@bayvar.qr>  [2011-04-04 19:19:52 +0200]:
>>>
>>> https://bugs.launchpad.net/python-mode/+bug/328853
>>>
>>> "I really love the hungry-delete feature of Emacs'
>>> c-mode. It would be great to have hungry-delete for
>>> python-mode as well."
>>
>> DEL (translated from<backspace>) runs the command
>> backward-delete-char-untabify
>>
>> backward-delete-char-untabify-method is a variable defined in `simple.el'.
>> The method for untabifying when deleting backward.
>> Can be `untabify' -- turn a tab to many spaces, then delete one space;
>>         `hungry' -- delete all whitespace, both tabs and spaces;
>>         `all' -- delete all whitespace, including tabs, spaces and newlines;
>>         nil -- just delete one character.
>
> However don't think customizing DEL does it.
> In most cases you will use DEL as `untabify'.

wfm:

(custom-set-variables
 '(backward-delete-char-untabify-method 'all))
(define-key global-map [remap delete-backward-char]
  'backward-delete-char-untabify)

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.5 (Final) X
http://www.memritv.org http://thereligionofpeace.com http://honestreporting.com
http://truepeace.org http://openvotingconsortium.org http://dhimmi.com
There are 10 kinds of people: those who count in binary and those who do not.



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

* Re: hungry-delete
  2011-04-04 20:02       ` hungry-delete Andreas Röhler
@ 2011-04-04 19:59         ` Sam Steingold
  2011-04-05  6:02           ` hungry-delete Andreas Röhler
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Steingold @ 2011-04-04 19:59 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: emacs-devel

>> (custom-set-variables
>>   '(backward-delete-char-untabify-method 'all))
>> (define-key global-map [remap delete-backward-char]
>>    'backward-delete-char-untabify)
>
> here my last results so far:

what problem are you trying to solve with your code which is not solved
by my 4 lines above?

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.5 (Final) X
http://pmw.org.il http://memri.org http://thereligionofpeace.com
http://jihadwatch.org http://truepeace.org http://camera.org http://ffii.org
When told to go to hell, ask for directions.



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

* Re: hungry-delete
  2011-04-04 19:00     ` hungry-delete Sam Steingold
@ 2011-04-04 20:02       ` Andreas Röhler
  2011-04-04 19:59         ` hungry-delete Sam Steingold
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Röhler @ 2011-04-04 20:02 UTC (permalink / raw)
  To: sds; +Cc: emacs-devel

Am 04.04.2011 21:00, schrieb Sam Steingold:
>> * Andreas Röhler<naqernf.ebruyre@bayvar.qr>  [2011-04-04 20:54:45 +0200]:
>>
>> Am 04.04.2011 20:20, schrieb Sam Steingold:
>>>> * Andreas Röhler<naqernf.ebruyre@bayvar.qr>   [2011-04-04 19:19:52 +0200]:
>>>>
>>>> https://bugs.launchpad.net/python-mode/+bug/328853
>>>>
>>>> "I really love the hungry-delete feature of Emacs'
>>>> c-mode. It would be great to have hungry-delete for
>>>> python-mode as well."
>>>
>>> DEL (translated from<backspace>) runs the command
>>> backward-delete-char-untabify
>>>
>>> backward-delete-char-untabify-method is a variable defined in `simple.el'.
>>> The method for untabifying when deleting backward.
>>> Can be `untabify' -- turn a tab to many spaces, then delete one space;
>>>          `hungry' -- delete all whitespace, both tabs and spaces;
>>>          `all' -- delete all whitespace, including tabs, spaces and newlines;
>>>          nil -- just delete one character.
>>
>> However don't think customizing DEL does it.
>> In most cases you will use DEL as `untabify'.
>
> wfm:
>
> (custom-set-variables
>   '(backward-delete-char-untabify-method 'all))
> (define-key global-map [remap delete-backward-char]
>    'backward-delete-char-untabify)
>

thanks again,

here my last results so far:


(defun hungry-delete-backward (&optional killp)
   "Delete backward all whitespaces including tabs.

If KILLP is non-nil, deleted string is stored into the kill-ring."
   (interactive "*P")
   (let ((backward-delete-char-untabify-method 'hungry))
     (backward-delete-char-untabify 1 killp)))

(defun hungry-delete-backward-all (&optional killp)
   "Delete backward all whitespaces, including tabs and newlines.

If KILLP is non-nil, deleted string is stored into the kill-ring."
   (interactive "*P")
   (let ((backward-delete-char-untabify-method 'all))
     (backward-delete-char-untabify 1 killp)))

(defun hungry-delete-forward (&optional killp)
   "Delete forward all whitespaces including tabs.

If KILLP is non-nil, deleted string is stored into the kill-ring."
   (interactive "*P")
   (let ((orig (point)))
     (or (< 0 (skip-chars-forward " \t"))
         (forward-char 1))
     (when killp
       (kill-new (buffer-substring-no-properties orig (point))))
     (delete-region orig (point))))

(defun hungry-delete-forward-all (&optional killp)
   "Delete forward all whitespaces including tabs and newlines.

If KILLP is non-nil, deleted string is stored into the kill-ring."
   (interactive "*P")
   (let ((orig (point)))
     (or (< 0 (skip-chars-forward " \t\r\n"))
         (forward-char 1))
     (when killp
       (kill-new (buffer-substring-no-properties orig (point))))
     (delete-region orig (point))))






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

* Re: hungry-delete
  2011-04-04 19:59         ` hungry-delete Sam Steingold
@ 2011-04-05  6:02           ` Andreas Röhler
  0 siblings, 0 replies; 8+ messages in thread
From: Andreas Röhler @ 2011-04-05  6:02 UTC (permalink / raw)
  To: sds; +Cc: emacs-devel

Am 04.04.2011 21:59, schrieb Sam Steingold:
>>> (custom-set-variables
>>>    '(backward-delete-char-untabify-method 'all))
>>> (define-key global-map [remap delete-backward-char]
>>>     'backward-delete-char-untabify)
>>
>> here my last results so far:
>
> what problem are you trying to solve with your code which is not solved
> by my 4 lines above?
>

Still seeing you customize.

Costumizing a variable is okay if you make your choose once a year or 
so. It's not recommendable for daily switches IMHO.

Maybe I miss something in the precise case.

Andreas



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

* Re: hungry-delete
  2011-04-04 18:54   ` hungry-delete Andreas Röhler
  2011-04-04 19:00     ` hungry-delete Sam Steingold
@ 2011-04-05 16:11     ` Andrew W. Nosenko
  1 sibling, 0 replies; 8+ messages in thread
From: Andrew W. Nosenko @ 2011-04-05 16:11 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: Sam Steingold, emacs-devel

On Mon, Apr 4, 2011 at 21:54, Andreas Röhler <andreas.roehler@online.de> wrote:
> Hi,
>
> thanks for the hint.
> However don't think customizing DEL does it.
> In most cases you will use DEL as `untabify'.
>
> "Hungry" eates a lot - that's is fine, but not as taking the common DEL.
>
> Therefore think a seperate key for hungry-delete is needed.

Unsure, whether separate key need.  If you have in minds to delete
char-by-char using regular DEL and then remove all spaces using
"hungry-DEL", then there is such key already: M-\

    (delete-horizontal-space &optional BACKWARD-ONLY)

    Delete all spaces and tabs around point.
    If BACKWARD-ONLY is non-nil, only delete them before point.


-- 
Andrew W. Nosenko <andrew.w.nosenko@gmail.com>



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

end of thread, other threads:[~2011-04-05 16:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-04 17:19 hungry-delete Andreas Röhler
2011-04-04 18:20 ` hungry-delete Sam Steingold
2011-04-04 18:54   ` hungry-delete Andreas Röhler
2011-04-04 19:00     ` hungry-delete Sam Steingold
2011-04-04 20:02       ` hungry-delete Andreas Röhler
2011-04-04 19:59         ` hungry-delete Sam Steingold
2011-04-05  6:02           ` hungry-delete Andreas Röhler
2011-04-05 16:11     ` hungry-delete Andrew W. Nosenko

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