[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inserting comment headings
From: |
Sean Richards |
Subject: |
Re: inserting comment headings |
Date: |
Tue, 20 Jan 2004 21:33:54 +1300 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) |
Brad Collins <brad@studiojungle.net> writes:
> Okay teacher -- here is my homework :)
>
> I'm just a beginner as well, but this seems to work... Is there a
> better way to do this?
>
> (defun insert-comment-heading (comment)
> "Insert COMMENT, followed by \" ---...\". The line will be
> commented based on which mode you are in."
> (interactive "sComment: ")
> (insert comment " " (make-string (- (window-width)
> (+ (length comment) 5)
> 10)
> ?-))
> (previous-line 1)
> (let ((line-start (point)))
> (forward-paragraph 1)
> (when comment-start
> (comment-region line-start (point))))
> (newline))
Well I'm pretty green with elisp as well but I think it is a bit nicer
to solve the problem as shown below ....
--8<----------------------------------------------------------------------
(defun insert-comment-heading (comment)
"Insert COMMENT, followed by \" ---...\". The line will be
commented based on which mode you are in."
(interactive "sComment: ")
(insert comment " " (make-string (- (window-width)
(+ (length comment) 5)
10)
?-))
(comment-region (point-at-bol) (point-at-eol)))
(newline))
--8<----------------------------------------------------------------------
Sean
--
"Hver sin smak", sa vintapperen, han drakk mens de andre sloss.
- Re: inserting comment headings, (continued)
- Re: inserting comment headings, Tim X, 2004/01/19
- Re: inserting comment headings, Patrick Drechsler, 2004/01/19
- Re: inserting comment headings, Kevin Rodgers, 2004/01/19
- Re: inserting comment headings, Patrick Drechsler, 2004/01/19
- Re: inserting comment headings, Paolo Gianrossi, 2004/01/19
- Re: inserting comment headings, Brad Collins, 2004/01/20
- Message not available
- Re: inserting comment headings,
Sean Richards <=
- Re: inserting comment headings, Paolo Gianrossi, 2004/01/20
- Re: inserting comment headings, Patrick Drechsler, 2004/01/20
Re: inserting comment headings, Stefan Monnier, 2004/01/20
Message not available