From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Pogonyshev Newsgroups: gmane.emacs.devel Subject: just-one-space Date: Fri, 23 Mar 2007 18:00:30 +0200 Message-ID: <200703231800.30770.pogonyshev@gmx.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1174665042 29934 80.91.229.12 (23 Mar 2007 15:50:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 23 Mar 2007 15:50:42 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 23 16:50:33 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HUm2A-0002MM-Ia for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2007 16:50:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HUm45-0001av-8L for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2007 10:52:29 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HUm41-0001Os-Bv for emacs-devel@gnu.org; Fri, 23 Mar 2007 11:52:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HUm3z-0001EW-Op for emacs-devel@gnu.org; Fri, 23 Mar 2007 11:52:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HUm3z-0001DH-EQ for emacs-devel@gnu.org; Fri, 23 Mar 2007 10:52:23 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1HUm23-0004en-A5 for emacs-devel@gnu.org; Fri, 23 Mar 2007 11:50:23 -0400 Original-Received: (qmail invoked by alias); 23 Mar 2007 15:50:20 -0000 Original-Received: from unknown (EHLO [80.94.234.126]) [80.94.234.126] by mail.gmx.net (mp004) with SMTP; 23 Mar 2007 16:50:20 +0100 X-Authenticated: #16844820 X-Provags-ID: V01U2FsdGVkX1+uucgWSwWuyQK6h28J62FQmBHGLs0EztfSzdnBVh h9XSird6xoan+k User-Agent: KMail/1.7.2 Content-Disposition: inline X-Y-GMX-Trusted: 0 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68407 Archived-At: 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 * 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)