Re: IDLWAVE and starting a comment on a new line [message #48645] |
Thu, 11 May 2006 12:21 |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Thu, 11 May 2006 06:05:18 -0700, Gianguido Cianci wrote:
> Thanks a lot JD!
>
>> It only works with the stanza in .emacs that I provided. The next release
>> won't need this, but for now, you must set the "comment-add" parameter.
>
> The M-; trick does not work despite the addition of the "command-add"
> parameter and that's why I am perplexed.
Perhaps you're not setting it correctly in .emacs. Try, in a .pro buffer,
C-h v comment-add. It should say something like:
comment-add is a variable defined in `newcomment.el'.
Its value is 1
Local in buffer foo.pro; global value is 0
>> Yes, indeed. You might add something like this to your idlwave-mode-hook
>> inside of .emacs:
>>
>> (define-key (current-local-map)
>> [f6]
>> '(lambda () (interactive)
>> (insert ";{{{")
>> (indent-according-to-mode)))
>>
>> The same pattern can be used to insert anything.
>
>
> For anyone wanting to try it the define-key trick works great, though
> it only indents if the cursor is not in column 1. Which I guess is how
> idlwave indents comments in the first place. In case you're curious, I
> use ;{{{ and ;}}} with folding.el to fold IDL code in emacs, pretty
> nifty.
This is the correct behavior, since any comment starting at the
beginning of the line is not moved when indenting. If you always want
it to indent no matter where point is, perhaps inset " ;{{{" instead.
By the way, for "folding", the next version of IDLWAVE will support
HideShow, which lets you collapse blocks (routine definitions or
otherwise) with a few keystrokes. Very useful, and no comment
trickery required. A hidden function, for instance, look like:
function my_func,arg1,arg2...
but contains the full collapsed text. Sometimes I find it useful to
collapse (C-c @ C-M-h) everything, and then show a few functions at a
time. You can also hide any control block.
> I realize this is an IDL forum and not an emacs forum but I will
> give this a shot anyway... I think the super-uber version of the
> define-key command above would act slightly differently: it would
> insert the string "{{{", prepend the relevant comment characters for
> the current mode and finally indent the whole thing properly. Is
> *this* possible or am I just asking too much of either xemacs or
> this fine community?
In that case just stick it in the global map.
(define-key global-map
[f6]
'(lambda () (interactive)
(insert (concat " " comment-start "{{{"))
(indent-according-to-mode)))
JD
|
|
|
Re: IDLWAVE and starting a comment on a new line [message #48651 is a reply to message #48645] |
Thu, 11 May 2006 06:05  |
cgguido
Messages: 195 Registered: August 2005
|
Senior Member |
|
|
Thanks a lot JD!
> It only works with the stanza in .emacs that I provided. The next release
> won't need this, but for now, you must set the "comment-add" parameter.
The M-; trick does not work despite the addition of the "command-add"
parameter and that's why I am perplexed.
> Yes, indeed. You might add something like this to your idlwave-mode-hook
> inside of .emacs:
>
> (define-key (current-local-map)
> [f6]
> '(lambda () (interactive)
> (insert ";{{{")
> (indent-according-to-mode)))
>
> The same pattern can be used to insert anything.
For anyone wanting to try it the define-key trick works great, though
it only indents if the cursor is not in column 1. Which I guess is how
idlwave indents comments in the first place. In case you're curious, I
use ;{{{ and ;}}} with folding.el to fold IDL code in emacs, pretty
nifty.
I realize this is an IDL forum and not an emacs forum but I will give
this a shot anyway...
I think the super-uber version of the define-key command above would
act slightly differently: it would insert the string "{{{", prepend the
relevant comment characters for the current mode and finally indent the
whole thing properly. Is *this* possible or am I just asking too much
of either xemacs or this fine community?
Many thanks,
Gianguido
|
|
|
Re: IDLWAVE and starting a comment on a new line [message #48654 is a reply to message #48651] |
Wed, 10 May 2006 19:34  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Wed, 10 May 2006 14:54:13 -0700, Gianguido Cianci wrote:
> I am running xemacs 21.4.15 and idlwave 5.1 and I get a different
> behaviour:
> on a blank line I get ";" at the beginnig of the line independantly of
> indentation. What do you think is going on? Feel free to just tell me
> to upgrade :-)
It only works with the stanza in .emacs that I provided. The next release
won't need this, but for now, you must set the "comment-add" parameter.
> While we are on the subject, is there a way to associate a key sequence
> in xemacs to inserting a set string, say ";{{{" ***with the
> appropriate indentation*** ?
Yes, indeed. You might add something like this to your idlwave-mode-hook
inside of .emacs:
(define-key (current-local-map)
[f6]
'(lambda () (interactive)
(insert ";{{{")
(indent-according-to-mode)))
The same pattern can be used to insert anything.
JD
|
|
|
Re: IDLWAVE and starting a comment on a new line [message #48657 is a reply to message #48654] |
Wed, 10 May 2006 14:54  |
cgguido
Messages: 195 Registered: August 2005
|
Senior Member |
|
|
I am running xemacs 21.4.15 and idlwave 5.1 and I get a different
behaviour:
on a blank line I get ";" at the beginnig of the line independantly of
indentation. What do you think is going on? Feel free to just tell me
to upgrade :-)
While we are on the subject, is there a way to associate a key sequence
in xemacs to inserting a set string, say ";{{{" ***with the
appropriate indentation*** ?
Thanks,
Gianguido
|
|
|
|
Re: IDLWAVE and starting a comment on a new line [message #48659 is a reply to message #48658] |
Wed, 10 May 2006 11:03  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Wed, 10 May 2006 07:09:36 -0700, newbie16 wrote:
> Hi Everyone:
>
> Just a quick question here. I routinely use EMACS for editing code and
> IDLWAVE has been working great for me so far...with one maddening
> exception.
>
> When using EMACS for FORTRAN, I routinely start a comment by the character
> sequence: M-;
>
> This puts a "C" at the beginning of a line and indents to column 7. I
> love this feature of EMACS and do it quite automatically now. However,
> when using the same sequence in IDLWAVE-mode, a ";" is placed in the
> middle of the line and the comment starts there, when I really want it at
> the beginning of the line.
>
> For the last week I've tried fooling around with the various IDLWAVE
> configuration examples online (here and at IDLWAVE.org), but for the life
> of me, I can't seem to figure out which line needs to be changed and/or
> added (or how for that matter). Now, I know this isn't a serious issue
> but man it drives me nuts, and I finally brokedown today.
>
>
> Does anyone know of a configuration setting I can add to my .emacs file to
> set the behaviour of the above sequence to what I'm used to?
>
> Any pointers in the right direction are appreciated.
I actually didn't know about M-;, thanks.
By default, comments starting with ";" are indented to the right
(usually after a line of code), those starting with ";;" are indented
to the code indent location, and those starting with ";;;" are not
moved at all. Also, any comment starting at the very beginning of the
line is left there (regardless of how many semi-colons it starts
with).
The best way to get what you want is to set `comment-add' to 1
locally, by adding to your idlwave-mode-hook in .emacs:
(add-hook 'idlwave-mode-hook
(lambda ()
(set (make-local-variable 'comment-add) 1)))
In fact, I like this so much I'm adding it to the next version of
IDLWAVE. It also affects C-c ; (comment-region -- for the better I
think).
For those of you who want to try M-;, with this fix, on a blank line it
indents and puts in ";; ", on a line with code, it moves to the right
of the code with a ";". Really quite useful. For the curious, M-; calls
`comment-dwim'... "do what I mean" indeed.
Thanks for the suggestion.
JD
|
|
|
Re: IDLWAVE and starting a comment on a new line [message #48660 is a reply to message #48659] |
Wed, 10 May 2006 10:45  |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
Hi t.,
<newbie16@hotmail.com> wrote in message
news:1147270176.136145.278620@i40g2000cwc.googlegroups.com.. .
> Hi Everyone:
>
> When using EMACS for FORTRAN, I routinely start a comment by the
> character sequence: M-;
>
> This puts a "C" at the beginning of a line and indents to column 7. I
> love this feature of EMACS and do it quite automatically now. However,
> when using the same sequence in IDLWAVE-mode, a ";" is placed in the
> middle of the line and the comment starts there, when I really want it
> at the beginning of the line.
Short answer: use ';;' instead of ';'
More helpful answer:
In IDLWAVE mode you can bring up help for the mode with C-h m (or menu
IDLWAVE:Documentation:Describe Mode), which says, in part:
Comments are indented as follows:
`;;;' Indentation remains unchanged.
`;;' Indent like the surrounding code
`;' Indent to a minimum column.
The indentation of comments starting in column 0 is never changed.
Hope this helps!
--
Cheers,
--
-Dick
Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Victoria, BC, Canada / +1-250-220-6117
|
|
|