Skip to content

Instantly share code, notes, and snippets.

@kurtharriger
Created February 3, 2014 23:00
Show Gist options
  • Save kurtharriger/8794195 to your computer and use it in GitHub Desktop.
Save kurtharriger/8794195 to your computer and use it in GitHub Desktop.
emacs autosave, mouse, and OS X clipboard
;; autosave
(defun full-auto-save ()
(interactive)
(save-excursion
(dolist (buf (buffer-list))
(set-buffer buf)
(if (and (buffer-file-name) (buffer-modified-p))
(basic-save-buffer)))))
(add-hook 'auto-save-hook 'full-auto-save)
;;(setq auto-save-interval 10)
(setq auto-save-timeout 1)
;; since files are flushed on each change auto
;; reload when changed on disk
(global-auto-revert-mode t)
;; Enable mouse support
(unless window-system
(require 'mouse)
(xterm-mouse-mode t)
(global-set-key [mouse-4] '(lambda ()
(interactive)
(scroll-down 1)))
(global-set-key [mouse-5] '(lambda ()
(interactive)
(scroll-up 1)))
(defun track-mouse (e))
(setq mouse-sel-mode t))
;; clipboard
(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))))
;; only enable this on OS X
(when (not (string= "" (shell-command-to-string "/usr/bin/which pbpaste")))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment