unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Harry Putnam <reader@newsguy.com>
Subject: Re: Wrap around and comment function
Date: Wed, 30 Nov 2005 08:36:53 -0600	[thread overview]
Message-ID: <87br02qk1m.fsf@newsguy.com> (raw)
In-Reply-To: 87acfo6q3r.fsf@stupidchicken.com

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.

      parent reply	other threads:[~2005-11-30 14:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-29  3:56 Wrap around and comment function Harry Putnam
2005-11-29  4:21 ` Chong Yidong
2005-11-30 13:55   ` Harry Putnam
2005-11-30 14:36   ` Harry Putnam [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87br02qk1m.fsf@newsguy.com \
    --to=reader@newsguy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).