From: <tomas@tuxteam.de>
To: Subhan Michael Tindall <SubhanT@familycareinc.org>
Cc: "'help-gnu-emacs@gnu.org'" <help-gnu-emacs@gnu.org>
Subject: Re: Find first line FOLLOWING a sequence of matches
Date: Fri, 1 May 2015 16:57:04 +0200 [thread overview]
Message-ID: <20150501145704.GA30776@tuxteam.de> (raw)
In-Reply-To: <ac47eff8a3e34250a411105598bb3c69@fcmailsvr3.familycareinc.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tue, Apr 28, 2015 at 04:53:58PM +0000, Subhan Michael Tindall wrote:
> Table like this: (abbreviated)
> |a|b|c|
> |a|d|e|
> |a|z||
> |m|b|c|
> |m|c|d|
> |ab|c|d|
Here's a little Emacs Lisp snippet to get you started:
(defun my-segmentize-table ()
(interactive)
(let ((curr-fc nil)) ;; current first col
(while (looking-at "^|\\([^|]*\\)")
(let ((fc (match-string 1)))
(unless (equal fc curr-fc)
;; we are at the start of a line with a "new" first column
(insert (format ",* %s\n" fc))
(setq curr-fc fc)))
;; advance one line:
(beginning-of-line 2))))
Season to taste :-)
If you don't know what to do with it, here are some instructions:
- Paste into a spare buffer (the *scratch* buffer is fine for that)
- Evaluate the whole thing by going to its end and keying C-x C-e
(aka "eval-last-sexp"). Now your Emacs should know a new command
"my-segmentize-table"
- Go to the first line of the table you want to transform
- Type there "M-x my-segmentize-table"
Make first a backup of your valuable buffers ;-)
Enjoy
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlVDlEAACgkQBcgs9XrR2kbFMQCdFbGodLScRS87XFBc8JT6rQTl
UI4An24LpRgeyjZ8gOPwCQSGEqbyOsKI
=HDE1
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2015-05-01 14:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 16:53 Find first line FOLLOWING a sequence of matches Subhan Michael Tindall
2015-04-29 4:37 ` Bob Proulx
2015-04-29 19:03 ` Robert Thorpe
2015-04-30 6:37 ` Bob Proulx
2015-04-30 16:19 ` Subhan Michael Tindall
2015-04-30 20:39 ` Bob Proulx
2015-04-30 18:41 ` Robert Thorpe
2015-04-30 21:17 ` Bob Proulx
2015-04-30 21:21 ` Bob Proulx
2015-04-30 21:55 ` Subhan Michael Tindall
2015-05-01 16:35 ` Thien-Thi Nguyen
2015-05-01 19:30 ` Bob Proulx
2015-05-01 14:57 ` tomas [this message]
[not found] <mailman.1821.1430240067.904.help-gnu-emacs@gnu.org>
2015-04-29 3:01 ` Rusi
2015-04-29 5:37 ` Rusi
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=20150501145704.GA30776@tuxteam.de \
--to=tomas@tuxteam.de \
--cc=SubhanT@familycareinc.org \
--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.