From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: remove all the whitespace characters from the cursor to the next symbol Date: Thu, 06 May 2010 21:34:21 -0600 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1273203318 31216 80.91.229.12 (7 May 2010 03:35:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 7 May 2010 03:35:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 07 05:35:17 2010 connect(): No such file or directory Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OAELK-0007EN-Rm for geh-help-gnu-emacs@m.gmane.org; Fri, 07 May 2010 05:35:15 +0200 Original-Received: from localhost ([127.0.0.1]:54788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OAELI-0002m2-1Q for geh-help-gnu-emacs@m.gmane.org; Thu, 06 May 2010 23:35:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1OAEKc-0002k3-7p for help-gnu-emacs@gnu.org; Thu, 06 May 2010 23:34:30 -0400 Original-Received: from [140.186.70.92] (port=34672 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OAEKa-0002iA-NN for help-gnu-emacs@gnu.org; Thu, 06 May 2010 23:34:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OAEKZ-0001cW-2B for help-gnu-emacs@gnu.org; Thu, 06 May 2010 23:34:28 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:39438) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OAEKY-0001cI-S0 for help-gnu-emacs@gnu.org; Thu, 06 May 2010 23:34:27 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OAEKT-00071v-UK for help-gnu-emacs@gnu.org; Fri, 07 May 2010 05:34:21 +0200 Original-Received: from c-71-237-24-138.hsd1.co.comcast.net ([71.237.24.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 May 2010 05:34:21 +0200 Original-Received: from kevin.d.rodgers by c-71-237-24-138.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 May 2010 05:34:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ connect(): No such file or directory Original-Lines: 43 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-24-138.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:73545 Archived-At: alex_sv wrote: > Hi all! > > Could you please clarify - is it possible to remove all the whitespace > characters including newline from the current cursor position to the > next meaningful symbol using one command? > > I mean if our buffer's content is as follows: > > texttexttext{cursor}___ > _ > ___text > > where '_' means space character, is it possible to press some known > key sequence to transform the given above to the following form: > > texttexttext{cursor}text ;; This is copied from delete-horizontal-space, with ;; skip-chars-forward/backward " \t" replaced by ;; skip-syntax-forward/forward " ": (defun delete-whitespace (&optional backward-only) "Delete all characters around point with whitespace syntax. If BACKWARD-ONLY is non-nil, only delete them before point." (interactive "*P") (let ((orig-pos (point))) (delete-region (if backward-only orig-pos (progn (skip-syntax-forward " ") (constrain-to-field nil orig-pos t))) (progn (skip-syntax-backward " ") (constrain-to-field nil orig-pos))))) ;; Now bind it to a convenient key: (global-set-key "\C-cw" 'delete-whitespace) -- Kevin Rodgers Denver, Colorado, USA