What's New in Emacs 24.4

Mickey Petersen has written up an excellent round-up of the latest features of the Emacs 24.4 release. Read the whole article at http://www.masteringemacs.org/articles/2013/12/29/whats-new-in-emacs-24-4/. He had also written a similar article for Emacs 24.3 (current stable version), which can be found here. New Settings that I am using I have already setup the load-prefer-newer, cycle-spacing, and ns-use-srgb-colorspace options. The new electric-pair-mode options also look interesting, and I have set these up (I was using skeleton-pair for the auto-pairing function till now). ...

December 30, 2013 · 2 min

Emacs function to add new path elements to the $PATH environment variable

A very simple eLisp function to add new path elements to the PATH environment variable. Very useful for adding new comint executables from within .emacs/init.el files. (defun my-add-path (path-element) "Add the specified path element to the Emacs PATH" (interactive "DEnter directory to be added to path: ") (if (file-directory-p path-element) (setenv "PATH" (concat (expand-file-name path-element) path-separator (getenv "PATH")))))

January 20, 2010 · 1 min

Google Search from within Emacs

A quick and dirty eLisp function for searching on the internet from within Emacs. The default is to search using Google, but you can add to the *internet-search-urls* variable to setup additional search URLs. By default, the search term is appended at end of the URL - however, you can also encode the specific search term insertion point in the URL by marking the position using the “%s” marker. ;;; The custom search URLs (defvar *internet-search-urls* (quote ("http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s" "http://en.wikipedia.org/wiki/Special:Search?search="))) ;;; Search a query on the Internet using the selected URL. (defun search-in-internet (arg) "Searches the internet using the ARGth custom URL for the marked text. If a region is not selected, prompts for the string to search on. The prefix number ARG indicates the Search URL to use. By default the search URL at position 1 will be used." (interactive "p") ;; Some sanity check. (if (> arg (length *internet-search-urls*)) (error "There is no search URL defined at position %s" arg)) (let ((query ; Set the search query first. (if (region-active-p) (buffer-substring (region-beginning) (region-end)) (read-from-minibuffer "Search for: "))) ;; Now get the Base URL to use for the search (baseurl (nth (1- arg) *internet-search-urls*))) ;; Add the query parameter (let ((url (if (string-match "%s" baseurl) ;; If the base URL has a %s embedded, then replace it (replace-match query t t baseurl) ;; Else just append the query string at end of the URL (concat baseurl query)))) (message "Searching for %s at %s" query url) ;; Now browse the URL (browse-url url))))

January 19, 2010 · 2 min

Quickly diff the changes made in the current buffer with its file

Update (23rd Jan 2010): Separated the key-assignment and function definition. A simple function to quickly do a diff of the current buffer contents with its underlying file. Very useful if the file has been changed outside (e.g., a log file). ;; Diff the current buffer with the file contents (defun my-diff-current-buffer-with-disk () "Compare the current buffer with it's disk file." (interactive) (diff-buffer-with-file (current-buffer))) (global-set-key (kbd "C-c w") 'my-diff-current-buffer-with-disk)

January 19, 2010 · 1 min