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

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

Re: LISP routines for commenting


From: weber
Subject: Re: LISP routines for commenting
Date: Sat, 9 Aug 2008 07:43:11 -0700 (PDT)
User-agent: G2/1.0

On Aug 8, 10:43 pm, "Joel J. Adamson " <address@hidden> wrote:
> >>>>> "Alex" == Alex Gusarov <address@hidden> writes:
>
>     Alex> Hello,
>     Alex> I want to implement some lisp functions for the following:
>     Alex> 1. Insert comment - when mark some lines of code and using it, 
> insert
>     Alex> ins-comments, like this:
>
>     Alex> before:
>
>     Alex> l = []
>     Alex> l.append(1)
>
>     Alex> then mark it and use ins-func, after:
>
>     Alex> # ins > <username>, <current date and time>
>     Alex> l = []
>     Alex> l.append(1)
>     Alex> # ins < <username>, <current date and time>
>
> If I understand correctly, you want to implement some lisp to comment
> your Python code?  Have you tried Python mode?  There is a commonly used
> key (M-;) that comments lines and regions --- look up the function
> "comment-region."  In each programming language mode, this function
> inserts the proper comments for the language you are using (e.g., ";"
> for lisp and "#" for Python, Perl, et al).
>
> Please be specific if you want something else.
>
> Joel
>
> --
> Joel J. Adamson
> (303) 880-3109
> Public 
> key:http://pgp.mit.eduhttp://www.unc.edu/~adamsonjhttp://trashbird1240.blogspot.com

Alex,
is this what you want?

(defun ins-comment (beg end)
  (interactive "r")
  (let ((str (concat user-login-name ", " (format-time-string "%d/%m/
%y %Hh%Mmin"))))
        (goto-char end)
        (insert "# ins < " str)
        (goto-char beg)
        (insert "# ins > " str "\n")))

HTH,
hugo


reply via email to

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