From: Sean Richards <somebody@nowhere.com>
Subject: Re: inserting comment headings
Date: Tue, 20 Jan 2004 21:33:54 +1300 [thread overview]
Message-ID: <878yk3t3wt.fsf@hugin.valhalla.net> (raw)
In-Reply-To: mailman.971.1074580719.928.help-gnu-emacs@gnu.org
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.
next prev parent reply other threads:[~2004-01-20 8:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-19 0:13 inserting comment headings Patrick Drechsler
2004-01-19 4:32 ` leo
2004-01-19 8:35 ` Tim X
2004-01-19 9:04 ` Patrick Drechsler
2004-01-19 17:21 ` Martin Stemplinger
2004-01-19 18:12 ` Patrick Drechsler
2004-01-20 22:59 ` Martin Stemplinger
2004-01-19 22:00 ` Tim X
2004-01-19 22:18 ` Patrick Drechsler
2004-01-19 22:38 ` Kevin Rodgers
2004-01-19 22:57 ` Patrick Drechsler
2004-01-19 23:28 ` Paolo Gianrossi
2004-01-20 6:36 ` Brad Collins
[not found] ` <mailman.971.1074580719.928.help-gnu-emacs@gnu.org>
2004-01-20 8:33 ` Sean Richards [this message]
2004-01-20 12:46 ` Paolo Gianrossi
2004-01-20 17:58 ` Patrick Drechsler
2004-01-20 17:02 ` Stefan Monnier
[not found] ` <q7uwu7esh4f.fsf@hw1371.wdf.sap.corp>
2004-01-26 19:51 ` Patrick Drechsler
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878yk3t3wt.fsf@hugin.valhalla.net \
--to=somebody@nowhere.com \
--cc=sean_news@myrealbox.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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.