* unairy delimited at point (snippet)
@ 2010-08-10 6:11 Andreas Röhler
2010-08-10 8:53 ` Thien-Thi Nguyen
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Röhler @ 2010-08-10 6:11 UTC (permalink / raw)
To: help-gnu-emacs
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))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: unairy delimited at point (snippet)
2010-08-10 6:11 unairy delimited at point (snippet) Andreas Röhler
@ 2010-08-10 8:53 ` Thien-Thi Nguyen
2010-08-10 9:27 ` Andreas Röhler
0 siblings, 1 reply; 3+ messages in thread
From: Thien-Thi Nguyen @ 2010-08-10 8:53 UTC (permalink / raw)
To: help-gnu-emacs
() Andreas Röhler <andreas.roehler@online.de>
() Tue, 10 Aug 2010 08:11:03 +0200
comments welcome.
(char (char-to-string char))
(beg (search-backward char nil t 1))
(search-forward char nil t 1)))
See also ‘skip-chars-forward’ and ‘skip-chars-backward’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: unairy delimited at point (snippet)
2010-08-10 8:53 ` Thien-Thi Nguyen
@ 2010-08-10 9:27 ` Andreas Röhler
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Röhler @ 2010-08-10 9:27 UTC (permalink / raw)
To: help-gnu-emacs
Am 10.08.2010 10:53, schrieb Thien-Thi Nguyen:
> () Andreas Röhler<andreas.roehler@online.de>
> () Tue, 10 Aug 2010 08:11:03 +0200
>
> comments welcome.
>
>
> (char (char-to-string char))
> (beg (search-backward char nil t 1))
>
> (search-forward char nil t 1)))
>
> See also ‘skip-chars-forward’ and ‘skip-chars-backward’.
>
>
Thanks a lot.
Thats much faster, isn't it?
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-10 9:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-10 6:11 unairy delimited at point (snippet) Andreas Röhler
2010-08-10 8:53 ` Thien-Thi Nguyen
2010-08-10 9:27 ` Andreas Röhler
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.