Mercurial > emacs
changeset 37791:5bd4843858ae
(delete-horizontal-space, just-one-space): Use `constrain-to-field'
instead of `field-end'/`field-beginning', because it's more efficient
for large files.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 18 May 2001 07:13:04 +0000 |
parents | 3d716c9eaa3f |
children | 96f0fed8e431 |
files | lisp/simple.el |
diffstat | 1 files changed, 20 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/simple.el Thu May 17 19:21:54 2001 +0000 +++ b/lisp/simple.el Fri May 18 07:13:04 2001 +0000 @@ -340,28 +340,31 @@ "Delete all spaces and tabs around point. If BACKWARD-ONLY is non-nil, only delete spaces before point." (interactive "*") - (delete-region - (if backward-only - (point) + (let ((orig-pos (point))) + (delete-region + (if backward-only + orig-pos + (progn + (skip-chars-forward " \t") + (constrain-to-field nil orig-pos t))) (progn - (skip-chars-forward " \t" (field-end)) - (point))) - (progn - (skip-chars-backward " \t" (field-beginning nil t)) - (point)))) + (skip-chars-backward " \t") + (constrain-to-field nil orig-pos))))) (defun just-one-space () "Delete all spaces and tabs around point, leaving one space." (interactive "*") - (skip-chars-backward " \t" (field-beginning)) - (if (= (following-char) ? ) - (forward-char 1) - (insert ? )) - (delete-region - (point) - (progn - (skip-chars-forward " \t" (field-end nil t)) - (point)))) + (let ((orig-pos (point))) + (skip-chars-backward " \t") + (constrain-to-field nil orig-pos) + (if (= (following-char) ? ) + (forward-char 1) + (insert ? )) + (delete-region + (point) + (progn + (skip-chars-forward " \t") + (constrain-to-field nil orig-pos t))))) (defun beginning-of-buffer (&optional arg) "Move point to the beginning of the buffer; leave mark at previous position.