aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-03-06 05:51:51 +0000
committerRichard M. Stallman1998-03-06 05:51:51 +0000
commitcc2b2b6cc88717e761f6abb05b5b754412ea47f8 (patch)
tree3dfd1a6c273d8b051faa2f466a1fddaa52a87806
parentb4b33e0104da8aa94178d78262a8bbafd4b8a44f (diff)
downloademacs-cc2b2b6cc88717e761f6abb05b5b754412ea47f8.tar.gz
emacs-cc2b2b6cc88717e761f6abb05b5b754412ea47f8.zip
(backward-delete-char-untabify-method): New user option.
(backward-delete-char-untabify): Obey it. This implements "hungry" delete.
-rw-r--r--lisp/simple.el20
1 files changed, 18 insertions, 2 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 91527bd4e15..27f977a5fb4 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -322,12 +322,22 @@ column specified by the function `current-left-margin'."
322 (if (eq arg '-) (setq arg -1)) 322 (if (eq arg '-) (setq arg -1))
323 (kill-region (point) (forward-point (- arg)))) 323 (kill-region (point) (forward-point (- arg))))
324 324
325(defcustom backward-delete-char-untabify-method 'untabify
326 "*The method for untabifying when deleting backward.
327Can be `untabify' -- turn a tab to many spaces, then delete one space.
328 `hungry' -- delete all whitespace, both tabs and spaces.
329 nil -- just delete one character."
330 :type '(choice (const untabify) (const hungry) (const nil))
331 :group 'killing)
332
325(defun backward-delete-char-untabify (arg &optional killp) 333(defun backward-delete-char-untabify (arg &optional killp)
326 "Delete characters backward, changing tabs into spaces. 334 "Delete characters backward, changing tabs into spaces.
335The exact behavior depends on `backward-delete-char-untabify-method'.
327Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil. 336Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil.
328Interactively, ARG is the prefix arg (default 1) 337Interactively, ARG is the prefix arg (default 1)
329and KILLP is t if a prefix arg was specified." 338and KILLP is t if a prefix arg was specified."
330 (interactive "*p\nP") 339 (interactive "*p\nP")
340 (when (eq backward-delete-char-untabify-method 'untabify)
331 (let ((count arg)) 341 (let ((count arg))
332 (save-excursion 342 (save-excursion
333 (while (and (> count 0) (not (bobp))) 343 (while (and (> count 0) (not (bobp)))
@@ -338,8 +348,14 @@ and KILLP is t if a prefix arg was specified."
338 (insert-char ?\ col) 348 (insert-char ?\ col)
339 (delete-char 1))) 349 (delete-char 1)))
340 (forward-char -1) 350 (forward-char -1)
341 (setq count (1- count))))) 351 (setq count (1- count))))))
342 (delete-backward-char arg killp)) 352 (delete-backward-char
353 (if (eq backward-delete-char-untabify-method 'hungry)
354 (let ((wh (- (point) (save-excursion (skip-chars-backward " \t")
355 (point)))))
356 (+ arg (if (zerop wh) 0 (1- wh))))
357 arg)
358 killp))
343 359
344(defun zap-to-char (arg char) 360(defun zap-to-char (arg char)
345 "Kill up to and including ARG'th occurrence of CHAR. 361 "Kill up to and including ARG'th occurrence of CHAR.