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: Thierry Volpiatto
Subject: Re: LISP routines for commenting
Date: Sat, 09 Aug 2008 18:33:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Python-mode provide a command for indenting that is bind to:

C-c # ==> comment
C-u C-c # ==> uncomment
The command is: `py-comment-region'

It is better to comment with that instead of the usual M-;
because it don't affect indentation after a block of commented code.

I don't know if python.el provide the same.

weber <hugows@gmail.com> writes:

> On Aug 8, 10:43 pm, "Joel J. Adamson " <adams...@email.unc.edu> wrote:
>> >>>>> "Alex" == Alex Gusarov <alex.m.gusa...@gmail.com> 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
>

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France




reply via email to

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