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
|
|
|