;; Set files to TEXT mode so they automatically open in Emacs and can ;; be indexed by spotlight, and open & reconvert binary plists. ;; ron@18james.com, 16 Jun 2005 (setq default-major-mode 'text-mode) (add-hook 'after-save-hook 'save-as-mac-text) (push '("\\.plist\\'" . simple-plist-hack) auto-mode-alist) (defun save-as-mac-text () (cond ((and (derived-mode-p 'text-mode 'sh-mode) (not (derived-mode-p 'sgml-mode))) (start-process-shell-command "save-mac-text" nil "/Developer/Tools/SetFile" "-t" "TEXT" (shell-quote-argument (buffer-file-name)))) ((and (derived-mode-p 'sgml-mode) (string= sgml-xml-mode "binary1")) (start-process-shell-command "save-as-binary" nil "plutil" "-convert" sgml-xml-mode (shell-quote-argument (buffer-file-name)))))) (defun simple-plist-hack () (when (string-match "^bplist" (buffer-string)) (shell-command-on-region (point-min) (point-max) (format "plutil -convert xml1 -o /dev/stdout %s" (shell-quote-argument (buffer-file-name))) t t)) (xml-mode) (save-excursion (goto-char (point-max)) (previous-line 1) (when (looking-at "/dev/stdout: Operation not supported") (progn (kill-line 1) (setq sgml-xml-mode "binary1"))) (set-buffer-modified-p nil)))