* inserting comment headings
@ 2004-01-19 0:13 Patrick Drechsler
2004-01-19 4:32 ` leo
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Patrick Drechsler @ 2004-01-19 0:13 UTC (permalink / raw)
Hi,
I can't find a command for inserting comment seperation
headers... I'm probably looking for the wrong keywords.
How do I insert something like this (i.e. lisp; preverably in all
modes):
;;* my comment ----------------------------------------
Doesn't have to look like that but you get my point, I hope.
TIA,
Patrick
--
Look Ma, this man can twist his fingers as if they were made of
rubber, isn't that amazing? -- Not really, he's been using Emacs for
years...!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
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-20 17:02 ` Stefan Monnier
[not found] ` <q7uwu7esh4f.fsf@hw1371.wdf.sap.corp>
2 siblings, 1 reply; 18+ messages in thread
From: leo @ 2004-01-19 4:32 UTC (permalink / raw)
"Patrick Drechsler" <patrick.drechsler@gmx.net> wrote in message
news:m3vfn8g5ia.fsf@pdrechsler.fqdn.th-h.de...
> Hi,
>
> I can't find a command for inserting comment seperation
> headers... I'm probably looking for the wrong keywords.
>
> How do I insert something like this (i.e. lisp; preverably in all
> modes):
>
> ;;* my comment ----------------------------------------
you can use `comment-region': set the mark before you begin, then write the
comment text and invoke `comment-region'.
should work in multiple modes.
cheers, leo
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 4:32 ` leo
@ 2004-01-19 8:35 ` Tim X
2004-01-19 9:04 ` Patrick Drechsler
0 siblings, 1 reply; 18+ messages in thread
From: Tim X @ 2004-01-19 8:35 UTC (permalink / raw)
>>>>> "leo" == leo <halloleo@noospaam.myrealbox.com> writes:
leo> "Patrick Drechsler" <patrick.drechsler@gmx.net> wrote in message
leo> news:m3vfn8g5ia.fsf@pdrechsler.fqdn.th-h.de...
>> Hi,
>>
>> I can't find a command for inserting comment seperation
>> headers... I'm probably looking for the wrong keywords.
>>
>> How do I insert something like this (i.e. lisp; preverably in all
>> modes):
>>
>> ;;* my comment ----------------------------------------
leo> you can use `comment-region': set the mark before you begin,
leo> then write the comment text and invoke `comment-region'.
leo> should work in multiple modes.
leo> cheers, leo
In addition, in most modes if you hit M-; (usually bound to
comment-region) without having set the region, you will get a comment
character and then if you hit M-j you will get a continuation of the
comment marker on the next line.
Tim
--
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you
really need to send mail, you should be able to work it out!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 8:35 ` Tim X
@ 2004-01-19 9:04 ` Patrick Drechsler
2004-01-19 17:21 ` Martin Stemplinger
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Patrick Drechsler @ 2004-01-19 9:04 UTC (permalink / raw)
Tim X. wrote on 19 Jan 2004 09:35:45 MET:
>>>>>> "leo" == leo <halloleo@noospaam.myrealbox.com> writes:
>
[...M-;, M-j...]
Thanks for the answers, I already use these commands
frequently. But this is not quit what I was looking for.
I wanted to include the `-----------------' stuff after the
comment automatically:
;;* comment -----------------------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Any ideas?
Patrick
--
"What happens if a big asteroid hits Earth ? Judging from
realistic simulations involving a sledge hammer and a common
laboratory frog, we can assume it will be pretty bad."
-- Dave Barry
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
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:38 ` Kevin Rodgers
2 siblings, 2 replies; 18+ messages in thread
From: Martin Stemplinger @ 2004-01-19 17:21 UTC (permalink / raw)
On Mon Jan 19 2004 at 10:04, Patrick Drechsler
<patrick.drechsler@gmx.net> wrote:
> I wanted to include the `-----------------' stuff after the
> comment automatically:
>
> ;;* comment -----------------------------------------------
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Any ideas?
>
You could write a little function that asks for the comment and
inserts it accordingly.
--
Remove NOSPAM to reply by mail
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 17:21 ` Martin Stemplinger
@ 2004-01-19 18:12 ` Patrick Drechsler
2004-01-20 22:59 ` Martin Stemplinger
1 sibling, 0 replies; 18+ messages in thread
From: Patrick Drechsler @ 2004-01-19 18:12 UTC (permalink / raw)
Martin Stemplinger wrote on 19 Jan 2004 18:21:35 MET:
> On Mon Jan 19 2004 at 10:04, Patrick Drechsler
> <patrick.drechsler@gmx.net> wrote:
>
>> I wanted to include the `-----------------' stuff after the
>> comment automatically:
>>
>> ;;* comment -----------------------------------------------
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> Any ideas?
>>
> You could write a little function that asks for the comment and
> inserts it accordingly.
If I were able to do just that... Sorry my lisp isn't that
good. I just started reading about atoms, list, etc.. :-(
I'll give it a try though.
Cheers
Patrick
--
Snoopy (on being house-trained with a rolled-up newspaper):
It does tend however to give one a rather distorted view of the press!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 17:21 ` Martin Stemplinger
2004-01-19 18:12 ` Patrick Drechsler
@ 2004-01-20 22:59 ` Martin Stemplinger
1 sibling, 0 replies; 18+ messages in thread
From: Martin Stemplinger @ 2004-01-20 22:59 UTC (permalink / raw)
On Mon Jan 19 2004 at 18:21, Martin Stemplinger
<mstemplingerNOSPAM@gmx.de> wrote:
> On Mon Jan 19 2004 at 10:04, Patrick Drechsler
> <patrick.drechsler@gmx.net> wrote:
>
>> I wanted to include the `-----------------' stuff after the
>> comment automatically:
>>
>> ;;* comment -----------------------------------------------
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> Any ideas?
>>
> You could write a little function that asks for the comment and
> inserts it accordingly.
In the meantime I had some spare time to come up with a solution:
(defun ms-insert-comment-at-line (comment)
"Insert a comment at the beginning of the current line."
(interactive "sComment:")
(forward-line 0)
(insert (comment-padright comment-start comment-add) " ** "
comment " " (make-string (- (window-width)
(+ (length comment) 5)
1)
?-))
(unless (string= "" comment-end)
(insert (comment-padleft comment-end comment-add))))
HTH
Martin
--
Remove NOSPAM to reply by mail
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 9:04 ` Patrick Drechsler
2004-01-19 17:21 ` Martin Stemplinger
@ 2004-01-19 22:00 ` Tim X
2004-01-19 22:18 ` Patrick Drechsler
2004-01-19 22:38 ` Kevin Rodgers
2 siblings, 1 reply; 18+ messages in thread
From: Tim X @ 2004-01-19 22:00 UTC (permalink / raw)
>>>>> "Patrick" == Patrick Drechsler <patrick.drechsler@gmx.net> writes:
Patrick> Tim X. wrote on 19 Jan 2004 09:35:45 MET:
>>>>>>> "leo" == leo <halloleo@noospaam.myrealbox.com> writes:
>>
Patrick> [...M-;, M-j...]
Patrick> Thanks for the answers, I already use these commands
Patrick> frequently. But this is not quit what I was looking for.
Patrick> I wanted to include the `-----------------' stuff after the
Patrick> comment automatically:
Patrick> ;;* comment -----------------------------------------------
Patrick> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Patrick> Any ideas?
Patrick> Patrick -- "What happens if a big asteroid hits Earth ?
Patrick> Judging from realistic simulations involving a sledge hammer
Patrick> and a common laboratory frog, we can assume it will be
Patrick> pretty bad." -- Dave Barry
In that case, I'd check out tempo.el and skel.el - you can define a
template/skeleton for your comment with optional dynamic parts which
are prompted for a the time you use it.
Tim
--
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you
really need to send mail, you should be able to work it out!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 22:00 ` Tim X
@ 2004-01-19 22:18 ` Patrick Drechsler
0 siblings, 0 replies; 18+ messages in thread
From: Patrick Drechsler @ 2004-01-19 22:18 UTC (permalink / raw)
Tim X. wrote on 19 Jan 2004 23:00:59 MET:
>>>>>> "Patrick" == Patrick Drechsler <patrick.drechsler@gmx.net> writes:
[...]
> Patrick> I wanted to include the `-----------------' stuff
> Patrick> after the comment automatically:
>
> Patrick> ;;* comment ----------------------------------
> Patrick> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> In that case, I'd check out tempo.el and skel.el - you can
> define a template/skeleton for your comment with optional
> dynamic parts which are prompted for a the time you use it.
Thanks Tim, I'll take a lot into these functions!
Cheers
Patrick
--
Computers are good at following instructions,
but not at reading your mind. -- Donald Knuth
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 9:04 ` Patrick Drechsler
2004-01-19 17:21 ` Martin Stemplinger
2004-01-19 22:00 ` Tim X
@ 2004-01-19 22:38 ` Kevin Rodgers
2004-01-19 22:57 ` Patrick Drechsler
2 siblings, 1 reply; 18+ messages in thread
From: Kevin Rodgers @ 2004-01-19 22:38 UTC (permalink / raw)
Patrick Drechsler wrote:
> Tim X. wrote on 19 Jan 2004 09:35:45 MET:
>
>
>>>>>>>"leo" == leo <halloleo@noospaam.myrealbox.com> writes:
>>>>>>>
>
> [...M-;, M-j...]
>
> Thanks for the answers, I already use these commands
> frequently. But this is not quit what I was looking for.
>
> I wanted to include the `-----------------' stuff after the
> comment automatically:
>
> ;;* comment -----------------------------------------------
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Any ideas?
(defun insert-comment-heading (comment)
"Insert COMMENT, preceded by \";;* \" and followed by \" ---...\"."
(interactive "sComment: ")
(insert ";;* " comment " " (make-string (- (window-width)
(+ (length comment) 5)
1)
?-))
(newline))
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 22:38 ` Kevin Rodgers
@ 2004-01-19 22:57 ` Patrick Drechsler
2004-01-19 23:28 ` Paolo Gianrossi
0 siblings, 1 reply; 18+ messages in thread
From: Patrick Drechsler @ 2004-01-19 22:57 UTC (permalink / raw)
Kevin Rodgers wrote on 19 Jan 2004 23:38:33 MET:
> Patrick Drechsler wrote:
>
>> Tim X. wrote on 19 Jan 2004 09:35:45 MET:
[...]
>> [...M-;, M-j...]
>> Thanks for the answers, I already use these commands
>> frequently. But this is not quit what I was looking for.
>> I wanted to include the `-----------------' stuff after the
>> comment automatically:
>> ;;* comment -----------------------------------------------
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> Any ideas?
>
>
> (defun insert-comment-heading (comment)
> "Insert COMMENT, preceded by \";;* \" and followed by \" ---...\"."
> (interactive "sComment: ")
> (insert ";;* " comment " " (make-string (- (window-width)
> (+ (length comment) 5)
> 1)
> ?-))
> (newline))
Cool! Thank you very much Kevin!
Now I just have to figure out how to let this function detect the
mode emacs is in. But I'll go ahead and try that on my own.
Cheers
Patrick
--
The shortest unit of time in the universe is the New York Second,
defined as the period of time between the traffic lights turning green
and the cab behind you honking. -- Terry Pratchett 'Lords and Ladies'
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
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>
0 siblings, 2 replies; 18+ messages in thread
From: Paolo Gianrossi @ 2004-01-19 23:28 UTC (permalink / raw)
On Mon, 19 Jan 2004 23:57:25 +0100
Patrick Drechsler <patrick.drechsler@gmx.net> wrote:
>
> Kevin Rodgers wrote on 19 Jan 2004 23:38:33 MET:
>
> > Patrick Drechsler wrote:
> >
> >> Tim X. wrote on 19 Jan 2004 09:35:45 MET:
>
> [...]
>
> >> [...M-;, M-j...]
> >> Thanks for the answers, I already use these commands
> >> frequently. But this is not quit what I was looking for.
> >> I wanted to include the `-----------------' stuff after the
> >> comment automatically:
> >> ;;* comment -----------------------------------------------
> >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >> Any ideas?
> >
> >
> > (defun insert-comment-heading (comment)
> > "Insert COMMENT, preceded by \";;* \" and followed by \" ---...\"."
> > (interactive "sComment: ")
> > (insert ";;* " comment " " (make-string (- (window-width)
> > (+ (length comment) 5)
> > 1)
> > ?-))
> > (newline))
>
> Cool! Thank you very much Kevin!
>
> Now I just have to figure out how to let this function detect the
> mode emacs is in. But I'll go ahead and try that on my own.
don't want to spoil your research :) but you might not need that... each mode defines comments... Won't say more if you don't ask, you might be having fun with this...
cheers
paolino
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
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>
1 sibling, 0 replies; 18+ messages in thread
From: Brad Collins @ 2004-01-20 6:36 UTC (permalink / raw)
Paolo Gianrossi <paolino.gnu@disi.unige.it> writes:
> don't want to spoil your research :) but you might not need
> that... each mode defines comments... Won't say more if you don't
> ask, you might be having fun with this...
>
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))
I tried it in a couple different modes:
> message mode ---------------------------------------------------
;; lisp-mode --------------------------------------------------------
# yaml mode --------------------------------------------------------
/* css mode --------------------------------------------------------- */
@Comment bibtex mode ------------------------------------------------------
@c texinfo mode -----------------------------------------------------
Cool, this is a useful little snippet, thanks everyone!
b/
--
Brad Collins
Chenla Labs
Bangkok, Thailand
^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <mailman.971.1074580719.928.help-gnu-emacs@gnu.org>]
* Re: inserting comment headings
[not found] ` <mailman.971.1074580719.928.help-gnu-emacs@gnu.org>
@ 2004-01-20 8:33 ` Sean Richards
2004-01-20 12:46 ` Paolo Gianrossi
0 siblings, 1 reply; 18+ messages in thread
From: Sean Richards @ 2004-01-20 8:33 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-20 8:33 ` Sean Richards
@ 2004-01-20 12:46 ` Paolo Gianrossi
2004-01-20 17:58 ` Patrick Drechsler
0 siblings, 1 reply; 18+ messages in thread
From: Paolo Gianrossi @ 2004-01-20 12:46 UTC (permalink / raw)
Sean Richards <somebody@nowhere.com> writes:
> Brad Collins <brad@studiojungle.net> writes:
>
> > Okay teacher -- here is my homework :)
It wasn't a teacher's attitude (I'm no lisp guru as well... :) i just thought
that if you wanted to research on your own for the fun of it, it would have
been bad to tell you...
> >
> > I'm just a beginner as well, but this seems to work... Is there a
> > better way to do this?
Your solution is quite nice...
> >
> > (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 ....
This looks even better to me...
> --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<----------------------------------------------------------------------
For my taste, though, I'd use fill-column and dynamic comment size to find the
-line length, like:
(defun inserrt-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 (- fill-column
(+ (length comment) (length comment-start)
(length comment-end)))
?-))
(comment-region (point-at-bol) (point-at-eol))
(goto-char (point-at-eol))
(newline)
)
cheers
paolino
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-20 12:46 ` Paolo Gianrossi
@ 2004-01-20 17:58 ` Patrick Drechsler
0 siblings, 0 replies; 18+ messages in thread
From: Patrick Drechsler @ 2004-01-20 17:58 UTC (permalink / raw)
Paolo Gianrossi wrote on 20 Jan 2004 13:46:18 MET:
> Sean Richards <somebody@nowhere.com> writes:
>
>> Brad Collins <brad@studiojungle.net> writes:
Just finished work and...
Damn, you guys are fast! ;-)
Thanks to all three of you!
Thanks also to Stefan Monnier for the tip to use `comment-box'.
Cheers
Patrick
--
Snoopy (on being house-trained with a rolled-up newspaper):
It does tend however to give one a rather distorted view of the press!
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: inserting comment headings
2004-01-19 0:13 inserting comment headings Patrick Drechsler
2004-01-19 4:32 ` leo
@ 2004-01-20 17:02 ` Stefan Monnier
[not found] ` <q7uwu7esh4f.fsf@hw1371.wdf.sap.corp>
2 siblings, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2004-01-20 17:02 UTC (permalink / raw)
> ;;* my comment ----------------------------------------
> Doesn't have to look like that but you get my point, I hope.
Something different, but in the same spirit (i.e. not just comment, but
make it more visible):
enter the "my comment" text;
select it
M-x comment-box RET
Stefan
^ permalink raw reply [flat|nested] 18+ messages in thread
[parent not found: <q7uwu7esh4f.fsf@hw1371.wdf.sap.corp>]
end of thread, other threads:[~2004-01-26 19:51 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).