Loving Ymacs!
I added this to my keybindings file:
"C-i": function() {
this.cmd("mark_whole_buffer");
this.cmd("indent_region");
},
It marks the entire buffer, but it doesn't indent the region. Any
idea why?
Ideally I'd like a command to indent the buffer without having to mark
the entire buffer but I don't know if there is a command for that.
Also, if I set the mark and I move the cursor around, the region that
is created doesn't get the different background so that I can see what
is delineated as the region as I scroll around. Is there a setting
to show the region's background color after setting a mark and moving
the point around?
thanks,
-joe
On Wed, Feb 10, 2010 at 11:37 PM, Joe <supe...@gmail.com> wrote:
>
> I added this to my keybindings file:
>
> "C-i": function() {
> this.cmd("mark_whole_buffer");
> this.cmd("indent_region");
> },
When called interactively, indent_region receives automatically the
begin/end position of the region. When calling it with this.cmd, you
need to supply these arguments manually. For your case the following
should do:
this.cmd("indent_region", 0, this.getCodeSize());
(and there's no need to call mark_whole_buffer).
> Also, if I set the mark and I move the cursor around, the region that
> is created doesn't get the different background so that I can see what
> is delineated as the region as I scroll around. Is there a setting
> to show the region's background color after setting a mark and moving
> the point around?
Nope, but it can be easily defined, for example:
Ymacs_Keymap_Emacs().defineKeys({
"C-=": Ymacs_Interactive("m", function(mark) {
if (!this.transientMarker) {
this.transientMarker = this.createMarker(mark);
this.ensureTransientMark();
}
})
});
Sorry for the general lack of API docs. :-(
Cheers,
-Mihai
> When called interactively, indent_region receives automatically the
> begin/end position of the region. When calling it with this.cmd, you
> need to supply these arguments manually. For your case the following
> should do:
>
> this.cmd("indent_region", 0, this.getCodeSize());
Sweet! works great. thanks!
> > Also, if I set the mark and I move the cursor around, the region that
> > is created doesn't get the different background so that I can see what
> > is delineated as the region as I scroll around. Is there a setting
> > to show the region's background color after setting a mark and moving
> > the point around?
>
> Nope, but it can be easily defined, for example:
>
> Ymacs_Keymap_Emacs().defineKeys({
> "C-=": Ymacs_Interactive("m", function(mark) {
> if (!this.transientMarker) {
> this.transientMarker = this.createMarker(mark);
> this.ensureTransientMark();
> }
> })
>
> });
Thanks. but is there a way to have it work without hitting a key such
as C-= every time you move the point to see the region?
So if a mark is set and the point is different from the mark, the
region is highlighted, even as it changes. Kind of like S-ARROW_UP, S-
ARROW_DOWN work. The difference being that it only highlights if the
mark is set and doesn't set one itself. My regular emacs works that
way, i think from:
;; highlite the selected region
(setq-default transient-mark-mode t)
thanks,
-joe
Not yet; that's because movement commands without SHIFT by default
clear the transient mark. I thought that whoever uses C-SPACE to set
the mark is used to not have it highlighted anyway (since Emacs early
days :).
--
Mihai Bazon,
http://mihai.bazon.net/blog
On Feb 10, 11:37 pm, Mihai Călin Bazon <mihai.ba...@gmail.com> wrote:
> On Thu, Feb 11, 2010 at 9:31 AM, Joe <super...@gmail.com> wrote:
>
> > Thanks. but is there a way to have it work without hitting a key such
> > as C-= every time you move the point to see the region?
>
> Not yet; that's because movement commands without SHIFT by default
> clear the transient mark. I thought that whoever uses C-SPACE to set
> the mark is used to not have it highlighted anyway (since Emacs early
> days :).
ya. well it's not a big deal, transient-mark-mode is pretty new to me,
and I lived without it for years :-)
Oh, I just noticed a potential bug: If you load up a sizable file
such as ymacs.js and then set the indentation level to 2. and then try
to indent the entire buffer (either by marking the whole buffer and
indent_region or by your new way), it doesn't indent anything. I get
a progress indicator on the status bar, it goes to 100% but nothing
gets indented. I can select portions of the file and indent that
however.
I tried both firefox and chrome and got the same result.
thanks,
-joe
>
> --
> Mihai Bazon,http://mihai.bazon.net/blog
I pushed a few minor changes including a fix for this. Updated the
demo and the latest.tar.gz too.
Cheers,
-Mihai
works great now!
thanks,
-joe