From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Toomas Rosin Newsgroups: gmane.emacs.bugs Subject: bug#15821: a better M-SPC Date: Wed, 06 Nov 2013 11:36:55 +0200 Message-ID: <2866409.xsAelUrJXd@toomas> Reply-To: toomas@rosin.ee NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Trace: ger.gmane.org 1383759453 27731 80.91.229.3 (6 Nov 2013 17:37:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Nov 2013 17:37:33 +0000 (UTC) To: 15821@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 06 18:37:37 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ve72u-0005ir-E5 for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Nov 2013 18:37:36 +0100 Original-Received: from localhost ([::1]:35208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve72u-0005OX-1W for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Nov 2013 12:37:36 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve71d-0003X7-Cc for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 12:36:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve71O-0007up-IW for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 12:36:17 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve71O-0007uk-Ej for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 12:36:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Ve71O-0005Cy-0D for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 12:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Toomas Rosin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Nov 2013 17:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15821 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.138375930419929 (code B ref -1); Wed, 06 Nov 2013 17:36:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Nov 2013 17:35:04 +0000 Original-Received: from localhost ([127.0.0.1]:37687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ve70R-0005BM-15 for submit@debbugs.gnu.org; Wed, 06 Nov 2013 12:35:03 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42022) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdzXu-0007dp-MT for submit@debbugs.gnu.org; Wed, 06 Nov 2013 04:37:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdzXf-0007We-Hj for submit@debbugs.gnu.org; Wed, 06 Nov 2013 04:37:01 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:58758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdzXf-0007Wa-Ew for submit@debbugs.gnu.org; Wed, 06 Nov 2013 04:36:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdzXX-00009L-BX for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 04:36:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdzXP-0007Sr-4U for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 04:36:43 -0500 Original-Received: from smtp-out.neti.ee ([194.126.106.83]:17195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdzXO-0007S1-Ts for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 04:36:35 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by vm-relay5.estpak.ee (Postfix) with ESMTP id 476B59AB for ; Wed, 6 Nov 2013 11:36:27 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at vm-relay5.estpak.ee Original-Received: from smtp-out.neti.ee ([127.0.0.1]) by localhost (vm-relay5.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HN4ZazyytKDm for ; Wed, 6 Nov 2013 11:36:20 +0200 (EET) Original-Received: from mail.neti.ee (neti-relayhost2.estpak.ee [88.196.174.199]) by vm-relay5.estpak.ee (Postfix) with ESMTP id CC51763E for ; Wed, 6 Nov 2013 11:36:20 +0200 (EET) Received-SPF: None (no SPF record) identity=mailfrom; client-ip=88.196.134.13; helo=toomas.localnet; envelope-from=toomas@rosin.ee; receiver=bug-gnu-emacs@gnu.org X-SMTP-Auth-NETI-Businessmail: no Original-Received: from toomas.localnet (rosin.ee [88.196.134.13]) by NETI-Relayhost2.estpak.ee (Postfix) with ESMTPS id B81E0371 for ; Wed, 6 Nov 2013 11:36:20 +0200 (EET) User-Agent: KMail/4.11 (Linux/3.10.10; KDE/4.11.0; i686; ; ) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Mailman-Approved-At: Wed, 06 Nov 2013 12:35:02 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:80085 Archived-At: Hello, I hope this is the right place for the following suggestion. My version of M-SPC is an improvement over the original Emacs one in two respects: it operates both horizontally and vertically, and it takes a numeric argument. See the docstring for details. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun adjust-space-2d (&optional arg) "Adjust horizontal or vertical whitespace. On a non-empty blank line, leave exactly ARG spaces on it (without ARG, make it empty). On an empty line, delete all blank lines above and below it, leaving ARG empty lines. When there is no ARG, the default is to leave no empty lines at the beginning or the end of the buffer or at a single blank line, and leave one empty line elsewhere. At the beginning or end of a non-blank line, delete all leading resp. trailing whitespace, leaving ARG (by default, zero) spaces. Elsewhere, insert and/or delete blanks, leaving ARG spaces (by default, one space)." (interactive "*P") (let ((num (if arg (prefix-numeric-value arg))) (pos (point))) (cond ;;; Empty line at the beginning of the buffer. ((and (bobp) (looking-at "$")) (delete-blank-lines) (if (looking-at "[ \t]*$") (kill-line)) (when num (open-line num))) ;;; Empty line elsewhere. ((save-excursion (beginning-of-line) (looking-at "$")) (delete-blank-lines) (when num (delete-blank-lines) (open-line num))) ;;; Beginning of line. ((save-excursion (skip-chars-backward " \t") (bolp)) (beginning-of-line) (while (looking-at "[ \t]") (delete-char 1)) (when num (insert (make-string num ? )) (beginning-of-line))) ;;; End of line. ((save-excursion (skip-chars-forward " \t") (eolp)) (skip-chars-backward " \t") (while (not (eolp)) (delete-char 1)) (when num (insert (make-string num ? )))) ;;; Anywhere else. (t (just-one-space) (when num (delete-char -1) (insert (make-string num ? ))))))) (global-set-key (kbd "M-SPC") 'adjust-space-2d) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Best regards, T.