From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Harry Putnam Newsgroups: gmane.emacs.help Subject: Re: Wrap around and comment function Date: Wed, 30 Nov 2005 08:36:53 -0600 Organization: Still searching... Message-ID: <87br02qk1m.fsf@newsguy.com> References: <87y838xd9v.fsf@newsguy.com> <87acfo6q3r.fsf@stupidchicken.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1133374470 15171 80.91.229.2 (30 Nov 2005 18:14:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 30 Nov 2005 18:14:30 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 30 19:14:29 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EhW28-0005LF-Fl for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Nov 2005 18:46:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EhW27-0001yq-NQ for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Nov 2005 12:46:19 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EhUtg-0006Dx-4M for help-gnu-emacs@gnu.org; Wed, 30 Nov 2005 11:33:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EhUte-0006Cy-7x for help-gnu-emacs@gnu.org; Wed, 30 Nov 2005 11:33:31 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EhUte-0006Cr-26 for help-gnu-emacs@gnu.org; Wed, 30 Nov 2005 11:33:30 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EhUtd-0008An-GH for help-gnu-emacs@gnu.org; Wed, 30 Nov 2005 11:33:29 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EhURN-0007AM-0z for help-gnu-emacs@gnu.org; Wed, 30 Nov 2005 17:04:17 +0100 Original-Received: from adsl-68-74-157-215.dsl.emhril.ameritech.net ([68.74.157.215]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 30 Nov 2005 17:04:17 +0100 Original-Received: from reader by adsl-68-74-157-215.dsl.emhril.ameritech.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 30 Nov 2005 17:04:17 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 46 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: adsl-68-74-157-215.dsl.emhril.ameritech.net User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:bs5eJuHlIItP2lIB4a0/ybUAlg8= 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:31531 Archived-At: Chong Yidong writes: > Probably something like this: > > (defun foo (beg end string) > (interactive "*r\nsEnter a few words: ") > (let ((fin (copy-marker end))) > (goto-char beg) > (insert "[HP DATE - NOTE: " string "\n") > (goto-char (marker-position fin)) > (set-marker fin nil) > (insert "\n==* END HP NOTE *== ]\n") > (comment-region beg (point)))) I'm liking this more and more... I figured out how to include the date and fixed up for actual use. I really like this and will use it a lot Thanks: ;; From: Chong Yidong ;; Subject: Re: Wrap around and comment function ;; Newsgroups: gmane.emacs.help ;; Date: Mon, 28 Nov 2005 23:21:44 -0500 ;; Message-ID: <87acfo6q3r.fsf@stupidchicken.com> (defun GrabAndSurround (beg end string) (interactive "*r\nsEnter a few keywords: ") (let ((fin (copy-marker end))) (goto-char beg) (insert (format-time-string "HP %m%d%y_%M%H%S NOTE: ") string "\n") ;; (insert "[HP DATE - NOTE: " string "\n") (goto-char (marker-position fin)) (set-marker fin nil) (insert " ==* END HP NOTE *== ]\n") (comment-region beg (point)))) If I wanted to save the date into a variable and put the variable into the string instead of generating a formatted date there. Like if I wanted to use the same current date in seveal places in my code for example, how would I do that? Also maybe you can point me in the right direction using similar code, not commenting the region, still inserting pre string and post string but then appending it to an existing file, and be queried for file name.