Showing posts with label emacs. Show all posts
Showing posts with label emacs. Show all posts

Monday, October 17, 2011

Two Quick Emacs tips


Two quick Emacs tips: These are really awesome

1. Opening compressed files in Emacs

Add the following line to your .emacs and open a .gz file directly in Emacs. 

(auto-compression-mode t)

Saves you hell lot of a time!

2. Renaming buffers/files when they are open

This is "wow" for an emacs user :)

There is a file that you are editing on on emacs. [An open buffer]. And now you want to rename this file and not only the buffer.

One way was to close the buffer, rename the file on shell and re-open again.
Another way was to just write the existing buffer into an entirely new file and name it the way you want. Basically you end up making a new "copy"

Another good way is to use emacs dired more. Lets assume you have an open buffer.
Open dired mode ( C-x C-d )
Open the directory in emacs.
Traverse to the file and press R (rename)
Rename the file to what you want.

The buffer too gets renamed in Emacs automatically and so the file on the disk!

Go Free,
Go Emacs!
Ghanashyam

Sunday, May 22, 2011

gmail integration with emacs

I think it is fun to have Emacs act as your mail client. It's like when u are busy writing code, and you got to send in some snippets or a quick mail on the issue, you just don't leave the editor!. So here is how you integrate Emacs to access your Gmail compose. Note, your mails sent from Emacs are also stores in the "sent" label on your Gmail!

pre-requisites
  1. emacs 23.2
    Use the latest version of emacs, I used emacs23.2 while i made the customization.

    download emacs from http://ftp.gnu.org/gnu/emacs/

  2. gnutls
    gnutls is the gnu transport layer security library which ensures secure client/server communication over the transport layer.

    http://www.gnu.org/software/gnutls/gnutls.html for more info on gnutls

     
  3. Libgcrypt
    To build gnutls, this package may be required it is provided in the gnutls download link along with gnu tls. One might have to download it separately.

The .authifo File

  1. The authinfo file stores the login information for the mail account. Create the .authinfo file
     
  2. Insert the following line into the .authinfo file which u can create and place in the ~/. directory

    machine smtp.gmail.com login @gmail.com password

     
  3. Modify the permissions of the .authinfo file as follows

    chmod go-rwx .authinfo

    chmod u+rw .authinfo

Emacs Init Config (.emacs)

Add this section to your .emacs

;; email setting for my emac
(setq send-mail-function 'smtpmail-send-it
message-send-mail-function 'smtpmail-send-it
smtpmail-starttls-credentials
'(("smtp.gmail.com" 587 nil nil))
smtpmail-auth-credentials
(expand-file-name "~/.authinfo")
smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 587
smtpmail-debug-info t)


Sending mail
The keybinding for emacs to send mail is
  1. C-x m to compose mail 
  2. C-c C-c to send mail when you are done composing the mails

Thanks
Shyam

Sunday, May 8, 2011

quick .emacs access

when one talks about emacs customization, most of it is going to be editing the .emacs, which is the init file of emacs. emacs loads the init file, by default, stored at the $HOME or the ~/. location in your system. Some times one never knows which is the .emacs that our emacs is using typically when one has been updating his emacs through different versions. the easiest way to find out where your .emacs is to do a C-x C-f ~/.emacs RET  

for frequent .emacs users, typing C-x C-f ~/.emacs is also tiring, or basically you might say its redundant. once a .emacs is edited, one has to load it again to see the change effects. to make it a quick access, you could just create a function which opens a .emacs if not open and loads it if its already open. a keybinding proves very convenient and here is what you add in your .emacs.


(defun open-load-init-emacs ()
"function to open the .emacs in lisp mode and load it"
    (interactive);; function be called interactively
    (if (equal (buffer-name) ".emacs")
         (eval-buffer) ;; if open, evaluate buffer or load it
         (progn (find-file "~/.emacs") (eval-buffer))
    )
    ;; the progn creates a body of commandsfind .emacs, load it
    (lisp-mode) ;; enable lisp mode)
(global-set-key "\C-x." 'open-load-init-emacs) ;; set the key binding to C-x.
cheers
shyam

git quick start guide

I can almost certainly assert that Emacs has been the best piece of open source software, for that matter, the best software I have ever used. The reasons are simple. Emacs in itself is simple, it just does the jobs right, it isn't troublesome. Some one somewhere has foreseen things which you would want in an editor and when you look out for that one thing you miss badly, you find it and it works awesome. Alongside Emacs, I started using this piece of open source software git.

Git is a version control software tool and was implemented by Linus Torvalds. I must say git has been as wonderful as software as emacs. My tryst with version control starts from using a commercial  Clearcase to an open source CVS, to a seemingly meaningless SVN to an ideal tool git. Apparently, any piece of open source software is almost always written by geeks for geeks and there is a lot of "meaningful" documentation underneath. And for many of the "just-get-the-job-done" people, I  think, this is the crux of the problem. There is no "next-click-next-click" tool flow. We all grew up playing "space commander" on "windows" you see.

To make things easier, to get as many people use git instead of svn, I thought, I should list down a quick start guide to moving from svn to git. There are numerous amounts of git tutorials on the net which are far more detailed and far more interesting. So this is by no means undermining the effectiveness and the content of all such documentation. This is not a detailed user guide, it's just a quick start guide, which lets you start with changing things.


Cheers 
Ghanashyam

Saturday, May 7, 2011

time stamping with org-mode calendar

org mode in emacs has this wonderful feature of integrating the calendar in itself. A C-c . key binding in org mode invokes the calendar. you can move around dates with the S- ->(shift right arrow: forward day) and S-<-(shift left arrow: backward day). but this is only in an org-mode buffer, buffers which have a .org extension or buffers where you manually switch on org-mode by M-x org-mode RET.

one can enable this on all types of buffers globally. put this in to your .emacs

(global-set-key "\C-c." 'org-time-stamp)

so in any buffer, one can C-c . to get in a date time stamp.

cheers!
shyam