From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenneth Goldman Newsgroups: gmane.emacs.help Subject: Re: Wrap predefined text around region Date: Fri, 3 Dec 2010 09:31:00 -0500 Message-ID: References: <87fwufhlup.fsf@newsguy.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=_alternative 004FBDF9852577EE_=" X-Trace: dough.gmane.org 1291388158 13828 80.91.229.12 (3 Dec 2010 14:55:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 3 Dec 2010 14:55:58 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 03 15:55:54 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 1POX3B-0006Op-2i for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Dec 2010 15:55:53 +0100 Original-Received: from localhost ([127.0.0.1]:58557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POX3A-0004B4-Hs for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Dec 2010 09:55:52 -0500 Original-Received: from [140.186.70.92] (port=40270 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POX2f-00045B-49 for help-gnu-emacs@gnu.org; Fri, 03 Dec 2010 09:55:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POX2Z-0000cx-EG for help-gnu-emacs@gnu.org; Fri, 03 Dec 2010 09:55:20 -0500 Original-Received: from e8.ny.us.ibm.com ([32.97.182.138]:51487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POX2Z-0000NS-Bf for help-gnu-emacs@gnu.org; Fri, 03 Dec 2010 09:55:15 -0500 Original-Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e8.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB3EbG3n004940 for ; Fri, 3 Dec 2010 09:37:17 -0500 Original-Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id A152772815E for ; Fri, 3 Dec 2010 09:31:03 -0500 (EST) Original-Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oB3EV372147626 for ; Fri, 3 Dec 2010 09:31:03 -0500 Original-Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oB3EV3pt009094 for ; Fri, 3 Dec 2010 09:31:03 -0500 Original-Received: from d01ml604.pok.ibm.com (d01ml604.pok.ibm.com [9.56.227.90]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id oB3EV33K009090 for ; Fri, 3 Dec 2010 09:31:03 -0500 In-Reply-To: <87fwufhlup.fsf@newsguy.com> X-KeepSent: DE32F692:BF8D3319-852577EE:004F809D; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 8.5.1FP1 SHF20 February 10, 2010 X-MIMETrack: S/MIME Sign by Notes Client on Kenneth Goldman/Watson/IBM(Release 8.5.1FP1 SHF20|February 10, 2010) at 12/03/2010 09:31:00 AM, Serialize by Notes Client on Kenneth Goldman/Watson/IBM(Release 8.5.1FP1 SHF20|February 10, 2010) at 12/03/2010 09:31:00 AM, Serialize complete at 12/03/2010 09:31:00 AM, S/MIME Sign failed at 12/03/2010 09:31:00 AM: The cryptographic key was not found, Serialize by Router on D01ML604/01/M/IBM(Release 8.5.2HF19 | August 31, 2010) at 12/03/2010 09:31:03, Serialize complete at 12/03/2010 09:31:03 X-Content-Scanned: Fidelis XPS MAILER X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:75495 Archived-At: This is a multipart message in MIME format. --=_alternative 004FBDF9852577EE_= Content-Type: text/plain; charset="US-ASCII" 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 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... 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. --=_alternative 004FBDF9852577EE_= Content-Type: text/html; charset="US-ASCII" 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.



--=_alternative 004FBDF9852577EE_=--