10.4: Edit binary .plist files with emacs

Jun 13, '05 08:24:00AM

Contributed by: Anonymous

Tiger only hintAdding this code to your ~/.emacs file makes editing .plist files much less annoying.


(push '(".plist'" . simple-plist-hack) auto-mode-alist)

(defun simple-plist-hack ()
  (when (string-match "`bplist" (buffer-string))
    (shell-command-on-region 
     (point-min) (point-max)
     ;; yes, the temp file is necessary :-(
     (format "plutil -convert xml1 -o /tmp/temp.plist %s; cat /tmp/temp.plist"
       (shell-quote-argument (buffer-file-name)))
     t t))
  (set-buffer-modified-p nil)
  (sgml-mode)) ;; replace this if you have xml-mode installed
[robg adds: I don't use emacs regularly, but tested this one and it worked very nicely -- I created the ~/.emacs file, added the above code, then tried to edit the Safari plist file. It opened in pure text mode, I made a simple change, saved it, then used the Dev Tools' Property List Editor to verify that the change I made was there (which it was, of course).]

Comments (15)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050526162847879