Tuesday, December 30, 2014

How to define a keyboard macro in Emacs

Link.


Here is how to define a keyboard macro: 
  • `C-x (’ or <f3>– start defining a keyboard macro
  • `C-x )’ or <f4>– stop defining the keyboard macro
And here is how to execute a keyboard macro you’ve defined: 
  • ‘C-x e’ or <f4> – execute the keyboard macro
Here’s how to execute the macro 37 times (you use ‘C-u’ to provide the 37): 
  • ‘C-u 37 C-x e’
Example:
You want to add the text “– foobar was here” at the end of each of the lines in a file. 
  1. Place the TextCursor at the beginning of the first line.
  2. `C-x (’ to start recording a keyboard macro.
  3. ‘C-e’ (or ‘M-x end-of-line’) to move the cursor to the end of the line.
  4. Type “-- foobar was here
  5. ‘C-a’ (or ‘M-x beginning-of-line’) to move the cursor to the beginning of the line.
  6. ‘C-n’ (or ‘M-x next-line’) to move the cursor to the beginning of the next line.
  7. `C-x )’ to stop recording the keyboard macro.
  8. ‘C-u 0 C-x e’ to execute the macro an infinite number of times until the end of the file is reached (See InfiniteArgument).
What’s important here is to stop defining the macro at a similar position to where you started it – so that you are in a position to execute it again, after it executes. This is a general rule that you will often follow when defining keyboard macros: try to make them executable N times in a row.
Actually, although it’s good to learn this general rule, there is a shortcut for just applying the last-defined keyboard macro to each of the lines of a region: 
  • ‘M-x apply-macro-to-region-lines’
Or to be more precise (from the documentation of the command):
  For each complete line between point and mark, move to the beginning
  of the line, and run the last keyboard macro.
You can name the last-defined keyboard macro, so that you can then execute it by name: 
  • ‘M-x name-last-kbd-macro’ – Name the last-defined keyboard macro.
Why do that? One reason is that it lets you have more than one macro defined at the same time. Once you have named this macro, say, ‘my-macro’, you can define another one that does something else. Then, you can execute the second macro using ‘C-x e’ and execute ‘my-macro’ as if it were a standard Emacs command: ‘M-x my-macro’. If you also name the second macro, then you can define a third one…
Keyboard macros are only defined for your current Emacs session. If you want to be able to reuse a macro in a future session, then save it in your initialization file (.emacs or _emacs). Open the file, then insert the macro definition using this command: 
  • ‘M-x insert-kbd-macro’ – Insert a named keyboard macro into your initialization file.
Now you can use ‘M-x’ to execute the named keyboard macro in future sessions – just as if it were a standard Emacs command of the same name. If you want to bind it to a key, you can add code like the following to your initialization file:
    (global-set-key (kbd "C-c a") 'my-macro)
This binds the key sequence ‘C-c a’ to the macro ‘my-macro’.
If you want to edit the macro in future sessions, you need to let the kmacro library know that the symbol is indeed a macro by putting the kmacro property on the symbol.
  (put 'my-macro 'kmacro t)
Read more ...

Wednesday, December 10, 2014

Re-install DirectX

Link.


  1. Run Regedit by pressing Win key+R to get the Run Box and type Regedit, then press enter.
  2. Locate the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectX (You should then see a value called “Version” with a data value of 4.09.00.0904).
  3. Simply double click on Version and change the number from 4.09.00.0904 to 4.08.00.0904. Then close the registry editor.
  4. Download and run the DirectX installer, and it should re-install.
Read more ...

Wednesday, November 19, 2014

Getting MacPorts to Work Behind a Firewall

Link.


MacPorts is an extremely useful command line utility for managing open-source software (ports) on your Mac. It makes it a breeze to to find, download, compile and install open-source software on your machine, as well as upgrade to the latest versions without wasting a lot of time.

Unfortunately those of us behind corporate firewalls are usually prevented from using the tool due to network security restrictions of the rsyncd protocol.

I hope this post helps you solve some of the most common issues encountered when running MacPorts selfupdate or sync commands behind a corporate firewall.

What you will need
  • A recent copy of MacPorts installed. If you have not done this yet, please head over to MacPorts to get the latest version 
  • Your corporate proxy server name, port and proxy user credentials if necessary. 
  • The ability to (sudo) temporarily increase your account privileges to those of an administrator on your Mac. 
Step 1: Switch MacPorts to use HTTP

MacPorts is configured to synchronize its list of ports via rsync. We will change it so it uses HTTP instead.

Open a terminal window and edit the MacPorts source configuration file. Enter the superuser password when prompted.
sudo vim /opt/local/etc/macports/sources.conf
Comment out the line at the bottom of the file and add a new one that uses the HTTP address. When you are done, it should look something like this:
#rsync://rsync.macports.org/release/ports/ [default]
http://distfiles.macports.org/ports.tar.gz [default]
Save the file and exit the editor.

Step 2: Setup your Proxies

Edit your profile script, this could be in the form ~/.profile, ~/.bash_profile, etc.
vim ~/.profile

Add the following to the bottom of the file:
################################### CORP PROXY ###################################
PROXY_SERVER=corporate-proxy-server-here
PROXY_PORT=8888
PROXY_USERNAME=proxy_account
PROXY_PASSWORD=proxy_password
PROXY=$PROXY_USERNAME:$PROXY_PASSWORD@$PROXY_SERVER:$PROXY_PORT
# HTTP and HTTPS
export http_proxy=http://$PROXY
export HTTP_PROXY=http://$PROXY
export https_proxy=http://$PROXY
export HTTPS_PROXY=http://$PROXY
# RSYNC
export rsync_proxy=$PROXY
export RSYNC_PROXY=$PROXY
##################################################################################

Save the file and exit the editor.

Step 3: Edit the sudoers file

This is required to forward your proxies to the superuser account every time you run sudo port commands.
sudo visudo

Append the following to the end of the list of Defaults:
Defaults env_keep += "http_proxy rsync_proxy HTTP_PROXY RSYNC_PROXY"

Save the file and exit the editor.

Restart the Shell

Exit the terminal shell and start a new session to load the new settings.

Test your new proxy environment variables are now available:
env | grep http
You should see something like this:
$ env | grep http
http_proxy=http://proxy_account:proxy_password@corporate-proxy-server-here:8888
HTTP_PROXY=http://proxy_account:proxy_password@corporate-proxy-server-here:8888

Update your Ports

You should now be able to load the latest ports using the http proxy. Test this by typing the following command. Note that the -d switch invokes the command in debug mode. We do this so you can see what is happening behind the scenes.
sudo port -d sync

You should see a long list of ports being downloaded.
Read more ...

Tuesday, October 28, 2014

pdftk in Mac OS X with tips

Download pdftk for Mac.

tips:

1. Split multi-page PDFs into single page PDFs
$ pdftk my_multi_page.pdf burst
$ pdftk my_multi_page.pdf burst output my_directory/page_%02d.pdf

2. Pull some pages out of a PDF but keep the rest
$ pdftk my.pdf cat 1-5 13-21 24-end output my_edited.pdf

3. Concatenate (that’s join!) multiple pdfs into one big pdf
$ pdftk part0.pdf part1.pdf cat output the_whole_book.pdf

4. Get all of the images and other attachments out of a PDF and put them in a folder
$ pdftk my.pdf unpack_files output ~/attachments_from_my_pdf/

5. Print stats and metadata about a PDF
$ pdftk my.pdf dump_data

6. Add a background watermark (or a foreground overlay) to a pdf

- For a background
$ pdftk my.pdf background bg.pdf output my_watermarked.pdf

- For an overlay
$ pdftk my.pdf stamp overlay.pdf output my_overlayed.pdf
Read more ...

Wednesday, October 22, 2014

Copy file or folder path to the clipboard in Mac OS X

Link.


  1. Launch Automator
  2. Double-click the Service icon
  3. Toward the top of the right column, you’ll see this line of text: “Service receives selected _____ in _____”. Choose “Files or Folders” from the first menu and “Finder” from the second.
  4. Click on Utilities in the Actions library on the left side. Double-click “Copy to Clipboard” in the middle column.
  5. Go to File > Save in the menu bar and name your service Copy File Path.
  6. Launch System Preferences and go to the Keyboard pane. Click on the Keyboard Shortcuts tab.
  7. Select “Application Shortcuts” from the list on the left. Next, click on the + button at the bottom of the list.
  8. A small window will come up with a few options that need to be set. Select “Finder” from the Application menu, type Copy File Path as the Menu Title, and create your own Keyboard Shortcut. If you don’t know what to put here, you can just press Shift+Command+C on your keyboard. Click Add and we’re done!


If you’re not keen on keyboard shortcuts, the service you created is also accessible when you right-click on an item in Finder and select Services > Copy File Path from the contextual menu. The actual file we created for this service is located in: ~/Library/Services in case you ever want to delete it or copy it to put on another Mac.
Read more ...

Tuesday, October 14, 2014

Terminal command to check used memory in OS X

top -l 1 | head -n 10 | grep PhysMem
Read more ...

Tuesday, September 23, 2014

How to disable Adobe Reader in Safari?

Link.


Go to the "Help" menu in Safari and select "Installed Plug-ins". This will open a new tab displaying information about all of the currently installed plug-ins. Find the entry for Adobe Acrobat. Below it will be a line that reads something like:
Adobe® Acrobat® Plug-in for Web Browsers — from file “AdobePDFViewer.plugin”.
Note the name of the file from that line.
On your hard drive you will find a Library folder. In that folder will be another folder called Internet Plug-Ins. Inside that folder you should find the file that was shown in the "Installed Plug-ins" tab. The full path should be /Library/Internet Plug-Ins/AdobePDFViewer.plugin. That file needs to be deleted. Dragging it to the trash will do the trick.
If you are not sure you want to delete the file, you can move it to another location. For instance, you could create a new folder named "Disabled Plug-Ins" in the "Installed Plug-Ins" folder, and move the file to the new folder.
Then quit & relaunch Safari.
Adobe acknowledges this is a "known issue" and recommends this procedure.
Read more ...

Monday, September 15, 2014

Friday, August 29, 2014

Split and merge pdf’s with pdftk in linux

Link.


Pdf Tolkit (pdftk) is a tool to split and merge the pdf’s.

First you need to install the pdftk with following command.
$ sudo apt-get install pdftk

An example to merge pdf’s
$ pdftk input1.pdf input2.pdf cat output merge-output.pdf

Above example is to merge input1.pdf and input2.pdf and create new output file with name merge-output.pdf

An example to split pdf(split from page 10 to 20)
$ pdftk A=input1.pdf cat A10-20 outpout split-output.pdf

Above example is to get only page number 10 to 20 from input1.pdf to split-output.pdf
Read more ...

Monday, August 18, 2014

Converting mp4 to mp3 in Linux

Link.


To convert Upd_Sanity.mp4 to Upd_Sanity.mp3

$ sudo apt-get install ffmpeg && sudo apt-get install libavcodec-extra-53

$ ffmpeg -i Upd_Sanity.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 Upd_Sanity.mp3
OR (as ffmpeg is deprecated)
$ avconv -i Upd_Sanity.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 Upd_Sanity.mp3

Description

   -i        input file name
   -vn       disable video recording
   -acodec   force audio codec to libmp3lame
   -ac       set the number of audio channels
   -ar       set the audio sampling frequency

If you need to use it frequently,

STEP 1 : Create a bash function that performs conversion
## utilities.sh
convertMP4toMP3(){
echo -n "Enter source mp4 file : "
read sourceFile

echo -n "Enter destination mp3 file : "
read destFile

avconv -i $sourceFile -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 $destFile
}
STEP 2 : source that bash file
 $ source utilities.sh
STEP 3 : start conversion calling above function convertMP4toMP3
 $ convertMP4toMP3
 Enter source mp4 file : Upd_Sanity.mp4
 Enter destination mp3 file : UPd_sanity.mp3
Read more ...

How to be a Google power user


Read more ...

Thursday, July 31, 2014

Install matplotlib for python3

you have to install python3-pip bu using apt-get (e.g. in debian)

then run:

pip install matplotlib

If got the error

(Currently using distribute 0.6.24dev-r0 (/usr/lib/python3.2/dist-packages))
    Complete output from command python setup.py egg_info:
    The required version of distribute (>=0.6.28) is not available,

and can't be installed while this script is running. Please

install a more recent version first, using

'easy_install -U distribute'.

Try:

sudo apt-get install python3-setuptools
easy_install3 -U distribute

If still does not work
Try:

export PYTHONHOME=/usr/local/lib/python3.2/

Read more ...

pip install h5py error fix

If you got the error like following when you install h5py:

...
...
h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1
...
...

To fix it, just run the following command.

sudo apt-get install libhdf5-dev
Read more ...

Emacs as a Python IDE

Link.



Update 04/08/2014It seems like this post has been helpful for a lot of people, which really makes me happy! I just wanted to let new readers coming by know that the configuration I present in this post is out-of-date. However, I have my Emacs configuration on GitHub, and do try to keep it up-to-date. If you have any difficulties getting the configuration in the GitHub to work, please do submit a bug request and I will try to help you fix the problem.
As I mentioned in last week’s post, I am a heavy Emacs user and find it invaluable as an environment for my research. In particular, I use Emacs most for data analysis and modeling in Python, including an interface to IPython, which allows me to quickly switch between writing and running snippets of code. This proves to be a great replacement MATLAB, at least in my opinion.
I frequently get requests for my .emacs configuration file or questions about how I have such an environment set up. As such, in this post I’m going to document how to set up your Emacs configuration to support rapid Python development, including the plugins I have installed and the keyboard shortcuts I use most often.
Note that I am running GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK Version 2.24.5). I have never tried running it under OSX or Windows, so I can’t guarantee that these instructions will transfer, but you are welcome to try. If you run into any inconsistencies, feel free to send them to me and I will update this post accordingly!
Also, if you are new to Emacs, please read my beginner’s guide first, as I will be assuming familiarity with basic Emacs functionality and terminology. I will also assume you can at least read and understand LISP to some extent (but you don’t necessarily have to be able to write it).

Overall Goal

In this tutorial, we’re going to be installing several Emacs plugins and modifying the Emacs initialization file, which is typically found at ~/.emacs. Here are my .emacs and configuration files that it includes (note these are NOT the same as the actual plugins: I just like to divide my configuration so into bite-sized chunks so it’s easier to manage):
  • .emacs
  • ido-settings.el
  • auto-complete-settings.el
  • fill-column-indicator-settings.el
  • python-settings.el
  • ui-settings.el
  • window-settings.el
  • cursor-settings.el
  • text-settings.el
  • color-theme-settings.el
You can find a zip of all these .el files (excluding the .emacs) here. EDIT: The most recent version of my emacs configuration (which might not necessarily be consistent with this post) can be found here.
If you choose to install these configuration files, place the .emacs in the root of your home directory (~/.emacs) and put the other files in ~/.emacs.d/settings.
A note about installing plugins: I’ve found that installing plugins from the Ubuntu repositories to be a bad idea because different versions don’t always play nicely with one another. It’s better to install the most recent version from source, and that’s what I’ve done for this tutorial. If you download and install the plugin versions (as I’ve indicated via the directories that I install them into), this should all work. Note that you may have to actually compile some of the plugins as well (if there’s a Makefile, run make; sudo make install and if there’s a setup.py file, run sudo python setup.py install. If there’s both, run the Makefile first and then run the Python setup).
Here is the list of plugins we’ll be going through/installing:

Non-Python Environment

There are several plugins that I use which aren’t related to Python coding, but are nonetheless very valuable: ido-mode (i.e., “Interactively Do Things”), general auto-completion, and the fill column indicator.

Interactively Do Things

“Interactively Do Things” (a.k.a. ido) is a plugin that should be included in Emacs by default; however, it is not typically enabled by default. You can enable it by running M-x ido-mode in Emacs, or by adding the following lines to your .emacs customization file:


Interactively Do Things
require 
ido-mode 

Ido is handy because it makes switching between buffers, opening/closing files, etc., extremely easy to do. Here’s a few screenshots of what it looks like to switch buffers; notice that it lists in the minibuffer all the different buffers you could switch to:
The *scratch* buffer is bolded, which means it’s the default. Let’s say I want to switch to *Messages*, though. As I start typing the name, the list of buffers in the minibuffer is updated to show only those that match what you’re typing (filtering) by:
I could, at this point, simply press enter and it would switch to the *Messages* buffer. You get similar functionality when searching for files, killing buffers, etc. Saves a lot of time, not having to remember buffer names exactly and not having to fully type them out!
There’s a lot more to ido that I’m not going to go into; I encourage you to read through the documentation and find out more about it.

Auto Complete

Auto complete is another handy plugin which keeps track of recent things you’ve typed and will offer to auto complete them for you. Let’s say I’m editing a python file:
And now I want to print out one of the arrays I just created. As I start to type, a list pops up with suggestions:
I can use the arrow keys to highlight the selection I want and press enter to choose it.
The variable name is completed and I don’t have to type the rest, similar to the auto-completion behavior you’d see in Eclipse or another popular IDE. This is useful even if you don’t have competing variable names — if you have particularly long names, auto-complete will remember them, too, and you will only need to type the first few characters.
To enable auto complete, download it, install the files into ~/.emacs.d/auto-complete-1.3.1/, and add the following lines to your .emacs:


Auto Complete
add-to-list 'load-path "~/.emacs.d/auto-complete-1.3.1"
require 'auto-complete
add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict"
require 'auto-complete-config
ac-config-default
global-auto-complete-mode 

Fill-Column Indicator

It is good coding etiquette to keep lines short (e.g., no longer than 72 characters — this is because some people use 80 character terminals, and constantly scrolling to the left/right is very annoying!). It’s furthermore just nice coding style to have lines a consistent length.
To let myself know when I’m running over line length, I have the fill column indicator plugin installed. This draws a line on the right side of the screen, indicating the “fill column” (which is just another way of saying “the ideal maximum line length”). If my text runs past this line, I know I need to do some formatting to make it span multiple lines (if I’m just writing text, I will use M-qto wrap it).
To enable this plugin, download it and install the file in the ~/.emacs.d/fill-column-indicator-1.83/ directory, then add the following to your .emacs:


Fill Column Indicator
add-to-list 'load-path "~/.emacs.d/fill-column-indicator-1.83"
require 'fill-column-indicator
define-globalized-minor-mode
 global-fci-mode fci-mode lambda  fci-mode 
global-fci-mode 

Python Environment

Ok, moving on to the actual Python configuration now! First off, you’ll (of course) need to have Python installed. I’m currently running 2.7. You’ll also want to install IPython and I recommend you avoid the version in the Ubuntu repositories because it’s out of date. You can download a newer version here; I am currently running a development version of 0.14.
Second, you’ll need to actually download the python-mode plugin and install the files into ~/.emacs.d/python-mode-6.0.11/. Add the following to your .emacs:


Python
; python-mode
 py-install-directory "~/.emacs.d/python-mode-6.0.11"
add-to-list 'load-path py-install-directory
require 'python-mode
; use IPython
setq-default py-shell-name "ipython"
setq-default py-which-bufname "IPython"
; use the wx backend, for both mayavi and matplotlib
 py-python-command-args
  "--gui=wx" "--pylab=wx" "-colors" "Linux"
 py-force-py-shell-name-p 
; switch to the interpreter after executing code
 py-shell-switch-buffers-on-execute-p 
 py-switch-buffers-on-execute-p 
; don't split windows
 py-split-windows-on-execute-p 
; try to automagically figure out indentation
 py-smart-indentation 

Now open up a Python file and hit C-c !. Another window will be created, and in it should be an IPython interpreter:
(I’m not entirely sure what’s up with the multiple In prompts at the beginning, but it doesn’t seem to matter so I haven’t bothered to investigate it as of yet.)
Not only can you run IPython inside of Emacs, but you can actually send code from the file you’re editing to the interpreter. To evaluate a snippet of code, first select a region:
Then hit C-c | to send it to IPython:
Now that the code’s been executed, you can refer to it in the IPython environment:
You can also send an entire buffer at once with C-c C-c:
python-mode also offers integration with IPython for tab completion. So, if you can’t quite remember the name of a function, just type what you can think of into the interpreter and press TAB. For example, if I type np.array and then TAB, a new buffer is created and shows the possible completions:
I actually dislike this behavior, however: my coding style is to have two windows open at once and to rapidly switch between them with C-c o. To have Emacs open a second window (or use an existing second window) and to maintain focus in the IPython interpreter, I’ve commented out the following lines in theipython-complete function of ~/.emacs.d/python-mode-6.0.11/python-mode.el:


with-output-to-temp-buffer "*IPython Completions*"
 display-completion-list
 all-completions pattern completions
;; (set-buffer "*IPython Completions*")
;; (switch-to-buffer "*IPython Completions*")
;; (goto-char (point-min))
;; (when
;;  (search-forward (car (all-completions pattern completions)))
;;  (forward-word -1)
;;  (delete-other-windows)
;;  (word-at-point))

This leads to behavior that instead looks like this:

Pymacs and ropemacs

Another handy set of plugins are Pymacs and ropemacs. To be honest, I don’t use them as much as I should — I’m hoping this post will re-familiarize me with the basic commands and I’ll start using them more!
Anyway, you probably don’t really need to worry about what Pymacs is: it’s an interface between Python and Emacs LISP, but we won’t be directly using that. What it’s necessary for is rope, which is a non-Emacs-specific Python refactoring library. Ropemacs is just the Emacs plugin for rope.
To install, first install rope itself:
sudo aptitude install python-rope
Now download the Pymacs code and install it into ~/.emacs.d/pymacs-0.25/. Download the ropemacs code and install it into ~/.emacs.d/ropemacs-0.7/. Add the following to your .emacs:


Pymacs and Ropemacs
; pymacs
add-to-list 'load-path "~/.emacs.d/pymacs-0.25"
autoload 'pymacs-apply "pymacs"
autoload 'pymacs-call "pymacs"
autoload 'pymacs-eval "pymacs"  
autoload 'pymacs-exec "pymacs"  
autoload 'pymacs-load "pymacs"  
autoload 'pymacs-autoload "pymacs"
; ropemacs
require 'pymacs
pymacs-load "ropemacs" "rope-"

There’s a lot that you can do with ropemacs — if you’re interested in finding out more, read the README that’s included in the source — but here’s a taste to get started. The first time you run a ropemacs command in an instance of Emacs, you will be prompted to specify your rope project folder. If you only have one folder for your project, just select that; if you have a whole module, choose the root module directory.
Ok, first, better autocompletion: where auto-complete will only keep track of what you have recently typed, ropemacs can actually look up method and variable names from a module. Use M-/ to bring up a list of completions in the minibuffer (note again the helpfulness of ido-mode, too!):
(Note that it’s not perfect; it seems to have trouble, for example, finding the correct completions of np.random.n. IPython doesn’t have this trouble, probably because ropemacs doesn’t actually import the module and so does not correctly obtain all the attributes.)
You can also look up documentation of an attribute if the point is over it with C-c d:
And you can rename attributes/refactor code in not just a file, but your entire project. For example, to rename data to arr, hit C-c r r and when the point is over the attribute you want to rename. Then type in the new name:
Hit enter, and you will be presented with a list of options (you can read about what they all do in the documentation). We just want “perform” here, so press enter again.
Voila, all instances of data are now renamed to arr!
This is more powerful than just a simple find-and-replace: for example, if you have a variable named data and another variable named data_array, you can’t just find-and-replace data with something else, because it will likely affect data_arrayas well!

Aesthetics

For the final part of this post, I’m just going to give you my elisp code for more aesthetic modifications. A fair amount of it is just the color scheme, but there are a few other useful options that I usually want to have set (like disabling the menu bar, scroll bar, and tool bar). I’ve tried to document it well, but am happy to clarify anything if it’s not obvious! Here’s a screenshot of how my typical Python Emacs environment looks:
You’ll notice that the current line (where the point is) is highlighted; to acheive this affect you’ll need to install the highlight current line plugin to the~/.emacs.d/highlight-current-line-0.57/ directory and use the configuration below in the “cursor” section.
For the base color them, you’ll need the color theme plugin. Install it to~/.emacs.d/color-theme-6.6.0/ and, again, use the configuration below in the “color theme” section.


Interface
;--------------------;
;;; User Interface ;;;
;--------------------;
; always use spaces, not tabs, when indenting
 indent-tabs-mode 
; ignore case when searching
 case-fold-search 
; require final newlines in files when they are saved
 require-final-newline 
; window modifications
global-set-key  "S-C-" 'shrink-window-horizontally
global-set-key  "S-C-" 'enlarge-window-horizontally
global-set-key  "S-C-" 'shrink-window
global-set-key  "S-C-" 'enlarge-window
; set the keybinding so that you can use f4 for goto line
global-set-key ;f4] 'goto-line)
;----------------------;
;;; Windows & Frames ;;;
;----------------------;
; language
 current-language-environment "English"
; don't show the startup screen
 inhibit-startup-screen 
; don't show the menu bar
menu-bar-mode 
; don't show the tool bar
require 'tool-bar
tool-bar-mode 
; don't show the scroll bar
scroll-bar-mode 
; number of characters until the fill column
 fill-column 
; specify the fringe width for windows -- this sets both the left and
; right fringes to 10
require 'fringe
fringe-mode 
; lines which are exactly as wide as the window (not counting the
; final newline character) are not continued. Instead, when point is
; at the end of the line, the cursor appears in the right fringe.
 overflow-newline-into-fringe 
; each line of text gets one line on the screen (i.e., text will run
; off the left instead of wrapping around onto a new line)
 truncate-lines 
; truncate lines even in partial-width windows
 truncate-partial-width-windows 
; display line numbers to the right of the window
global-linum-mode 
; show the current line and column numbers in the stats bar as well
line-number-mode 
column-number-mode 
;------------;
;;; Cursor ;;;
;------------;
; highlight the current line
require 'highlight-current-line
global-hl-line-mode 
 highlight-current-line-globally 
 highlight-current-line-high-faces 
 highlight-current-line-whole-line 
 hl-line-face quote highlight
; don't blink the cursor
blink-cursor-mode 
; make sure transient mark mode is enabled (it should be by default,
; but just in case)
transient-mark-mode 
; turn on mouse wheel support for scrolling
require 'mwheel
mouse-wheel-mode 
;-------------------------;
;;; Syntax Highlighting ;;;
;-------------------------;
; text decoration
require 'font-lock
 font-lock-maximum-decoration 
global-font-lock-mode 
global-hi-lock-mode 
 jit-lock-contextually 
 jit-lock-stealth-verbose 
; if there is size information associated with text, change the text
; size to reflect it
size-indication-mode 
; highlight parentheses when the cursor is next to them
require 'paren
show-paren-mode 
;-----------------;
;;; Color Theme ;;;
;-----------------;
; use the "Subtle Hacker" color theme as a base for the custom scheme
require 'color-theme
color-theme-initialize
 color-theme-is-global 
color-theme-subtle-hacker
custom-set-faces
 default  :overline  :inherit  :stipple  :background "gray2"
                :foreground "#FFF991" :inverse-video   
                :strike-through  :underline 
                :slant normal :weight normal :height  :width normal
                :foundry "unknown" :family "DejaVu Sans Mono"
 border  
 cursor  :background "firebrick1" :foreground "black"
 font-lock-comment-delimiter-face
    default :inherit font-lock-comment-face :weight ultra-bold
    class color min-colors  
 font-lock-comment-face  :foreground "lime green"
 font-lock-doc-face  :foreground "tomato" :slant italic
 font-lock-function-name-face
     :foreground "deep sky blue" :underline  :weight 
 font-lock-keyword-face  :foreground "gold" :weight 
 font-lock-string-face  :foreground "tomato" :slant italic
 fringe  :background "black"
 highlight  :background "khaki1" :foreground "black"
                   :line-width  :color "firebrick1")))))
 highlight-current-line-face  :inherit highlight
 lazy-highlight  :background "paleturquoise" :foreground "black"
   :foreground "DodgerBlue3" :underline 
   :background "gray2" :foreground "#FFF991"
 minibuffer-prompt  :foreground "royal blue"
 mode-line  :background "dark olive green"
                  :foreground "dark blue"
                   :line-width  :color "gray75"
                  :weight 
 mode-line-buffer-id  :background "dark olive green" :foreground "beige"
 mode-line-highlight class color min-colors  
 mode-line-inactive  :background "dark olive green"
                           :foreground "dark khaki" :weight light
 mouse  :background "Grey" :foreground "black"
 trailing-whitespace class color background 
                          :background "firebrick1")))))
; make sure the frames have the dark background mode by default
 default-frame-alist quote 
  frame-background-mode  
Read more ...