From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Wrap predefined text around region Date: Fri, 03 Dec 2010 03:18:48 -0700 Message-ID: References: <87fwufhlup.fsf@newsguy.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1291371615 20514 80.91.229.12 (3 Dec 2010 10:20:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 3 Dec 2010 10:20:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 03 11:20:11 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1POSkN-0000uz-3u for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Dec 2010 11:20:11 +0100 Original-Received: from localhost ([127.0.0.1]:35329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POSkM-0003kg-9q for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Dec 2010 05:20:10 -0500 Original-Received: from [140.186.70.92] (port=56604 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POSjH-0003M7-OJ for help-gnu-emacs@gnu.org; Fri, 03 Dec 2010 05:19:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POSjG-00048t-Cu for help-gnu-emacs@gnu.org; Fri, 03 Dec 2010 05:19:03 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:49794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POSjG-00047n-71 for help-gnu-emacs@gnu.org; Fri, 03 Dec 2010 05:19:02 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1POSjB-0000SS-46 for help-gnu-emacs@gnu.org; Fri, 03 Dec 2010 11:18:57 +0100 Original-Received: from c-24-8-96-241.hsd1.co.comcast.net ([24.8.96.241]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 03 Dec 2010 11:18:57 +0100 Original-Received: from kevin.d.rodgers by c-24-8-96-241.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 03 Dec 2010 11:18:57 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 52 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-24-8-96-241.hsd1.co.comcast.net User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 In-Reply-To: <87fwufhlup.fsf@newsguy.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75488 Archived-At: 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... > > > > > > 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