diff options
| author | Miles Bader | 2001-05-18 07:13:47 +0000 |
|---|---|---|
| committer | Miles Bader | 2001-05-18 07:13:47 +0000 |
| commit | 9ab59a1aa74d4f3ea52fb369e4485352e1600a35 (patch) | |
| tree | f9808a67a1bca026fe26152ca6c5b0a56dd1b9c5 | |
| parent | f042e7b9aeb1848f8865988888f96d1247188847 (diff) | |
| download | emacs-9ab59a1aa74d4f3ea52fb369e4485352e1600a35.tar.gz emacs-9ab59a1aa74d4f3ea52fb369e4485352e1600a35.zip | |
(delete-horizontal-space, just-one-space): Use `constrain-to-field'
instead of `field-end'/`field-beginning', because it's more efficient
for large files.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/simple.el | 37 |
2 files changed, 26 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1e95f3c7c71..a09f9ba6533 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2001-05-18 Miles Bader <miles@gnu.org> | ||
| 2 | |||
| 3 | * simple.el (delete-horizontal-space, just-one-space): Use | ||
| 4 | `constrain-to-field' instead of `field-end'/`field-beginning', | ||
| 5 | because it's more efficient for large files. | ||
| 6 | |||
| 1 | 2001-05-17 Gerd Moellmann <gerd@gnu.org> | 7 | 2001-05-17 Gerd Moellmann <gerd@gnu.org> |
| 2 | 8 | ||
| 3 | * mail/rmail.el (rmail-require-mime-maybe): New function. | 9 | * mail/rmail.el (rmail-require-mime-maybe): New function. |
diff --git a/lisp/simple.el b/lisp/simple.el index 367bc2465fe..a58f8003bac 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -340,28 +340,31 @@ Leave one space or none, according to the context." | |||
| 340 | "Delete all spaces and tabs around point. | 340 | "Delete all spaces and tabs around point. |
| 341 | If BACKWARD-ONLY is non-nil, only delete spaces before point." | 341 | If BACKWARD-ONLY is non-nil, only delete spaces before point." |
| 342 | (interactive "*") | 342 | (interactive "*") |
| 343 | (delete-region | 343 | (let ((orig-pos (point))) |
| 344 | (if backward-only | 344 | (delete-region |
| 345 | (point) | 345 | (if backward-only |
| 346 | orig-pos | ||
| 347 | (progn | ||
| 348 | (skip-chars-forward " \t") | ||
| 349 | (constrain-to-field nil orig-pos t))) | ||
| 346 | (progn | 350 | (progn |
| 347 | (skip-chars-forward " \t" (field-end)) | 351 | (skip-chars-backward " \t") |
| 348 | (point))) | 352 | (constrain-to-field nil orig-pos))))) |
| 349 | (progn | ||
| 350 | (skip-chars-backward " \t" (field-beginning nil t)) | ||
| 351 | (point)))) | ||
| 352 | 353 | ||
| 353 | (defun just-one-space () | 354 | (defun just-one-space () |
| 354 | "Delete all spaces and tabs around point, leaving one space." | 355 | "Delete all spaces and tabs around point, leaving one space." |
| 355 | (interactive "*") | 356 | (interactive "*") |
| 356 | (skip-chars-backward " \t" (field-beginning)) | 357 | (let ((orig-pos (point))) |
| 357 | (if (= (following-char) ? ) | 358 | (skip-chars-backward " \t") |
| 358 | (forward-char 1) | 359 | (constrain-to-field nil orig-pos) |
| 359 | (insert ? )) | 360 | (if (= (following-char) ? ) |
| 360 | (delete-region | 361 | (forward-char 1) |
| 361 | (point) | 362 | (insert ? )) |
| 362 | (progn | 363 | (delete-region |
| 363 | (skip-chars-forward " \t" (field-end nil t)) | 364 | (point) |
| 364 | (point)))) | 365 | (progn |
| 366 | (skip-chars-forward " \t") | ||
| 367 | (constrain-to-field nil orig-pos t))))) | ||
| 365 | 368 | ||
| 366 | (defun beginning-of-buffer (&optional arg) | 369 | (defun beginning-of-buffer (&optional arg) |
| 367 | "Move point to the beginning of the buffer; leave mark at previous position. | 370 | "Move point to the beginning of the buffer; leave mark at previous position. |