help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrap around and comment function


From: Harry Putnam
Subject: Re: Wrap around and comment function
Date: Wed, 30 Nov 2005 08:36:53 -0600
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Chong Yidong <cyd@stupidchicken.com> 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 <cyd@stupidchicken.com>
;; 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]