Textarea Resize And Curly Quotes For Conkeror
People say Google Chrome is a step behind Firefox because Firefox has addons. Well, excuse me, but Firefox was already a step behind Conkeror and Vimperator! Making Google Chrome a whopping TWO steps behind. (But I’m sure we’re all another full step behind some completely obscure browser which only runs on Plan 9 and is being ported to the Erlang VM.)
Here are a few Conkeror hacks that can be easily dropped into your ~/.conkerorrc
. (If you need a introduction to Conkeror, see Conkeror Comes Unstuck.)
function resize_textarea_up(field) {
var h = field.offsetHeight;
if (h > 120)
field.style.height = (h - 60) + "px";
}
function resize_textarea_down(field) {
field.style.height = (parseInt(field.offsetHeight) + 60) + "px";
}
interactive(
"resize-textarea-up",
"Resize a textarea to be smaller.",
function (I) call_on_focused_field(I, resize_textarea_up)
);
interactive(
"resize-textarea-down",
"Resize a textarea to be taller.",
function (I) call_on_focused_field(I, resize_textarea_down)
);
define_key(content_buffer_textarea_keymap, "C-up", "resize-textarea-up", $category = "Movement");
define_key(content_buffer_textarea_keymap, "C-down", "resize-textarea-down", $category = "Movement");
This one enables Ctrl-Up
and Ctrl-Down
inside a textarea. So you can stretch the box without reaching for the mouse. How about that!
var quotes = [["squote", "C-quote", "2018"],
["apostrophe", "M-quote", "2019"],
["lquote", "C-S-quote", "201c"],
["rquote", "M-S-quote", "201d"],
["emdash", "M--", "2014"],
["ellipsis", "M-.", "2026"]];
for (var i in quotes) {
var q = quotes[i];
eval("function curly_" + q[0] + "(field) { modify_region(field, function(str) \"\\u" + q[2] + "\" ); }");
interactive(
"curly-" + q[0],
"Inserts a curly " + q[0] + " at the cursor in a textarea.",
eval("function (I) call_on_focused_field(I, curly_" + q[0] + ")")
);
define_key(content_buffer_text_keymap, q[1], "curly-" + q[0], $category = "Editing");
}
I find myself using more UTF-8 characters that aren’t on the keyboard. Like these are four keybindings for curly quotes.
If you hit the Ctrl
key and the single- or double-quote key, you’ll get a left-side curl. An Alt
gives a right-side curl. There are a few dashes in there, too. This stuff could be done in the keymaps, but I wanted to see how it could be scripted. OS X already has keymaps for these I think.
One other thing. If you are in a textarea and you hit Ctrl-I
, it’ll open the textarea in an external editor. For some reason, vim wasn’t doing it for me. Well, I had the setting wrong.
define_variable("editor_shell_command", "gvim -f");
Lastly, if you’re using a site that has its own keybindings (such as Try Ruby,) you can use Ctrl-Alt-Q
to let all keystrokes pass through. Hit Esc
to give focus back to the browser.
diogo_terror
Now, that’s a Hacketyfull browser!
dadeafea
feafaefafaf
fe
fea
fae
f
fae
f
af
af
Matthias Georgi
Conkeror is nice, but how about a full emacs implementation running inside a web browser (including a lisp-to-javascript compiler)?
Burke Libbey
@matthias: As cool as that would be, many people have tried and failed miserably to reimplement emacs and emacs lisp, whether it be in common lisp (this happened a couple times), ruby, or javascript. As tempting as it sounds, emacs’ code base has been growing for the last 30-some years. It’s scary. Most people seem to end up realizing it’s easier to implement the language in emacs than it is to implement emacs in the language.
Back on topic, as much as I liked the emacs-ness when I tried conkeror, I just couldn’t rip myself away from the real Firefox. _why (or others), have you tried Firemacs ? — I haven’t got around to trying it, but it seems to be a decent compromise.
Matthias Georgi
@burke: Perhaps it’s possible to reuse most of the emacs souce code and to implement the rendering and input routines inside a browser extension.
stephencelis
Ah, but is there a WebKit-based hacker’s browser?
If not, there very well should be.
James
“Ah, but is there a WebKit-based hacker’s browser?”
SECONDED !
Sebastian
@burke – Holy cow! I just installed Firemacs, and it is totally awesome! I’ve only played with it for a few minutes, but it’s already improved my browsing experience by leaps and bounds.
Someone (hint, hint) should write a blog entry on all it’s nifty features.
doki_pen
I’ve always dreamed of having a vim editor embedded in all the web page text areas. How many times have I hit escape and lost all my work. :(