Conkeror - tips
Posted on Mon 13 November 2006 in Hacks (wannabe) • 8 min read
Kilka tipsów dla Conkerora znalezionych na blogu: http://bc.tech.coop/blog/060603.html
Firefox for Emacs users - Part 2 (Tips and Techniques)
Saturday, June 3, 2006
I recently `
posted <http://bc.tech.coop/blog/060529.html>`__ about my experience using `
Conkeror <http://conkeror.mozdev.org/>`__, a Firefox extension that lets you use emacs-style key
bindings in place of the mouse. I really enjoy using Conkeror, but the
documentation does leave a bit to be desired! The #conkeror IRC
channel and the `
mailing list <http://www.mozdev.org/pipermail/conkeror/>`__ are good sources of information; however, new users
often like to read through some basic stuff first to help them get
started. So, to help others who might want to play around with
Conkeror, I have accumulated a whole bunch of tips & techniques from
the mailing list and IRC channel and my own personal experience using
Conkeror. Some of the code samples are already in Conkeror; however,
looking at them may help others figure out how to start scripting
things in Conkeror. Hopefully, this will help someone
else get up-to-speed faster with using Conkeror.
Here they are (edited and reformatted a bit so that they are in a
Question/Answer format):
- Q. There doesn't seem to be any way to list "buffers" inConkeror.A. When you do a C-x r b (for a bookmark) or C-x b (for a buffer),pressing tab cycles through the available choices. There is alsosupport for "partial completion" (e.g. - if you type in the first fewcharacters, TAB only cycles through the ones that start with thosecharacters).
- Q. I really like Conkeror; however, there are times when I want touse "normal" Firefox. Is there any way to do this other than goingthrough the ResetChrome/ExitConkeror/RestartFirefox routine?
- Yes, put the following in your .conkerorrc file:
// Regular Firefox (non-conkeror) function firefox (arg) { window.openDialog("chrome://browser/content/"); } add_command ("ff", firefox, []);
Then, when you want to start up Firefox, type:
M-x ff
Incidentally, creating a ` bookmarklet <http://en.wikipedia.org/wiki/Bookmarklet>`__ in "normal" Firefox should allow you to do the samething in reverse (e.g. - bring up Conkeror without exitingFirefox). I created the following bookmarklet:javascript:window.openDialog('chrome://conkeror/content/');
Unfortunately, itdoesn't work as it creates a security exception in Firefox(surprisingly, it actually worked the first time I tried it but notafter that). Ifanyone can figure out how to make this work, I would appreciate the enlightenment! - Q. Is there anything I can use to help debug commands that Icreate in my .conkerorrc file.A. Try using the Javascript Console. Put the following in your.conkerorrc file to create a "jsconsole" command:
// Javascript console function jsconsole(args) { var prefix = args[0]; open_url_in (prefix, "chrome://global/content/console.xul"); } add_command("jsconsole", jsconsole, [["p"]]);
- Q. I make a lot of changes to my .conkerorrc file. Can't I reloadit without exiting/restarting Conkeror?A. Yes, you can use the built-in "source" command to load anyJavascript file (including your .conkerorrc file). Alternatively,you can create the following "reinit" command in your .conkerorrc file:
// Reload .conkeror RC file function reinit() { load_rc_file("/Users/bc/.conkerorrc"); } add_command("reinit", reinit, []);
- Q. Is there any way to copy a numbered link's URL? I can't figure outhow get to a link without activating it, or reaching for the mouse,clicking nearby and tabbing my way to it so I can yank it with 'Y',which kind of defeats the point of having a keyboard-driven browser.A. (number) M-RET will select the link. I don't think that's documentedanywhere. obviously it should be. C-RET opens in a new buffer.Just pressing 'c' RET copies the link of the current page.
- Q. Since there is no toolbar, how do you do things like access thepreferences?A. You can use Conkeror commands for most things (or create your owncommands and stick them in your .conkerorrc file). For example:
M-x customize
brings up the Firefox Preferences dialog
M-x extensions
brings up the Firefox Extensions dialog
- Q. Things don't seem to work in Conkeror anymore. I've muckedaround with my installation and I think I should just start overagain.
- If things get really hosed (e.g. - nothing seems to work), to uninstall & reinstall conkeror, do:
M-x help-page hit the 'Reset Chrome' button quit conkeror boot regular firefox -> extensions -> uninstall conkeror quit firefox boot firefox install conkeror
- Some things don't work as documented on Mac OS X.
- There are some problems with Conkeror on Mac OS X:
- The initial conkeror window doesn't allow itself to be resized if you start firefox from the command line (as per the installation instructions). However any following created conkeror windows can be resized without any problems. My strategy is to create a new window and kill the first one.
- For numbered links, M-RET focuses the link fine, but C-RET doesn't do anything.
- M-< and M-> do not do anything.
- Some people have the "Option" key mapped to "Meta" in Emacs; however, there is not any way to detect "Option" in Conkeror so "Meta" is always mapped to the Apple "Cmd" key.
- Q. Are you able to switch between several open Conkeror windows with theletter 'f' key?A. The 'f' key will cycle through the frames on a page. you'll have to useyour window manager to switch between conkeror windows.
- Q. How do you open up a new "buffer" in firefox from a commandline (or calling from another program)?
- Try this:
firefox -a firefox -remote "openURL(http://slashdot.org,new-tab)"
- I have lots of bookmarks in subdirectories that I can't see.
A. The following code will list all of your bookmarks (a variation of this is nowincluded in Conkeror as "C-x r l"):function findit () { var dirService = Components.classes["@mozilla.org/file/directory_service=;1"] .getService(Components.interfaces.nsIProperties); var dir = dirService.get("ProfD", Components.interfaces.nsIFile); dir.append("bookmarks.html"); open_url_in (1, "file://" + dir.path); } add_command("my-bookmarks", findit, []); define_key(ctrlc_kmap, make_key("b", MOD_CTRL), "my-bookmarks");
You can stick that in your .conkerorrc file.
- Q. Is there a way to highlight text that can be copied without using themouse? It seems intuitive to have a cursor that can be turned on oroff for this purpose.A. Press F7 gets you into "caret mode" with a visible cursor on theHTML page - then hold Shift and use arrows to select. This alsoworks in standard Firefox. the cursor with arrow keys to selectsomething. Some people find this setting useful:
user_pref("accessibility.warn_on_browsewithcaret", false);
- Q. Say I've got a link #108 on a page. How can I select it andopen it in a different buffer?
- Use the following:
1 0 8 M-RET C C-x C-f C-y RET
(C-x C-f is the same as C-u g, but more emacs-y)
- Q. Some people have difficulty withgetting emacs' 'browse-url' functions to play nice with Conkeror. Whatsettings work?
- Some people find that the following settings work fine...
(setq browse-url-browser-function 'browse-url-firefox browse-url-new-window-flag t browse-url-firefox-new-window-is-tab nil)
Obviously you need to have Firefox's chrome set to"chrome://conkeror/content" for that to work. And any URL you'browse-url' on will open in a new Conkeror frame. Don't set 'browse-url-firefox-new-window-is-tab' to 't' becauseConkeror seems not to understand the "new-tab" option to be an 'openURL'call. - How can you edit Firefox preferences from within Conkeror?
A. I've found two ways to edit Firefox prefs from within Conkeror.First, you can...g about:config
...and edit the raw variables by hand. The downside is that you haveto know what you're doing. I figured that there had to be a betterway, so I came up with...function my_prefs () { openDialog("chrome://browser/content/pref/pref.xul", "PrefWindow", "chrome,titlebar,resizable,modal", "catFeaturesbutton"); } add_command("prefs", my_prefs, []); define_key(ctrlc_kmap, make_key("p", MOD_META), "prefs");
Then 'C-c M-p' opens the familiar Firefox preferences dialog. Thereis also the built-in 'customize' command now.- How do you print a web page from conkeror?
A. There are a couple of ways. There is the built-in command'print-buffer'; however, you can also do:g javascript:window.print()
... which pops up a printing dialog.
- I use gmail extensively, and it fights with conqueror for keybindings. Has anyone else come up with a solution for this?
A. Well, this should soon be in Conkeror, but the relevant little block ofcode in utils.js (just after the call to clearMessage() inreadKeyPress()) is:// BWE: hack out non-modified keys from Gmail if( kmap == top_kmap && !metaPressed(event) && !event.ctrlKey && window._content.location.host == 'mail.google.com' ) { return; }
It's a hack, but it makes conkeror ignore all unmodified keystrokesfor pages at Gmail, which is enough to free up the regular Gmailkeybindings. A near future challenge is to try and hack somethingwith Greasemonkey to let me set my own Gmail keybindings for all thecurrently mouseonly stuff I need, then I can use it without the mouse,and without the over-numlinked HTML interface.- How does the jump to bookmark command work ?
A. This is the C-x r b binding right? You type the name of the bookmark. Unfortunately it's case sensitiveand bookmark names are often long and difficult to remember. You canuse TAB to tab complete. I usually just hit TAB and cycle through themuntil I get to the one I want. This isn't very good, of course. OneDay, I'd like to implement something like iswitchb...- How can I save an image or use the "save target as" function ?
A.Currently you can't really do it. The workaround is: Press 'i' and a pink number will appear in the corner of theimage. type the number, press RET. The image uri will be copied into theclipboard. you can then yank the url into a shell and use wget orsomething similar to download it.- How do you open the link of the current page in a new buffer?
- There's a section on the help page about the universal argument. To summarize:
C-u g www.someurl.com
opens url in new buffer
C-u C-u g www.someurl.com
opens url in new window
C-u will also work for other commands.
- Q. Is there a way to follow a link in anew buffer? (I did try the universal argument, with no luck.)
- Yes:
C-u i link#
or
C-u n link#
- Q. Is it possible to toggle visibility of pictures from conkeror?It would be very helpful to have this available. In general, is itpossible to access the settings that can be usually accessed fromfirefox's preferences in conkeror or is editing firefox/.../prefs.js byhand the preffered solution?A. Putting the code below in your .conkerorrc should do the trick. Thelast line maps toggle-images to C-c t
function toggle_images() { if (!gPrefService) { message("EEP: no gPrefService"); return 0; } var pref; if (!gPrefService.prefHasUserValue("network.image.imageBehavior")) { pref = 0; } else { pref = gPrefService.getIntPref("network.image.imageBehavior"); } gPrefService.setIntPref("network.image.imageBehavior", pref ? 0 : 2); pref = gPrefService.getIntPref("network.image.imageBehavior"); // redraw(); message ("imageBehavior set to " + pref); } add_command("toggle-images", toggle_images, []); define_key(ctrlc_kmap, make_key("t", 0), "toggle-images");
- Q. When I first started Conkeror, I got an error messageending with "...chrome://conkeror/content/utils.js::LocalFile::line 846date::no"(I looked at line in utils.js, but I don't know what it means.)A. This could be related to the conkeror rc file. Perhaps you had a valuefor the conkeror.rcfile pref (specifies your rc file) set but the filespecified didn't exist? Apparently, that was it. I did a "touch .conkerorrc" and the errorwent away.