emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hungry-delete


From: Andreas Röhler
Subject: Re: hungry-delete
Date: Mon, 04 Apr 2011 22:02:08 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

Am 04.04.2011 21:00, schrieb Sam Steingold:
* Andreas Röhler<address@hidden>  [2011-04-04 20:54:45 +0200]:

Am 04.04.2011 20:20, schrieb Sam Steingold:
* Andreas Röhler<address@hidden>   [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))))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]