Wednesday, September 30, 2009

Sharing the Mac Clipboard with Emacs

From Doug: original post

Add the following lines to your .emacs or .emacs.d/init.el file to share the OS X clipboard with emacs.
From emacs inside the terminal in a “no window” mode. You can use M-w to copy something from emacs and then Cmd-V it in another Terminal window or likewise Cmd-C something in Terminal and then paste it into emacs with C-y.

(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))

(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))

(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx)

Sunday, September 27, 2009

Install java script mode in emacs

From the terminal

wget http://code.google.com/p/js2-mode/wiki/InstallationInstructions
mv js2-20090723b.el ~/.emacs.d/lisp (js2-20090723b.el is the version at the time of writing)

#in Emacs

M-x byte-compile-file RET js2.el RET

#You need the following lines in your ~/.emacs file:
(add-to-list 'load-path "/export/home/user_name/.emacs.d/lisp") !!!change user_name accordingly!!!
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))

#make sure the path is in your "load-path" variable:
C-h v:load-path

#Load the mode:
M-x js2-mode

remove duplicates from iTunes Music folder

Use fdupes

In the terminal:

sudo port install fdupes

cd ~/Music/iTunes/iTunes Music

fdupes -rf Music/ | tee duplicates.txt

(-r flag recursively reads subdirectories, -f omits the first match, tee redirects the output to a file)

#parse the duplicates file

sort duplicates.txt | uniq | grep -v '^$'

#remove the duplicates
while read line; do rm -v '$line'; done < duplicates.txt

#clean up
rm duplicates.txt

itunes will have broken links to the deleted files:

Within itunes I remove all files from my library choosing the "keep files" option, and drag the Music folder back into iTunes