* Wrap predefined text around region
@ 2010-12-02 22:05 Harry Putnam
2010-12-03 10:18 ` Kevin Rodgers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Harry Putnam @ 2010-12-02 22:05 UTC (permalink / raw)
To: help-gnu-emacs
Can anyone show an example of how to do something like this:
I want to wrap this:
# [HP 101202_15:55:07
# ]
Around the selected text...
<selected text region here>
<selected text region here>
<selected text region here>
<selected text region here>
that is, select some text and press a key
combo ... voila... its now surrounded by:
# [HP 101202_15:55:07
# ]
Over the yrs I've acquired a fairly lengthy .emacs mostly by theft
from more skilled people. Coding something like that is clear out of
my skill set.
I use lots of `skeleton' things for inserting various predefined texts
but don't know how to make that happen to selected region.
Usually given an example, I've been able to hack it up to my needs.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Wrap predefined text around region
2010-12-02 22:05 Wrap predefined text around region Harry Putnam
@ 2010-12-03 10:18 ` Kevin Rodgers
2010-12-03 12:14 ` Andreas Röhler
2010-12-03 14:31 ` Kenneth Goldman
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2010-12-03 10:18 UTC (permalink / raw)
To: help-gnu-emacs
On 12/2/10 3:05 PM, Harry Putnam wrote:
> Can anyone show an example of how to do something like this:
>
> I want to wrap this:
>
> # [HP 101202_15:55:07
> # ]
>
> Around the selected text...
> <selected text region here>
> <selected text region here>
> <selected text region here>
> <selected text region here>
>
> that is, select some text and press a key
> combo ... voila... its now surrounded by:
> # [HP 101202_15:55:07
>
> # ]
>
> Over the yrs I've acquired a fairly lengthy .emacs mostly by theft
> from more skilled people. Coding something like that is clear out of
> my skill set.
>
> I use lots of `skeleton' things for inserting various predefined texts
> but don't know how to make that happen to selected region.
>
> Usually given an example, I've been able to hack it up to my needs.
`skeleton' sounds like it's the right level of abstraction, but since I'm not
familiar with it here's a hack:
(defun delimit-region (beg end beg-delim end-delim)
"Delimit region from BEG to END by inserting BEG-DELIM and END-DELIM text."
(interactive "r\nsBegin: \nsEnd: ")
(unless (markerp end)
(setq end (copy-marker end)))
(unwind-protect
(progn
(save-excursion
(goto-char beg)
(insert-before-markers beg-delim))
(save-excursion
(goto-char end)
(insert end-delim)))
(when (markerp end)
(set-marker end nil))))
Hope that helps,
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Wrap predefined text around region
2010-12-02 22:05 Wrap predefined text around region Harry Putnam
2010-12-03 10:18 ` Kevin Rodgers
@ 2010-12-03 12:14 ` Andreas Röhler
2010-12-03 14:31 ` Kenneth Goldman
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Röhler @ 2010-12-03 12:14 UTC (permalink / raw)
To: help-gnu-emacs
Am 02.12.2010 23:05, schrieb Harry Putnam:
> Can anyone show an example of how to do something like this:
>
> I want to wrap this:
>
> # [HP 101202_15:55:07
> # ]
>
> Around the selected text...
> <selected text region here>
> <selected text region here>
> <selected text region here>
> <selected text region here>
>
> that is, select some text and press a key
> combo ... voila... its now surrounded by:
> # [HP 101202_15:55:07
>
> # ]
>
> Over the yrs I've acquired a fairly lengthy .emacs mostly by theft
> from more skilled people. Coding something like that is clear out of
> my skill set.
>
> I use lots of `skeleton' things for inserting various predefined texts
> but don't know how to make that happen to selected region.
>
> Usually given an example, I've been able to hack it up to my needs.
>
>
>
Hi,
maybe try `ar-blok-region-atpt'
from
thing-at-point-utils.el at
https://launchpad.net/s-x-emacs-werkstatt
`blok' means arbitrary beg- and end-string, ie a markup.
Should be easy to re-define for your needs.
HTH
Andreas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Wrap predefined text around region
2010-12-02 22:05 Wrap predefined text around region Harry Putnam
2010-12-03 10:18 ` Kevin Rodgers
2010-12-03 12:14 ` Andreas Röhler
@ 2010-12-03 14:31 ` Kenneth Goldman
2 siblings, 0 replies; 4+ messages in thread
From: Kenneth Goldman @ 2010-12-03 14:31 UTC (permalink / raw)
Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]
Like you, I have a huge .emacs that I've acquired over the years. Here's
what I use to comment out a C region with #if 0:
(define-key c-mode-base-map "\C-ci" 'if0-region)
; function to comment a region using #if 0
(defun if0-region (p1 p2)
(interactive "r")
(let* ()
(goto-char p1)
(beginning-of-line)
(insert "#if 0\n")
(goto-char (+ p2 +9))
(beginning-of-line)
(insert "#endif\n")))
From: Harry Putnam <reader@newsguy.com>
To: help-gnu-emacs@gnu.org
Date: 12/02/2010 05:06 PM
Subject: Wrap predefined text around region
Sent by: help-gnu-emacs-bounces+kgold=watson.ibm.com@gnu.org
Can anyone show an example of how to do something like this:
I want to wrap this:
# [HP 101202_15:55:07
# ]
Around the selected text...
<selected text region here>
<selected text region here>
<selected text region here>
<selected text region here>
that is, select some text and press a key
combo ... voila... its now surrounded by:
# [HP 101202_15:55:07
# ]
Over the yrs I've acquired a fairly lengthy .emacs mostly by theft
from more skilled people. Coding something like that is clear out of
my skill set.
I use lots of `skeleton' things for inserting various predefined texts
but don't know how to make that happen to selected region.
Usually given an example, I've been able to hack it up to my needs.
[-- Attachment #2: Type: text/html, Size: 2932 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-03 14:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-02 22:05 Wrap predefined text around region Harry Putnam
2010-12-03 10:18 ` Kevin Rodgers
2010-12-03 12:14 ` Andreas Röhler
2010-12-03 14:31 ` Kenneth Goldman
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).