From: "Andreas Röhler" <andreas.roehler@online.de>
To: help-gnu-emacs@gnu.org
Subject: unairy delimited at point (snippet)
Date: Tue, 10 Aug 2010 08:11:03 +0200 [thread overview]
Message-ID: <4C60ED77.1040109@online.de> (raw)
just for fun...
comments welcome.
Andreas
--
https://code.launchpad.net/~a-roehler/python-mode
https://code.launchpad.net/s-x-emacs-werkstatt/
;;;;;;;;;;;;;;;;;;;;;;;;
(defun unairy-delimited-atpt (char arg)
"Takes any char inserted at prompt as delimiter.
Returns the string if any. With ARG 2 the bounds of this string are
returned as a list, with ARG 3 it's lenght, a number.
If looking for parentized, braced at point etc., its delivered with
thing-at-point-utils.el at
https://code.launchpad.net/s-x-emacs-werkstatt "
(interactive "cinsert: \np")
(let*
((orig (point))
(char (char-to-string char))
(beg (search-backward char nil t 1))
(end (progn
(when (looking-at char)
(push-mark)
(goto-char (match-end 0)))
(search-forward char nil t 1)))
(erg
(when (ignore-errors (and (< beg end)(<= beg orig)(<= orig end)))
(cond ((eq 1 arg)
(buffer-substring-no-properties beg end))
((eq 2 arg)
(list beg end))
((eq 3 arg)
(- end beg))))))
(exchange-point-and-mark)
(when (interactive-p) (message "%s" erg))
erg))
next reply other threads:[~2010-08-10 6:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-10 6:11 Andreas Röhler [this message]
2010-08-10 8:53 ` unairy delimited at point (snippet) Thien-Thi Nguyen
2010-08-10 9:27 ` Andreas Röhler
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C60ED77.1040109@online.de \
--to=andreas.roehler@online.de \
--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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).