changeset 34462:6a7373de926f

(delete-horizontal-space): Add BACKWARD-ONLY parameter. Respect field end too. (just-one-space): Respect fields as `delete-horizontal-space'. (newline-and-indent, reindent-then-newline-and-indent): Use `delete-horizontal-space'.
author Miles Bader <miles@gnu.org>
date Tue, 12 Dec 2000 01:20:22 +0000
parents 2cdc07b5db85
children 144a3dcc72e1
files lisp/simple.el
diffstat 1 files changed, 20 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Mon Dec 11 22:55:41 2000 +0000
+++ b/lisp/simple.el	Tue Dec 12 01:20:22 2000 +0000
@@ -245,7 +245,7 @@
 In some text modes, where TAB inserts a tab, this command indents to the
 column specified by the function `current-left-margin'."
   (interactive "*")
-  (delete-region (point) (progn (skip-chars-backward " \t") (point)))
+  (delete-horizontal-space t)
   (newline)
   (indent-according-to-mode))
 
@@ -258,7 +258,7 @@
 column specified by the function `current-left-margin'."
   (interactive "*")
   (save-excursion
-    (delete-region (point) (progn (skip-chars-backward " \t") (point)))
+    (delete-horizontal-space t)
     (indent-according-to-mode))
   (newline)
   (indent-according-to-mode))
@@ -331,21 +331,32 @@
 	nil
       (insert ?\ ))))
 
-(defun delete-horizontal-space ()
-  "Delete all spaces and tabs around point."
+(defun delete-horizontal-space (&optional backward-only)
+  "Delete all spaces and tabs around point.
+If BACKWARD-ONLY is non-nil, only delete spaces before point."
   (interactive "*")
-  (skip-chars-backward " \t" (field-beginning))
-  (delete-region (point) (progn (skip-chars-forward " \t") (point))))
+  (delete-region
+   (if backward-only
+       (point)
+     (progn
+       (skip-chars-forward " \t" (field-end))
+       (point)))
+   (progn
+     (skip-chars-backward " \t" (field-beginning nil t))
+     (point))))
 
 (defun just-one-space ()
   "Delete all spaces and tabs around point, leaving one space."
   (interactive "*")
-  (skip-chars-backward " \t")
+  (skip-chars-backward " \t" (field-beginning))
   (if (= (following-char) ? )
       (forward-char 1)
     (insert ? ))
-  (delete-region (point) (progn (skip-chars-forward " \t") (point))))
-
+  (delete-region
+   (point)
+   (progn
+     (skip-chars-forward " \t" (field-end nil t))
+     (point))))
 
 (defun beginning-of-buffer (&optional arg)
   "Move point to the beginning of the buffer; leave mark at previous position.