Posted on 08-04-2014
Filed Under (Technology) by bigbang

If you are under Windows, you may need to config golang develop environment manually.

Get Emacs go-mode from misc/emacs/, there are two files: go-mode-load.el and go-mode.el.

Put them into your Emacs load-path, then add following code to .emacs:

;; golang mode
(add-to-list 'load-path "~/emacs/site-lisp/go-mode")
(require 'go-mode-load)
(require 'go-mode)

Then you can open go source file with syntax highlight now.

If you are under Ubuntu/Debian, the easiest way to install golang-mode is by:

sudo apt-get install golang-mode

After this installation, retart your Emacs then you can edit go source file with syntax highlight.

(0) Comments   
Posted on 08-04-2014
Filed Under (Technology) by bigbang

If you have a keyboard with two Alt keys (e.g. a US Keyboard), you will find that PuTTY doesn’t recognize the one on the right side. It is a fatal problem if you are using Emacs in putty on Windows to editing files on a remote computer.

After doing some reasearching on it, I think there are two soluctions for this problem.

  1. Easily fixed the problem with a simple registry edit

    The putty topic Right Alt Key Broken shows an easy solution for it by add following registry code:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
    "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,38,00,38,e0,00,00,00,00
  2. Use AutoHotkey to cheat Putty right Alt as left Alt

    Right click on AutoHotkey icon and click ‘Window Spy’ in the menu, you can get Putty class name in AutoHotkey. Then add following setting in current script in AutoHotkey:

    #IfWinActive ahk_class PuTTY

    Reload the script and you can use right Alt to invoke Emacs M-x key bindings in Putty.

I prefer the second way to fix the Right Alt Key Broken problem in Putty under Windows.

(0) Comments   
Posted on 25-01-2013
Filed Under (Technology) by bigbang

I use Putty to edit code romotely today. Because for some reason I can’t download or upload the files by WinSCP or something else, I can only do the coding using Emacs under Putty. It is really a bad experience using Emacs under Putty, and I don’t know why Emacs M-v keybinding doesn’t work under Putty. It is also really bad that I can’t use my own Emacs config file. I think there should be the same situation under secureCTR. It seems using Emacs Tramp is the best choice.

1. Install Putty

There is nothing to discuss about Putty installation, just do it.

2. Add Putty Installation Path to Windows System PATH

Make sure you add Putty installation path to Windows system PATH:

C:\Program Files\PuTTY

By doing it, we can let Emacs file plink.exe file.

3. Add Tramp code in Emacs Config File

Just put following elisp code into .emacs file:

(require 'tramp)
(setq tramp-auto-save-directory "c:\\tmp")
(setq tramp-default-method "plink")

4. Use Tramp to Edit Remote File

Now, we can use M-x find-file or C-x C-f to open remote file. When Emacs prompts the open info, just input the URL pattern of following:


For example, if you want to explore ~/main.c on remote host, you can open it with path:


Some machines use different port to provide SSH service, and in this situation we can use following URL to open file or folder:


, which means using # to add specific port. Just write down the SSH port behind # to enable the connection.

When you are editing the remote file or folder, all the thing is the same as editing locally.

5. Tips

Although Emacs Tramp is very convinent for editing remote Linux host, it is still a better choice if you can download files and edit them locally. By this way, you can use Emacs, use more tools ( for example, Visual Studio, WinMerge, etc.) to coding, merging, copying. There is nothing happier than done the work quickly!

(0) Comments   
Posted on 25-01-2013
Filed Under (Emacs) by bigbang

If we don’t want Muse to escape * symbol which means export * directly, we can use = to do it.

For example,


will be exported as


Actually, = is short for <code></code> expression, and <code></code> is also very convinent to escape big block text.

(0) Comments   
Posted on 16-11-2012
Filed Under (Technology) by bigbang

The basic usage of Emacs-w3m is the same as w3m itself. The host keys is the same as w3m. So it is very easy for the users who are familiar with w3m to use Emacs-w3m.

Although the manual of w3m has described the operation of w3m very clearly, I still want to outline some points confused me when I use Emacs-w3m at the beginning.

  1. How do I fill in forms with w3m?

    Form input fields are displayed in red (or reverse). Move the cursor to them and hit RETURN.

  2. How do I enter a URL?

    Type SHIFT-U, or use ‘U’ instead.

  3. How to get link URL?

    When the cursor is on a link, use ‘u’ to peek link URL. Emacs will get the link URL into system’s clipboard.

In which suitation should I use Emacs-w3m? Comparing with other browsers like Chrome, Firefox, is there any reason for you to use Emacs-w3m?

At first the reason I used Emacs-w3m was jsut for fun, just want to enjoy the cleanness provided by text browser. But right now I use w3m in three suitations:

  1. To read some articles I don’t want other colleagues know. By using w3m, I can make the website look ugly and not easy to identify.
  2. To copy formatted text from HTML to Emacs Org file. When I take notes or write blogs in Org Mode, I need to copy some content from internet and I don’t want to edit hyperlinks manually. So Emacs-w3m together with org-w3m is the thing for me.

    I will write a mode for Emacs which can copy the Chrome, Firefox region into the clipboard in org-mode format, so that pasting into org-mode buffers retains all html links and images. It will be more convinent.

  3. To find my blog article links. There are a lot of internal links in my blog articles, when I need them I use Emacs-w3m to find them and copy links directly.

Is it awsome? Let Emacs be your time killer at first, and Emacs will be your time saver at last.

(0) Comments   
Posted on 15-11-2012
Filed Under (Technology) by bigbang

When we need to copy rich content from HTML page while using Emacs Org Mode to take notes or write blogs, I used to copy the content directly and paste it to org file. Then all the rich text becomes plain text.

This way is simple but has a defect: if you are copy rich text with hyperlinks or formatted text, you need to add hyperlinks and formats after you pasting the text. The business is too troublesome to miss anything important.

Today I find a tool which can copy w3m rich text to Org file and keep the format. The steps to do it are:

First use Emacs-w3m to explore internet, then install org-w3m mode, and finally you can use command M-x org-w3m-copy-for-org-mode or keybindings C-c C-x M-w to copy rich text and convert HTML content to Org tags automatically.

It seems that org-w3m is a good toy, haha~~

PS: it will be better if we can copy images from HTML and cache them under folder which we are editing org files. Maybe someday I will make one Emacs mode for this.

(1) Comment   
Posted on 13-11-2012
Filed Under (Technology) by bigbang

Emacs Marmalade provides the way to install Emacs packages automatically, just like Ubuntu installing softwares.

It is very convenient to install Emacs Addons for Emacs 24.

Emacs 24 has embeded Marmalade and can turn it on by following code:

(require 'package)
(add-to-list 'package-archives 
    '("marmalade" .

Then we can use M-x list-packages to list all packages, choose one and install it.

If you know the package name, you can also install it directly by using command M-x package-install [RET] [Package-name] to install the specific package.

(0) Comments   
Posted on 13-11-2012
Filed Under (Technology) by bigbang

We always need to indent spaces for code block or text block in Emacs, especially in Org files.

For example, when you inserts a code block in Emacs Org file, you always need to insert blocks similar to following:

#+begin_src cpp
#include <iostream>

int main()
    return 0;

But when you copy the code from your source code file, the code is always aligned to the left of the page. When you export your org file to html file, the # mark will damage all the code block content.

We need to indent the code block for 2 spaces or 4 spaces, then the block mark will work.

It’s easy! There are two ways to do the indention.

The first way, Use the indent-rigidly command with a numeric prefix.

For example, after selecting the block, C-u 4 M-x indent-rigidly to indent the region by four spaces, C-u -4 M-x indent-rigidly to remove four spaces.

You can also use C-x <TAB> key bindings to replace M-x indent-rigidly command.

The second way, we could also use column mode.

We can select the lines in column mode, then add four spaces to all of them at once by following steps:

  1. Jump to column 1 of the first line you want to indent.
  2. C-<space> to set mark.
  3. move the point down to the last lines (stay in column one).
  4. C-x r t to enter column mode (or C-<RET> if you’ve got CUA mode), the input <space><space><space><space><RET> to indent four spaces.
(0) Comments   
Posted on 17-10-2012
Filed Under (Technology) by bigbang

I want to add a tag like C++ in Emacs Org Mode file, but Org Mode doesn’t let me to do it. I find the explanation about tags in Org Mode:

Tags are normal words containing letters, numbers, '_', and '@'.

So, if you want to add tags with characters besides letters, numbers, ‘_’, and ‘@’, it seems that the only way is to change the tags into other words.

I use cpp or CPlusPlus to replace C++ in the tag position in my own Org Mode file.

(0) Comments   
Posted on 10-10-2012
Filed Under (Technology) by bigbang

I can use my style file under 23.1, 23.4, but after I update Emacs to 24.1, I can’t use the old style files. For example, one of my style files is color-theme-arjen.el.

In my elisp file, I use following code to load the color theme:

(load-file "~/emacs/site-lisp/color-theme/master_color-theme-arjen.el")

I don’t know why the color theme works under Emacs 23.1 & 23.4 but just doesn’t work under Emacs 24.1.

While Emacs is loading the file, Emacs gives following error:

Symbol's function definition is void: plist-to-alist

If I uncomment above code and don’t load the style file, the error is dismissed.

Why this happens? Here is the answer:

The color theme stuff was heavily revamped in 24, there is a color theme package included with emacs (see M-x customize-themes), and as far as I know breakage of older themes is expected.

The color theme package from marmalade reportedly works as well.

It seems that the only solution is to open a bug report for color-theme-arjen if I want to use the old theme. So I use M-x customize-themes to find my best theme right now.

(0) Comments    Read More