From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) Newsgroups: gmane.emacs.help Subject: Re: fill comma separated list Date: Thu, 02 Jun 2016 14:36:53 -0400 Message-ID: <87inxr8mka.fsf@yale.edu> References: <31550a04-e2c8-4169-9818-b392379237af@googlegroups.com> <87r3cf8rx4.fsf@yale.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: ger.gmane.org 1464893177 14832 80.91.229.3 (2 Jun 2016 18:46:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 2 Jun 2016 18:46:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 02 20:46:10 2016 Return-path: Envelope-to: geh-help-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 1b8XdB-0006Gw-9U for geh-help-gnu-emacs@m.gmane.org; Thu, 02 Jun 2016 20:46:09 +0200 Original-Received: from localhost ([::1]:49776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8XdA-00036w-Lv for geh-help-gnu-emacs@m.gmane.org; Thu, 02 Jun 2016 14:46:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8XUU-0003uv-Fs for help-gnu-emacs@gnu.org; Thu, 02 Jun 2016 14:37:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8XUO-0006n5-Gw for help-gnu-emacs@gnu.org; Thu, 02 Jun 2016 14:37:09 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:56645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8XUO-0006mx-AD for help-gnu-emacs@gnu.org; Thu, 02 Jun 2016 14:37:04 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1b8XUL-00083G-B0 for help-gnu-emacs@gnu.org; Thu, 02 Jun 2016 20:37:01 +0200 Original-Received: from 130.132.236.141 ([130.132.236.141]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Jun 2016 20:37:01 +0200 Original-Received: from jorge.alfaro-murillo by 130.132.236.141 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 02 Jun 2016 20:37:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 81 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 130.132.236.141 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:+8wzNscYn1qlvwu/GvuFMyifqso= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110265 Archived-At: Kaushal Modi writes: > Jorge A. Alfaro-Murillo writes: > >> >> Let's play emacs golf: (I assume no whitespace and cursor at >> the initial 5): >> >> F3 C-e C-d C-e C-d C-e C-n C-a F4 >> C-0 F4 >> >> 14 key strokes. > > With cursor at the initial 5, > > (1) F3 (2,3) M-4 M-^ (In fact, I have bound the functionality of > C-u M-^ to C-j [see below]) (4,5) M-4 M-^ (6) C-n (7,8) M-0 F4 > (you do not need to hit F4 and then do M-0 F4) True! I didn't know that thanks! > 8 keys (10 keys, if adding the 2 spaces) I count M-4/M-0 as > single keystrokes as I use the Alt key, not Esc. That should be > OK? :) Cool! Most people would have do C-u instead of M-4, I thought there was something special with the 4, M-^ runs delete-indentation which joins this line with the previous and with universal argument joins this line with the following one. I was also not sure if with OP wanted spaces or to remove the commas at the end. He posted it without the ; and I did it without commas at the end. For the emacs golf let's play leaving it at 5.1816,-3.81,4.8768, 5.1816,-4.4196,4.8768, 6.4008,-4.4196,5.48640, 6.4008,-3.81,5.486400; For the OP, if you want indentation you should remove the commas at the end and take a look at csv-mode, in particular C-c C-a. Alternatively, transform it to: |5.1816|-3.81|4.8768,| |5.1816|-4.4196|4.8768| |6.4008|-4.4196|5.48640| |6.4008|-3.81|5.486400| And take a look at > > ===== > > If interested, I bind C-j to below: > > (defun modi/pull-up-line () > "Join the following line onto the current one (analogous to > `C-e', `C-d') > or `C-u M-^' or `C-u M-x join-line'. > > If the current line is a comment and the pulled-up line is also > a comment, remove the comment characters from that line." > (interactive) (join-line -1) ;; If the current line is a > comment (when (nth 4 (syntax-ppss)) > ;; Remove the comment prefix chars from the pulled-up line > if present (save-excursion > ;; Delete all comment-start and space characters (while > (looking-at (concat "\\s<" ; comment-start char as per > syntax > table > "\\|" (substring comment-start > 0 1) ; > first char of `comment-start' > "\\|" "\\s-")) ; extra spaces > (delete-forward-char 1)) > (insert-char ? )))) ; insert space > > -- -- Jorge.