Hi Christian,

Right now the ‘matlab-comment’ function is pretty simple.   A quick look at it 
indicates that it wouldn’t be too hard to add in something like what you 
describe.

I’ve attached a small patch that does something vaguely like what you are 
interested in.  Hopefully it provides hints so you can expand it to do what you 
are interested in.

Eric

From: Christian Ridderström [mailto:christian.ridderst...@gmail.com]
Sent: Saturday, August 16, 2014 12:16 PM
To: matlab-emacs-discuss@lists.sourceforge.net
Subject: [Matlab-emacs-discuss] Adaptive comment column for 'matlab-comment', 
i.e. like 'comment-dwim' in Emacs?

Hi,

Is it possible to make 'matlab-comment' behave more like 'comment-dwim' in the 
mode 'Emacs-Lisp'?

What I'd like is the following behaviour. When you use 'M-;' (matlab-comment) 
and there is already a comment on the line that is too long, i.e. extends 
beyond 'fill-column' (76), then the '%' is shifted to the left if possible in 
order to keep the comment within the 'fill-column'.

Note: I tried calling 'comment-dwim' in matlab-mode, but it places the '% ' at 
the wrong place and the right alignment isn't working properly. I.e. the '% ' 
is moved as far left as possible, not merely as much that is needed to make the 
comment fit.

Best regards,
Christian

PS. In case the above isn't clear, here's an example.
Let's say we have this line of code:

x = 1;

Pressing 'M-;' will add '% ' at column 40. Then we add a long comment, getting 
this:

x = 1; % Here is a comment that is getting long

Now press 'M-;' again, and now the '%' is shifted to the left, resulting in 
e.g.:

x = 1; % Here is a comment that is getting long

--
Christian Ridderström,     +46-70 687 39 44

Attachment: matlab-emacs.el.patch
Description: matlab-emacs.el.patch

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Matlab-emacs-discuss mailing list
Matlab-emacs-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss

Reply via email to