;;; macos X specific stuff (taken from ;;; http://www.webweavertech.com/ovidiu/emacs.html) (provide 'macosx) ;;(setq mac-command-key-is-meta nil) (setq mac-command-modifier 'alt) (setq mac-option-modifier 'meta) (defun add-to-path-env (path) "Add a path to the PATH environment variable" (let* ((key "PATH") (env (getenv key)) (newenv (if (and env (not (equal env ""))) (if (not (member path (split-string env ":"))) (setenv key (concat env ":" path)) env) (setenv key path)))) (message (concat key "=" newenv)))) (defun add-to-exec-path (path) "Add a path to the exec-path emacs variable" (if (not (memq path exec-path)) (add-to-list 'exec-path path t))) (defun add-path (path) "Add the specified path to PATH and exec-path, after verifying it exists" (interactive "DEnter path to add: ") (when (and (stringp path) (file-directory-p path)) (add-to-path-env path) (add-to-exec-path path))) (defun add-paths (paths) "Add the specified paths to PATH and exec-path, after verifying they exist" (if (listp paths) (dolist (path paths) (add-path path)))) ;; paths (add-paths '( "/usr/local/bin" ; stuff "/usr/X11R6/bin" ; X window "/usr/local/teTeX/bin/i386-apple-darwin-current" ; teTeX (i386) "/usr/local/teTeX/bin/powerpc-apple-darwin-current" ; teTeX (PPC) "/opt/local/bin" ; DarwinPorts )) ;; Define the return key to avoid problems on MacOS X ;;(define-key function-key-map [return] [13]) (global-set-key [(alt a)] 'mark-whole-buffer) (global-set-key [(alt v)] 'yank) (global-set-key [(alt c)] 'kill-ring-save) (global-set-key [(alt x)] 'kill-region) (global-set-key [(alt s)] 'save-buffer) (global-set-key [(alt l)] 'goto-line) (global-set-key [(alt o)] 'find-file) (global-set-key [(alt f)] 'isearch-forward) (global-set-key [(alt g)] 'isearch-repeat-forward) (global-set-key [(alt w)] (lambda () (interactive) (kill-buffer (current-buffer)))) (global-set-key [(alt .)] 'keyboard-quit) ;; I disabled this since I want to avoid hitting Cmd-q accidentally. ;;(global-set-key [(alt q)] 'save-buffers-kill-emacs) (require 'redo) (global-set-key [(alt z)] 'undo) (global-set-key [(alt shift z)] 'redo) ;;; patch for browse-url.el tosupport remote control of Safari on Mac OS X ;;; by Ram Krishnan (defun browse-url-mac-safari (url &optional new-window) (interactive) (let ((rc (concat "tell application \"Safari\"\n" "activate\n" (if new-window "open location \"%s\"\n" "set URL of the first document to \"%s\"\n") "end tell\n" "tell application \"Emacs\"\n" "activate\n" "end tell\n"))) (do-applescript (format rc url)))) (setq browse-url-browser-function 'browse-url-mac-safari)