Firefox: find as you type

Back in the days when I used Kubuntu, I used konqueror because if I hit the CTRL key, all the links would light up with a yellow tag by its side with either a letter or a number (or some character). If I typed that character then konqueror would go to that link’s page. I love this feature because I can be efficient surfing the web with the keyboard (mouse / trackpad is slow!).

Anywho, I always wanted Firefox to have this feature. I just discovered that Firefox has a similar feature. Check this page for a description. To turn on the feature, go to preferences > Advance and check “Search text as i start typing”. Firefox just got better.

The following is taken from the previous link to remind myself of some features.

  • Type several characters into the active browser window to navigate to any link with that text in it
  • If you repeat the same character, it will start to cycle through all the links that begin with that character. However, if it can find a match with the exact string you’ve typed, such as “oo” in “woods” it will go there first. Typing “o” more times will then cycle through the links that start with “o”.
  • Use the backspace key to undo the last character typed
  • Type a ‘ before your string to search only links. Type / before your string to search all text.
  • You can use the text search field to get to buttons, text boxes and other form controls. Just search for the text right before it, and then press Tab when to move from there.
  • To cancel a find, change focus or scroll, press Escape, or wait for the timeout
  • Press Accel+G or F3 to use “find next”. Press Accel+Shift+G or Shift+F3 to find previous, with the current string you’ve typed. This respects the current “linksonly” setting. Note: ‘accel’ means Ctrl on Windows, and Cmd on Mac. On Unix, ‘accel’ usually means Ctrl, but it can be set to Alt.
  • Works with any Gecko HTML content window – embedded clients, IM conversation window, help, etc.
  • works with IME for input of Chinese, Japanese, Korean, etc.
  • When focused on a link, the following keys will work:
    • Enter – activate the link
    • Shift+Enter – save the page that the link points to
    • Ctrl+Enter (Cmd+Enter on Mac) – open the link in a new window
    • Insert – open the link in a new foreground or background tab, depending on the “Load links in the background” pref. under Preferences – Navigator – Tabbed Browsing.
    • Shift+Insert – same as Insert, but does the opposite of the foreground/background pref

Open remote file while in emacs ansi-term buffer/window: ansi-term + tramp

In emacs, I can edit files remotely using tramp. While ssh’d to a remote server in ansi-term at a specific location, I can open the remote files in emacs as if that remote location is my working directory. This is taken form here. Put the following in the remote server’s .bashrc file:

## Emacs: ansi-term + tramp integration
## in ansi-term, ssh to this remote computer, can do C-x C-f and find file in REMOTE working directory
#Emacs ansi-term directory tracking
# track directory, username, and cwd for remote logons
if [ $TERM = eterm-color ]; then
 function eterm-set-cwd {
 echo -e "\033AnSiTc" $(pwd)

# set hostname, user, and cwd function eterm-reset { echo -e "\033AnSiTu" $(whoami) echo -e "\033AnSiTc" $(pwd) echo -e "\033AnSiTh" $(hostname) }

for temp in cd pushd popd; do alias $temp="eterm-set-cwd $temp" done

# set hostname, user, and cwd now eterm-reset fi

For SunOS servers, /usr/ucb is not in path, and whoami is not found. I need to put /usr/ucb in PATH in my .bashrc file. Credit belongs to this thread. Now while ssh’d to a remote server in ansi-term, try C-x C-f, and see the working directory on the remote server available by default.

edit files remotely: emacs + tramp

Suppose I want to edit a file remotely. I don’t want to download/ftp the file to my computer, edit, and send it back to the remote server. In emacs, I can edit it remotely using tramp via the ssh or rcp protocol. Put following in the .emacs file after installing tramp.

<pre class="src src-sh">;; tramp stuff

;; (require ‘tramp) (setq tramp-default-method “ssh”)

Read a remote file by C-x C-f / Note we Need that ‘/’ before username. This is a good reference for tramp.

Run screen in emacs with ansi-term (combine this with emacs + ess + remote R)

This is actually an update to this post, but since I discovered a few more things, I’ll write a new post. To run screen within a shell buffer in emacs, I tried M-x shell and fired up screen (ditto with M-x term). It gave me this error: Clear screen capability required. I found the solution to this here. To fix this issue, do M-x ansi-term (use /bin/bash when asked of course). screen now works inside emacs. Combine this with running a remote R session in emacs, and there you have it, the perfect work flow for developing and running computationally intensive R code! I can utilize screen to not have my R sessions interrupted, and I can utilize ESS to send code to an R session/buffer. I have to say, this WILL be the way I use R for any computationally-intensive project!


So screen doesn’t work in emacs after I ssh to a remote server inside ansi-term. I get the error: Cannot find terminfo entry for 'eterm-color'. To fix this, I put the following in my remote server’s .bashrc file (info from here.):

if [ "$TERM" = "eterm-color" ] ; then

UPDATE AGAIN (better solution)

This page (Remote Term Type section) shows how to fix the e-term color issue. Do make sure you create the .terminfo folder if its not there:

$ scp /usr/share/emacs/22.1/etc/e/eterm-color username@remoteserver:~/.terminfo/e/eterm-color
$ scp /usr/share/emacs/22.1/etc/e/eterm-color.ti username@remoteserver:~/.terminfo/e/eterm-color.ti


So copying files into .terminfo didn’t fix everything. I guess SunOS servers don’t look in my home directory for those files. I guess we can copy things into /usr/share/lib/terminfo/?/* (more information at man terminfo), but I don’t have access to this location in some of my servers. I will have to resort back to the old trick (changing TERM). This time, change it to xterm (this doesn’t give me funny characters in emacs ansi-term); found this at the bottom of this page. Put the following in the remote .bashrc file:

if [ $TEMP = "SunOS" ]; then
 if [ "$TERM" = "eterm-color" ] ; then

I hope there aren’t any more issues. What the previous trick does is check if system is SunOS, and if so, use xterm. I got the unix command information from here. I got the uname command info from here.


To get eterm-color to work in SunOS, put the following in my .bashrc file:

##following to get eterm-color working in SunOS

I guess I’ve been doing this, but I never exported TERMINFO. Didn’t know this was needed. Make sure the eterm-files are copied over (see top of post). Now everything should work, hopefully flawlessly. To summarize, copy eterm files into ~/.terminfo, and put the TERMINFO stuff in ~/.bashrc.

Now screen works in emacs. An issue that arised from this method is that when screen is run inside emacs, I can’t execute ess-remote anymore because I can’t press M-x. In ansi-term, C-x C-j : behave like emacs, cursor can go anywhere C-x C-k : behave like a terminal (default) This is documented here and here. Press C-x C-j and I can press M-x again. However, ess-remote still doesn’t work.

I guess when I use screen, I am forced to copy and paste code. If I really must use screen with ESS, do the regular M-x shell. After logging into the remote server, execute “TERM\=’vt100′” in the shell. Now, run screen -> R -> ess-remote. I can send code with keypresses now, but screen steals some of my emacs key bindings. To fix this, put the following,

escape \^Oo

in my remote ~/.screenrc file to switch the default command key from C-a to C-o so it doesn’t conflict with my emacs key bindings (documented here).

More information on ansi term (like remaping C-x to C-c) can be found here.

This was a long post. Summary:

  1. ansi-term in emacs behaves VERY much like a terminal. I can run vi, emacs, etc, inside of it. Emacs behavior is ‘term’ and ‘shell’.
  2. I can change things by editing the env variable, TERM.
  3. Change keybinding in the remote .screenrc file.

NEED TO DO: get ess-remote to work with ansi-term and screen in emacs!

UPDATE2: It seems the best way to do things so far is to use ansi-term -> ssh to remote server -> screen -> R, then go to line run (C-c C-j) and copy and paste code from there. To get screen commands to work (like detach, etc), need to go back to char run (C-c C-k). Remember, I now use C-o instead of C-a (defined in .screenrc); this only works on a regular terminal or in emacs with ansi-term, not using ‘shell’ in emacs with the hack I mentioned up there.

Displaying code with Syntax Highlighting on websites and blogger

This actually took me quite some time as some information out on the web are deprecated and because I have little to no knowledge of html, javascript, and css.

Use Syntax Highlighting, the latest version being here. Set up instructions here. Note that the code for the two css files are not closed correctly, so u need to change the closing to ‘/>’. For blogger, there is some kind of

issue, and i don’t want to turn the line break feature on blogger off, so based on the comment at the end of the page, add ‘SyntaxHighlighter.config.bloggerMode = true;’ to the code.

To use in blogger, type, in html mode,

 <pre class="src src-js">&lt;pre <span style="color: #00ffff;">class</span>=<span style="color: #ffa07a;">"brush:js"</span>&gt;

code in here


where you type whatever language you want after brush:. Here is a list.

Example 1:

 <pre class="src src-C">testing;



Paste the following in after HEAD declaration in the blogger template. I am using the Emacs theme of course. NOTE I GUESS SYNTAX HIGHLIGHTER IS NOT DISPLAYING the “/>” when the two css files end, REMEMBER to do so!

 <pre class="src src-js">&lt;link href=<span style="color: #ffa07a;">""</span> rel=<span style="color: #ffa07a;">"stylesheet"</span> type=<span style="color: #ffa07a;">"text/css"</span>&gt;

<link href=“” rel=“stylesheet” type=“text/css”>

<script src=“” type=“text/javascript”> <script src=“‘'” type=“‘text/javascript’/”> <script src=“‘'” type=“‘text/javascript’/”> <script src=“‘'” type=“‘text/javascript’/”> <script src=“‘'” type=“‘text/javascript’/”> <script src=“‘'” type=“‘text/javascript’/”> <script src=“‘'” type=“‘text/javascript’/”> <script src=“‘'” type=“‘text/javascript’/”> <script src=“‘'” type=“‘text/javascript’/”> <script src=“‘'” type=“‘text/javascript’/”> <script type=“‘text/javascript'”> SyntaxHighlighter.all(); SyntaxHighlighter.config.bloggerMode = true; </script>

When pasting html / javascript, etc, if blogger gives an error, just hit ignore!

Copy and paste code by hitting the view source icon!

Run a remote R session in emacs: emacs + ESS + R + ssh

I don’t know how, but somehow, I stumbled on how to run a remote R session in emacs.

Since Spring 2006 I’ve always used emacs with ESS to run R (did it on windows, switched to linux for years, and most recently, on my macbook). I liked this workflow because I get the same usual interface across multiple platforms. Plus, I use emacs for everything computery or scientific, like using coding Python or C.

Regarding the same interface across multiple platforms, I use, for example, emacs + ESS + R whenever I remotely log into the remote servers dedicated to computing. I just need to ssh into the server, fire up emacs and fire up R. However, I almost always write all of my code on the local computer, and when I’m ready to run the final code, I either run it as a batch script (utlizing nohup and &), through screen (to keep the session runnning after I log out, see my post on R with unix tools), or through emacs. These days, I’ve been doing it with screen mainly so disconnects to the server won’t interrupt my script.

I just found yet another way to do this: write code on my local computer and then send code to a remote R session in my local emacs. I ran into this by googling ‘emacs ess multiple R session’. Instructions are described here (section 3.3: ESS on remote computers). We need this file for things to work. This site clarified how to get graphics to work.

Instructions as follow:

  1. Download the ssh.el file.
  2. Install it the usual way or place it in ~/elisp or ~/.emacs.d. In your emacs init file, add:
 <pre class="src src-sh">;; add path to emacs

;; (add-to-list ‘load-path “~/elisp”)

;; load ssh.el file from elisp ;; this is to run ESS remotely on another computer in my own emacs, or just plai n old reading remote files ;; (require ‘ssh)

  1. Fire up emacs. Type ‘M-x ssh’. For the host settings, do something like ‘-X -C’ (X is for X windows forwarding, C is for compression of graphics, so plots can be displayed faster). Type in password.
  2. You wil be logged into a shell session on your server. Fire up R by typing R then enter. R is now running in an emacs buffer. Type M-x ess-remote. For dialect, select r.
  3. Open up any .R file on your computer, and use the usual keyboard shortcuts to send code to the remote R session.

W can also achieve the same results without the ssh.el file. In emacs, type M-x shell. In the shell buffer, ssh into the server and then run R. Type M-x ess-remote and everything should still work.

Next thing to get working is to open remote files in my local emacs.

Emacs: AucTeX + Rubber + Sweave

I got rubber to work with AucTeX and Sweave (Rnw) files with the help of this.

Basically, combined with my other stuff, I tweaked my .emacs file to look like:

<pre class="src src-sh">;;following is AucTeX with Sweave -- works

;; (setq TeX-file-extensions ‘(“Snw” “Rnw” “nw” “tex” “sty” “cls” “ltx” “texi” “texinfo”)) (add-to-list ‘auto-mode-alist ‘(“\.Rnw\'” . Rnw-mode)) (add-to-list ‘auto-mode-alist ‘(“\.Snw\'” . Snw-mode)) (add-hook ‘Rnw-mode-hook (lambda () (add-to-list ‘TeX-command-list (“Sweave” “R CMD Sweave %s” TeX-run-command nil (latex-mode) :help “Run Sweave”) t) (add-to-list ‘TeX-command-list (“LatexSweave” “%l %(mode) %s” TeX-run-TeX nil (latex-mode) :help “Run Latex after Sweave”) t) ;; following 3 lines for rubber, taken from same site as next paragraph,, xpdf to open (add-to-list ‘TeX-command-list (“RubberSweave” “rubber -d %s && open ‘%s.pdf'” TeX-run-command nil t) t) (setq TeX-command-default “Sweave”)))

;; AucTeX with rubber ;; (eval-after-load “tex” ‘(add-to-list ‘TeX-command-list ;;‘(“Rubber” “rubber -d %t && xpdf ‘%s.pdf‘” TeX-run-command nil t) t)) ;; change by vinh (“Rubber” “rubber -d %t && open ‘%s.pdf'” TeX-run-command nil t) t))

Now, when an Rnw file is open, I can press C-c C-c, select Sweave. Then repeat, select RubberSweave (or LatexSweave).

LaTeX in blogger, pt 2

In my previous post on this topic, I didn’t get LaTeX to work in Blogger because forkosh closed their mimetex service to the public. For LaTeX to work in blogs, I would either have to switch to wordpress or get my own host and install mimetex. The First option wasn’t too appealing as I’d like to keep everything google since a lot of my personal services are hosted here (yes, I’m not afraid of google having too much information about myself). Second option also wasn’t feasible. I found out from some more searching that codecogs is generous enough to host this kind of service. I updated wolverine’s script in firefox/greasemonkey with this, and now I have an UnLaTeX button as well! Really cool. To use, in compose mode in blogger, type dollar sign dollar sign LaTeX code dollar sign dollar sign, then hit the latex button. Bamm! To see original code, hit UnLatex. Here is an example.;%20%5Ctheta)

Looks good ehh? Optimally I would like blogger to have a LaTeX feature, but this suffices for now. This is different than before because I now have an unlatex command. This is useful because when codecogs goes down I am able to recover the original LaTeX code.

Hopefully for “LaTeX in blogger, pt 3″ a native LaTeX feature in blogger will be available. UPDATE: forgot to mention that I found codeclogs on here first.