From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo)
To: help-gnu-emacs@gnu.org
Subject: Re: fill comma separated list
Date: Thu, 02 Jun 2016 14:36:53 -0400 [thread overview]
Message-ID: <87inxr8mka.fsf@yale.edu> (raw)
In-Reply-To: CAFyQvY1zsqQ2Bq31ySW2U7+ZLSDrEHmfO5NgQA6W0g0TodcnyA@mail.gmail.com
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 <space> C-d C-e <space> C-d C-e <backspace> 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.
next prev parent reply other threads:[~2016-06-02 18:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 13:02 fill comma separated list papab
2016-05-19 13:12 ` Emanuel Berg
2016-06-02 16:08 ` Kaushal Modi
[not found] ` <mailman.702.1464883755.1216.help-gnu-emacs@gnu.org>
2016-06-02 17:11 ` Emanuel Berg
2016-06-02 16:41 ` Jorge A. Alfaro-Murillo
2016-06-02 17:47 ` Kaushal Modi
2016-06-02 18:36 ` Jorge A. Alfaro-Murillo [this message]
2016-06-02 18:50 ` Jorge A. Alfaro-Murillo
2016-06-02 19:06 ` Kaushal Modi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87inxr8mka.fsf@yale.edu \
--to=jorge.alfaro-murillo@yale.edu \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.