[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
just-one-space
From: |
Paul Pogonyshev |
Subject: |
just-one-space |
Date: |
Fri, 23 Mar 2007 18:00:30 +0200 |
User-agent: |
KMail/1.7.2 |
Hi,
Would it be a good enhancement if that function could also optionally
delete newlines around point, based on a customizable variable? Same
could also apply to `delete-horizontal-space', probably, but its name
insists on current behaviour.
Paul
2007-03-23 Paul Pogonyshev <address@hidden>
* simple.el (just-one-space-also-eat-newlines): New custom option.
(just-one-space): Also delete newlines if
`just-one-space-also-eat-newlines' is non-nil.
--- simple.el 23 Mar 2007 17:53:23 +0200 1.852
+++ simple.el 23 Mar 2007 17:58:09 +0200
@@ -719,11 +719,17 @@ If BACKWARD-ONLY is non-nil, only delete
(skip-chars-backward " \t")
(constrain-to-field nil orig-pos)))))
+(defcustom just-one-space-also-eat-newlines nil
+ "If non-nil, `just-one-space' also deletes newlines, not only horizontal
space."
+ :type 'boolean
+ :group 'kill
+ :version "22.1")
+
(defun just-one-space (&optional n)
"Delete all spaces and tabs around point, leaving one space (or N spaces)."
(interactive "*p")
(let ((orig-pos (point)))
- (skip-chars-backward " \t")
+ (skip-chars-backward (if just-one-space-also-eat-newlines " \t\n\r" " \t"))
(constrain-to-field nil orig-pos)
(dotimes (i (or n 1))
(if (= (following-char) ?\s)
@@ -732,7 +738,7 @@ If BACKWARD-ONLY is non-nil, only delete
(delete-region
(point)
(progn
- (skip-chars-forward " \t")
+ (skip-chars-forward (if just-one-space-also-eat-newlines " \t\n\r" "
\t"))
(constrain-to-field nil orig-pos t)))))
(defun beginning-of-buffer (&optional arg)
- just-one-space,
Paul Pogonyshev <=